Article View: linux.kernel.netdev
Article #16622[PATCH net-next v3 3/4] netfilter: nft_fwd_netdev: drop the stale dst when steering to a device
From: Jamal Hadi Salim
Date: Sun, 15 Nov 2026 10:19
Date: Sun, 15 Nov 2026 10:19
85 lines
14250 bytes
14250 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: Pablo Neira Ayuso <pablo@netfilter.org>
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
v2 -> v3:
- Add the Reviewed-by tag from Pablo Neira Ayuso, given on the v2
posting of this patch.
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 7447da931a95..f486c7be385c 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/netfilter/nf_recursion.h>
#include <net/neighbour.h>
#include <net/ip.h>
@@ -160,6 +161,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.v3.r0.20261115050625-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-363662-linux-kernel-netdev=dewy.ruReferences:
<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-363662-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 3/4] netfilter: nft_fwd_netdev: drop the stale dst when steering to a device
Date: Sun, 15 Nov 2026 05:19:10 -0500
Organization: Usenet Network
Message-ID: <CORE-9NOG.v3.r0.20261115050625-3@mojatatu.com>
References: <CORE-9NOG.v3.r0.20261115050625@mojatatu.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1772417"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8XrFhqGinwbfJ7e34ak9ec0cXHg= sha256:fKKL2VnupI2k/9nCCXnEYD0W010JumUjvQ184I0FYGE=
sha1:vNUtMspkUxUPFm0ZqQJ2kt94gGA= sha256:iny1NOWzNh+Vv4E2WHjFlGcjgcvIkFxybM1NDiV2TsE=
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 62A4C1149A9; Sun, 15 Nov 2026 13:20:02 +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 7snoXnzr3S41;
Sun, 15 Nov 2026 13:19:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363662-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 134B91149A0; Sun, 15 Nov 2026 13:19:43 +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 B51013CE03; Sun, 15 Nov 2026 10:19:24 +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=1794737964;
b=SQzqF0MxBtAY7/cHRrdlhOrHugGLWLQKF3KgS0AV8tur1KXvt9xCSNyqtpzsXPNxBUlh
NFQR27wwgz6oRmKZh9GY62Xdc58ZuoustpjS6V24a+0OOeUrUWT6Pt29x6Be20cG4q1OM
bLMzP8ZH/chj5pcZ87N8PM8v7vDZ6Qq0T5OH64wagT+9AErGZqKzubdJFYftc4ltB772T
7aXLMZnzJcVNVtguQY+ps7zBtMRPbjQwFGudOt7uw/BW5IaxDf2mLrKdnUC8wfoVGbxjS
cigjWIRqoVnzYjePR2xGGWAGB2+wYFms6G1lbg16jrN6BuJnvAKS2gvbn2p7I/5Ikrg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794737964;
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=8FdZmPYxVJRZwepv2ASwo7Gw6muFW4JO5etLfzKYWPY=;
b=ZLQK2EndVxdE/VmskEmsqMe7PzO3FKc52eMhvs+xL0dUay5MICPhOFeMgR+aTFSNFAu8
0OEDh41NCPV+StyNKZo9zCnNmu8sjHLt4gv3qD5ewLPF6cUWowFf7+oncvYjNBwLiN+dM
GjoATs0UPC0qRQnTWD0v4hostYMWOYOzBBZQn/BfVrahLHtzziaG9K6JCtWjFbNtcuThW
9znYx+rkE7o9axzhlY/T9Ckchn2G7VkhSGUF7of9Z1AvcKjZQV8W3Cthdx+Nxutlk2Gym
tNlgr/vEmO9cCcIeUhVKLkWsbF/p2XhfCS0mbGzexqygK3oCPQHYTPMmJk4wSFRBOYw==
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=MWGVQG1E;
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 8D560606A31F;
Sun, 15 Nov 2026 10:19:24 +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=MWGVQG1E
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.174
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794737963;
b=25yDAPozFfswSjW7A62/M8IqxPeOesd/nh7rT54C3GUsgy9Gzk1OW9iTeduA/BZOTEnk
1phs9livGQIcXk5HuZgNp4uRYQ0HCJXxHP9ESgYVV6XvDT0mjNn6G0oYkYqb6pEUBm6zd
9Ao+nUrNQZek+Ib6fVDZKXqqfb//zHeimw+pDGRYlSsiz78HUs5ZkeoqrMVxj6/6yL975
TFB1kwz0fhmA4blizl0XKmZX+WX/qTRdR1INPHT7cOrsdYaDoPaCbGhXFMi6UxoxL2Xnk
sil7yxPme+XNIoaLdwyZZ1Af52Yko8i3h1tbleaQqg56xMkezzRgtxkvCdVhrA1NA2w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794737963;
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=8FdZmPYxVJRZwepv2ASwo7Gw6muFW4JO5etLfzKYWPY=;
b=LwUEwJao+NYJxq7Qi6X7nQfLQUDDpZOM2Ko8G5zfz1GMjBFZbBt6AtL+PND0fureCY5r
Yuev7+1I8e7QsTXqzXpCdXwg6zdYIbzdmHOLQ/Fx71aCm1eLepgl10Ceb17pd7pcCmTv/
qEhPa5t6GTN8PTZN9fZArl6I+9l8P8L/DC6jMVGGNfBxSADAJopGyxba7l6lsvq1/Sslv
AWXhKWnt6tyUyX6hibO6Il2xld9ybDiAzxypwywSTlUKifNcSBvLLlubKMgCUPi15sSTR
K9EwFAdHDFve13/FgFLxRJ9nr9Tl78Ig+ESXUt+LAZ6qKYDR1FM/9mshbiHy0L+lPig==
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=MWGVQG1E;
arc=none smtp.remote-ip=209.85.222.174
X-Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174])
(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 612FF606A32E
for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 10:19:23 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 612FF606A32E
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-f174.google.com with SMTP id af79cd13be357-93f20b304c0so324083085a.3
for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 02:19:23 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=mojatatu.com; s=google; t=1794737962; x=1795342762; 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=8FdZmPYxVJRZwepv2ASwo7Gw6muFW4JO5etLfzKYWPY=;
b=MWGVQG1EmcCvaAbT9BiccGy3hK999wI2mBLTw6m0Jbj4d6yki8WXtF7CKwieJGeiKr
a4Z9bNV2qZuskUaYPhoXKkQzopPtL2AGzmsoJtv72MFl8HnwHgpxz63X+EQ+zRH6R7aR
IoLhQ6Hip33egtOCGe5g8lpSnTcFGX20yluAI=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794737962; x=1795342762;
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=8FdZmPYxVJRZwepv2ASwo7Gw6muFW4JO5etLfzKYWPY=;
b=gfqH2NFADVDGUEMbsf3IjSaqToCsWxnhB3Wweckd5E5H9UR+0OLQbElvadif63uZgP
j2VeZM0VgawQuQTDibVn3hlCQwE7LFdGTndu1lcBiotdgzvbwPPOq70TLCf3C1krrr26
VPydpPFXr+E+kMNKjC5SiE4s+kiJ0gZvO28Vqf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mr1274673485a.68.1794737962445;
Sun, 15 Nov 2026 02:19:22 -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.20
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 15 Nov 2026 02:19:21 -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.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