diff options
author | Maciej Żenczykowski <maze@google.com> | 2021-11-24 01:31:54 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-11-25 05:57:14 +0300 |
commit | 9f7b3a69c88daabaacc6596c6409ff52e57d3067 (patch) | |
tree | 0dcb0536e4223dc287533a9c403351895546d8cd /net | |
parent | 079925cce1d06fe6614b1559b0020497b5b83d6a (diff) | |
download | linux-9f7b3a69c88daabaacc6596c6409ff52e57d3067.tar.xz |
net-ipv6: do not allow IPV6_TCLASS to muck with tcp's ECN
This is to match ipv4 behaviour, see __ip_sock_set_tos()
implementation at ipv4/ip_sockglue.c:579
void __ip_sock_set_tos(struct sock *sk, int val)
{
if (sk->sk_type == SOCK_STREAM) {
val &= ~INET_ECN_MASK;
val |= inet_sk(sk)->tos & INET_ECN_MASK;
}
if (inet_sk(sk)->tos != val) {
inet_sk(sk)->tos = val;
sk->sk_priority = rt_tos2priority(val);
sk_dst_reset(sk);
}
}
Cc: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20211123223154.1117794-1-zenczykowski@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv6/ipv6_sockglue.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 04683ad6d3df..8970b1a45257 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -599,6 +599,10 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, /* RFC 3542, 6.5: default traffic class of 0x0 */ if (val == -1) val = 0; + if (sk->sk_type == SOCK_STREAM) { + val &= ~INET_ECN_MASK; + val |= np->tclass & INET_ECN_MASK; + } np->tclass = val; retv = 0; break; |