Article View: linux.kernel.netdev
Article #19945[RFC next-net 2/3] ipv4: accept the reported route type when deleting a blackhole nexthop route
From: Stephen Hemminger
Date: Fri, 20 Nov 2026 20:01
Date: Fri, 20 Nov 2026 20:01
100 lines
15183 bytes
15183 bytes
fib_dump_info() rewrites rtm_type to RTN_BLACKHOLE for a blackhole nexthop
object, before the nexthop_compat_mode bail-out:
if (fi->nh) {
if (nla_put_u32(skb, RTA_NH_ID, fi->nh->id))
goto nla_put_failure;
if (nexthop_is_blackhole(fi->nh))
rtm->rtm_type = RTN_BLACKHOLE;
So rtm_type describes the nexthop object, not the alias, which keeps the
type it was created with. fib_table_delete() matches the stored type, so
the kernel won't delete a route using the type it just reported:
# ip nexthop add id 301 blackhole
# ip route add 192.0.2.0/24 nhid 301
# ip route show 192.0.2.0/24
blackhole 192.0.2.0/24 nhid 301 dev lo
# ip route del blackhole 192.0.2.0/24 nhid 301
RTNETLINK answers: No such process
# ip route del unicast 192.0.2.0/24 nhid 301
#
"ip route flush" echoes the dumped message back, rtmsg header included, so
it carries the rewritten type and fails with ESRCH. Because the rewrite
happens before the compat-mode check, this breaks flush even with
nexthop_compat_mode off, where there are no legacy attributes at all.
Accept RTN_BLACKHOLE on delete when the alias uses a blackhole nexthop
object, so a route can be removed using the type that was advertised.
"ip route flush type blackhole" works too: the type filter is applied to
the dump in userspace, so the kernel only ever sees the type it reported.
Dropping the rewrite in fib_dump_info() instead would change what every
existing dump reader sees.
IPv6 is unaffected, ip6_route_del() doesn't compare rtm_type.
Reported-by: Yuen Su <zypulsecore@gmail.com>
Link: https://lore.kernel.org/netdev/CAC9WPdwmM4=64DH5nY85srnLhRBS7PkjR9vrsALpob-GutbmZw@mail.gmail.com/
Fixes: 4c7e8084fd46 ("ipv4: Plumb support for nexthop object in a fib_info")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
net/ipv4/fib_lookup.h | 1 +
net/ipv4/fib_semantics.c | 14 ++++++++++++++
net/ipv4/fib_trie.c | 2 +-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/fib_lookup.h b/net/ipv4/fib_lookup.h
index 0b72796dd1ad..5109cc197de2 100644
--- a/net/ipv4/fib_lookup.h
+++ b/net/ipv4/fib_lookup.h
@@ -40,6 +40,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
struct netlink_ext_ack *extack);
int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
struct netlink_ext_ack *extack);
+bool fib_type_match(u8 fc_type, const struct fib_alias *fa);
bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi);
int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
const struct fib_rt_info *fri, unsigned int flags);
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index db030bc26b6d..a089761e2104 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1061,6 +1061,20 @@ int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
return 0;
}
+/* fib_dump_info() reports a blackhole nexthop object as RTN_BLACKHOLE
+ * whatever type the alias has, so accept that type back on delete.
+ */
+bool fib_type_match(u8 fc_type, const struct fib_alias *fa)
+{
+ const struct fib_info *fi = fa->fa_info;
+
+ if (!fc_type || fa->fa_type == fc_type)
+ return true;
+
+ return fc_type == RTN_BLACKHOLE && fi->nh &&
+ nexthop_is_blackhole(fi->nh);
+}
+
bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi)
{
struct nlattr *nla;
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 523a5a4228d0..c67df5aa1b96 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1726,7 +1726,7 @@ int fib_table_delete(struct net *net, struct fib_table *tb,
(fa->fa_dscp != dscp))
break;
- if ((!cfg->fc_type || fa->fa_type == cfg->fc_type) &&
+ if (fib_type_match(cfg->fc_type, fa) &&
(cfg->fc_scope == RT_SCOPE_NOWHERE ||
fa->fa_info->fib_scope == cfg->fc_scope) &&
(!cfg->fc_prefsrc ||
--
2.53.0
Technical Details
Message-ID:
<20261120200635.95798-3-stephen@networkplumber.org>Path:
mbox-mo1.pugleaf.net!srv.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-368116-linux-kernel-netdev=dewy.ruReferences:
<20261120200635.95798-1-stephen@networkplumber.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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-368116-linux-kernel-netdev=dewy.ru
From: stephen@networkplumber.org (Stephen Hemminger)
Newsgroups: linux.kernel.netdev
Subject: [RFC next-net 2/3] ipv4: accept the reported route type when deleting a blackhole nexthop route
Date: Fri, 20 Nov 2026 12:01:29 -0800
Organization: Usenet Network
Message-ID: <20261120200635.95798-3-stephen@networkplumber.org>
References: <20261120200635.95798-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3252067"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:FsqDbK+14Nd/+RQjOvu/TfDl5Gg= sha256:oU23F0gpcUdUMMgXTDtynMot8oziunN9qerINK+hCgA=
sha1:IJN4vKo+W/YvHuH6SpvxZHS4UnU= sha256:PvHHN44SssPOb9wSQvzjpcnEr/V0B4t+18zA/Vub+Xg=
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 2E4FA115A6B; Fri, 20 Nov 2026 23:07:05 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.951
X-Spam-Status: No, score=-2.951 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-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 (2048-bit key)
header.d=networkplumber-org.20260707.gappssmtp.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 X_mRESQhI7IQ;
Fri, 20 Nov 2026 23:06:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368116-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=quarantine dis=none) header.from=networkplumber.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 7CC751159FE; Fri, 20 Nov 2026 23:06:46 +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 6545668180; Fri, 20 Nov 2026 20:06:44 +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=1795205204;
b=Wojh7ehU3lfjN4teVF3EEqn8aXor6dHzekWo+o6iLX2KTjGENlJA3eqQiziG/Wotq0M8
CVdJjuEEVcaF6+MVd7itnxnEYD6Zn+eUgDAG0GO5zthRra8Jnuu/sI3afqNOwE7ZgMdLh
XekfwD0nv0sVkZD9RDc9d1JI3XxctF0K0HaPsAv/skyYdZzqS6qEXD17cv/SuBbC+ipPt
F96JKYFStJzB1mCuslixpwiVd2xSj4us1J190L0RgdTuS8SqsfqiUgJymFo77zqB9iYA3
KNNEKKtWjalaKFHc6JrS5LxAc1owNyxWroQZ25E8mB3wOM7dysspEOlbAgLKd87C9xA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795205204;
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=5VbTKyUQtrAhX3grORwqbl6JK+pg2ixihCAArXS2TXE=;
b=pBG0/Uz0d00c8z7N9fNOejpABXZ8ADIl3vPjT4DDBNHVnToRa98aza6xMjdd4nNL0oKi
DeYFnE7KKSgo0IyP6q33/z2FIWLjm5GVU6nmhgICEURUiZnmE4xVgadX2tfenlfbkM5nr
eXFtqZ24iKViyPfxTC4UUuidQogUBSJdRUKgOA81C8TxBFU8qSPKUABLMv32eHmunJjgL
8HkHpLcwrL6JeL1Bs/aT1I+3Wq2apnV5PgG1bdA8tJ4cWLno0QLR60C6HR9O8lBH+IOCf
UCk5y4wpP/vWY0Jpd6GgU1P+u/YIrLSS5uRB7SluKW5UVsJId3UlNbragfjN2jYQo4w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=ViIAh6mj;
dmarc=pass header.from=networkplumber.org;
spf=pass smtp.mailfrom=networkplumber.org;
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 3C7C060A2606;
Fri, 20 Nov 2026 20:06:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=ViIAh6mj
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.182
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795205203;
b=hLhpS+ST8Cqa4/XxPJ/XcNAfipmlreP97fXZqx1QaECEWHPhZk6fsp2mFg3cyiz1hKEQ
B/WSgqAEpGIu4zBckMxUQLMv5+C3cxmLrqFseNicoT37YXRVjn/FshpD8S+92TEh6q29l
QORLZItBDUFsE9pKbpcTMgUh+SlGXyl6cXiXVG3p7cxHnfXW/osiVRDhfwPXmOVL9jgWz
crtx/c5rKc4i08sKffREy8pr/Pr0XVYssQW7EPpYE1ebPs117hQU1nAYdHwfhMu7sjS3v
A3B1lDd1w2n5HXSOg4TJnNQhiiB2QwFQNz4toNHSzpo6KXGOLr5e5wXXwr9D8Afwoug==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795205203;
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=5VbTKyUQtrAhX3grORwqbl6JK+pg2ixihCAArXS2TXE=;
b=GRk6M7V3YvPPyQ3zcz6qUT9w1FclwQrA9Sd5T2EclM8Wo+DOI230Ri/d/cwa7V/9UqNc
pehcEfLG9hbEWZ3ZM6bFPDfVxVQcZzZGvs84BUSGXMKjQU47wURp7aZPoGyVt67YfHRK3
zs/1WP5D2J7tXjBcIsEKZkCfU0s8jg2GvlJdkaH5jJeb7+GUg7mYE++3YBXL1Q6z3YR/E
TFS0ri2/2bodYGd2+JvUXCDJBkV+UAxjSvFDb+B1urclmexYSApq98Ph2NpNL1qwCBYUr
U5EXQTDTt9beCoV5DZ2cvCC4KGd/eeVG00A5q5TkbBu1Hq5UepC/R5ZG/0yebgsMi8w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=networkplumber.org;
spf=pass smtp.mailfrom=networkplumber.org;
dkim=pass header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=ViIAh6mj;
arc=none smtp.remote-ip=209.85.215.182
X-Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182])
(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 C52D9606A6D9
for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 20:06:40 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C52D9606A6D9
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org
X-Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-ccca948203aso1454389a12.3
for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 12:06:40 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1795205200; x=1795810000; 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=5VbTKyUQtrAhX3grORwqbl6JK+pg2ixihCAArXS2TXE=;
b=ViIAh6mjzBzn9IlM0DwNU0438MM2fVuM9DDLogvaV1d6GAkYu2LI0tzY4FJy9uGQxS
6bSlXKebplEx28kyQJdlhkZZA53gf3jUtAZrSq2FA6mr8DtC2TtQTh22x2p5jozMElep
DMvkCWz7uLzHfdIpQafXEsP9ezmIlpqUbJ9GRxKOBGMNirDizuFWc+z2bH5o4C4BhxIZ
Ilq/Ta1Qh0uUz/FDatdPeoaq06rmCWPblhWEFUMZBg+D0mqWjuam85s1zMEY9Elcrzu0
xwfGrS6Z6GyzxemmbrBb+wsCEeBie0MQnmTN+ShNVfGm7TgxSXMVRcQyCw88Hg68cMFB
Ww7w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795205200; x=1795810000;
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=5VbTKyUQtrAhX3grORwqbl6JK+pg2ixihCAArXS2TXE=;
b=STEK1/vimIni5W5jz1LTPhypV+CPUAkWIrNz+2d66tZz8xiYsOioqZ4cVx41YPjtwE
Um3X261orN22JoHGZOa75yijJbJOP+1YmYWMh1AUrwD7ktcSizQm13hMyL5KPNkfh0oS
TZnSId6vS45ROvDIbrD6DAQBypA7OZ+g0p/yR9L5Mnsm9LtF2UZOC7fFOm1Gc9zH15q7
IGERB5M3sm+A8OdNW1bASTrlfpdGQUOqPWbVre7wQ17pR0jFXQDgGCimVwBpCpWCxjtN
XcIEz3Isz3tVU44O5r3Ul43FBo5cZjwUrwW7H+y/ZffpDyxAW9vHGiEA2Xd7vMR4l45e
onlQ==
X-Gm-Message-State: APuU4Z/RUpXWQbLBLUB9QScDnizeIkDo0n51DIrjJCpOWxJtWFBmboRv
ZP905z4d32YaSuNA06fjsCvVWmHA12hb7DJDEMQB/FM+k9vuOMLEyqXnkM+yT2iP4QX6REil57j
kZQjLiaQ=
X-Gm-Gg: AYBFou22bSdvzmFIaAYCrwKfdhlhUUouh+2pu2mIOH2HkZkuJLmUpusHEltdkL+0W2n
0jv6dEMLM2sop13kUntCwnkVlNK4ZoDFkHepajWgBfvEy7GjeMzarDkS1JFrZR7WoVtNPhKfirk
aF+9XXmsAqTnUyLM5wyq6S0UgGTb0cCfgACJboJyCejUFq0ohW3jbVzl67uNOjy4yjj0vglmRBS
UJB9O5c5DtigsdaUnmi853xb1j7hXesMJAa1RSS/jg45C8oStXL5KuQP9lQ1j+cCDvZZ6DdaRCm
zQEzg77XwCRYiYFvO2o/BnBiI73Gco9aEDxuQMUAn9fvz0JVG/XTqZbXM+iSayqouKdVrrVKMzM
xK4h059d4qB81QDyO5lefqt+JQDj+3VdxElmrkJaigdzYSQd+oCkPkteye9iSMA7UpPVutPrNxn
gCIVnYMslIhde/azaiH5rPjJn4RQNlSn/+9ohVPh3U8GvyZBRPSuH5N6G6EVlKyfwwuzmGAG0xg
t6x/4GKW4dI7O0pNVq1sKOxkddeX08Q0w8YWXR3bPwgLHvVD4MMQu8ItNZaAJs1JeFhRl+Gv3bL
ZN6a1uDbDsUR9Qnf1wQRGFToAGHuifrXHlW/5q3PIjwUMHl0pES3Z8l74R7P8bjQxIqY
X-Received: by 2002:a05:6a21:e089:b0:3f9:20d7:984a with SMTP id adf61e73a8af0-4014a17aa71mr5227956637.13.1795205200153;
Fri, 20 Nov 2026 12:06:40 -0800 (PST)
X-Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43])
by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cde6d028a54sm1619282a12.18.2026.11.20.12.06.39
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 20 Nov 2026 12:06:39 -0800 (PST)
X-Cc: dsahern@kernel.org,
Stephen Hemminger <stephen@networkplumber.org>,
Yuen Su <zypulsecore@gmail.com>,
Ido Schimmel <idosch@nvidia.com>,
"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>,
linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261120200635.95798-1-stephen@networkplumber.org>
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