Netdev List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Jamal Hadi Salim" <jhs@mojatatu.com>, <netdev@vger.kernel.org>
Cc: "Daniel Borkmann" <daniel@iogearbox.net>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>, <bpf@vger.kernel.org>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"Victor Nogueira" <victor@mojatatu.com>,
	"Sashiko" <sashiko-bot@kernel.org>
Subject: Re: [PATCH net-next v4 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop
Date: Mon, 16 Nov 2026 20:46:27 +0000	[thread overview]
Message-ID: <DMWXH28YQDYH.1SI4Y5WQ7EPSR@gmail.com> (raw)
In-Reply-To: <CORE-9NOG.v4.r0.20261116135311-4@mojatatu.com>

On Mon, Nov 16, 2026 at 11:01 AM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
> The release goes through skb_dst_drop_keep_metadata(), so encapsulation
> parameters a route carries are handed over to a metadata dst instead of
> being lost, and a metadata dst already on the packet is left in place. Both
> wrappers take their existing drop path when that copy cannot be allocated,
> so a packet is never sent with the stale route.

Just briefly looked at it. skb_dst_drop_keep_metadata() with kmalloc()
in the fast path is really no go.

Why not do something like this instead of patches 2, 3 and 4 ?

diff --git a/net/core/filter.c b/net/core/filter.c
index 946b07a..13f2d57 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2470,6 +2470,10 @@ static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev,
 	skb_unset_mac_header(skb);
 	skb_reset_network_header(skb);

+	/* The route is for the old skb->dev. Keep the tunnel key. */
+	if (skb_valid_dst(skb))
+		skb_dst_drop(skb);
+
 	if (skb->protocol == htons(ETH_P_IP))
 		return __bpf_redirect_neigh_v4(skb, dev, nh);
 	else if (skb->protocol == htons(ETH_P_IPV6))
diff --git a/net/netfilter/nft_fwd_netdev.c b/net/netfilter/nft_fwd_netdev.c
index 7447da9..d1ac4eb 100644
--- a/net/netfilter/nft_fwd_netdev.c
+++ b/net/netfilter/nft_fwd_netdev.c
@@ -15,6 +15,7 @@
 #include <net/netfilter/nf_tables_offload.h>
 #include <net/netfilter/nf_dup_netdev.h>
 #include <net/netfilter/nf_recursion.h>
+#include <net/dst_metadata.h>
 #include <net/neighbour.h>
 #include <net/ip.h>

@@ -176,6 +177,9 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,
 		}
 	}

+	/* The route is for the old skb->dev. Keep the tunnel template. */
+	if (skb_valid_dst(skb))
+		skb_dst_drop(skb);
 	skb->dev = dev;
 	skb_clear_tstamp(skb);


pw-bot: cr

      reply	other threads:[~2026-11-16 20:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 19:01 [PATCH net-next v4 0/4] net: drop the stale dst when steering to another device Jamal Hadi Salim
2026-11-16 19:01 ` [PATCH net-next v4 1/4] net: xfrm: interface: restore dst_orig on every xfrm interface Jamal Hadi Salim
2026-11-16 19:01 ` [PATCH net-next v4 2/4] net: dst: keep the LWT metadata of a dropped route Jamal Hadi Salim
2026-11-16 19:01 ` [PATCH net-next v4 3/4] netfilter: nft_fwd_netdev: drop the stale dst when steering to a device Jamal Hadi Salim
2026-11-16 19:01 ` [PATCH net-next v4 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop Jamal Hadi Salim
2026-11-16 20:46   ` Alexei Starovoitov [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=DMWXH28YQDYH.1SI4Y5WQ7EPSR@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sashiko-bot@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=victor@mojatatu.com \
    --cc=yonghong.song@linux.dev \
    /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