diff mbox series

[net] gro_cells: Avoid packet re-ordering for cloned skbs

Message ID 20250109142724.29228-1-tbogendoerfer@suse.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] gro_cells: Avoid packet re-ordering for cloned skbs | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2025-01-09--18-00 (tests: 882)

Commit Message

Thomas Bogendoerfer Jan. 9, 2025, 2:27 p.m. UTC
gro_cells_receive() passes a cloned skb directly up the stack and
could cause re-ordering against segments still in GRO. To avoid
this copy the skb and let GRO do it's work.

Fixes: c9e6bc644e55 ("net: add gro_cells infrastructure")
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 net/core/gro_cells.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Eric Dumazet Jan. 9, 2025, 2:56 p.m. UTC | #1
On Thu, Jan 9, 2025 at 3:27 PM Thomas Bogendoerfer
<tbogendoerfer@suse.de> wrote:
>
> gro_cells_receive() passes a cloned skb directly up the stack and
> could cause re-ordering against segments still in GRO. To avoid
> this copy the skb and let GRO do it's work.
>
> Fixes: c9e6bc644e55 ("net: add gro_cells infrastructure")
> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
> ---
>  net/core/gro_cells.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/gro_cells.c b/net/core/gro_cells.c
> index ff8e5b64bf6b..2f8d688f9d82 100644
> --- a/net/core/gro_cells.c
> +++ b/net/core/gro_cells.c
> @@ -20,11 +20,20 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
>         if (unlikely(!(dev->flags & IFF_UP)))
>                 goto drop;
>
> -       if (!gcells->cells || skb_cloned(skb) || netif_elide_gro(dev)) {
> +       if (!gcells->cells || netif_elide_gro(dev)) {
> +netif_rx:
>                 res = netif_rx(skb);
>                 goto unlock;
>         }
> +       if (skb_cloned(skb)) {
> +               struct sk_buff *n;
>
> +               n = skb_copy(skb, GFP_KERNEL);

I do not think we want this skb_copy(). This is going to fail too often.

Can you remind us why we have this skb_cloned() check here ?
diff mbox series

Patch

diff --git a/net/core/gro_cells.c b/net/core/gro_cells.c
index ff8e5b64bf6b..2f8d688f9d82 100644
--- a/net/core/gro_cells.c
+++ b/net/core/gro_cells.c
@@ -20,11 +20,20 @@  int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
 	if (unlikely(!(dev->flags & IFF_UP)))
 		goto drop;
 
-	if (!gcells->cells || skb_cloned(skb) || netif_elide_gro(dev)) {
+	if (!gcells->cells || netif_elide_gro(dev)) {
+netif_rx:
 		res = netif_rx(skb);
 		goto unlock;
 	}
+	if (skb_cloned(skb)) {
+		struct sk_buff *n;
 
+		n = skb_copy(skb, GFP_KERNEL);
+		if (!n)
+			goto netif_rx;
+		kfree_skb(skb);
+		skb = n;
+	}
 	cell = this_cpu_ptr(gcells->cells);
 
 	if (skb_queue_len(&cell->napi_skbs) > READ_ONCE(net_hotdata.max_backlog)) {