public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcp: update outdated comment for removed _decode_session6()
@ 2026-03-21 10:59 Kexin Sun
  2026-03-21 13:59 ` Kuniyuki Iwashima
  2026-03-22  5:24 ` [PATCH v2] " Kexin Sun
  0 siblings, 2 replies; 5+ messages in thread
From: Kexin Sun @ 2026-03-21 10:59 UTC (permalink / raw)
  To: edumazet, ncardwell, kuniyu, davem, dsahern, kuba, pabeni, horms,
	netdev, linux-kernel
  Cc: julia.lawall, xutong.ma, kexinsun, yunbolyu, ratnadiraw

The function _decode_session6() was moved to
net/xfrm/xfrm_policy.c and renamed to decode_session6() by commit
c53ac41e3720 ("xfrm: remove decode_session indirection from
afinfo_policy"), and was later refactored to use flow dissector
instead of accessing IP6CB() directly by commit 7a0207094f1b
("xfrm: policy: replace session decode with flow dissector").

Replace the stale function reference with a general description of
the ordering constraint.

Assisted-by: unnamed:deepseek-v3.2 coccinelle
Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>
---
 net/ipv6/tcp_ipv6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index d10487b4e5bf..84d95e76085a 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1690,7 +1690,7 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,
 {
 	/* This is tricky: we move IP6CB at its correct location into
 	 * TCP_SKB_CB(). It must be done after xfrm6_policy_check(), because
-	 * _decode_session6() uses IP6CB().
+	 * the flow decoding during XFRM policy check uses IP6CB().
 	 * barrier() makes sure compiler won't play aliasing games.
 	 */
 	memmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb),
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] tcp: update outdated comment for removed _decode_session6()
  2026-03-21 10:59 [PATCH] tcp: update outdated comment for removed _decode_session6() Kexin Sun
@ 2026-03-21 13:59 ` Kuniyuki Iwashima
  2026-03-22  5:24 ` [PATCH v2] " Kexin Sun
  1 sibling, 0 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-03-21 13:59 UTC (permalink / raw)
  To: Kexin Sun
  Cc: edumazet, ncardwell, davem, dsahern, kuba, pabeni, horms, netdev,
	linux-kernel, julia.lawall, xutong.ma, yunbolyu, ratnadiraw

On Sat, Mar 21, 2026 at 4:00 AM Kexin Sun <kexinsun@smail.nju.edu.cn> wrote:
>
> The function _decode_session6() was moved to
> net/xfrm/xfrm_policy.c and renamed to decode_session6() by commit
> c53ac41e3720 ("xfrm: remove decode_session indirection from
> afinfo_policy"), and was later refactored to use flow dissector
> instead of accessing IP6CB() directly by commit 7a0207094f1b
> ("xfrm: policy: replace session decode with flow dissector").
>
> Replace the stale function reference with a general description of
> the ordering constraint.
>
> Assisted-by: unnamed:deepseek-v3.2 coccinelle
> Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>
> ---
>  net/ipv6/tcp_ipv6.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index d10487b4e5bf..84d95e76085a 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -1690,7 +1690,7 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,
>  {
>         /* This is tricky: we move IP6CB at its correct location into
>          * TCP_SKB_CB(). It must be done after xfrm6_policy_check(), because

Is the second sentence still true after the flow dissector
commit ?


> -        * _decode_session6() uses IP6CB().
> +        * the flow decoding during XFRM policy check uses IP6CB().
>          * barrier() makes sure compiler won't play aliasing games.
>          */
>         memmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb),
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] tcp: update outdated comment for removed _decode_session6()
  2026-03-21 10:59 [PATCH] tcp: update outdated comment for removed _decode_session6() Kexin Sun
  2026-03-21 13:59 ` Kuniyuki Iwashima
@ 2026-03-22  5:24 ` Kexin Sun
  2026-03-23 20:29   ` Kuniyuki Iwashima
  2026-03-23 20:40   ` Eric Dumazet
  1 sibling, 2 replies; 5+ messages in thread
From: Kexin Sun @ 2026-03-22  5:24 UTC (permalink / raw)
  To: edumazet, ncardwell, kuniyu, davem, dsahern, kuba, pabeni, horms,
	netdev, linux-kernel
  Cc: julia.lawall, xutong.ma, yunbolyu, ratnadiraw, Kexin Sun

The comment in tcp_v6_fill_cb() states that the memmove of
IP6CB into TCP_SKB_CB must be done after xfrm6_policy_check()
because _decode_session6() uses IP6CB().

This ordering constraint was introduced by commit 2dc49d1680b5
("tcp6: don't move IP6CB before xfrm6_policy_check()") and was
valid at the time.  However, commit 7a0207094f1b ("xfrm: policy:
replace session decode with flow dissector") replaced the
per-family decode_session callbacks with the flow dissector,
which parses packet headers directly without accessing IP6CB().

Since xfrm6_policy_check() no longer reads IP6CB() anywhere in
its call chain, the ordering constraint no longer applies.
Simplify the comment to describe only what the memmove and
barrier() actually do.

Assisted-by: unnamed:deepseek-v3.2 coccinelle
Suggested-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>
---
 net/ipv6/tcp_ipv6.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index d10487b4e5bf..619b35669361 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1688,10 +1688,9 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
 static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,
 			   const struct tcphdr *th)
 {
-	/* This is tricky: we move IP6CB at its correct location into
-	 * TCP_SKB_CB(). It must be done after xfrm6_policy_check(), because
-	 * _decode_session6() uses IP6CB().
-	 * barrier() makes sure compiler won't play aliasing games.
+	/* Move IP6CB to its saved location in TCP_SKB_CB().
+	 * barrier() makes sure compiler won't play aliasing
+	 * games.
 	 */
 	memmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb),
 		sizeof(struct inet6_skb_parm));
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] tcp: update outdated comment for removed _decode_session6()
  2026-03-22  5:24 ` [PATCH v2] " Kexin Sun
@ 2026-03-23 20:29   ` Kuniyuki Iwashima
  2026-03-23 20:40   ` Eric Dumazet
  1 sibling, 0 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-03-23 20:29 UTC (permalink / raw)
  To: Kexin Sun
  Cc: edumazet, ncardwell, davem, dsahern, kuba, pabeni, horms, netdev,
	linux-kernel, julia.lawall, xutong.ma, yunbolyu, ratnadiraw

On Sat, Mar 21, 2026 at 10:24 PM Kexin Sun <kexinsun@smail.nju.edu.cn> wrote:
>
> The comment in tcp_v6_fill_cb() states that the memmove of
> IP6CB into TCP_SKB_CB must be done after xfrm6_policy_check()
> because _decode_session6() uses IP6CB().
>
> This ordering constraint was introduced by commit 2dc49d1680b5
> ("tcp6: don't move IP6CB before xfrm6_policy_check()") and was
> valid at the time.  However, commit 7a0207094f1b ("xfrm: policy:
> replace session decode with flow dissector") replaced the
> per-family decode_session callbacks with the flow dissector,
> which parses packet headers directly without accessing IP6CB().
>
> Since xfrm6_policy_check() no longer reads IP6CB() anywhere in
> its call chain, the ordering constraint no longer applies.
> Simplify the comment to describe only what the memmove and
> barrier() actually do.
>
> Assisted-by: unnamed:deepseek-v3.2 coccinelle
> Suggested-by: Kuniyuki Iwashima <kuniyu@google.com>
> Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>
> ---
>  net/ipv6/tcp_ipv6.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index d10487b4e5bf..619b35669361 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -1688,10 +1688,9 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
>  static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,
>                            const struct tcphdr *th)
>  {
> -       /* This is tricky: we move IP6CB at its correct location into
> -        * TCP_SKB_CB(). It must be done after xfrm6_policy_check(), because
> -        * _decode_session6() uses IP6CB().
> -        * barrier() makes sure compiler won't play aliasing games.

nit: unnecessary change.

Also, please check this guidline for next submission.

> The new version of patches should be posted as a separate thread, not as a reply to the previous posting.
https://docs.kernel.org/process/maintainer-netdev.html#resending-after-review


> +       /* Move IP6CB to its saved location in TCP_SKB_CB().
> +        * barrier() makes sure compiler won't play aliasing
> +        * games.
>          */
>         memmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb),
>                 sizeof(struct inet6_skb_parm));
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] tcp: update outdated comment for removed _decode_session6()
  2026-03-22  5:24 ` [PATCH v2] " Kexin Sun
  2026-03-23 20:29   ` Kuniyuki Iwashima
@ 2026-03-23 20:40   ` Eric Dumazet
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2026-03-23 20:40 UTC (permalink / raw)
  To: Kexin Sun, Florian Westphal
  Cc: ncardwell, kuniyu, davem, dsahern, kuba, pabeni, horms, netdev,
	linux-kernel, julia.lawall, xutong.ma, yunbolyu, ratnadiraw

On Sat, Mar 21, 2026 at 10:24 PM Kexin Sun <kexinsun@smail.nju.edu.cn> wrote:
>
> The comment in tcp_v6_fill_cb() states that the memmove of
> IP6CB into TCP_SKB_CB must be done after xfrm6_policy_check()
> because _decode_session6() uses IP6CB().
>
> This ordering constraint was introduced by commit 2dc49d1680b5
> ("tcp6: don't move IP6CB before xfrm6_policy_check()") and was
> valid at the time.  However, commit 7a0207094f1b ("xfrm: policy:
> replace session decode with flow dissector") replaced the
> per-family decode_session callbacks with the flow dissector,
> which parses packet headers directly without accessing IP6CB().
>
> Since xfrm6_policy_check() no longer reads IP6CB() anywhere in
> its call chain, the ordering constraint no longer applies.
> Simplify the comment to describe only what the memmove and
> barrier() actually do.

Adding Florian to this thread.

So... the real question is :

Do we still need to call tcp_v6_fill_cb() from 4 different points,
and having this dance with tcp_v6_restore_cb() ?

Otherwise I see no real value in rephrasing a comment...

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-23 20:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 10:59 [PATCH] tcp: update outdated comment for removed _decode_session6() Kexin Sun
2026-03-21 13:59 ` Kuniyuki Iwashima
2026-03-22  5:24 ` [PATCH v2] " Kexin Sun
2026-03-23 20:29   ` Kuniyuki Iwashima
2026-03-23 20:40   ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox