Thread View: linux.kernel.netdev
5 messages
5 total messages
Started by Jamal Hadi Salim
Fri, 20 Nov 2026 15:42
[PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb
Author: Jamal Hadi Salim
Date: Fri, 20 Nov 2026 15:42
Date: Fri, 20 Nov 2026 15:42
100 lines
15002 bytes
15002 bytes
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
Re: [PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb
Author: "Alexei Starovoitov"
Date: Fri, 20 Nov 2026 19:06
Date: Fri, 20 Nov 2026 19:06
19 lines
11838 bytes
11838 bytes
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>
Re: [PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb
Author: Jamal Hadi Salim
Date: Sat, 21 Nov 2026 11:35
Date: Sat, 21 Nov 2026 11:35
43 lines
13352 bytes
13352 bytes
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>
Re: [PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb
Author: Jamal Hadi Salim
Date: Sun, 29 Nov 2026 22:39
Date: Sun, 29 Nov 2026 22:39
74 lines
14733 bytes
14733 bytes
On Sun, Nov 29, 2026 at 12:08 PM <willemb@google.com> wrote: > > 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. > This is a bit confusing—what is wrong with the code as is? Unles you are pointing to what Alexei said - I believe that has to do with the commit log (and not the code). If I were to send the change to the commit it would look as follows: ----- -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 packet sent to 10.10.0.2 egresses va; the rule rewrites the nexthop to +10.1.0.2 on vb, whose neighbour is incomplete, so it is parked there with +va's route. ---- Alexei already acked it despite that. > Also, typo in the reproducer: `10.10.0.2` should be `10.1.0.2`. 10.10.0.2 is correct. To clarify, that is the sender's destination which makes the frame egress va and hit the egress rule. The rule then rewrites the nexthop to 10.1.0.2 on vb, whose neighbour is incomplete, so the skb is parked there while its dst still names va's route - that stale dst is the bug. > Please do include a Fixes tag even if sending to net-next. > Ok, i was intentionaly leaving that out in previous net-next (most merged) and argued many times with sashiko that it is not needed, but i just checked the docs since you are bringing it - will add it going forward. > 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. I sent 00 to helped provide context which seemed useful in this case. The previous revision was 4 patches and under a different subject. This one carried one of those 4. Note: I understand everyone is overloaded (so am i, I have a large number of patches i am holding back so far); my frustration is that this has been sitting in the queue for 9 days - if I resend, will I have to wait another nine days just for a commit log change? cheers, jamal > -- > > pw-bot: cr > >
Re: [PATCH net-next 1/1] net: neighbour: skip the stale dst lookup for a redirected skb
Author: "Alexei Starovoitov"
Date: Sun, 29 Nov 2026 23:35
Date: Sun, 29 Nov 2026 23:35
11 lines
11517 bytes
11517 bytes
On Sun, Nov 29, 2026 at 02:39 PM Jamal Hadi Salim <jhs@mojatatu.com> wrote: > This is a bit confusing—what is wrong with the code as is? > Unles you are pointing to what Alexei said - I believe that has to do > with the commit log (and not the code). Right. Only the log. Sorry about confusion. > Alexei already acked it despite that. Yes. I think the patch is fine. I don't think log change deserves a respin.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads