Commit d0ee011f authored by Remi Denis-Courmont's avatar Remi Denis-Courmont Committed by David S. Miller

[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: default avatarRemi Denis-Courmont <rdenis@simphalempin.com>
Acked-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e012d51c
...@@ -696,7 +696,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, ...@@ -696,7 +696,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
} }
tc = *(int *)CMSG_DATA(cmsg); tc = *(int *)CMSG_DATA(cmsg);
if (tc < 0 || tc > 0xff) if (tc < -1 || tc > 0xff)
goto exit_f; goto exit_f;
err = 0; err = 0;
......
...@@ -362,7 +362,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -362,7 +362,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
break; break;
case IPV6_TCLASS: case IPV6_TCLASS:
if (val < 0 || val > 0xff) if (val < -1 || val > 0xff)
goto e_inval; goto e_inval;
np->tclass = val; np->tclass = val;
retv = 0; retv = 0;
...@@ -947,6 +947,8 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, ...@@ -947,6 +947,8 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
case IPV6_TCLASS: case IPV6_TCLASS:
val = np->tclass; val = np->tclass;
if (val < 0)
val = 0;
break; break;
case IPV6_RECVTCLASS: case IPV6_RECVTCLASS:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment