All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Jamal Hadi Salim" <jhs@mojatatu.com>
Cc: <netdev@vger.kernel.org>,
	"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: Tue, 17 Nov 2026 04:50:26 +0000	[thread overview]
Message-ID: <DMX7RM93TMGR.AXFN4YJ55REF@gmail.com> (raw)
In-Reply-To: <CAM0EoMk10vCoAKZq0P=8A_jed=Z3SudLEUV8uvXO5F=ewNjnGQ@mail.gmail.com>

On Mon, Nov 16, 2026 at 02:06 PM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
> encap ip/ip6 or encap xfrm template the tunnel template lives in
> dst->lwtstate  that wont work (packet reaches the tunnel or xfrm
> device with no encapsulation).

ok. agree.

> For that reason we cant drop 3 and 4. I see the change in 2/4 (I see
> 1/4 not changing either) .  The change is not that small because it
> will have to touch multiple core files (although just small mechanical
> surgeries). Summary it will still be 4 patches..

can we keep the route and fix neigh_update_process_arp_queue() instead ?
The bug is its lookup via dst. Only teql needs that lookup, I think.
A is the device of the route, B is the target of the redirect:

  skb is queued by        skb->dev  neigh->dev  lookup via dst gives
  ----------------------  --------  ----------  --------------------
  ip_finish_output2()     A         A           the same neigh
  bpf_redirect_neigh(nh)  B         B           neigh on A, the bug
  nft fwd                 B         B           neigh on A, the bug
  __teql_resolve()        master    slave       neigh on master

The diff skips the lookup when skb->dev is neigh->dev.
lwtstate, NBMA tunnels, realm and ICMP errors work as today.
The fast path doesn't change. No need for patches 2, 3 and 4.
and 1/4 is not a prerequisite.

Your teql 3/3 queues the skb with skb->dev == slave. With this diff
the neigh of the slave adds the header and sends the skb.

thoughts?

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index d6e9c7c..04758ca 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1331,9 +1331,11 @@ static void neigh_update_process_arp_queue(struct neighbour *neigh)
 		 * the packet in the output path.  So what we need to do
 		 * here is re-lookup the top-level neigh in the path so
 		 * we can reinject the packet there.
+		 * When skb->dev is neigh->dev 'neigh' is the top-level one.
+		 * dst can be a route via another device after a redirect.
 		 */
 		n2 = NULL;
-		if (dst &&
+		if (dst && skb->dev != neigh->dev &&
 		    READ_ONCE(dst->obsolete) != DST_OBSOLETE_DEAD) {
 			n2 = dst_neigh_lookup_skb(dst, skb);
 			if (n2)

  reply	other threads:[~2026-11-17  4:50 UTC|newest]

Thread overview: 13+ 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-17 19:02   ` sashiko-bot
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-17 19:02   ` sashiko-bot
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
2026-11-16 22:06     ` Jamal Hadi Salim
2026-11-17  4:50       ` Alexei Starovoitov [this message]
2026-11-17 13:15         ` Jamal Hadi Salim
2026-11-17 14:00           ` Jamal Hadi Salim
2026-11-17 19:02   ` sashiko-bot

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=DMX7RM93TMGR.AXFN4YJ55REF@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.