This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: Error:bsd_bind
- From: Andrew Lunn <andrew at lunn dot ch>
- To: reji <reji at codito dot com>
- Cc: ecos-patches at sources dot redhat dot com
- Date: Tue, 14 Oct 2003 18:47:32 +0200
- Subject: Re: Error:bsd_bind
- References: <000501c39269$4ef11670$0100a8c0@codito.co.in>
On Tue, Oct 14, 2003 at 09:09:08PM +0530, reji wrote:
> Problem in bsd_bind(packages/net/bsd_tcpip/current/src/sys/kern/sockio.c)
>
> bsd_bind(cyg_file *fp, const sockaddr *sa, socklen_t len)
> {
> int error;
>
> error = sobind((struct socket *)fp->f_data, (sockaddr *)sa, 0);
> return error;
> }
>
> The sa which was declared to be a const is passed to sobind without making
> a copy.
> In the call to in_pcbbind ,in_pcbbind zeroes out the port number in the
> socket address structure for passing it to ifa_ifwithaddr for doing a
> binary comparision of the whole structure .
Yes, it looks like you have found a problem. This is the result of
running the code on a system without a user/kernel
seperation. Normally the sockaddr would be copied from user space into
kernel space and then passed to the network stack. Any changes it made
are not seen in userspace unless it explicitly copies it back into
user space. eCos does not do this copying in and out since it does not
have userspace/kernel space. Hence the problem. This may also be
happening for other socket calls.
I don't like you fix though. I would just have a local variable rather
than have the big overhead of malloc/free. I would also do it a level
up since the OpenBSD stack probably has the same problem.
Andrew