From: Remi Denis-Courmont Date: Thu, 14 Sep 2006 03:08:07 +0000 (-0700) Subject: [IPV6]: Accept -1 for IPV6_TCLASS X-Git-Tag: v2.6.18~11^2~10 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0ee011f7290b51974e4d058cf4455a5ef91177d;p=linux-2.6 [IPV6]: Accept -1 for IPV6_TCLASS 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 Acked-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 99a6eb2337..3b55b4c8e2 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -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; diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 43327264e6..a5eaaf693a 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -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: