🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15401

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

#15401
From: Jamal Hadi Salim
Date: Thu, 12 Nov 2026 20:40
81 lines
14509 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>
---
v1 -> v2:
- Do not drop a dst that is not a route, and keep the encapsulation
  parameters a route carries: the release goes through a helper that moves
  them onto a metadata dst first (new 2/4), and a copy that cannot be
  allocated drops the packet instead of sending it with the stale route.

 net/core/filter.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 2d574ae52c4b..4980fb8db299 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.v2.r0.20261112151659-4@mojatatu.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362215-linux-kernel-netdev=dewy.ru
References: <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!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362215-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop
Date: Thu, 12 Nov 2026 15:40:49 -0500
Organization: Usenet Network
Message-ID: <CORE-9NOG.v2.r0.20261112151659-4@mojatatu.com>
References: <CORE-9NOG.v2.r0.20261112151659@mojatatu.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="1179876"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:F+aKdIMnhYyv00LlMmq4SsTho34= sha256:5bvVcb2cAAOh8g3pC6ELBnXE7CUBKIPfdjYwYAlRmlk= sha1:7eCRrFysV6CcCk4ECo8MVWowl24= sha256:IlTleWFEtz6D9Rs7lzIi3kr0pX50n2S3TG15iWU6b4o=
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 12E8D114391; Fri, 13 Nov 2026 00:16:39 +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 s1Q5_5aa1ShW; Fri, 13 Nov 2026 00:16:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-362215-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 1F173114096; Fri, 13 Nov 2026 00:16:24 +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 25A4D1889D7; Thu, 12 Nov 2026 20:41:47 +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=1794516078; b=b6nGkJB1kCtds33AV7mytryRGELhqBr+Bk0W+ylk7aarB+MEAn6rMxaJ+dYy1Q9aGAJG 0rDHu/XrX44KPo/mSyjnmUjH6S7+yodaP56/nSKq6QtMuBGGrjP+cdWXXu52KJrmh+cXS 6xjcjFln9BWptg6jtSl+/BmuHVbnRJZrk91dHf/qkDnv/PTXGSvuESz4uvD3AwQxuhnte 7rMBNlc5aRUd50VX/3130OOccBnCi9Azutd3MSyt/NCbw4b843Bk19g6YX6KZLfBvOtyA oS059DIC9PsNJ/DpP2DfKRjWlwM/JCmBr0FaIjysQcW9c2xQ+vS44BkgQxpGMg8wMwA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794516078; 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=xXKJrbALur9qe5R1OS4jb0FmQE/KqmF7j3A3hmQEcbY=; b=CsDJpTb4fdwOyytdjhuP3UTJ8wUwqWnzg7mOTP23jbGsADV1SZ9FhtaLGtUVOxw3yM80 UuRgpHpIBbK6+4lFfQOL4DxrTsZxzTCX7uNFiW8qCH5fzj6fpjCYuHgUPvdQj/4ZOvuwI nF8K1Ifw6GYZKxpyNjMXNR5rfcOBCDJq6kcTcCK7bqpJYDCyyPLMdXcfIjFA7Y8dWlkWq jwQLqP8YV2e53GDImtp15ZrTQ1BEMtZN6Gxnv33e94+iFQ+DA+WIBMgzU0ydexVctOtmU pgpEssmymaRfib5ACjWT84DB5dZz5S3m4r3tAlvzk4bvjcaysw6nBCci6Ni8E2aQFqg==
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=QCCeiEPd; 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 21213606A881; Thu, 12 Nov 2026 20:41:18 +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=QCCeiEPd
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.47
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794516077; b=owt4VnFbMG8JR16BqURzX1DNTIu48O0Ex6/oENgugt5HQ+inw86jvsDWGmkAQsjNb4qk iUkTCWHYmLXasDJqiNF2YI3R1msl+ltS0AIRqs2ckBK7SvfcnfDHUhdMAF9mOQV1Oi/bj aoHOiphyzNMYMildA5pdB137OemagNbbqk+NntAi6bdTL55psWdEdoQlb0Tgx444A3cEi 8W1zFhLFm2RldBqdBQm1tnL8rEltz9tCOTm/dyyV7TlP4QUuie00/DgJqckqpP/3ThVcZ DyqxcVaO8236q19bSyJ6Zo/3L/l8jwcaWBztJbXctvCgxEXJF83dPOQVorMMX39gSvQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794516077; 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=xXKJrbALur9qe5R1OS4jb0FmQE/KqmF7j3A3hmQEcbY=; b=qV+um34j6PhwwSC9SBwjSCX5vLekB7ZjcnVLFPw5jMf3zMpjZRiLFbbFFJ5654seL9Lr v/MMJlexoQhjuM0ypSP+sFgJmOWtiLE34D9QYxUwsF5NeiDjbrSwWDEmzYyhbV6EDZuI7 Ar6FVNp0H82vetpuNlqXvoyYP3YDdzAv+CUBmJOB6WjiI3wyItxXGBljC+drSOMExnQ3a Qbehao6VUkmCL5f4q3i+dhFBbhEF4UFR5Mx3biPXiYqKOqmYMiPOD1mg3jNcxhycotyYv UM9q/+6VtqIIA1xSSLdOCTyePH/olw+lOM0/MU4ZtPGAtMdNGS8YRSi4TIg65dBG/tQ==
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=QCCeiEPd; arc=none smtp.remote-ip=209.85.219.47
X-Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 E23D5606A327 for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 20:41:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E23D5606A327
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-qv1-f47.google.com with SMTP id 6a1803df08f44-91f0b9f0b1cso3043126d6.1 for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 12:41:16 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu.com; s=google; t=1794516076; x=1795120876; 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=xXKJrbALur9qe5R1OS4jb0FmQE/KqmF7j3A3hmQEcbY=; b=QCCeiEPdNJrcVUtK/DxCUhgGfoj2frCxgAy/wmSkApRQgfDIonwFzsTYT8ILwV3F+u QX5pxCNrhbnRKOJ2vWHH5n3PG9K4SInOJUDsYIGjUdxBCE0gfPT0KTrIHI0+rZ/o0pft smGUFJUfk518nVFOW3jNoV2uRsn4TU11b1Siw=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794516076; x=1795120876; 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=xXKJrbALur9qe5R1OS4jb0FmQE/KqmF7j3A3hmQEcbY=; b=YmG543Oo/UJrPPaR33rk+tODauRXjN+b7AV/r3WqZuUZI2h7+kd3BYKEZhgyEZr4xB 6b0wz+YBrswf/Ve2ApLY4u0X59uNsg6AcFmn1RnGd9RE4tKklAI8Dee6x0kgFAiSeZcO Uc7cdBXRWy8LwslpL248Uqo9fXysh8hGqfpwnq1fhPDvcoya8ZJmK6c2+GnqTq43hWSu 2tDVLw7ITgwIBJ9HM72g+iuWAJCR14NO/WoeOQ8+pmCJF1zScB0Uan9GOAShwNbLqKr4 s5JBUXTOWux/I9uBxKeKtXPTnS0NQVkmABtg7tJiPn+kuBKBz7wTSZ+DeuKyAnrTSNh3 ssFg==
X-Gm-Message-State: APuU4Z/iyfeKhX6hPAN4gsl/fY24KY4urcwwbHcSeDr+A+LXAgilpDq/ bmofu+UeLUqeYI7SyAVn0zt35ynK7LXOXTMfIwX7YIMq+za9jNlmtwco1vXO40pul9MQiMv88kU y3Ps=
X-Gm-Gg: AYBFou18MvhCfydh+IF0IEewJQoLVqxQNO3/Mckp5XicFgtDbZy2D+J0X28GKSH5FKS A57TeJnFE/4bqPLujSoc6vyio9egVRbOAry5wT6S3ld05jXAczHMIG47xGzZFliSOlyGd6Ad7FO IwHde2WpWq0dkpoboq2H7gYYV9OAWs6IxjSzXlrE+wEImMaBoWJMMX6uO69RomTwZlplPNmAbqt JTLNYuVnmS3IdywDnucZUp4CZ9xxoOXt/LRPwUxHvnB1H/9ngLXLBTtoMyKmmRB+hMCHD2ISUb+ 8pzolDCKh0cJlGQmPXUsVUaIqYmSRe82vC6YJd6PNf6tyJPlmCgHheFOTjlU9oE+W/1n3jrrRo6 YZkwSol9Y7Rkx2pNJuHzP8PE/IO9Ro0UEeq5s3gqJ9ijDEnE775e1hEmRt1MlXmxBRnT+3B1PEh 0TNOhAtH5LFWjEVj+AWHA9F4Ix7rXKICXHAOiXrMwQqYwN5XLJDmZDlR+VXb6MOc3CugxXSkjFT wqjp+rwQMUfNGg05L5ci55lWW3R6KEQtJw2hncGJGYGF6Kt9UJ/j8HOJ2TrHtzk16kqDPaMMvpx rJuu0zjjUIGuwcaYAY7UecICeT35M4TpF/cWbwFpwGyvzleCoI1V81yh0SKRpS3PsTzU0PqgKs+ /qBIWTaFsyqPlN1ic6eBw
X-Received: by 2002:ad4:5764:0:b0:91e:93df:7968 with SMTP id 6a1803df08f44-91f2427df7dmr8048966d6.58.1794516065405; Thu, 12 Nov 2026 12:41:05 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2026 12:41:04 -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.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
X-Received-Bytes: 14223