Article View: linux.kernel.netdev
Article #24619[PATCH net v3 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace
From: Jedrzej Jagielski
Date: Mon, 30 Nov 2026 12:30
Date: Mon, 30 Nov 2026 12:30
96 lines
13244 bytes
13244 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. Let userspace know via extack that hardware may be
partially updated, without overriding a reason set by the driver.
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..bf4dc4244b84 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
+ NL_SET_ERR_MSG_WEAK_MOD(extack,
+ "Replace failed, hardware may be partially updated");
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:
<20261130123028.516696-4-jedrzej.jagielski@intel.com>Path:
mbox-mo1.pugleaf.net!srv.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!peer01.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-374180-linux-kernel-netdev=dewy.ruReferences:
<20261130123028.516696-1-jedrzej.jagielski@intel.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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!peer01.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-374180-linux-kernel-netdev=dewy.ru From: jedrzej.jagielski@intel.com (Jedrzej Jagielski) Newsgroups: linux.kernel.netdev Subject: [PATCH net v3 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace Date: Mon, 30 Nov 2026 13:30:26 +0100 Organization: Usenet Network Message-ID: <20261130123028.516696-4-jedrzej.jagielski@intel.com> References: <20261130123028.516696-1-jedrzej.jagielski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1427567"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:PGd2uUBk7DNCY5U2oZ2d13mAKpY= sha256:T+HYwXWqJ3bnpbdgGTXZlfLl8OcBbll+DxUJep9THvw= sha1:Wz3FxM1vvn0eNFMxwr9v3nBjeiM= sha256:L509QFa0QQUKBaVnhh+aPKYb6psQM6R4W6wUZuAiihQ= 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 BE852125FE2; Mon, 30 Nov 2026 15:53:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.052 X-Spam-Status: No, score=-3.052 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 (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 dHEwqU0kdovn; Mon, 30 Nov 2026 15:53:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374180-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id E049D125FE1; Mon, 30 Nov 2026 15:53:30 +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 A972330D80; Mon, 30 Nov 2026 12:53:08 +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=1796043188; b=EjAXZHzl8IHvXnxSI/0YjYQbJ7y3Orlqd7zdozIPkuYNFUTyN0u/+4hmIb0GkY1axcAJ QiffqiWpDwYtvDgQvYvocH44a+DAScOXECMcZm7qWj56Cj8pWwJ75Ag+RTFiY6hzU+lBW N36IxeCGPmCS+qkHBLoYq50ZgrPhBS3XSl3Q1S+qNm9AlkRkqIue3PQapnz9NkL10pyFE qma7y3BeXbkpTQImFfi1+zsZX+6URQQdsRt0/0Qe5FLpGWsYCjWHft3L5jD1Ukp17LG1d lhO413RVGEBaALEB70stvw2G4In3xoFSguEf+j6qVAoRRzecYB4OQU78YQjOTmXeh9A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796043188; 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=U38jIJKHJLrHGJNaSd6euqBQelVS3MpM9KcXZ5p+nWc=; b=kGP8733Hw/suOVIvzdsJ4eG6CyWM+n0hN2iQdCg5XKORTDMSE8VqvoMnq40iL2/lh65l adUJHN8HvwDCsU07gu0vI5bL6+rynrmroWlGfjK4ozH9garJf6PCUv4EF/RSImWilCihy iOZ+lMdh2uP8l0fgqbyBHghD06CBuVGiol9DCqHItlOBge40nSBagrOes/ZyAETa/NLfX UcEqNRZ2wQp1j5S+/v4nLht0n2TGHRyA/feJfdHY6utW3z6NU/FMv6rouRCfW0PMfZQ7Q SbtVOBmQkre7+q2NpnxuSButqTPx5JVgqUnYhR6dALHn5LY0Ncm1rQESmCZeIUdMv2g== 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=MaELDU5c; 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 0DF02606A69D; Mon, 30 Nov 2026 12:53:08 +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=MaELDU5c X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.14 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796043182; b=HONsEjM+f064l1j4FZ/bIXWOdThfv5NeKtEZE85YvgCx38x9OBBDEmcTrpsv8Z4L44IT tDxOOJ+78KeaFDh+GJATBiAhxE0qYu8D7GAFn+LqU34XZeMywXxb4hOtivWIiBPTMfD6c 5Ho/KuyDbBavGKP/kRc/5/e/dRtfgFamKgBt+X4n22k+AA26Qn0EUeXTkydX8Gx9ofcIB 1XP2zcbOyTC0G3Q5CMqQeDdt47zyCP23xrE4q03AAXRr1FMzuFTjvnb9vMpwm8PqP+V6a y1/3buBW5tFGO+/LrEn4ISVJlybwjCPc7+ISFSCOe3TxxA4NEXX+EZJl30azS78jG5Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796043182; 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=U38jIJKHJLrHGJNaSd6euqBQelVS3MpM9KcXZ5p+nWc=; b=lcxwv52n0U56e+ZXUYnEbfIm6WYHAoY4F2jRIs3eefaTmt5Bn83hztVzN/r06Px8eG0X N9qbBdHwk9bW7Tt048X6rY2G1PncK7KlwmjClZzJdLBbQs26iIOFEc7LzoVaIbtj7/ha2 4kdMgzgG0TeCSPZOo9EYHyN+lcZOzMT4mdRSoELZeTouGu/ZMLaRo97NpsREyftKEJVdh FBeOBwPxfdO/CCcG3jqDRMZTa3dKoacg9Y4Bv0Mde+ZBhO9S7ylNZEaTTPrcEDVuJnhVV j9ExABV+VUChuTtLpeRl+hkxL/XTYjQImLdd2igir83ILocB9LyD6x+6z2IG4mlU9OA== 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=MaELDU5c; arc=none smtp.remote-ip=198.175.65.14 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 C531E606A31C; Mon, 30 Nov 2026 12:53:01 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C531E606A31C 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=1796043182; x=1827579182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U38jIJKHJLrHGJNaSd6euqBQelVS3MpM9KcXZ5p+nWc=; b=MaELDU5cwDZ2CCTR4H9yakt8TEahby6HtHN35RncyIJFPyZjsUvxIyUQ +aUq+nLzUlEBAlFJWENs3QmWibOeVzZaaLuMI5G8LC+5s4KEt9GX3zfo2 wWRXf8U5LnQqEFCs2dy56yWORt47sMqBpPuq7irCxjiWei/pASnFvKnih 5heh3AwxCxEMmCs4Gy7VfX6FG5fJw6GgZO9wmDt7+oK3mLeybfPXazH/a ewkog5Y1L1jqs+bIjX8X6fsirpjHkScjS+gAk0SWm1QHdAwZ5aGnxIKBT Rt4/L5DZdFvlQ2xSwBBSDr1OhvH67awGQkxIk7mXi/GjPvh1X+GfznZXz w==; X-CSE-ConnectionGUID: PPdoZ2y+Q4uvtPH5lN4Bjw== X-CSE-MsgGUID: kwCBqRo6Q0W032ukjL+srw== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4778602" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4778602" X-Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 04:53:02 -0800 X-CSE-ConnectionGUID: 7iztU3UCTuqv/YsLHNhshg== X-CSE-MsgGUID: nYAJgtLFTpWorRmhSkxAIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="12957222" X-Received: from os-delivery.igk.intel.com ([10.102.18.218]) by orviesa002.jf.intel.com with ESMTP; 30 Nov 2026 04:53:00 -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: <20261130123028.516696-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 X-Received-Bytes: 12985