Skip to content

Commit

Permalink
[IPV6]: Accept -1 for IPV6_TCLASS
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Remi Denis-Courmont authored and David S. Miller committed Sep 18, 2006
1 parent e012d51 commit d0ee011
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion net/ipv6/datagram.c
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion net/ipv6/ipv6_sockglue.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d0ee011

Please sign in to comment.