* RE: [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0
@ 2004-08-17 16:45 Paul Riley
2004-08-17 16:49 ` Andrew Lunn
0 siblings, 1 reply; 9+ messages in thread
From: Paul Riley @ 2004-08-17 16:45 UTC (permalink / raw)
To: Andrew Lunn; +Cc: ecos-discuss
I may have the wrong stack, if so sorry, so to clarify the files
affected live in
packages\net\bsd_tcpip\v2_0\src\sys\netinet\in_pcb.c(194)
packages\net\bsd_tcpip\v2_0\src\sys\netinet6\in6_pcb.c(174)
packages\net\tcpip\v2_0\src\sys\netinet\in_pcb.c(284)
Paul
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0
@ 2004-08-17 16:59 Paul Riley
2004-08-17 17:20 ` Andrew Lunn
0 siblings, 1 reply; 9+ messages in thread
From: Paul Riley @ 2004-08-17 16:59 UTC (permalink / raw)
To: Andrew Lunn; +Cc: ecos-discuss
That will work as I've already done something similar. I was wonderring
if anyone knew why it was zeroed as there appears to be no good reason
that I can see.
As for OpenBSD. No I'm not sure, but the code looks pretty similar.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0
2004-08-17 16:59 Paul Riley
@ 2004-08-17 17:20 ` Andrew Lunn
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2004-08-17 17:20 UTC (permalink / raw)
To: Paul Riley; +Cc: Andrew Lunn, ecos-discuss
On Tue, Aug 17, 2004 at 05:59:32PM +0100, Paul Riley wrote:
> That will work as I've already done something similar. I was wonderring
> if anyone knew why it was zeroed as there appears to be no good reason
> that I can see.
The code is:
} else if (sin->sin_addr.s_addr != INADDR_ANY) {
sin->sin_port = 0; /* yech... */
if (ifa_ifwithaddr((struct sockaddr *)sin) == 0)
return (EADDRNOTAVAIL);
}
ie, if you have asked it to bind to a specific interface, not
IMADDR_ANY, it calls ifa_ifwithaddr to see if the interface exists.
Now look at the search function:
ifa_ifwithaddr(addr)
register struct sockaddr *addr;
{
register struct ifnet *ifp;
register struct ifaddr *ifa;
#define equal(a1, a2) \
(bcmp((caddr_t)(a1), (caddr_t)(a2), ((struct sockaddr *)(a1))->sa_len) == 0)
for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next)
for (ifa = ifp->if_addrhead.tqh_first; ifa;
ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family != addr->sa_family)
continue;
if (equal(addr, ifa->ifa_addr))
return (ifa);
if ((ifp->if_flags & IFF_BROADCAST) && ifa->ifa_broadaddr &&
/* IP6 doesn't have broadcast */
ifa->ifa_broadaddr->sa_len != 0 &&
equal(ifa->ifa_broadaddr, addr))
return (ifa);
}
return ((struct ifaddr *)0);
}
It does a memcpy of the address with the address associated with the
interface. It compares sa_len bytes, which will include the port
number. If it did not zero the port number, the compare would fail
since its port number is zero.
Simply realy, when you read the code.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0
@ 2004-08-17 16:51 Paul Riley
2004-08-17 16:55 ` Andrew Lunn
0 siblings, 1 reply; 9+ messages in thread
From: Paul Riley @ 2004-08-17 16:51 UTC (permalink / raw)
To: Andrew Lunn; +Cc: ecos-discuss
FreeBSD, I'm trying to get all the regression tests on our architecture,
but the problem is in both.
Paul
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0
2004-08-17 16:51 Paul Riley
@ 2004-08-17 16:55 ` Andrew Lunn
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2004-08-17 16:55 UTC (permalink / raw)
To: Paul Riley; +Cc: Andrew Lunn, ecos-discuss
On Tue, Aug 17, 2004 at 05:51:17PM +0100, Paul Riley wrote:
> FreeBSD, I'm trying to get all the regression tests on our architecture,
> but the problem is in both.
You are realy sure it happens with the OpenBSD stack?
Anyway, here is a totally untested patch for the FreeBSD stack. Please
let me know if it works.
Andrew
Index: net/bsd_tcpip/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/ChangeLog,v
retrieving revision 1.48
diff -u -r1.48 ChangeLog
--- net/bsd_tcpip/current/ChangeLog 16 Jul 2004 10:43:28 -0000 1.48
+++ net/bsd_tcpip/current/ChangeLog 17 Aug 2004 16:55:24 -0000
@@ -1,3 +1,9 @@
+2004-08-17 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/sys/kern/sockio.c (bsd_bind): Pass a copy of the sa into
+ bind so that the "kernel" code does not modify the "user" codes
+ version of the socket address.
+
2004-07-15 Oyvind Harboe <oyvind.harboe@zylin.com>
*cdl/freebsd_net.cdl:
Index: net/bsd_tcpip/current/src/sys/kern/sockio.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/src/sys/kern/sockio.c,v
retrieving revision 1.5
diff -u -r1.5 sockio.c
--- net/bsd_tcpip/current/src/sys/kern/sockio.c 17 Jan 2004 14:10:52 -0000 1.5
+++ net/bsd_tcpip/current/src/sys/kern/sockio.c 17 Aug 2004 16:55:25 -0000
@@ -246,8 +246,9 @@
bsd_bind(cyg_file *fp, const sockaddr *sa, socklen_t len)
{
int error;
-
- error = sobind((struct socket *)fp->f_data, (sockaddr *)sa, 0);
+ sockaddr sa1=*sa;
+
+ error = sobind((struct socket *)fp->f_data, (sockaddr *)&sa1, 0);
return error;
}
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0
@ 2004-08-17 16:24 Paul Riley
2004-08-17 16:31 ` Andrew Lunn
2004-08-17 16:43 ` Andrew Lunn
0 siblings, 2 replies; 9+ messages in thread
From: Paul Riley @ 2004-08-17 16:24 UTC (permalink / raw)
To: ecos-discuss
Unless I'm missing something there is an inconsistency between the Open
BSD stack and the io/fileio socket.c test.
It transpires that upon a call to bind then inside the function
in_pcbbind the port entry in the sockaddr_in structure is set to zero,
with the syntax
sin->sin_port = 0; /* yech... */
Why?
In addition this breaks the socket test as the subsequent connect is now
connecting to a port which is zero and this barfs. Now it's easy to fix
the test so that the port is set after the call to bind, however that
feels wrong. Does anyone know why this is zero'd out?
Thanks,
Paul
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0
2004-08-17 16:24 Paul Riley
@ 2004-08-17 16:31 ` Andrew Lunn
2004-08-17 16:43 ` Andrew Lunn
1 sibling, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2004-08-17 16:31 UTC (permalink / raw)
To: Paul Riley; +Cc: ecos-discuss
On Tue, Aug 17, 2004 at 05:24:12PM +0100, Paul Riley wrote:
> Unless I'm missing something there is an inconsistency between the Open
> BSD stack and the io/fileio socket.c test.
>
> It transpires that upon a call to bind then inside the function
> in_pcbbind the port entry in the sockaddr_in structure is set to zero,
> with the syntax
>
> sin->sin_port = 0; /* yech... */
>
> Why?
>
> In addition this breaks the socket test as the subsequent connect is now
> connecting to a port which is zero and this barfs. Now it's easy to fix
> the test so that the port is set after the call to bind, however that
> feels wrong. Does anyone know why this is zero'd out?
This is probably a userspace/kernel space problem. The origional stack
would have made a copy of the sockaddr_in when moving over the kernel
boundary. Any modifications made to the address in the kernel would
not be reflectred in userspace unless the kernel explicitely copied it
back again.
But eCos does not have this userspace/kernel space boundary. The
FreeBSD stack has had a similar problem which i remember adding a
patch for. The same patch is probably needed here as well.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0
2004-08-17 16:24 Paul Riley
2004-08-17 16:31 ` Andrew Lunn
@ 2004-08-17 16:43 ` Andrew Lunn
1 sibling, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2004-08-17 16:43 UTC (permalink / raw)
To: Paul Riley; +Cc: ecos-discuss
On Tue, Aug 17, 2004 at 05:24:12PM +0100, Paul Riley wrote:
> Unless I'm missing something there is an inconsistency between the Open
> BSD stack and the io/fileio socket.c test.
Old on a minute. Are you sure we are talking about the OpenBSD stack
here? bsd_bind in the OpenBSD stack is:
static int bsd_bind ( cyg_file *fp, const sockaddr *sa, socklen_t len )
{
struct mbuf *nam;
int error;
error = sockargs(&nam, (caddr_t)sa, len, MT_SONAME);
if (error)
return (error);
error = sobind((struct socket *)fp->f_data, nam);
m_freem(nam);
return error;
}
The call to sockargs makes a copy of the sockaddr which is what is
passed into sobind. So i don't see who the "userspace" value can
change.
The FreeBSD stack however looks like it could have the problem you
describe.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-08-17 17:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-17 16:45 [ECOS] Inconsistency between the Open BSD IP stack and the tests in version 2.0 Paul Riley
2004-08-17 16:49 ` Andrew Lunn
-- strict thread matches above, loose matches on Subject: below --
2004-08-17 16:59 Paul Riley
2004-08-17 17:20 ` Andrew Lunn
2004-08-17 16:51 Paul Riley
2004-08-17 16:55 ` Andrew Lunn
2004-08-17 16:24 Paul Riley
2004-08-17 16:31 ` Andrew Lunn
2004-08-17 16:43 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).