netdev
[Top] [All Lists]

sin6_scope_id and 2.2.x kernel

To: netdev@xxxxxxxxxxx
Subject: sin6_scope_id and 2.2.x kernel
From: Arkadiusz Miskiewicz <misiek@xxxxxxxxxx>
Date: Fri, 17 Nov 2000 18:15:02 +0100
Sender: owner-netdev@xxxxxxxxxxx
User-agent: Mutt/1.2.5i
Hi,

in glibc 2.2 functions (ie. getnameinfo()) check for sizeof(struct sockaddr_in6)
passed from 2.2 kernel against sizeof(struct sockaddr_in6+with sin6_scope_id 
field)
and for 2.2.x kernels these functions will fail, so maybe such patch
should be applied to 2.2.x kernel tree. Just add sin6_scope_id field
to struct sockaddr_in6 (as in 2.4 kernel) but don't use it.

diff -urN linux-2.2.x.org/include/linux/in6.h linux-2.2.x/include/linux/in6.h
--- linux-2.2.x.org/include/linux/in6.h Fri Nov 17 18:21:58 2000
+++ linux-2.2.x/include/linux/in6.h     Fri Nov 17 18:22:26 2000
@@ -56,6 +56,7 @@
        __u16                   sin6_port;      /* Transport layer port # */
        __u32                   sin6_flowinfo;  /* IPv6 flow information */
        struct in6_addr         sin6_addr;      /* IPv6 address */
+       __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
 };
 
 
diff -urN linux-2.2.x.org/include/net/ipv6.h linux-2.2.x/include/net/ipv6.h
--- linux-2.2.x.org/include/net/ipv6.h  Tue May 11 19:36:50 1999
+++ linux-2.2.x/include/net/ipv6.h      Fri Nov 17 18:55:27 2000
@@ -20,6 +20,8 @@
 #include <net/ndisc.h>
 #include <net/flow.h>
 
+#define        SIN6_LEN_RFC2133        24
+
 /*
  *     NextHeader field of IPv6 header
  */
diff -urN linux-2.2.x.org/net/ipv6/af_inet6.c linux-2.2.x/net/ipv6/af_inet6.c
--- linux-2.2.x.org/net/ipv6/af_inet6.c Thu May  4 02:16:53 2000
+++ linux-2.2.x/net/ipv6/af_inet6.c     Fri Nov 17 18:56:34 2000
@@ -199,7 +199,7 @@
                
        /* Check these errors (active socket, bad address length, double bind). 
*/
        if ((sk->state != TCP_CLOSE)                    ||
-           (addr_len < sizeof(struct sockaddr_in6))    ||
+           (addr_len < SIN6_LEN_RFC2133)               ||
            (sk->num != 0))
                return -EINVAL;
                
diff -urN linux-2.2.x.org/net/ipv6/raw.c linux-2.2.x/net/ipv6/raw.c
--- linux-2.2.x.org/net/ipv6/raw.c      Mon Aug  9 21:04:41 1999
+++ linux-2.2.x/net/ipv6/raw.c  Fri Nov 17 18:57:01 2000
@@ -117,7 +117,7 @@
        int addr_type;
 
        /* Check these errors. */
-       if (sk->state != TCP_CLOSE || (addr_len < sizeof(struct sockaddr_in6)))
+       if (sk->state != TCP_CLOSE || (addr_len < SIN6_LEN_RFC2133))
                return -EINVAL;
 
        addr_type = ipv6_addr_type(&addr->sin6_addr);
@@ -360,7 +360,7 @@
        fl.fl6_flowlabel = 0;
 
        if (sin6) {
-               if (addr_len < sizeof(struct sockaddr_in6)) 
+               if (addr_len < SIN6_LEN_RFC2133) 
                        return(-EINVAL);
 
                if (sin6->sin6_family && sin6->sin6_family != AF_INET6) 
diff -urN linux-2.2.x.org/net/ipv6/tcp_ipv6.c linux-2.2.x/net/ipv6/tcp_ipv6.c
--- linux-2.2.x.org/net/ipv6/tcp_ipv6.c Thu May  4 02:16:53 2000
+++ linux-2.2.x/net/ipv6/tcp_ipv6.c     Fri Nov 17 18:57:12 2000
@@ -387,7 +387,7 @@
        if(!ipv6_addr_any(&np->daddr))
                return -EINVAL;
        
-       if (addr_len < sizeof(struct sockaddr_in6)) 
+       if (addr_len < SIN6_LEN_RFC2133) 
                return(-EINVAL);
 
        if (usin->sin6_family && usin->sin6_family != AF_INET6) 
diff -urN linux-2.2.x.org/net/ipv6/udp.c linux-2.2.x/net/ipv6/udp.c
--- linux-2.2.x.org/net/ipv6/udp.c      Mon Aug  9 21:04:41 1999
+++ linux-2.2.x/net/ipv6/udp.c  Fri Nov 17 18:58:13 2000
@@ -210,7 +210,7 @@
                goto ipv4_connected;
        }
 
-       if (addr_len < sizeof(*usin)) 
+       if (addr_len < SIN6_LEN_RFC2133) 
                return(-EINVAL);
 
        if (usin->sin6_family && usin->sin6_family != AF_INET6) 
@@ -777,7 +777,7 @@
                if (sin6->sin6_family == AF_INET)
                        return udp_sendmsg(sk, msg, ulen);
 
-               if (addr_len < sizeof(*sin6))
+               if (addr_len < SIN6_LEN_RFC2133)
                        return(-EINVAL);
 
                if (sin6->sin6_family && sin6->sin6_family != AF_INET6)

-- 
Arkadiusz Miśkiewicz, AM2-6BONE    [ PLD GNU/Linux IPv6 ]
http://www.t17.ds.pwr.wroc.pl/~misiek/ipv6/   [ enabled ]

<Prev in Thread] Current Thread [Next in Thread>