This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: [ECOS] Re: bsp_connect function in packages/net/bsd_tcpip/current/src/sys/kern/sockio.c improvement proposal
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Philippe Vandermersch <phil at equator dot com>,eCos Patches <ecos-patches at ecos dot sourceware dot org>
- Date: Sat, 17 Jan 2004 15:10:26 +0100
- Subject: Re: [ECOS] Re: bsp_connect function in packages/net/bsd_tcpip/current/src/sys/kern/sockio.c improvement proposal
- References: <3FFDF2E8.90904@equator.com> <20040109082736.GI11494@biferten.ma.tech.ascom.ch>
> This is not quite correct. Take a look at the FreeBSD code. It does
> fill in the length, but only the kernel copy of the sockaddr. It
> leaves the userspace copy alone. See
>
> http://fxr.watson.org/fxr/source/kern/uipc_syscalls.c#L1595
>
> Please could you write a proper patch with ChangeLog.
>
> It will also need testing properly. This might show up bugs in the
> rest of eCos's network code and applications. eg a properly filled in
> IPv6 sockaddr is being passed to connect, but the len parameter is
> that of an IPv4 address etc.
I've fixed this now and performed some testing.
Andrew
Index: net/bsd_tcpip/current//ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/ChangeLog,v
retrieving revision 1.40
diff -u -r1.40 ChangeLog
--- net/bsd_tcpip/current//ChangeLog 21 Dec 2003 12:28:39 -0000 1.40
+++ net/bsd_tcpip/current//ChangeLog 17 Jan 2004 14:08:50 -0000
@@ -1,3 +1,8 @@
+2004-01-17 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/sys/kern/sockio.c (bsd_connect): Set the sa_len field in
+ the sockaddr structure. Real FreeBSD does this.
+
2003-12-21 Nick Garnett <nickg@calivar.com>
* include/sys/param.h: Restored MD5 function mappings. These were
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.4
diff -u -r1.4 sockio.c
--- net/bsd_tcpip/current//src/sys/kern/sockio.c 29 Jul 2003 14:02:12 -0000 1.4
+++ net/bsd_tcpip/current//src/sys/kern/sockio.c 17 Jan 2004 14:08:53 -0000
@@ -257,14 +257,17 @@
bsd_connect(cyg_file *fp, const sockaddr *sa, socklen_t len)
{
struct socket *so;
+ sockaddr sa1=*sa;
+
int error, s;
+ sa1.sa_len = len;
so = (struct socket *)fp->f_data;
if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING))
return (EALREADY);
- error = soconnect(so, (struct sockaddr *)sa, 0);
+ error = soconnect(so, (struct sockaddr *)&sa1, 0);
if (error)
goto bad;