This is the mail archive of the ecos-patches@sourceware.org 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]

[Bug 1001656] FreeBSD: add AF_PACKET socket familiy


Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #11 from D.Zebralla <daniel.zebralla@arcor.de> ---
I stumbled across a problem sending normal UDP packets with this patch.
I'm not sure whether the problem is introduced by this patch or our way of
opening a UDP socket is wrong.

I'm referring to this change of the patch:

diff -Nur ecos-cvs-120723/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c
ecos/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c
--- ecos-cvs-120723/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c   
2009-01-29 18:49:56.000000000 +0100
+++ ecos/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c    2012-08-02
10:15:18.000000000 +0200
@@ -234,7 +234,8 @@
 {
     int error;
     sockaddr sa1=*sa;
-    
+    sa1.sa_len = len;
+
     error = sobind((struct socket *)fp->f_data, (sockaddr *)&sa1, 0);
     return error;
 }


We're starting the UDP connection like this (error checking omitted for
readability):
    memset(&hints, 0, sizeof hints); // make sure the struct is empty
    hints.ai_family = AF_INET6; // IPv6
    hints.ai_socktype = SOCK_DGRAM; // UDP
    hints.ai_flags = AI_PASSIVE; // fill in my IP for me

    getaddrinfo(NULL, "12345", &hints, &servinfo);

    acceptSocket = socket(servinfo->ai_family, servinfo->ai_socktype,
servinfo->ai_protocol);

    setsockopt(acceptSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&on,sizeof(on);

    bind(acceptSocket, servinfo->ai_addr, servinfo->ai_addrlen);

servinfo->ai_addrlen was set to 32 Bytes (size of struct sockaddr) inside
alloc_addrinfo-function:
    struct sockaddr * sa;
    [...]
    nai->ai_addrlen = sizeof(*sa);


Due to the patch inside bsd_bind sa1.sa_len is now changed from 28 (size of
struct sockaddr_in6) to 32 (size of struct sockaddr).

After finally arriving in the udp6_output function, the following sanity check
now fails because addr6->m_len is now 32 instead of 28:
    if (addr6) {
    [...]
        sin6 = mtod(addr6, struct sockaddr_in6 *);

        if (addr6->m_len != sizeof(*sin6))
            return(EINVAL);
    [...]
    }


Can someone please confirm this or point me to errors we may have made?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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