๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17056

Re: [PATCH net-next v3 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop

#17056
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 10:48
165 lines
14068 bytes
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
Technical Details
Message-ID: <179482609749.3136.1445693542374471720@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364206-linux-kernel-netdev=dewy.ru
References: <CORE-9NOG.v3.r0.20261115050625-4@mojatatu.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364206-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179482609749.3136.1445693542374471720@kernel.org>
References: <CORE-9NOG.v3.r0.20261115050625-4@mojatatu.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2038307"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+DIsRZ91w8yHU9FD67JWDz5jxD8= sha256:/G1xArwhE5Q8S+pdWVpGIjsay6daMXB7thy/VJXD/iQ=
	sha1:4ulDK1rCmVE70EkiKDU6QHsRtts= sha256:WVd3laojkS7iU61OpCER5ADiUwgQyPYhpYhYUCYdD0w=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D8F40114BA5; Mon, 16 Nov 2026 13:48:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id voo_7mlSjO7h;
	Mon, 16 Nov 2026 13:48:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-364206-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 0E6BF114BA7; Mon, 16 Nov 2026 13:48:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id E98C62AB08; Mon, 16 Nov 2026 10:48:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794826100;
	b=YepWh8TQoDZh2uooFPPSeRgW5gdbkVaOUqTjCM0LuwqohBnuCGQNLGung02uWIZaOtgN
	 zgVNyrCHErQfOCx7Z0BiK470oKykhcoUTV+ZdJH8XMq0+33fWW7RFb4oGNWdzSN2Lj+so
	 S4RGya67nniOxtmCJtAs3l9Jej2ucq0ORrdexhiOapBCt4fuIXCvpVsMRiqiAKkEeSHEC
	 WHokG19CqZhZgrboB3CLpQzHeZyk/OMeAxSeLdB1DxYgttKXU+WDXZIgxAUVWbztrxXJ6
	 pBld/fal36bljOqcPbESxiDdpCBfbuXulMaFiWQyzgOHLaqQdPK/McHBtcO+gC0tg/A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794826100;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=RBr7T08CDXyEh5Mk2Quq/4B5EMCAxfNNg9PgBZ+5htE=;
	b=LsD5B8IPZzHVn1xnmCyl9GzU/3p7NoeSt+QiaRyQHBQaI6wTSZacSR1dUBzlPpQ9epIN
	 ViCUCT3T6IlhnTZ2h1Byfe+DphmZXeCJX5KakVHLiAAEccu0ysThdpR7+3VvyIUeqLaFl
	 Tx67jxwpMkAJJ7uyaowgI0Y2xpvXLr3/6SQWWPOIzopM2dmlToZzJUn6L4ro8wjv/aSI6
	 e7P4Uck9tjECjEMMSBah4lVYy2NfKyCRRuiKIu1pmrCVpcg9B+jVDrEl6vqkHp5ku1u7l
	 2jv/xoCm9Jc1luz2pblc9Kqad09RPOfARCdiToyExOxSSIqfPNr4QrScmcD6F6RlxLw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e8CjlPNh;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EA72C606A330;
	Mon, 16 Nov 2026 10:48:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e8CjlPNh
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794826099;
	b=rcwuYxslq+kjs/Sqa8DXA2MSrJMJI/vbuv/OjGK3I/gG5+ZnP7B5HJ3hvadQn87Z9RyV
	 mAC4CQgY1hqjJM+EM9aMSPuFEH8eyEZgm1tLPj+HjUyBei+18BH3obEN8DbZ/25o4WvNM
	 rsJNgVvSxCjk1MaBQnOWUmo2uzui4ed/FHdpg68f2/ISUGDL1cvszG9ZP7m6TnCbOgUeb
	 BHdpCEOy25Z15a6+435pGUdenRH8D8fNA61hTDcUXYp+agMMZNEpiuK+GDTW491Kl1sNo
	 uiviNfGqrikqEdDcrSGNz6Bc+VaEWHSGbh1pLVWdcQCACLtqJ8m0OJNKDUejWvpHQrw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794826099;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=RBr7T08CDXyEh5Mk2Quq/4B5EMCAxfNNg9PgBZ+5htE=;
	b=Cdg486dnG3I4T93hA+5wCIBH5AKVn7q14dfb7E0AqIUs7q45sNamARkrmYwWUYoRRpOL
	 gCt0ZtGOzs6iDmNZcVKyz75PBdanDEatxF8OG5Z/sdc/dmWfJF/QRpg+WSl7Ufead9BMB
	 Yqk+7zC/yS5CaIkAGAdGwhqo7PU5495eihYYW0ANEfjvZNdt0fByKEC7HS34lqt9Thcpl
	 VdLhu4t165FgXtsYbpnidARNfb2qHT8DjVsULBgReyLxer8CwYure0im5HSmP66BhC/Z+
	 dYc9UkQmKzLJ61o/mIPiRN/KZfPAdKX7NSLv9iIULNCvoef7uexziT12Sq41IwPHdKA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e8CjlPNh;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17E58606A329;
	Mon, 16 Nov 2026 10:48:19 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2B681F000C8;
	Mon, 16 Nov 2026 10:48:17 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794826098;
	bh=RBr7T08CDXyEh5Mk2Quq/4B5EMCAxfNNg9PgBZ+5htE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=e8CjlPNhE7F22ngOM2+QLr64fLVsvNQzUplJBn7/HbcpZqTd7s7Gl0dWdKUJ6aF9c
	 BETF2ZGYPoHLQuMG7UZzuvRd4ngWKppHXB+L52n0SjehLREKGp53qRJIiQhn7VQVui
	 Pd0EUEiC01mOz96C1D9Wnlpx5Im/LIJ9tHvPIH+ZQELBl9WXpzEFpB1W8XmYvRhV1/
	 QVYUFScNXwdwIirAAGqikWKzvTZEtd+oqOQaQif/rudcbSl3VF5xY8OboQLUjXE5GC
	 2pFn5ECuRhcJoo6tAvE8RV2jSJFr8sf0hGiG/ho88tmHDhABs5H5xjABwAumwSpBww
	 HlFRc8GlpmweA==
X-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
X-In-Reply-To: <CORE-9NOG.v3.r0.20261115050625-4@mojatatu.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list