Article View: linux.kernel.netdev
Article #16558Re: [PATCH v7 net-next 6/9] net: dsa: netc: check return value of ntmp_ipft_delete_entry()
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 07:24
Date: Sun, 15 Nov 2026 07:24
184 lines
15088 bytes
15088 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] netc_port_remove_host_flood()
(drivers/net/dsa/netc/netc_main.c:1874-1898) keeps np->ipft_hf_eid on…
- [Medium] The new retry loop in netc_port_set_host_flood()
(drivers/net/dsa/netc/netc_main.c:1943-1952) sends another IPFT ADD…
- [Low] The commit message says that if adding the new host flood rule
fails, the driver will "log an error to help users find out why host…
--
net: dsa: netc: check return value of ntmp_ipft_delete_entry()
This patch makes netc_port_remove_host_flood() return errors from
ntmp_ipft_delete_entry(), and it only clears the tracked entry ID after
the delete succeeds. Host flood rule replacement changes from
add-then-delete to delete-then-add, with a retry loop on the add. Bridge
join now fails if the existing host flood rule cannot be deleted.
> diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c
> index d23cfa076e842..6756bf9edfdb2 100644
> --- a/drivers/net/dsa/netc/netc_main.c
> +++ b/drivers/net/dsa/netc/netc_main.c
[ ... ]
> @@ -1877,32 +1871,37 @@ static int netc_port_add_host_flood_rule(struct netc_port *np,
> return err;
> }
>
> -static void netc_port_remove_host_flood(struct netc_port *np, u32 entry_id)
> +static int netc_port_remove_host_flood(struct netc_port *np)
> {
> struct netc_switch *priv = np->switch_priv;
> - bool disable_host_flood = false;
> + u32 entry_id = np->ipft_hf_eid;
> + int err;
>
> if (entry_id == NTMP_NULL_ENTRY_ID)
> - return;
> + return 0;
>
> - if (np->ipft_hf_eid == entry_id)
> - disable_host_flood = true;
> + /* The command BD ring is always enabled here, with the ring
> + * enabled, the hardware completes a command well within 1 ms,
> + * so -ETIMEDOUT cannot happen here. Any error therefore means
> + * that the entry has not been deleted, so keep tracking it.
> + */
> + err = ntmp_ipft_delete_entry(&priv->ntmp, entry_id);
> + if (err)
> + return err;
[Severity: Medium]
Does the NTMP command layer actually guarantee what this comment assumes?
ntmp_ipft_delete_entry()->ntmp_delete_entry_by_id() passes back whatever
netc_xmit_ntmp_cmd() returns. In netc_xmit_ntmp_cmd() in
drivers/net/ethernet/freescale/enetc/ntmp.c, the BD goes to hardware
before the completion poll starts:
netc_write(cbdr->regs.pir, i);
err = read_poll_timeout(netc_read, val,
(val & NETC_CBDRCIR_INDEX) == i,
NETC_CBDR_DELAY_US, NETC_CBDR_TIMEOUT,
true, cbdr->regs.cir);
if (unlikely(err))
return err;
On -ETIMEDOUT the BD stays queued, so hardware could still carry out the
delete later. NETC_CBDR_TIMEOUT is exactly the 1 ms this comment relies
on, with no margin.
The -EIO returns (NETC_CBDRCIR_SBE and the writeback error status) are
only raised after hardware has consumed the BD. Only -ENOMEM and -EBUSY
seem to prove that the command never reached hardware.
Suppose the delete did take effect but np->ipft_hf_eid is kept. Wouldn't
every later delete of that ID fail?
In that case netc_port_set_host_flood() would always return early. Also,
netc_port_bridge_join() would always fail with "Failed to delete host
flood rule", so the port could not join a bridge again until the driver
is reloaded. Before this patch, the error was ignored and the state was
cleared.
IPFT entry IDs are assigned by hardware. Could a freed ID be reused by
another rule? Examples are the PTP trap entries tracked in
np->ptp_ipft_eid[] later in the series, or another port's host flood
rule. A later netc_port_remove_host_flood() would then silently delete
that unrelated entry and report success.
The commit message's statement that "the software state always stays
consistent with the hardware" seems to depend on this assumption holding.
[ ... ]
> @@ -1919,19 +1923,33 @@ static void netc_port_set_host_flood(struct dsa_switch *ds, int port,
[ ... ]
> + /* Restoring the previous configuration is pointless because
> + * .port_set_host_flood() returns void, so the upper layer cannot
> + * detect the error and the RX flags have changed. Furthermore, we
> + * cannot guarantee that we can successfully restore the previous
> + * state.
> + */
> +retry:
> + if (netc_port_add_host_flood_rule(np, uc, mc)) {
> + if (retry_num++ < 2) {
> + usleep_range(100, 110);
> + goto retry;
> + }
[Severity: Low]
This isn't a bug, but the commit message only says it will "log an error
to help users find out why host flooding is not working". Neither the
commit message nor a code comment mentions this retry loop with
usleep_range(). Could the reason for it be documented?
The loop retries no matter which error code is returned. Errors that will
fail the same way again, such as -EIO from a writeback error status when
the table is full, get retried too. Each retry also widens the
delete-to-add window that the commit message calls "very short".
The other add sites don't retry: the restore path in
netc_port_bridge_join() and the add in netc_port_bridge_leave(). Is that
difference intentional?
[Severity: Medium]
Can this retry leave an untracked IPFT entry behind?
netc_port_add_host_flood_rule()->ntmp_ipft_add_entry()->netc_xmit_ntmp_cmd()
writes PIR before polling. On -ETIMEDOUT, or on -EIO after the BD has been
consumed, hardware may still carry out the ADD. In that case
ntmp_ipft_add_entry() returns before reading back the entry ID:
err = netc_xmit_ntmp_cmd(cbdr, &cbd, &swcbd);
if (err) {
...
goto unlock_cbdr;
}
resp = (struct ipft_resp_query *)req;
entry->entry_id = le32_to_cpu(resp->entry_id);
netc_port_add_host_flood_rule() also records np->ipft_hf_eid only on
success.
The retry then queues another ADD. If that one succeeds, only its ID is
tracked. Up to two FLTFA=REDIRECT / NETC_HR_HOST_FLOOD entries keyed on
this source port could be left with no tracked ID. ntmp_ipft_delete_entry()
would never remove them.
netc_port_bridge_join() deletes only np->ipft_hf_eid, so such an entry
would survive bridge join. The comment at the top of
netc_port_set_host_flood() says this kind of entry sends bridged ingress
frames straight to the CPU, which skips FDB lookup and learning.
Isn't this the untracked-entry problem the commit message says the patch
removes? The -ETIMEDOUT argument in netc_port_remove_host_flood() covers
only the delete path, but this loop retries the add on any error code.
> +
> + dev_err(ds->dev,
> + "Failed to add host flood rule on port %d\n", port);
> + }
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111062753.1397582-1-wei.fang%40oss.nxp.com
Technical Details
Message-ID:
<179472746510.2199510.5500169981091992734@kernel.org>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-363588-linux-kernel-netdev=dewy.ruReferences:
<20261111062753.1397582-7-wei.fang@oss.nxp.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-363588-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v7 net-next 6/9] net: dsa: netc: check return value of ntmp_ipft_delete_entry() Date: Sun, 15 Nov 2026 07:24:25 +0000 Organization: Usenet Network Message-ID: <179472746510.2199510.5500169981091992734@kernel.org> References: <20261111062753.1397582-7-wei.fang@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1747360"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:E6bxEIxiQ5PDvojhpbQ02X6NX4E= sha256:RRQKAJOGNZyzQmYHS2izg+cG3tH5ZNy93PkmArsxhzI= sha1:8vkUpCT+uUlFB+3i28MhUkwUcOg= sha256:xoGbrMAfAqvu3jkmQHVN9jUAfNodPaGmpP9EXBcu7O0= 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 8DBCD114950; Sun, 15 Nov 2026 10:25:04 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 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, DKIM_VALID_EF=-0.1, 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=kernel.org 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 c4aqWAJ5SKPC; Sun, 15 Nov 2026 10:25:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-363588-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 25A5E114956; Sun, 15 Nov 2026 10:24:51 +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 5D52E3805E; Sun, 15 Nov 2026 07:24:42 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1794727467; b=qJqxBULz6zrIl2h9hzwff2u/exoC94s0aMzApy14KaqD+l00zRmCsrbsNzPgo39gzrMj 392PdVHdBsJobDLoTQ7yKiCoLFwz+Ccy1okVvYHQxYbxepWQ9OimDsiwV/UXvAyeZ3puy MYwxT6/Vq08loig4WbdYQ5a8ww8cjdo+CtfPiZNAJGkSco8mk3o1f7G+ifQ85dZE4YHVs 2xK6XMxIK9CBI2cj6b1U6v02+QC4It3G3x2SF7XQ6HXX3A3s/7oWUuh/y+6hs/Mrf3rnK s/Z1Hqji9YVzztPIoyj+ZHZrU3jYgpa/5qHmL401rv9227usHueMRT9bUzMzQp1b3zw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794727467; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=NzpBRw/cBkBhGgg5TTiPsQ+nsl4pu7G97F49dIghoks=; b=Hqf60Ng76by09pBJA4FCY0WOaJOi5DTE6yD6MLjlgXp0xQ/sGvnW4hJK/Vkr4glKR4bJ tKj5C6a6XyXmYWxzFU3zxh3edmLc1m6tD0FXVknHp1GA8M2W9HawB4mO78esWJ9kXidyx zD05BniWtXWBTJGHIByh/CKm898IdGlZb+IOjnLsyL8bKlQTpfVOFcR6VzBfz7+WDBhbh fdFljA1+AeXwujmwLT4fkJ8+b/fh/lNLT89TVVsqyeuI0ASmYiatrTjuvi9XWycKbah4b 36LvdN5MDWl2xQMhaWQ+keXYthpZ87Nshughb8Hvc5kjQsMR5jn+61URbzmp48RFKzA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eDfdSkQN; arc=fail 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 6FA03606A88B; Sun, 15 Nov 2026 07:24:27 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eDfdSkQN X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794727466; b=zKEKz/gRmACB8QX6aQzdH3TXgvDCKvqM6b26n0Ml1oYzljsbRMoF4lx8Ax0dUN77+K0Y dpGSOfNz93tQLHYYDkvgh5PAIUZIJVI3wzHFVHTWngXczqJ4c4uhNgjyPr33W0e85LyaI AR/DjMWkICc+7TG6N5tE4z8SKbifCsH4UndEy7ZIW9VHer3yhczuNBzSnOLbIMAPK3yCc Mh3KAnfWp8sFhY4q9SK9Yfh4x76Yv61SJ66EkUUcYdgcoPgAfM99Tc1FjSBQOaJCLy6Q3 dvqZPbzQGBFT5OCbSI9fVfDuSv7tm7bQh0/vulhL1prG8vCjuryZeR92UapqEUymlWQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794727466; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=NzpBRw/cBkBhGgg5TTiPsQ+nsl4pu7G97F49dIghoks=; b=0YHEtgavu2JtFakOlxDarnYlutZ25newXbrbCJD0kFBTAfQ3cUfafUs/A3q3gPyVSlbd Q52BCRajeqr4kDCLB4+memsKaJ04LpLp7KBN876KJGSR5M2/TjAEvF3isN601BLMVPXjt zz+JIUNOjqSbuVAyBwgyVaDdex6s/22NpuuOlDXbKZr3iiMj8OukdtmfkpUl0znbdGF6v Py5URiZSy9Fyjznccxs8gJd0LvDvzeTHx15U+jah7TqsvlXaZCxsk+TuiddkIGU17P3lV T8MRE2bRBmNn/a/kPhECVHB8Q2e0rqZeXp3cquT6D+ewiZjxwWyLuSesNrmV1NL1fWQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eDfdSkQN; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FA50606A339; Sun, 15 Nov 2026 07:24:26 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 815CF1F000C4; Sun, 15 Nov 2026 07:24:25 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794727466; bh=NzpBRw/cBkBhGgg5TTiPsQ+nsl4pu7G97F49dIghoks=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=eDfdSkQNh1lPjw015Splx3gPWiIVtpKuozkc9f7ptmS8U5jifBLBq29LFmeK6rDoQ HqNK+c4xZVVvkdXR1fuMvjE3k1+c2hYzHGEsaoWcD5KVvNK+s7yDfFLgELibpBtmgW JKx5k4iIS0dVnPhszuxMvoB/2fFLA5RlyMjhmKI4EI6XTmNHkJlgT41ja0wAgevt/4 i/XQntGJDMRKhFmWCPN8Q18duYH3juIRoCFMz3/voMvNGNbgQ0+wjXWDE9oTtYjD4d 1kkQcJVUhPkRDLurQzaMYbi5Frvx3SYtADB/Nn7TEOKsoE+d1JaBiSY3aPD3Bt8viY Ct0cgORoJdbQQ== X-Cc: xiaoning.wang@nxp.com, andrew@lunn.ch, olteanv@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, richardcochran@gmail.com, linusw@kernel.org, linux@armlinux.org.uk, wei.fang@nxp.com, imx@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-In-Reply-To: <20261111062753.1397582-7-wei.fang@oss.nxp.com> X-sashiko-severity: Medium 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