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 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop
Date: Mon, 16 Nov 2026 10:48:17 +0000 [thread overview]
Message-ID: <179482609749.3136.1445693542374471720@kernel.org> (raw)
In-Reply-To: <CORE-9NOG.v3.r0.20261115050625-4@mojatatu.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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] The commit message says the explicit-nexthop branch "never
consults the route dst, so nothing that describes the route is lost".
- [Low] The patch fixes a user-visible bug but has no Fixes: tag, and its
commit message does not say which earlier patches it needs.
--
bpf: drop the stale dst when redirecting to an explicit nexthop
The patch changes __bpf_redirect_neigh_v4() and __bpf_redirect_neigh_v6().
When the BPF program supplies the nexthop, they now release the dst the
packet arrived with, using skb_dst_drop_keep_metadata(). This stops a frame
parked on the target device's arp_queue from being rebuilt later from the
original route.
Link: https://lore.kernel.org/netdev/QDISC-6HS9.v3.r0.20261103062649-2@mojatatu.com/
Link: https://lore.kernel.org/netdev/avTfQjFQYR2NNdRg@chamomile/
> diff --git a/net/core/filter.c b/net/core/filter.c
> index bd98d29ed7f8f..ae5346d6abd23 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -2318,6 +2318,8 @@ static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev,
> skb_dst_set(skb, dst);
> } else if (nh->nh_family != AF_INET6) {
> goto out_drop;
> + } else if (!skb_dst_drop_keep_metadata(skb)) {
> + goto out_drop;
> }
[Severity: Low]
This isn't a runtime bug, but should this patch carry a Fixes: tag?
In both __bpf_redirect_neigh_v4() and __bpf_redirect_neigh_v6(), the
if (!nh) { ... skb_dst_drop(); skb_dst_set(); } block with no else branch
for an explicit nexthop came from:
ba452c9e996d ("bpf: Fix bpf_redirect_neigh helper api to support supplying nexthop")
So the stale dst has been reachable since that commit. Something like this
would get the fix into stable:
Fixes: ba452c9e996d ("bpf: Fix bpf_redirect_neigh helper api to support supplying nexthop")
The baseline tree also has no skb_dst_drop_keep_metadata(). It is added
earlier in this series by "net: dst: keep the LWT metadata of a dropped
route".
The METADATA_XFRM dst it can install also depends on "net: xfrm: interface:
restore dst_orig on every xfrm interface". Without that commit, xfrmi_xmit2()
hits the skb_dst_set() warning, which panics under panic_on_warn.
Could the commit message name these prerequisites? A backport of this patch
alone will not build. A backport with only the helper would bring back the
xfrmi warning.
>
> err = bpf_out_neigh_v6(net, skb, dev, nh);
> @@ -2433,6 +2435,8 @@ static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,
>
> skb_dst_drop(skb);
> skb_dst_set(skb, &rt->dst);
> + } else if (!skb_dst_drop_keep_metadata(skb)) {
> + goto out_drop;
> }
[Severity: Medium]
The commit message says:
That branch never consults the route dst, so nothing that describes the
route is lost
That holds for bpf_out_neigh_v4() and bpf_out_neigh_v6(). Does it also hold
for the target device's xmit path when the target is an NBMA tunnel (ipip,
gre, sit or ip6tnl with no remote address)?
On those devices the neighbour is NOARP with direct output, so the BPF
nexthop has no effect. The tunnel picks its outer endpoint from skb_dst():
tc egress prog
bpf_redirect_neigh(nbma_ifindex, &nh, ...)
__bpf_redirect_neigh_v4()
skb_dst_drop_keep_metadata()
bpf_out_neigh_v4()
neigh_output() -> dev_queue_xmit()
ipip_tunnel_xmit() / ipgre_xmit()
ip_tunnel_xmit()
If the incoming route has no LWT state, skb_dst_drop_keep_metadata() leaves
the skb with no dst. ip_tunnel_xmit() then always drops the packet:
net/ipv4/ip_tunnel.c:ip_tunnel_xmit() {
...
dst = tnl_params->daddr;
if (dst == 0) {
/* NBMA tunnel */
if (!skb_dst(skb)) {
DEV_STATS_INC(dev, tx_fifo_errors);
goto tx_error;
}
...
}
ip6_tnl_xmit() goes to tx_err_link_failure in the same situation, and sit's
ipip6_tunnel_dst_find() returns false. Before this patch these
configurations transmitted, using rt_nexthop() of the original route.
If the incoming route has LWTUNNEL_ENCAP_IP or LWTUNNEL_ENCAP_IP6, the skb
gets a METADATA_IP_TUNNEL metadata_dst instead. When that tun_info is not a
usable IPv4 endpoint (encap ip6, or encap ip with no dst), ip_tunnel_xmit()
falls through to:
} else if (payload_protocol == htons(ETH_P_IP)) {
rt = skb_rtable(skb);
dst = rt_nexthop(rt, inner_iph->daddr);
}
and ip6_tnl_xmit() does:
} else if (payload_protocol == htons(ETH_P_IP)) {
const struct rtable *rt = skb_rtable(skb);
...
if (rt->rt_gw_family == AF_INET6)
memcpy(&fl6->daddr, &rt->rt_gw6, sizeof(fl6->daddr));
}
skb_rtable() is a plain cast. Doesn't that mean rt_gw_family and
rt_gw4/rt_gw6 are read from the metadata_dst's tun_info key bytes?
The reads stay inside the metadata_dst allocation, and rt is not used as
the output route. The outer endpoint would still come from unrelated bytes,
though.
>From the struct layouts, rt_gw_family appears to overlay the first byte of
key.u.ipv4.src. If so, a 10.x.x.x source address would look like AF_INET6
to ip6_tnl_xmit() and produce a bogus fl6->daddr.
The tunnel drivers calling skb_rtable() without skb_valid_dst() is not new.
bpf_skb_set_tunnel_key() plus bpf_redirect() can already reach it. This
patch adds another way to get there, though, and turns a configuration that
used to transmit into one that always drops.
The same applies to __bpf_redirect_neigh_v6() when it hands packets to sit
and ip6tnl NBMA devices.
Is this change in behaviour intended? Could the commit message mention it?
>
> err = bpf_out_neigh_v4(net, skb, dev, nh);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/CORE-9NOG.v3.r0.20261115050625%40mojatatu.com
prev parent 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
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 [this message]
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=179482609749.3136.1445693542374471720@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