Article View: linux.kernel.netdev
Article #15462[PATCH net-next v2 3/4] netfilter: nft_fwd_netdev: drop the stale dst when steering to a device
From: Jamal Hadi Salim
Date: Thu, 12 Nov 2026 20:40
Date: Thu, 12 Nov 2026 20:40
90 lines
14641 bytes
14641 bytes
This is a followup of the review of the teql arp-queue fix as reported
by Sashiko.
The issue:
The neighbour variant of fwd rewrites skb->dev to the configured output
device and calls neigh_xmit(), but leaves the skb's dst untouched. If that
device's neighbour for the configured nexthop is incomplete, the packet is
parked on the neighbour's arp_queue while the stale dst still describes the
device the packet was routed through. Draining the queue re-looks the
neighbour up from that dst, so the frame is built with the routed device's
link-layer header and then transmitted on the configured device. The packet
leaves with another device's addresses.
The Fix:
Release the dst before the device switch. Both lookup inputs the neighbour
transmission needs, the device and the nexthop, are supplied by the rule,
so the route dst is never consulted. Without it the queue drain keeps the
parking neighbour and the frame carries the configured device's addresses.
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. If
that copy cannot be allocated the packet is dropped, 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, then load this ruleset on A:
table netdev t {
chain c {
type filter hook egress device va priority 0
policy accept
fwd ip to 10.1.0.2 device vb
}
}
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>
---
v1 -> v2:
- Do not drop a dst that is not a route: a DST_METADATA dst is the tunnel
template a tunnel helper attached to the packet, and dropping it discards
the encapsulation parameters. Considered comment from Pablo Neira Ayuso.
- Keep a route's encapsulation parameters as well: a route installed with an
ip, ip6 or xfrm encapsulation carries them in dst->lwtstate, which a drop
would discard before a downstream tunnel or xfrm device could use them.
The dst release now goes through a helper that moves them onto a metadata
dst first (new 2/4).
net/netfilter/nft_fwd_netdev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/netfilter/nft_fwd_netdev.c b/net/netfilter/nft_fwd_netdev.c
index a48c2f765bba..3f2ffda1998c 100644
--- a/net/netfilter/nft_fwd_netdev.c
+++ b/net/netfilter/nft_fwd_netdev.c
@@ -14,6 +14,7 @@
#include <net/netfilter/nf_tables.h>
#include <net/netfilter/nf_tables_offload.h>
#include <net/netfilter/nf_dup_netdev.h>
+#include <net/dst_metadata.h>
#include <net/neighbour.h>
#include <net/ip.h>
@@ -159,6 +160,11 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,
goto out;
}
+ if (!skb_dst_drop_keep_metadata(skb)) {
+ verdict = NF_DROP;
+ goto out;
+ }
+
local_bh_disable();
if (nf_dev_xmit_recursion()) {
local_bh_enable();
--
2.43.0
Technical Details
Message-ID:
<CORE-9NOG.v2.r0.20261112151659-3@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-362214-linux-kernel-netdev=dewy.ruReferences:
<CORE-9NOG.v2.r0.20261112151659@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-362214-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 3/4] netfilter: nft_fwd_netdev: drop the stale dst when steering to a device
Date: Thu, 12 Nov 2026 15:40:48 -0500
Organization: Usenet Network
Message-ID: <CORE-9NOG.v2.r0.20261112151659-3@mojatatu.com>
References: <CORE-9NOG.v2.r0.20261112151659@mojatatu.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1215227"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:bYJsB4RDO/PaUkE3I5HNtDDjxvg= sha256:nU8yd5oFC0ZQ2hSlaH3xRQBTrWaK1epHj3TzBDWhrRo=
sha1:dsUsKrhlS04QIzkECps7YUxG3lE= sha256:bdhIfnqWFUh0wfI49aTK8cAyAhVHv6/45GgKn/Ckk2Q=
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 0DCAE1143F5; Fri, 13 Nov 2026 03:29:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 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, URIBL_BLOCKED=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 TsEMbptaCj2u;
Fri, 13 Nov 2026 03:29:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-362214-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 6BAD51143F1; Fri, 13 Nov 2026 03:29:22 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 9664B16A073; Thu, 12 Nov 2026 20:41:39 +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=1794516065;
b=aF8F2xywv1qOJIa1HRFZH5QT3B8w4H65Idk9Vr3RiZL1R1lS2u5O4FAuyJC0RkLxb0sn
QCsP1TzGUjq+Djoxo5mQXacQFTFjS/FCzj/4ZXh7NCewXMYYKk1Jj7nfEQ8lPhO508A+4
vf6UMZIA8ncGVon7MuH1JflOK5yGDAbrnR8pqb+dP871bf/PHYjvGZQur4pfzgQll8pAX
dODN26Er+0CbLzgO10Y0/WJwhs2JntRSlMI8fnicVGYapopHz1n8noJOoR/X9SXoxzUnF
4rNzpsWRZ7bvd2IRzGm9lRn3DA5OjEKSYBGnhAB0Ei8gEzWk8VUnR7pmou29KDZMkyA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794516065;
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=3Yb4kVEFgMEgPKm+KoyaP1A4M2GZljeQjc5uyGS7RaM=;
b=4x8Sv39benNh9bL482mGeLPTdyEr4Y5cfcYk+Smz+BPhP2VXQ6mrxNWvsY0sQx+e54rM
M3JeffC4JNEcMs18DlToUy/8x27OdFzgKlJ2R/4ODylapChX7sDc4KjiAAxSIntSbnpFV
9ZDI5DPmft+E2jp1LirLv4Kjtv+1BvwaLY+gcJmcYliOD4esq40/3JyFNcK304vjCTKMS
yhiHSZOxWszjYddvWnQAZZtlJKyImqHoOYJbOl91beRF0C/8cRRnFPYyKnuRVzvN15Nho
Yp4XS/goHS0HDE1T4MNpoMU2Fbo8RWnAEKYuZnEL+z+RVnlP13naxHq03U52lgNhUoA==
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=LnqU7fZZ;
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 3EA6C606A8B9;
Thu, 12 Nov 2026 20:41:05 +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=LnqU7fZZ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.172
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794516064;
b=i+ZbZgLl5pZZ8W8wLp3XnMn2FAH28WqOf7jdevFo1SoBie0hDMCUz40rPdadUgdn13kS
ez9XMY6QV+cn2KmfFcvFEsgfXKgZh5LzRS4SKz3Gum5Qd2Eaitd5K7S1pJee1/qdb9cfi
nZGu13brS6Nnkj+WoOGLfK+FWomCMN5dG/8r95BRHbURlEFxuBCuOKrb5sPfMj16bd8lA
grpqqjGsoDA1/8TQbaD3D6nFmHduX2ypnHj/UiJtU8pGXzVORRLazCAnudZvrlZfKQATF
OArelS+ij/kE8K9OTfVSWtU56b6SHqSiY22GNzuM9lCj9/BhsDe5A6B2txD7YzLVo4g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794516064;
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=3Yb4kVEFgMEgPKm+KoyaP1A4M2GZljeQjc5uyGS7RaM=;
b=aDym+SfIJSRwPml79fm9d7TDd6lL7LmmKTGrvmMFX8LwoxJJ6R9OdIkMGhbSdGaUe6/3
gPC1BynDNHEChBgMz0V2W4RZbfVpEWYHQwYDGr2B1CtNWkdP4TJTokc6u9PlNfi87c0Ty
jr8CmK0gN8GYtPNH39/f6oURoSPG/CjUNVfv83bJwaGRAaDKjIdb8iKqiSEmRb2iru1NR
CdKBcVtrs6rmDPfOWNSHWeGQfUw1lP2IVPigtODA3s6ufr0TxXTFAwUCYPvulTFihI11t
6FfEvA2U2+/vQdnaBE1ouQOOOfQ2gB4JPE7+c8Zf+II0WZMtU+tqNpk7pnB42aFkO8Q==
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=LnqU7fZZ;
arc=none smtp.remote-ip=209.85.160.172
X-Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172])
(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 0FB2F606A89B
for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 20:41:03 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0FB2F606A89B
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-qt1-f172.google.com with SMTP id d75a77b69052e-53c4b82919fso1771221cf.0
for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 12:41:03 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=mojatatu.com; s=google; t=1794516063; x=1795120863; 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=3Yb4kVEFgMEgPKm+KoyaP1A4M2GZljeQjc5uyGS7RaM=;
b=LnqU7fZZmWIwa5cGC7/3ZZfwKcvi/O6kUXU+kXsJpqk3FgtXw2cS1ZI3L6stI+6N1t
JSwtn2NXkHxrTcnkOQ8745vdji2oUdnv67cQLQQYFdWKqMrRjHWeasbX8hfn5cSQNw2i
3gVgn+/BuE9ZhWUAPhVFfDoqL7wf5A6LH7MCE=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794516063; x=1795120863;
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=3Yb4kVEFgMEgPKm+KoyaP1A4M2GZljeQjc5uyGS7RaM=;
b=fa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qb273hRa2UDTu7kploLDJKLAwSrpQJ
0BJdaa9brDr5E3UyGdVBfUgxfd5x0fxnKZSiZK1Ai31WlEVujJZhYmBpchi3v+gymPVtD4xxtYc
=
X-Received: by 2002:a05:622a:229e:b0:536:33bf:7bf5 with SMTP id d75a77b69052e-55ac8895596mr9023091cf.29.1794516062959;
Thu, 12 Nov 2026 12:41:02 -0800 (PST)
X-Received: from mbili.waya ([64.203.83.2])
by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91f23d61888sm4452116d6.20.2026.11.12.12.41.01
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 12 Nov 2026 12:41:02 -0800 (PST)
X-Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Florian Westphal <fw@strlen.de>,
Phil Sutter <phil@nwl.cc>,
"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>,
netfilter-devel@vger.kernel.org,
coreteam@netfilter.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.v2.r0.20261112151659@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