All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v3] gtp: parse extension headers before reading inner protocol
@ 2026-07-08  4:22 Zhixing Chen
  2026-07-20  7:28 ` Zhixing Chen
  2026-07-21  9:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Zhixing Chen @ 2026-07-08  4:22 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Harald Welte
  Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, osmocom-net-gprs, netdev, Zhixing Chen

GTPv1-U packets may carry a chain of extension headers before the inner
IP packet. The receive path already parses and skips these extension
headers, but it currently reads the inner protocol before doing so.

As a result, the first extension header byte is interpreted as the inner
IP version. Packets with extension headers are then dropped before PDP
lookup.

Parse the extension header chain before calling gtp_inner_proto(), so the
inner protocol is read from the actual inner IP header.

Fixes: c75fc0b9e5be ("gtp: identify tunnel via GTP device + GTP version + TEID + family")
Signed-off-by: Zhixing Chen <running910@gmail.com>
---

Changes in v3:
- Refetch the GTP header after pskb_may_pull() before checking the
  extension-header flag.

Changes in v2:
- Add missing Fixes tag.

v2: https://lore.kernel.org/netdev/20260703093708.18141-1-running910@gmail.com/T/ 
v1: https://lore.kernel.org/netdev/20260703084244.59077-1-running910@gmail.com/T/

---
 drivers/net/gtp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index a60ef32b35b8..c0e38878af51 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -826,13 +826,17 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb)
 	if (!pskb_may_pull(skb, hdrlen))
 		return -1;
 
+	gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr));
+
+	if (gtp1->flags & GTP1_F_EXTHDR &&
+	    gtp_parse_exthdrs(skb, &hdrlen) < 0)
+		return -1;
+
 	if (gtp_inner_proto(skb, hdrlen, &inner_proto) < 0) {
 		netdev_dbg(gtp->dev, "GTP packet does not encapsulate an IP packet\n");
 		return -1;
 	}
 
-	gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr));
-
 	pctx = gtp1_pdp_find(gtp, ntohl(gtp1->tid),
 			     gtp_proto_to_family(inner_proto));
 	if (!pctx) {
@@ -840,10 +844,6 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb)
 		return 1;
 	}
 
-	if (gtp1->flags & GTP1_F_EXTHDR &&
-	    gtp_parse_exthdrs(skb, &hdrlen) < 0)
-		return -1;
-
 	return gtp_rx(pctx, skb, hdrlen, gtp->role, inner_proto);
 }
 
-- 
2.34.1


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

* Re: [PATCH net v3] gtp: parse extension headers before reading inner protocol
  2026-07-08  4:22 [PATCH net v3] gtp: parse extension headers before reading inner protocol Zhixing Chen
@ 2026-07-20  7:28 ` Zhixing Chen
  2026-07-21  9:22   ` Paolo Abeni
  2026-07-21  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 5+ messages in thread
From: Zhixing Chen @ 2026-07-20  7:28 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Harald Welte
  Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, osmocom-net-gprs, netdev

Hi Pablo,

Gentle ping on this v3, in case it fell through the cracks.

It refetches the GTP header after pskb_may_pull() before checking the
extension-header flag, as you pointed out on v2.

Thanks,
Zhixing

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

* Re: [PATCH net v3] gtp: parse extension headers before reading inner protocol
  2026-07-20  7:28 ` Zhixing Chen
@ 2026-07-21  9:22   ` Paolo Abeni
  2026-07-21  9:50     ` Zhixing Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2026-07-21  9:22 UTC (permalink / raw)
  To: Zhixing Chen, Pablo Neira Ayuso, Harald Welte
  Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	osmocom-net-gprs, netdev

On 7/20/26 9:28 AM, Zhixing Chen wrote:
> Gentle ping on this v3, in case it fell through the cracks.

Please, don't.

Maintainers are overflown by LLM generated contents, and conferences &&
season interruption reduce the available time. While the patch is alive
in PW and no comments from reviewer and/or sashiko are pending, no
additional action is needed.

The patch LGTM, I'm applying it now.

/P


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

* Re: [PATCH net v3] gtp: parse extension headers before reading inner protocol
  2026-07-08  4:22 [PATCH net v3] gtp: parse extension headers before reading inner protocol Zhixing Chen
  2026-07-20  7:28 ` Zhixing Chen
@ 2026-07-21  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-21  9:30 UTC (permalink / raw)
  To: Zhixing Chen
  Cc: pablo, laforge, andrew+netdev, davem, edumazet, kuba, pabeni,
	osmocom-net-gprs, netdev

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Wed,  8 Jul 2026 12:22:44 +0800 you wrote:
> GTPv1-U packets may carry a chain of extension headers before the inner
> IP packet. The receive path already parses and skips these extension
> headers, but it currently reads the inner protocol before doing so.
> 
> As a result, the first extension header byte is interpreted as the inner
> IP version. Packets with extension headers are then dropped before PDP
> lookup.
> 
> [...]

Here is the summary with links:
  - [net,v3] gtp: parse extension headers before reading inner protocol
    https://git.kernel.org/netdev/net/c/96e37e2f618e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH net v3] gtp: parse extension headers before reading inner protocol
  2026-07-21  9:22   ` Paolo Abeni
@ 2026-07-21  9:50     ` Zhixing Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Zhixing Chen @ 2026-07-21  9:50 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Pablo Neira Ayuso, Harald Welte, Andrew Lunn, David S . Miller,
	Eric Dumazet, Jakub Kicinski, osmocom-net-gprs, netdev

> season interruption reduce the available time. While the patch is alive
> in PW and no comments from reviewer and/or sashiko are pending, no
> additional action is needed.

Thanks Pablo, understood. I just learned this workflow and will keep it in
mind next time.

I appreciate your review and help.

Best regards,
Zhixing

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

end of thread, other threads:[~2026-07-21  9:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08  4:22 [PATCH net v3] gtp: parse extension headers before reading inner protocol Zhixing Chen
2026-07-20  7:28 ` Zhixing Chen
2026-07-21  9:22   ` Paolo Abeni
2026-07-21  9:50     ` Zhixing Chen
2026-07-21  9:30 ` patchwork-bot+netdevbpf

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.