Article View: linux.kernel.netdev
Article #26393[PATCH net v4 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace
From: Jedrzej Jagielski
Date: Thu, 03 Dec 2026 12:40
Date: Thu, 03 Dec 2026 12:40
96 lines
13437 bytes
13437 bytes
On knode replace, u32_init_knode() copies the handle of the existing
knode into the new one. If offloading the new knode fails,
u32_replace_hw_knode() rolls back with u32_remove_hw_knode(), which
issues TC_CLSU32_DELETE_KNODE for that shared handle and so removes
the HW rule of the old knode, which is still installed in software.
For a skip_sw filter, u32_classify() skips it, so the filter matches
neither in SW nor in HW, while userspace is told the replace failed.
Add @new_handle to u32_replace_hw_knode() and roll back only when the
handle is not shared with an installed knode, i.e. when adding a new
one. On replace, leave the old HW rule in place, in line with
tc_setup_cb_add() treating a failed add as non-destructive.
This is a trade-off for blocks with multiple offload callbacks.
tc_setup_cb_add() stops at the first failing callback, so callbacks
which accepted the replace before it keep the new rule, and its
link_handle may refer to an hnode no longer referenced in software
once the new knode is destroyed. The removed rollback deleted the rule
on all callbacks instead, including those which rejected the replace
and still held the old rule. Since commit 695176bfe5de ("net_sched:
refactor TC action init API") skip_sw is ignored, so the same split
HW state is left, but silently and with the new knode installed in
software. Unless a netdev sharing the block is not offload-capable
let userspace know via extack that the hardware rollback was skipped.
Rolling back per callback is not possible, as tc_setup_cb_add() does
not report which callbacks succeeded and drivers identify u32 rules by
handle only. Re-offloading the old knode is not done either, as
drivers which reject an existing handle (e.g. ixgbe) or handle
REPLACE_KNODE as an add (e.g. cxgb4) would not be restored by it.
Drivers which destroy the old rule themselves when REPLACE_KNODE fails
(e.g. stmmac, nfp abm) still lose it, which is not changed by this
patch.
This is a forward fix for currently dead code, which will be uncovered
by the upcoming patch "net/sched: cls_u32: feed u32_replace_hw_knode()
with correct set of flags".
Fixes: 245dc5121a9b ("net: sched: cls_u32: call block callbacks for offload")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260813122242.1690024-1-jedrzej.jagielski%40intel.com
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
net/sched/cls_u32.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index ae1b6476f921..7ec05629e860 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -548,7 +548,8 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
}
static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
- u32 flags, struct netlink_ext_ack *extack)
+ u32 flags, bool new_handle,
+ struct netlink_ext_ack *extack)
{
struct tc_u_hnode *ht = rtnl_dereference(n->ht_down);
struct tcf_block *block = tp->chain->block;
@@ -576,7 +577,11 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
err = tc_setup_cb_add(block, tp, TC_SETUP_CLSU32, &cls_u32, skip_sw,
&n->flags, &n->in_hw_count, true);
if (err) {
- u32_remove_hw_knode(tp, n, NULL);
+ if (new_handle)
+ u32_remove_hw_knode(tp, n, NULL);
+ else if (!block->nooffloaddevcnt)
+ NL_SET_ERR_MSG_WEAK_MOD(extack,
+ "Replace failed, hardware rollback was skipped");
return err;
}
@@ -951,7 +956,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
u32_bind_filter(tp, new, base, tb);
- err = u32_replace_hw_knode(tp, new, flags, extack);
+ err = u32_replace_hw_knode(tp, new, flags, false, extack);
if (err) {
u32_unbind_filter(tp, new, tb);
__u32_destroy_key(new);
@@ -1189,7 +1194,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
struct tc_u_knode __rcu **ins;
struct tc_u_knode *pins;
- err = u32_replace_hw_knode(tp, n, flags, extack);
+ err = u32_replace_hw_knode(tp, n, flags, true, extack);
if (err)
goto errunbind;
--
2.31.1
Technical Details
Message-ID:
<20261203124056.547555-4-jedrzej.jagielski@intel.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!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-376618-linux-kernel-netdev=dewy.ruReferences:
<20261203124056.547555-1-jedrzej.jagielski@intel.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!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-376618-linux-kernel-netdev=dewy.ru From: jedrzej.jagielski@intel.com (Jedrzej Jagielski) Newsgroups: linux.kernel.netdev Subject: [PATCH net v4 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace Date: Thu, 3 Dec 2026 13:40:54 +0100 Organization: Usenet Network Message-ID: <20261203124056.547555-4-jedrzej.jagielski@intel.com> References: <20261203124056.547555-1-jedrzej.jagielski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2496881"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:aoUkPkfQv3m2kQy9JpNrdJOLKwk= sha256:SoYmGLfW2931ZQd7kU7dzrkAWGf6IGSbcvRgEMeCgpY= sha1:4MeB1I6iJh4HS+PLfMO5WRnsF+E= sha256:130717KTrXka5F48nhYLvwjvkpq8QGTxuzYiTxBdHpI= 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 C3978117956; Thu, 3 Dec 2026 16:04:04 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.639 X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, 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=intel.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 SyiF0bV5fpbZ; Thu, 3 Dec 2026 16:04:02 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376618-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=intel.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id B1EA4117954; Thu, 3 Dec 2026 16:03:53 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id D27C7298F7; Thu, 3 Dec 2026 13:03:36 +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=1796303001; b=LvJ41kmleIug3vWZcS7Y6MH1OX40RmoQTlsBa/pc2To2esENgqLosVAOWULIUI1rEiqm G18hgfjUY6QOopM/rPbuqXemsTpw3wIkBg8ExnUmrjBe+vPXgH8RbE7pyJBwzCQoFvVC7 Q/Y6fhJ0mCTrRNcmbfEVtyDrykF5S8rfgpfIX3xVkNU76gh2Wa54nZXRU9BpR0L4bsAlh pwgf2Ubg92HDyc8GaOQVylduSlHWbAVnoxADQr44i9yILMEnrsxRDJ7ztVbp26zsuq4bA XYHI0P73A3/o6LRwCdBsHtc3BzhCkK5chMLv+Lajlbbv2beu0gMp1ypU5/+w2vMHhWw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303001; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV:X-IronPort-AV: Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV: 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=98inL/yNQkJSaSi0XA8cs69fKuqGUsUu/ybUoMEohPY=; b=EeuEDNtEBCm/p/XbPBbwWiNtnzFnGqNEqPcqOI512ALgBbuJvvovxO5SFHr5KOFJmxgY SZVyKjB3OUkc2xpeT8mph3xuxXBTw/I+BT9mbQgcMmvKghkBc49lMzFMaSmAJZp5xKkra pZmo6LZbacF5DwQIYf8seiRPtk/9Dwop98GLVtoSleOS6e+fa4HDzYVpqwD57KDYz23HD qr/aNKD/UWKKcu9FT8QKwC9KgAwrwhPit20a5vbndDF2arw4ywMbe4k2uKFzwMN8d29XG HA3HrPavOmWHAQBxeALLgzto6k4bWpW5O4nX5S6u7J/g8djrdfl8l6Fp2bRyfjiRbqw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GxrwMHrH; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.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 166F460A2600; Thu, 3 Dec 2026 13:03:21 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GxrwMHrH X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.21 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796303000; b=L/7bwgREvRdsFPLkExHJM32tSVX5uTE2LNId4ELKBJyaNDeppDhRPmC3sLvPBTMzz+7P 0sUiOzoJDm7x2MZTZwjTlcEMZS+w0GnVGm/ssGB+1lrE18cA6WI1CQSweA8ZfTuJwnFj7 CVMQTrIo4RIT17Q/5GbBBKoXLm31qGzihMhF96HplTkHpQCEYZER01XNmVqV2eVyRjyfd yaMs8GpprN7tIeThgWXOxUFBo4F+h3KesWNHWAGrRhDYupfkVR31OWBBIrr74YzwlY84u BalZVWdUBb8sSVOcvII5u4pkTDZTFbZDyfYoVX4BV+UCahx6d1RmtzGCptrrTn8ixTw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303000; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=98inL/yNQkJSaSi0XA8cs69fKuqGUsUu/ybUoMEohPY=; b=PVvsIxOO98m/gcBDFE12yEfl3lnHlVwoWDyaWqQFhFypDjo06QHoJVAQv+1JC9+gn56c pM/LplE/AJcevOtpeSVmMs3ALvWNBFE9yt0nwpUoWm9BAIwcZSYtYfGyMHoX/p++qKhyZ 3fmkuxWhm4l/oV6cqqoaEmNF56rJVAaO/WpwGsGHIKf5UOpd18tfx5TpynvlAKw0r82+/ IdNLwho88OR/2hgCDcIQ7o6kBoHu4R23lYkE0W9j6u7OE2i7iQMSXohY492Np5A5aTvgu ykh+ZSszVvtWXk3Nd4DXPOKEPDCaa1NsSn8DPR+NOlXBE/07F5rGR10Lv77yEH6+fTg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GxrwMHrH; arc=none smtp.remote-ip=198.175.65.21 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D376E606A691; Thu, 3 Dec 2026 13:03:19 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D376E606A691 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796303000; x=1827839000; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=98inL/yNQkJSaSi0XA8cs69fKuqGUsUu/ybUoMEohPY=; b=GxrwMHrHfWxz7EGUR4UyaWocO290DdLDdIAVxdDsjwGtSaex5iB06LiC gjnbzi/YdjC4ATX9KdaPBK/rWKE1WZfSZyE6teOmK1wkT+xZyM3i9Okmm 4y5j6RP2XhdRNSYlssWziOSIVkNcB/8ladqNQezlZD3edsVk0j/y4DV+a 45/LGY5WHE2S9ceNaLj3ExL0f0PPQsYlz3/IbA1vauVqjUX11awpLwKM/ nTcadDdBGXCOquVF4C6QKtKw68Xre5I75EYTMwwtVkgRLbv/99rt0gLB4 HQINnDbugzrKHfq9DdJyjvdb6h/O+qeAXPgWgMuLAaQf9UhkQuqf3p4sS g==; X-CSE-ConnectionGUID: 9u/mJuvpSJ29mqjbuP3QlA== X-CSE-MsgGUID: rgiT58yiRLyZb7xtTUhjZQ== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5366934" X-IronPort-AV: E=Sophos;i="6.29,248,1794902400"; d="scan'208";a="5366934" X-Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 05:03:20 -0800 X-CSE-ConnectionGUID: QTAiUv/cTvmXJRJZtUh+Rw== X-CSE-MsgGUID: 4ATlHU4WS0WY1r11XYKotw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,248,1794902400"; d="scan'208";a="14195741" X-Received: from os-delivery.igk.intel.com ([10.102.18.218]) by orviesa009.jf.intel.com with ESMTP; 03 Dec 2026 05:03:18 -0800 X-Cc: anthony.l.nguyen@intel.com, kuba@kernel.org, jhs@mojatatu.com, jiri@resnulli.us, edumazet@google.com, Jedrzej Jagielski <jedrzej.jagielski@intel.com>, stable@vger.kernel.org, Sashiko <sashiko-bot@kernel.org> X-Mailer: git-send-email 2.31.1 X-In-Reply-To: <20261203124056.547555-1-jedrzej.jagielski@intel.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