This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Error:bsd_bind


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]