]> err.no Git - linux-2.6/commitdiff
[IPV6]: Accept -1 for IPV6_TCLASS
authorRemi Denis-Courmont <rdenis@simphalempin.com>
Thu, 14 Sep 2006 03:08:07 +0000 (20:08 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 18 Sep 2006 06:21:08 +0000 (23:21 -0700)
This patch should add support for -1 as "default" IPv6 traffic class,
as specified in IETF RFC3542 ยง6.5. Within the kernel, it seems tclass
< 0 is already handled, but setsockopt, getsockopt and recvmsg calls
won't accept it from userland.

Signed-off-by: Remi Denis-Courmont <rdenis@simphalempin.com>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/datagram.c
net/ipv6/ipv6_sockglue.c

index 99a6eb23378bcc2d3b079ce3bc5ff7efd8e9ff58..3b55b4c8e2d1814f0bfe43210491efa8497d9813 100644 (file)
@@ -696,7 +696,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                        }
 
                        tc = *(int *)CMSG_DATA(cmsg);
-                       if (tc < 0 || tc > 0xff)
+                       if (tc < -1 || tc > 0xff)
                                goto exit_f;
 
                        err = 0;
index 43327264e69c4be3fadaa055adf0b0940fec717e..a5eaaf693abf7dad7c3e320f775bafa0f4be631b 100644 (file)
@@ -362,7 +362,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
                break;
 
        case IPV6_TCLASS:
-               if (val < 0 || val > 0xff)
+               if (val < -1 || val > 0xff)
                        goto e_inval;
                np->tclass = val;
                retv = 0;
@@ -947,6 +947,8 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
 
        case IPV6_TCLASS:
                val = np->tclass;
+               if (val < 0)
+                       val = 0;
                break;
 
        case IPV6_RECVTCLASS: