Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jhs@mojatatu.com
Cc: netdev@vger.kernel.org, pablo@netfilter.org, fw@strlen.de,
	phil@nwl.cc, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	jiri@resnulli.us, victor@mojatatu.com, sashiko-bot@kernel.org
Subject: Re: [PATCH net-next v3 2/4] net: dst: keep the LWT metadata of a dropped route
Date: Mon, 16 Nov 2026 10:48:14 +0000	[thread overview]
Message-ID: <179482609455.3136.1654206746484449957@kernel.org> (raw)
In-Reply-To: <CORE-9NOG.v3.r0.20261115050625-2@mojatatu.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message presents this patch as a bug fix, with a "The
  Fix:" section, a "Conditions to recreate the bug" section and the…
- [Low] The Return: section of the kernel-doc for
  skb_dst_drop_keep_metadata() (net/core/dst.c:370-373) does not match…

--

net: dst: keep the LWT metadata of a dropped route

This adds skb_dst_drop_keep_metadata(). It releases an skb's route dst
and moves any LWT encapsulation metadata onto a newly allocated metadata
dst: ip_tunnel_info for ip/ip6 encaps, xfrm_md_info for xfrm. The helper
is meant for the nft fwd and bpf_redirect_neigh() producers changed later
in the series.

> Found while working on the two producers that steer a packet to another
> device's neighbour, fixed later in this series. Both release the route
> dst on the way, and a route installed with an encapsulation carries the

[Severity: Low]
Is this description accurate for the tree at this commit?

nft_fwd_neigh_eval() in net/netfilter/nft_fwd_netdev.c goes straight to
neigh_xmit() and never calls skb_dst_drop():

	skb->dev = dev;
	skb_clear_tstamp(skb);

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

The nh != NULL path of __bpf_redirect_neigh_v4() and
__bpf_redirect_neigh_v6() in net/core/filter.c also leaves the original
route attached to the skb.

This commit adds no callers of skb_dst_drop_keep_metadata(). The route
release only appears in the later patches "netfilter: nft_fwd_netdev:
drop the stale dst when steering to a device" and "bpf: drop the stale
dst when redirecting to an explicit nexthop". The commit messages of
those patches say the producers currently leave the dst untouched.

> The Fix:
> Add skb_dst_drop_keep_metadata(), which moves those parameters onto a
> metadata dst of its own before the route is released.

[ ... ]

> Conditions to recreate the bug:
> Install a route with an encapsulation (ip route add ... encap ip id <id>
> dst <remote>, or encap xfrm if_id <id>), steer a packet to another
> device's neighbour with a netdev egress fwd rule or
> bpf_redirect_neigh(), and release the route dst before neigh_xmit() hands
> the packet on.

To reproduce, the reader has to release the route dst before
neigh_xmit(). Current code does not do that.

Could the message present this patch as a prerequisite helper for the
later producer changes, rather than as a fix with "The Fix:" and
"Conditions to recreate the bug:" sections?

> diff --git a/net/core/dst.c b/net/core/dst.c
> index 092861133023c..9c80c225cbfdd 100644
> --- a/net/core/dst.c
> +++ b/net/core/dst.c
> @@ -353,3 +353,79 @@ void metadata_dst_free_percpu(struct metadata_dst __percpu *md_dst)

[ ... ]

> + * A dst that is metadata is left in place.
> + *
> + * Return: true if the skb is left free to be sent, either because its dst is
> + * metadata already or because the LWT metadata was moved onto a new dst;
> + * false if no copy could be allocated, in which case the caller must drop the
> + * skb.
> + */

[Severity: Low]
Does this Return: section match what skb_dst_drop_keep_metadata() does?

The doc says false only means no copy could be allocated. The XFRM
branch also returns false when skb_dst_force() fails:

		if (!skb_dst_force(skb)) {
			metadata_dst_free(md_dst);
			return false;
		}

This happens when a noref route's refcount has already reached zero, for
example during a concurrent route removal. By that point skb_dst_force()
has set skb->_skb_refdst to 0, so the skb comes back with no dst. The
commit message's "the skb is left untouched for its owner to drop" does
not hold here either.

The doc says true only means the dst was already metadata or the metadata
was moved. True is also returned when the skb has no dst at all, because
skb_valid_dst() is false for a NULL dst:

	if (!skb_valid_dst(skb))
		return true;

True is also returned when the route has no lwtstate, or an lwtstate type
other than IP, IP6 or XFRM (MPLS, SEG6, BPF and so on). In that case the
route is dropped and the skb is left without a dst:

	skb_dst_drop(skb);
	if (md_dst)
		skb_dst_set(skb, &md_dst->dst);
	return true;

The callers added later in the series drop the skb on false. Since this
helper is exported, could the kernel-doc spell out these cases?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/CORE-9NOG.v3.r0.20261115050625%40mojatatu.com

  reply	other threads:[~2026-11-16 10:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 10:19 [PATCH net-next v3 0/4] net: drop the stale dst when steering to another device Jamal Hadi Salim
2026-11-15 10:19 ` [PATCH net-next v3 1/4] net: xfrm: interface: restore dst_orig on every xfrm interface Jamal Hadi Salim
2026-11-16 10:48   ` netdev-bot+sashiko
2026-11-15 10:19 ` [PATCH net-next v3 2/4] net: dst: keep the LWT metadata of a dropped route Jamal Hadi Salim
2026-11-16 10:48   ` netdev-bot+sashiko [this message]
2026-11-15 10:19 ` [PATCH net-next v3 3/4] netfilter: nft_fwd_netdev: drop the stale dst when steering to a device Jamal Hadi Salim
2026-11-16 10:48   ` netdev-bot+sashiko
2026-11-15 10:19 ` [PATCH net-next v3 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop Jamal Hadi Salim
2026-11-16 10:48   ` 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=179482609455.3136.1654206746484449957@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=sashiko-bot@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