Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jhs@mojatatu.com
Cc: netdev@vger.kernel.org, victor@mojatatu.com, jiri@resnulli.us,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, stable@vger.kernel.org,
	sashiko-bot@kernel.org
Subject: Re: [PATCH net v5 1/3] net/sched: sch_teql: unshare the header before writing and fix retry strip
Date: Thu, 19 Nov 2026 10:38:38 +0000	[thread overview]
Message-ID: <179508471843.3136.7272721682226577890@kernel.org> (raw)
In-Reply-To: <QDISC-6HS9.v5.r0.20261116052927-1@mojatatu.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] This patch changes how teql_master_xmit()
  (net/sched/sch_teql.c) retries when an skb has a dst attached and…

--

net/sched: sch_teql: unshare the header before writing and fix retry strip

This patch calls skb_cow_head() in __teql_resolve() before the slave
neighbour can write or queue the skb, so a cloned header is not
corrupted. It also changes the retry path in teql_master_xmit(). The
retry now pulls back only the bytes the current slave pushed, instead of
pulling to the network header, so AF_PACKET frames without a dst keep
their own link header.

Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v4.r0.20261111094338-1%40mojatatu.com
Link: https://lore.kernel.org/netdev/20260824115928.4099988-1-victor@mojatatu.com/
Link: https://lore.kernel.org/netdev/20261110101908.2e64e8e9@kernel.org/

> diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
> index dc21cd9704a25..626dc001ec231 100644
> --- a/net/sched/sch_teql.c
> +++ b/net/sched/sch_teql.c

[ ... ]

>  	if (neigh_event_send(n, skb_res) == 0) {
> +		int off = skb_network_offset(skb);
>  		char haddr[MAX_ADDR_LEN];
>  
>  		neigh_ha_snapshot(haddr, n, dev);
>  		if (dev_hard_header(skb, dev, ntohs(skb_protocol(skb, false)),
>  				    haddr, NULL, skb->len) < 0)
>  			err = -EINVAL;
> +		/* The bytes prepended above skb->data, pulled back on retry. */
> +		*hlen = skb_network_offset(skb) - off;
>  	} else {
>  		err = (skb_res == NULL) ? -EAGAIN : 1;
>  	}

[ ... ]

> @@ -408,8 +421,10 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
>  			nores = 1;
>  			break;
>  		}
> +		/* Pull back only the header this slave added. */
> +		if (hlen > 0)
> +			__skb_pull(skb, hlen);
>  		skb->dev = dev;
> -		__skb_pull(skb, skb_network_offset(skb));
>  	} while ((q = rcu_dereference(NEXT_SLAVE(q))) != start);

[Severity: Medium]
What happens on retry when the skb has a dst and already carries
link-layer bytes in front of its network header?

The old retry reset skb->data to the network header. That matches what
neigh_resolve_output() and neigh_connected_output() do before building
a header:

net/core/neighbour.c:neigh_resolve_output() {
    ...
		do {
			__skb_pull(skb, skb_network_offset(skb));
			seq = read_seqbegin(&neigh->ha_lock);
			err = dev_hard_header(skb, dev, ntohs(skb->protocol),
					      neigh->ha, NULL, skb->len);
    ...
}

__teql_resolve() pushes the slave header at skb->data without pulling
to the network header first, and hlen only counts that push. So with
the new retry, any L2 bytes already present when teql_master_xmit() was
entered stay in place across every retry.

One path that still delivers such an skb, even with the rest of the
series applied, is nft fwd ... neigh on a netdev egress chain.
nft_fwd_validate() allows NF_NETDEV_EGRESS, and nft_fwd_neigh_eval()
neither pulls to the network header nor drops the dst:

net/netfilter/nft_fwd_netdev.c:nft_fwd_neigh_eval() {
    ...
	skb->dev = dev;
	skb_clear_tstamp(skb);

	nf_dev_xmit_recursion_inc();
	neigh_xmit(neigh_table, dev, addr, skb);
    ...
}

teql0 has no header_ops, so arp_constructor() installs
neigh_direct_output() for it:

nft_fwd_neigh_eval()
  neigh_xmit()
    neigh_direct_output()
      dev_queue_xmit(teql0)
        teql_master_xmit()
          __teql_resolve()

The skb arrives with eth0's header in front of the IP header (network
offset 14) and eth0's route dst still attached. Because dst->dev !=
slave, __teql_resolve() looks up the slave's neighbour. From there:

If the slave neighbour is resolved, dev_hard_header() pushes 14 bytes
and hlen = 14. If the trylock then fails or the slave returns
NETDEV_TX_BUSY, the retry pulls only 14 bytes. The next slave sends
slave header + eth0 header + IP, while the old code pulled 28 bytes
and sent a single header.

If the slave neighbour is unresolved (-EAGAIN, nores), hlen = 0 and
nothing is pulled. The next slave in the same pass gets the double
header, while the old code pulled the stale 14 bytes.

At this commit alone there is a second trigger: an arp_queue skb
drained back into teql0 after neigh_resolve_output() wrote an eth0
header. Here skb->dev = slave is only set inside case 0, so the parked
skb still has skb->dev pointing at teql0.

That second trigger is closed later in the series. "net/sched: sch_teql:
keep skb->dev consistent on the arp-queue path" sets skb->dev = slave
before teql_resolve(). "net: neighbour: reinject a parked skb through a
headerless output device" only reverts skb->dev to a headerless
n1->dev, whose output is neigh_direct_output(), so no header is written
in that case. The nft fwd path above is not affected by either change.

The AF_PACKET case in the commit message only seems to need the
dst == NULL early return in teql_resolve(), where hlen is always 0.
Would it work to keep pulling to the network header for skbs with a
dst? Another option would be to pull to the network header in
__teql_resolve() before dev_hard_header(), as neigh_resolve_output()
does.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v5.r0.20261116052927%40mojatatu.com

  reply	other threads:[~2026-11-19 10:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 10:36 [PATCH net v5 0/3] net/sched: sch_teql: keep the transmit path's skb geometry and device lifetime intact Jamal Hadi Salim
2026-11-16 10:36 ` [PATCH net v5 1/3] net/sched: sch_teql: unshare the header before writing and fix retry strip Jamal Hadi Salim
2026-11-19 10:38   ` netdev-bot+sashiko [this message]
2026-11-16 10:36 ` [PATCH net v5 2/3] net: neighbour: reinject a parked skb through a headerless output device Jamal Hadi Salim
2026-11-19 10:38   ` netdev-bot+sashiko
2026-11-16 10:36 ` [PATCH net v5 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path Jamal Hadi Salim
2026-11-19 10:38   ` netdev-bot+sashiko

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=179508471843.3136.7272721682226577890@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sashiko-bot@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=victor@mojatatu.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