public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>, Joe Damato <joe@dama.to>,
	 netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 1/9] net: tso: add tso_features_check()
Date: Fri,  3 Apr 2026 04:32:29 +0000	[thread overview]
Message-ID: <20260403043237.3909226-2-edumazet@google.com> (raw)
In-Reply-To: <20260403043237.3909226-1-edumazet@google.com>

net/core/tso.c users expecting headers size is smaller
than TSO_HEADER_SIZE must fallback to GSO when headers
are too big.

Provide tso_features_check() for drivers .ndo_features_check().

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/tso.h | 11 +++++++++++
 net/core/tso.c    | 12 ++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/net/tso.h b/include/net/tso.h
index e7e157ae0526c8d655aca67a8a49191ec870746b..9be7cb6553975a2a82e0987214fee6883bf74404 100644
--- a/include/net/tso.h
+++ b/include/net/tso.h
@@ -28,4 +28,15 @@ void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso,
 void tso_build_data(const struct sk_buff *skb, struct tso_t *tso, int size);
 int tso_start(struct sk_buff *skb, struct tso_t *tso);
 
+static inline int tso_compute_hdr_len(const struct sk_buff *skb)
+{
+	int tlen = skb_is_gso_tcp(skb) ? tcp_hdrlen(skb) : sizeof(struct udphdr);
+	int hdr_len = skb_transport_offset(skb) + tlen;
+
+	return hdr_len;
+}
+
+netdev_features_t tso_features_check(struct sk_buff *skb,
+				     struct net_device *dev,
+				     netdev_features_t features);
 #endif	/* _TSO_H */
diff --git a/net/core/tso.c b/net/core/tso.c
index 6df997b9076e9842f3de7bb3e34599d8ff4e4fd4..81e2cc66d0dd29eeb647232e04032b1412382a6f 100644
--- a/net/core/tso.c
+++ b/net/core/tso.c
@@ -87,3 +87,15 @@ int tso_start(struct sk_buff *skb, struct tso_t *tso)
 	return hdr_len;
 }
 EXPORT_SYMBOL(tso_start);
+
+netdev_features_t tso_features_check(struct sk_buff *skb,
+				     struct net_device *dev,
+				     netdev_features_t features)
+{
+	if (skb_is_gso(skb)) {
+		if (tso_compute_hdr_len(skb) > TSO_HEADER_SIZE)
+			features &= ~NETIF_F_GSO_MASK;
+	}
+	return features;
+}
+EXPORT_SYMBOL(tso_features_check);
-- 
2.53.0.1213.gd9a14994de-goog


  reply	other threads:[~2026-04-03  4:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-03  4:32 [PATCH net-next 0/9] net: safe guard net/core/tso.c users Eric Dumazet
2026-04-03  4:32 ` Eric Dumazet [this message]
2026-04-03  6:41   ` [PATCH net-next 1/9] net: tso: add tso_features_check() Eric Dumazet
2026-04-03  7:20     ` Eric Dumazet
2026-04-03 20:47       ` Jakub Kicinski
2026-04-03 20:49         ` Eric Dumazet
2026-04-03 21:00           ` Eric Dumazet
2026-04-03  4:32 ` [PATCH net-next 2/9] net: mvneta: use tso_features_check() Eric Dumazet
2026-04-03  4:32 ` [PATCH net-next 3/9] net: thunderx: " Eric Dumazet
2026-04-03  4:32 ` [PATCH net-next 4/9] dpaa2-eth: " Eric Dumazet
2026-04-03  4:32 ` [PATCH net-next 5/9] net: enetc: " Eric Dumazet
2026-04-03  4:32 ` [PATCH net-next 6/9] net: fec: " Eric Dumazet
2026-04-03  4:32 ` [PATCH net-next 7/9] net: mv643xx_eth: " Eric Dumazet
2026-04-03  4:32 ` [PATCH net-next 8/9] net: mvpp2: " Eric Dumazet
2026-04-03  4:32 ` [PATCH net-next 9/9] octeontx2-pf: " Eric Dumazet

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=20260403043237.3909226-2-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=joe@dama.to \
    --cc=kuba@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox