* [PATCH net-next 0/1] net: neighbour: skip the stale dst lookup for a redirected skb
@ 2026-11-20 15:42 Jamal Hadi Salim
2026-11-20 15:42 ` [PATCH net-next 1/1] " Jamal Hadi Salim
2026-11-20 15:47 ` [PATCH net-next 0/1] " netdev-bot+sinfo
0 siblings, 2 replies; 7+ messages in thread
From: Jamal Hadi Salim @ 2026-11-20 15:42 UTC (permalink / raw)
To: netdev
Cc: Jamal Hadi Salim, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, bpf, Alexei Starovoitov, Jiri Pirko,
Victor Nogueira
This replaces the four-patch series posted as [PATCH net-next v4 0/4]
"net: drop the stale dst when steering to another device":
https://lore.kernel.org/netdev/CORE-9NOG.v4.r0.20261116135311@mojatatu.com/
Patches 2/4, 3/4 and 4/4 are withdrawn, and 1/4 is split out into a
separate posting against net:
* 2/4, 3/4 and 4/4 dropped the stale dst at each producer that steers a
packet to another device. Alexei Starovoitov pointed out that a route
for one device is a normal thing to find on a frame that leaves
another one, and that the xfrm, tunnel and lwtstate consumers further
down still need it, so they are gone.
* 1/4 is a regression of the xfrm interface helper, so it goes to net
on its own.
What is left is the drain guard Alexei proposed in his review of v4:
https://lore.kernel.org/netdev/DMX7RM93TMGR.AXFN4YJ55REF@gmail.com/
It is adopted as written: neigh_update_process_arp_queue() skips the
re-lookup of the neighbour from the skb's dst when skb->dev is already
neigh->dev. The parking neighbour is the top-level one in that case and
can reinject the frame itself; a dst that is a route via another device,
which is the sch_teql shape, still takes the lookup.
Jamal Hadi Salim (1):
net: neighbour: skip the stale dst lookup for a redirected skb
net/core/neighbour.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb 2026-11-20 15:42 [PATCH net-next 0/1] net: neighbour: skip the stale dst lookup for a redirected skb Jamal Hadi Salim @ 2026-11-20 15:42 ` Jamal Hadi Salim 2026-11-20 19:06 ` Alexei Starovoitov 2026-11-20 15:47 ` [PATCH net-next 0/1] " netdev-bot+sinfo 1 sibling, 1 reply; 7+ messages in thread From: Jamal Hadi Salim @ 2026-11-20 15:42 UTC (permalink / raw) To: netdev Cc: Jamal Hadi Salim, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, bpf, Alexei Starovoitov, Jiri Pirko, Victor Nogueira Alexei Starovoitov suggested guarding the re-lookup in neigh_update_process_arp_queue() with the skb's device instead of changing every producer that steers a packet to another device. This is that guard. The issue: neigh_update_process_arp_queue() re-looks the neighbour up from the skb's dst, because shapers, eql and sch_teql can output a packet through a different neigh object and it has to be reinjected at the top of the path. A packet steered to another device by bpf_redirect_neigh(), or by an nft "fwd ... device" rule, is parked on that device's neighbour while its dst is still the route that named the device it arrived on. The lookup returns the neighbour of that route, so the drained frame leaves the parking device with the arrived-on device's source address and that route's neighbour as the destination. The Fix: Skip the lookup when skb->dev is already neigh->dev; the parking neighbour is the top-level one in that case and can reinject the packet itself. A dst that is a route via another device, which is the sch_teql shape, still takes the lookup. Some context: A route for one device is a normal thing to find on a frame that leaves another one; bpf_redirect() and mirred have always produced it, and the packet has to keep it for the xfrm, tunnel and lwtstate consumers further down. lwtstate, NBMA tunnels, the route realm and ICMP errors are unaffected, and the fast path does not change. Conditions to recreate the bug: Two network namespaces joined by two veth pairs, va/vb in the first and va_peer/vb_peer in the second. vb_peer carries no address, so the neighbour for its side stays unresolved. ip netns add ns1 ip netns add ns2 ip link add va type veth peer name va_peer ip link add vb type veth peer name vb_peer ip link set va netns ns1 ip link set va_peer netns ns2 ip link set vb netns ns1 ip link set vb_peer netns ns2 ip -n ns1 link set va address 02:aa:00:00:00:01 ip -n ns1 link set vb address 02:bb:00:00:00:01 ip -n ns1 addr add 10.10.0.1/24 dev va ip -n ns1 addr add 10.1.0.1/24 dev vb ip -n ns2 addr add 10.10.0.2/24 dev va_peer ip -n ns1 link set va up ip -n ns1 link set vb up ip -n ns2 link set va_peer up ip -n ns2 link set vb_peer up ip -n ns1 neigh replace 10.10.0.2 lladdr 02:aa:00:00:00:ab dev va nud permanent ip netns exec ns1 nft add table netdev t ip netns exec ns1 nft "add chain netdev t c { type filter hook egress device va priority 0; policy accept; }" ip netns exec ns1 nft add rule netdev t c fwd ip to 10.1.0.2 device vb One packet to 10.10.0.2 egresses va and the rule steers it through vb to 10.1.0.2, whose neighbour is incomplete, so it is parked there with va's route. A cls_bpf program returning struct bpf_redir_neigh nh = { .nh_family = AF_INET, .ipv4_nh = htonl(0x0a010002) }; return bpf_redirect_neigh(vb, &nh, sizeof(nh), 0); in the same hook produces the same park. Making that neighbour valid drains the queue: ip -n ns1 neigh replace 10.1.0.2 lladdr 02:bb:00:00:00:cd dev vb nud permanent The single frame that leaves vb_peer carries 02:aa:00:00:00:01 as its source and 02:aa:00:00:00:ab as its destination instead of vb's own addresses. Link: https://lore.kernel.org/netdev/DMX7RM93TMGR.AXFN4YJ55REF@gmail.com/ Suggested-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> --- net/core/neighbour.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 887d2e35cd04..219dc89716f8 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1334,9 +1334,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) -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb 2026-11-20 15:42 ` [PATCH net-next 1/1] " Jamal Hadi Salim @ 2026-11-20 19:06 ` Alexei Starovoitov 2026-11-21 11:35 ` Jamal Hadi Salim 2026-11-29 17:08 ` willemb 0 siblings, 2 replies; 7+ messages in thread From: Alexei Starovoitov @ 2026-11-20 19:06 UTC (permalink / raw) To: Jamal Hadi Salim, netdev Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, bpf, Jiri Pirko, Victor Nogueira On Fri, Nov 20, 2026 at 07:42 AM Jamal Hadi Salim <jhs@mojatatu.com> wrote: > Skip the lookup when skb->dev is already neigh->dev; the parking neighbour > is the top-level one in that case and can reinject the packet itself. A > dst that is a route via another device, which is the sch_teql shape, still > takes the lookup. It doesn't. The check never reads dst->dev: if (dst && skb->dev != neigh->dev && In the repro dst->dev is va, skb->dev and neigh->dev are vb. The lookup is skipped. teql takes it, because skb->dev is the master. That ends with 3/3 of your teql series: https://lore.kernel.org/bpf/QDISC-6HS9.v6.r0.20261119070330@mojatatu.com/ Then 2/3 of it and the lookup itself can go. It can be a follow up. Acked-by: Alexei Starovoitov <ast@kernel.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb 2026-11-20 19:06 ` Alexei Starovoitov @ 2026-11-21 11:35 ` Jamal Hadi Salim 2026-11-29 17:08 ` willemb 1 sibling, 0 replies; 7+ messages in thread From: Jamal Hadi Salim @ 2026-11-21 11:35 UTC (permalink / raw) To: Alexei Starovoitov Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, bpf, Jiri Pirko, Victor Nogueira On Fri, Nov 20, 2026 at 2:06 PM Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > > On Fri, Nov 20, 2026 at 07:42 AM Jamal Hadi Salim <jhs@mojatatu.com> wrote: > > Skip the lookup when skb->dev is already neigh->dev; the parking neighbour > > is the top-level one in that case and can reinject the packet itself. A > > dst that is a route via another device, which is the sch_teql shape, still > > takes the lookup. > > It doesn't. The check never reads dst->dev: > > if (dst && skb->dev != neigh->dev && > > In the repro dst->dev is va, skb->dev and neigh->dev are vb. > The lookup is skipped. teql takes it, because skb->dev is the master. > > That ends with 3/3 of your teql series: > https://lore.kernel.org/bpf/QDISC-6HS9.v6.r0.20261119070330@mojatatu.com/ > Then 2/3 of it and the lookup itself can go. It can be a follow up. IIUC, that is the plan i.e a followup (not a respin of the series). To be precise: - v6 is on the list as 1/3, 2/3, 3/3. 2/3 has to stay in it: without the restore, 3/3 parks the skb naming the slave and the drain sends it out the slave through neigh_direct_output() with no link header. - 3/3 carries Cc: stable, and stable trees will never have this guard, so 2/3 has to travel with it there. Once your guard and 3/3 are both in the tree I will send the follow-up: drop 2/3's three lines and the dst/n2 re-lookup, and back the "dead branch" claim with a runtime check (kprobe should be sufficient) Thanks for the ack. cheers, jamal > Acked-by: Alexei Starovoitov <ast@kernel.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb 2026-11-20 19:06 ` Alexei Starovoitov 2026-11-21 11:35 ` Jamal Hadi Salim @ 2026-11-29 17:08 ` willemb 1 sibling, 0 replies; 7+ messages in thread From: willemb @ 2026-11-29 17:08 UTC (permalink / raw) To: Alexei Starovoitov, Jamal Hadi Salim, netdev Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, bpf, Jiri Pirko, Victor Nogueira Alexei Starovoitov wrote: > On Fri, Nov 20, 2026 at 07:42 AM Jamal Hadi Salim <jhs@mojatatu.com> > wrote: > > Skip the lookup when skb->dev is already neigh->dev; the parking > neighbour > > is the top-level one in that case and can reinject the packet itself. A > > dst that is a route via another device, which is the sch_teql shape, > still > > takes the lookup. > It doesn't. The check never reads dst->dev: > if (dst && skb->dev != neigh->dev && Please resend with this revised. Also, typo in the reproducer: `10.10.0.2` should be `10.1.0.2`. Please do include a Fixes tag even if sending to net-next. No need for a series/cover-letter for a single line patch, and please do make explicit that this patch can be merged immediately, is not subject to the other patches that the cover letter refers to. -- pw-bot: cr ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 0/1] net: neighbour: skip the stale dst lookup for a redirected skb 2026-11-20 15:42 [PATCH net-next 0/1] net: neighbour: skip the stale dst lookup for a redirected skb Jamal Hadi Salim 2026-11-20 15:42 ` [PATCH net-next 1/1] " Jamal Hadi Salim @ 2026-11-20 15:47 ` netdev-bot+sinfo 2026-11-20 16:05 ` Jamal Hadi Salim 1 sibling, 1 reply; 7+ messages in thread From: netdev-bot+sinfo @ 2026-11-20 15:47 UTC (permalink / raw) To: Jamal Hadi Salim Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, bpf, Alexei Starovoitov, Jiri Pirko, Victor Nogueira Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 0/1] net: neighbour: skip the stale dst lookup for a redirected skb 2026-11-20 15:47 ` [PATCH net-next 0/1] " netdev-bot+sinfo @ 2026-11-20 16:05 ` Jamal Hadi Salim 0 siblings, 0 replies; 7+ messages in thread From: Jamal Hadi Salim @ 2026-11-20 16:05 UTC (permalink / raw) To: netdev-bot+sinfo Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, bpf, Alexei Starovoitov, Jiri Pirko, Victor Nogueira On Fri, Nov 20, 2026 at 10:47 AM <netdev-bot+sinfo@kernel.org> wrote: > > Hi! > > This is an automated message. This series looks like a fix, but its > commit messages seem to be missing some information: > > - How the issue was discovered, e.g. hit in production, hit during > development, syzbot report, manual code inspection, LLM or static > analysis tool scan. > It is a followup of the thread listed on the cover letter. The original thread is derived from a sashiko followup of "pre-existing bug" cheers, jamal > Please do not repost the series just to address the above. Instead, > reply to this email with the missing information, so that reviewers > can take it into account. > > *IMPORTANT*: If you do repost (for other reasons) - please include > the relevant info in the cover letter or commit messages. > -- > The evaluation is done by an LLM so it may be wrong, if you think > that is the case please reply and explain. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-29 17:08 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-20 15:42 [PATCH net-next 0/1] net: neighbour: skip the stale dst lookup for a redirected skb Jamal Hadi Salim 2026-11-20 15:42 ` [PATCH net-next 1/1] " Jamal Hadi Salim 2026-11-20 19:06 ` Alexei Starovoitov 2026-11-21 11:35 ` Jamal Hadi Salim 2026-11-29 17:08 ` willemb 2026-11-20 15:47 ` [PATCH net-next 0/1] " netdev-bot+sinfo 2026-11-20 16:05 ` Jamal Hadi Salim
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox