From: Antonio Pastor <antonio.pastor@gmail.com>
To: edumazet@google.com, netdev@vger.kernel.org
Cc: antonio.pastor@gmail.com, pabeni@redhat.com, horms@kernel.org,
	kuba@kernel.org, "David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org
Subject: [PATCH net v3] net: llc: reset skb->transport_header
Date: Tue, 24 Dec 2024 20:07:20 -0500	[thread overview]
Message-ID: <20241225010723.2830290-1-antonio.pastor@gmail.com> (raw)
In-Reply-To: <CANn89i+9Lt78ErDdbgVuOgvSy=UBz2Vhnp=cJYGvwuuQLp6qjg@mail.gmail.com>

802.2+LLC+SNAP frames received by napi_complete_done with GRO and DSA
have skb->transport_header set two bytes short, or pointing 2 bytes
before network_header & skb->data. As snap_rcv expects transport_header
to point to SNAP header (OID:PID) after LLC processing advances offset
over LLC header (llc_rcv & llc_fixup_skb), code doesn't find a match
and packet is dropped.

Between napi_complete_done and snap_rcv, transport_header is not used
until __netif_receive_skb_core, where originally it was being reset.
Commit fda55eca5a33 ("net: introduce skb_transport_header_was_set()")
only does so if not set, on the assumption the value was set correctly
by GRO (and also on assumption that "network stacks usually reset the
transport header anyway"). Afterwards it is moved forward by
llc_fixup_skb.

Locally generated traffic shows up at __netif_receive_skb_core with no
transport_header set and is processed without issue. On a setup with
GRO but no DSA, transport_header and network_header are both set to
point to skb->data which is also correct.

As issue is LLC specific, to avoid impacting non-LLC traffic, and to
follow up on original assumption made on previous code change,
llc_fixup_skb to reset the offset after skb pull. llc_fixup_skb
assumes the LLC header is at skb->data, and by definition SNAP header
immediately follows.

Fixes: fda55eca5a33 ("net: introduce skb_transport_header_was_set()")
Signed-off-by: Antonio Pastor <antonio.pastor@gmail.com>
---
 net/llc/llc_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c
index 51bccfb00a9c..61b0159b2fbe 100644
--- a/net/llc/llc_input.c
+++ b/net/llc/llc_input.c
@@ -124,8 +124,8 @@ static inline int llc_fixup_skb(struct sk_buff *skb)
 	if (unlikely(!pskb_may_pull(skb, llc_len)))
 		return 0;
 
-	skb->transport_header += llc_len;
 	skb_pull(skb, llc_len);
+	skb_reset_transport_header(skb);
 	if (skb->protocol == htons(ETH_P_802_2)) {
 		__be16 pdulen;
 		s32 data_size;
-- 
2.43.0


  parent reply	other threads:[~2024-12-25  1:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 14:20 [PATCH] net: llc: explicitly set skb->transport_header Antonio Pastor
2024-12-23 13:39 ` [PATCH net v2] " Antonio Pastor
2024-12-23 13:54   ` Eric Dumazet
     [not found]     ` <c8145fd0-df13-4c6a-8678-fbf9547cc112@gmail.com>
2024-12-23 18:18       ` Eric Dumazet
2024-12-25  1:35         ` Antonio Pastor
2024-12-28  2:12           ` [PATCH net] net: 802: reset skb->transport_header Antonio Pastor
2024-12-30  8:26             ` Eric Dumazet
2025-01-03  0:18               ` Antonio Pastor
2025-01-03  1:23               ` [PATCH net v2] net: 802: LLC+SNAP OID:PID lookup on start of skb data Antonio Pastor
2025-01-03  8:46                 ` Eric Dumazet
2025-01-04 16:20                 ` patchwork-bot+netdevbpf
2024-12-25  1:07     ` Antonio Pastor [this message]
2024-12-26  9:38       ` [PATCH net v3] net: llc: reset skb->transport_header Eric Dumazet
2024-12-27 19:30       ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241225010723.2830290-1-antonio.pastor@gmail.com \
    --to=antonio.pastor@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.