🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16621

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

#16621
From: Jamal Hadi Salim
Date: Sun, 15 Nov 2026 10:19
75 lines
14450 bytes
This is a followup of the review of the teql arp-queue fix as reported
by Sashiko.

The issue:
__bpf_redirect_neigh_v4() and __bpf_redirect_neigh_v6() install a dst for
the redirect target only when the program lets the helper do the FIB
lookup. With BPF_F_NEXTHOP the program supplies the nexthop, the lookup is
skipped, and whatever dst the packet arrived with stays attached while
bpf_out_neigh_v{4,6}() switch skb->dev to the target device. If that
device's neighbour is incomplete the packet is parked on its arp_queue with
the original route's dst; draining the queue re-looks the neighbour up from
that dst and builds the frame with the original device's link-layer header,
then transmits it on the target device.

The Fix:
Release the dst when the nexthop is supplied. That branch never consults
the route dst, so nothing that describes the route is lost, and the queue
drain keeps the target device's parking neighbour.

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.

Conditions to recreate the bug:
Two network namespaces, A (10.10.0.1/24) and B (10.1.0.1/24) in one, their
veth peers in the other with only A's peer addressed (10.10.0.2/24) so B's
nexthop cannot be resolved by ARP. Resolve A's neighbour for 10.10.0.2 as
permanent and attach a cls_bpf egress program to A, with vb the index of B:

    struct bpf_redir_neigh nh = { .nh_family = AF_INET,
                                  .ipv4_nh = htonl(0x0a010002) };

    return bpf_redirect_neigh(vb, &nh, sizeof(nh), 0);

Send one packet to 10.10.0.2. It is parked on B's incomplete neighbour
for 10.1.0.2; once that neighbour becomes valid the frame leaves B
carrying A's source address and A's neighbour as the destination.

Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v3.r0.20261103062649-2@mojatatu.com
Link: https://lore.kernel.org/netdev/QDISC-6HS9.v3.r0.20261103062649-2@mojatatu.com/
Link: https://lore.kernel.org/netdev/avTfQjFQYR2NNdRg@chamomile/
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 net/core/filter.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index bd98d29ed7f8..ae5346d6abd2 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;
 	}
 
 	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;
 	}
 
 	err = bpf_out_neigh_v4(net, skb, dev, nh);
