diff mbox series

net-ipv6: do not allow IPV6_TCLASS to muck with tcp's ECN

Message ID 20211123223154.1117794-1-zenczykowski@gmail.com (mailing list archive)
State Accepted
Commit 9f7b3a69c88daabaacc6596c6409ff52e57d3067
Delegated to: Netdev Maintainers
Headers show
Series net-ipv6: do not allow IPV6_TCLASS to muck with tcp's ECN | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 4 maintainers not CCed: yoshfuji@linux-ipv6.org davem@davemloft.net dsahern@kernel.org kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Maciej Żenczykowski Nov. 23, 2021, 10:31 p.m. UTC
From: Maciej Żenczykowski <maze@google.com>

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: Eric Dumazet <edumazet@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/ipv6_sockglue.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Eric Dumazet Nov. 23, 2021, 10:52 p.m. UTC | #1
On Tue, Nov 23, 2021 at 2:32 PM Maciej Żenczykowski
<zenczykowski@gmail.com> wrote:
>
> From: Maciej Żenczykowski <maze@google.com>
>
> 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: Eric Dumazet <edumazet@google.com>
> Cc: Neal Cardwell <ncardwell@google.com>
> Signed-off-by: Maciej Żenczykowski <maze@google.com>
>

This makes sense, thanks, even if INET_ECN_dontxmit() would eventually
catch up for non dctcp.

Reviewed-by: Eric Dumazet <edumazet@google.com>
patchwork-bot+netdevbpf@kernel.org Nov. 25, 2021, 3:10 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 23 Nov 2021 14:31:54 -0800 you wrote:
> From: Maciej Żenczykowski <maze@google.com>
> 
> 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);
>   }
> }
> 
> [...]

Here is the summary with links:
  - net-ipv6: do not allow IPV6_TCLASS to muck with tcp's ECN
    https://git.kernel.org/netdev/net-next/c/9f7b3a69c88d

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 41efca817db4..204b0b4d10c8 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;