-- 
2.43.0
Technical Details
Message-ID: <CORE-9NOG.v3.r0.20261115050625-4@mojatatu.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363663-linux-kernel-netdev=dewy.ru
References: <CORE-9NOG.v3.r0.20261115050625@mojatatu.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363663-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop
Date: Sun, 15 Nov 2026 05:19:11 -0500
Organization: Usenet Network
Message-ID: <CORE-9NOG.v3.r0.20261115050625-4@mojatatu.com>
References: <CORE-9NOG.v3.r0.20261115050625@mojatatu.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1772121"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:gAdyJC1ZOAF15tBxTja74OYE9XA= sha256:nBtjdE1ii9fx6W4C+nFN1mCTARDfR6Qb//jLLASo9xY=
	sha1:fpk6ImUahjQlSfV34M5aZLFUKvA= sha256:1hSbsea+RhzDysYz35H2TN/d1YQuAMTtSpkEXFBsWbc=
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 F15B01149A8; Sun, 15 Nov 2026 13:20:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	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 (1024-bit key)
	header.d=mojatatu.com
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 8z-4Wv_Trx01;
	Sun, 15 Nov 2026 13:19:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-363663-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id C88561149A6; Sun, 15 Nov 2026 13:19:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id C2C332C537; Sun, 15 Nov 2026 10:19:27 +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=1794737967;
	b=IJ4/VabBJBxAW5vjT3LBihvluepvmKLiB+G/dL0xy+/Dgx0EArBBVbSlTgzyL1m//Wjd
	 zF4XQ3gIUJlxxD5AGAqbTo9qUDIIRZcI5YJuYtP+wZ4X7HRbCw1uqZdNw3OuKjcFz/6Ic
	 pccSySlWPXaJRVawazz196E6BW1zJwcEZ6gMIuhegS/N2F5NnYATmtDs+MNhyAZooiwkr
	 VSyv3HQ09mjDavudTG0RbSOvXb4ke+L/m3Ca/8d8e95ZphheTSr4Y8K5hOMwa3kreeObT
	 sBpvQKKAGaS9Y96Yc2pKtF7PkkRfYI/lxqpAPkOUwdPdv3o2t5of5KZrc0RW9S8PmTg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794737967;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=7/GM6+U/65nqtViXkrPAxR1Old8xs3zW47itheeRLoo=;
	b=Y7jlk5DqGpXF6twgnTp+ulWP1zizEvtIUdTqlwh7DTl9j47jVMp40MardxKpCp8v2+Pw
	 eYvxrdeXQcV+RJbSpHUUWLZAfIhCDMB/gjrXF4deaq2ah1YACdynKhrU4thycXdM2Wrzy
	 mGYT/ypuBa54xyLmkP55uMZ7n6aIiz5GsYBIWZWcCX+q9q20CFdW8Nc38W1o/j0ouRhRO
	 0p3iAbBfk3ob9++AY4s4CPmNJW0MmOy19Lrlc+SEnLirZ1tNhhWIJ9mL2LuA2GPqexPnH
	 Ex+bQB0FZlIOBqbizF4kRJ+ghqyWlI5jKx/akrcJdCoHMAmcJ7OfIzf5pdXhCdN1FEw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=rFt8QNoA;
	dmarc=none header.from=mojatatu.com;
	spf=none smtp.mailfrom=mojatatu.com;
	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 350B3606A334;
	Sun, 15 Nov 2026 10:19:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=rFt8QNoA
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.170
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794737966;
	b=OcZoRz+5qICaJVomFLBlL08XOE/zxbPOWE/QUh4MvYiicpGUC4M39rx5i/1XUE1tzx8p
	 q6fb28bPxoGhi9sYhuxIEK0v+Ic7zXlv2iS82dXaBnPLZwnb/TaAbi5C3CesrGesSGe9I
	 8r7ROHKFfa11MoEA+ME/PM1GuehH7Vt7+11l1Z1AQapyc/BO7GwKL87yQWkaavlli+h3Y
	 RO13cExyYv5maUjavnyajLERZUjowUZMcplUNE8mnz8Yfp0gq1zvcXaStfNjOsVSlMGKJ
	 CH3plJlsIN+UakW9suWFxHHAm/q9PThGIc0clauz4ilURgRZ4hMPl3szrt2Z8kt7VsA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794737966;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=7/GM6+U/65nqtViXkrPAxR1Old8xs3zW47itheeRLoo=;
	b=tJh2SbJwreHKKF+byybPK/XnMo+KwtyOGMkKrsNmsiCQXlXA0D/dvptRtfAJ8f6wBBVa
	 x0S4TSFWZNsTM7dIvFDaO5vTREGxFF1u3vQ0LwUfXMCThInmuLQbUP84MveDlBIMDZA3q
	 1k7R5ncUcGhDEqrKoveCBR85PDLBZkaDdkymef7/prRIBIjkqU3A93h5Gl3IYW57zQpkt
	 qTtEsQ8AaLVQiaFoz4jeVXrNmi4AFBEoY4sfrOHO1zbZAb3wgLy5ak8BbpFSLJ65jmwdc
	 937H3eLsuNkwCWRokfywqi4i9oSDGWzwPVICuJA80hzFHCpztxXA3xYTZNjMztDV+VQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=mojatatu.com;
	spf=none smtp.mailfrom=mojatatu.com;
	dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=rFt8QNoA;
	arc=none smtp.remote-ip=209.85.222.170
X-Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06927606A31A
	for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 10:19:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 06927606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-94959217274so330096985a.0
        for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 02:19:25 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=mojatatu.com; s=google; t=1794737965; x=1795342765; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=7/GM6+U/65nqtViXkrPAxR1Old8xs3zW47itheeRLoo=;
        b=rFt8QNoAMS5qTe3CN8yYf54nuToMLRcweBvu28VjEblmU6azUP6a1b7a8pl4EN0EMS
         fmp2uxDiC9Sk12HFqImZMlBlUmUOZQMEVu/jsQborx0seX1uwBQ5AQ05MByTq2ylGwaI
         3TyxjFBp2cqOnjzrIkkat+SZZXbo7CVWKiRB4=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794737965; x=1795342765;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=7/GM6+U/65nqtViXkrPAxR1Old8xs3zW47itheeRLoo=;
        b=KKL7Bs/OnUNpS2jTymRfDcCHUcSJi+f9RYr2WY125GmO/7x0gverwgDy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BLfCtqNpSVBVT1Si9JNtAPWBYbVjvHE9TpZ3/f1r84WXh/1NfxeiON+QwdsFFrAMWHbte
	l
X-Received: by 2002:a05:620a:410e:b0:93e:c12c:fbc4 with SMTP id af79cd13be357-9494bcaf24cmr1224410885a.81.1794737964950;
        Sun, 15 Nov 2026 02:19:24 -0800 (PST)
X-Received: from mbili.waya ([64.203.83.2])
        by smtp.gmail.com with ESMTPSA id af79cd13be357-9494c6025f5sm592337085a.5.2026.11.15.02.19.22
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sun, 15 Nov 2026 02:19:24 -0800 (PST)
X-Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	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>
X-Mailer: git-send-email 2.34.1
X-In-Reply-To: <CORE-9NOG.v3.r0.20261115050625@mojatatu.com>
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