From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.226 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795026163; b=LCpFfauS0iwZPvGo7hchyQPFwLs/jLwTeRHDROaicotwdBQFYflj+obYUj+Cvq1FZ/Sw wslJ5woKxP+ImUUylfohVbIP2vdOxQhSR1XdE2SXAuBk6OCRLFsFi/xrcappe5wPY8oPB MinQiPEkPHjfmX4s/PySWWsTopANVoVD8GBsAe2lErpR2s8dW6t2GOJ8CEHJTw9YnH/ic cwKFCNznZKYrFnKQuVqacq720w3UJlPuyjd2evhUWkegNRFJRyb4jvo3mgTjat1hRRoH9 xokTygn3J0bF1NtwOYM0qek5hc+9iJSfHR0RsIh5hNgelF/8SfCEGjmhf+9dW1orf0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795026163; h=DMARC-Filter:Received:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:X-Relaying-Domain: X-CFilter-Loop:Received:DKIM-Signature:X-Forwarded-Encrypted: X-Received:X-Received:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:Autocrypt: In-Reply-To:Content-Type:Content-Transfer-Encoding: X-DetectorID-Processed; bh=bnUtfuLqcXc6hvJeKnEgqslam6AebsSq4f86rbz9d/c=; b=B6q9IzdYOkrPZxCdIWWPFxYPw+ORMVMSOCy+zClNA/r4tOOyW15rbGfcY7LfnUhBpwwq WClY56k7osMtAINF6C3Vmd96eqOGrRRzKsWw67u6OjiY9bgt9nfKyvSGZDtUmhnAOVSi6 vtwlJXS4dhzreNInM55WHWwMgI6/N6gh5ZseAUZSYMZ2IkStvVggTMFIgxucspX/0eB++ WreqVFNGWakEzZ31VTqPOaAwUXlvaDVrhQrjecN43l2zxw7uUwoZewVE5NX881NXkObjT p/vrwJTAOu3lib6oNTvf/kogRgo9vv0ZdaVbMqw8VidQeSi+JXAsghLnjYh0hjayVgw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=FyCt61lc; arc=none smtp.remote-ip=209.85.215.226 Received: from mail-pg1-f226.google.com (mail-pg1-f226.google.com [209.85.215.226]) (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 506B5606A33B for ; Wed, 18 Nov 2026 18:22:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 506B5606A33B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=FyCt61lc Received: by mail-pg1-f226.google.com with SMTP id 41be03b00d2f7-cdac6d19ddaso699894a12.2 for ; Wed, 18 Nov 2026 10:22:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795026162; x=1795630962; h=content-transfer-encoding:content-type:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=bnUtfuLqcXc6hvJeKnEgqslam6AebsSq4f86rbz9d/c=; b=gGfiYaNVPTdSKD2mKy9BNQQz71mHHpMANrK7OolUHUUfxxyassxJ5I0/8QInxRsEY1 ZffBKPXWZ4ZnnVe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aavj+rOm9/JuaP3Yoqjg4uvCjCgIidnWVQ0cPg5qHCt5yREKQH+FYvYhfRaTT+dgrEjep/ +WNdYvJATr9FRJVZCep81xFjeOaQ4oe7Bl1L30/zEJ X-Received: by 2002:a17:90b:52:b0:3ac:7556:8eed with SMTP id 98e67ed59e1d1-3b3d07d4542mr3215677a91.44.1795026162417; Wed, 18 Nov 2026 10:22:42 -0800 (PST) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-26.dlp.protect.broadcom.com. [144.49.247.26]) by smtp-relay.gmail.com with ESMTPS id 98e67ed59e1d1-3b3f6bb5f6fsm169063a91.5.2026.11.18.10.22.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2026 10:22:42 -0800 (PST) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-8aa185840bdso1105237b3a.3 for ; Wed, 18 Nov 2026 10:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1795026161; x=1795630961; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=bnUtfuLqcXc6hvJeKnEgqslam6AebsSq4f86rbz9d/c=; b=FyCt61lc2AoKF1u64xV290xH2mDnINZUn4WkLv1rS2gs7O/ZYcSnl1nmlAEh4a7759 I02YuCRU3qN86DZ72JzF3dLXyBfAh+UHkH5Gf0gs4xC8U2m6g955gIIuJv4H65xSvuDd vdRr/mWAqaonFBNhzxZqRb8g2t33SCh9wx4dU= X-Forwarded-Encrypted: i=1; AL+hErHGbzGgRa6j8+8aU4P5olcyxp3pFOBKl9i6AXz/k8EpPadJ4ZKthfLaT3gTdGFKvBd4RZO1QR1pyqT94W4=@vger.kernel.org X-Received: by 2002:aa7:888a:0:b0:89f:600b:610d with SMTP id d2e1a72fcca58-8c5d49d36b4mr2982276b3a.31.1795026160549; Wed, 18 Nov 2026 10:22:40 -0800 (PST) X-Received: by 2002:aa7:888a:0:b0:89f:600b:610d with SMTP id d2e1a72fcca58-8c5d49d36b4mr2982253b3a.31.1795026160014; Wed, 18 Nov 2026 10:22:40 -0800 (PST) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c5c7e9e93fsm1703971b3a.2.2026.11.18.10.22.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Nov 2026 10:22:39 -0800 (PST) Message-ID: Date: Wed, 18 Nov 2026 10:22:35 -0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next 8/9] net: add KUnit coverage for FA and flowtable path validation To: netdev-bot+sashiko@kernel.org Cc: netdev@vger.kernel.org, rafal@milecki.pl, bcm-kernel-feedback-list@broadcom.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, horms@kernel.org, corbet@lwn.net, jonas.gorski@gmail.com, olteanv@gmail.com, pablo@netfilter.org, fw@strlen.de, phil@nwl.cc, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org References: <20261116222519.1416501-9-florian.fainelli@broadcom.com> <179495816919.3136.9689954625386670626@kernel.org> Content-Language: en-US, fr-FR From: Florian Fainelli Autocrypt: addr=florian.fainelli@broadcom.com; keydata= xsBNBFPAG8ABCAC3EO02urEwipgbUNJ1r6oI2Vr/+uE389lSEShN2PmL3MVnzhViSAtrYxeT M0Txqn1tOWoIc4QUl6Ggqf5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= In-Reply-To: <179495816919.3136.9689954625386670626@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e On 11/17/26 15:29, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 5 potential > issue(s) to consider. > > Critical: 0 · High: 0 · Medium: 2 · Low: 3 > > 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] Three bcm-ns-fa KUnit cases use plain slab memory as if it > were an MMIO register window: fa_test_tcp_control_readiness,… > - [Medium] nf_flow_test_gc_routes() sets NF_FLOW_HW and NF_FLOW_HW_DYING > on every flow, under the comment "Avoid queuing real DELETE/STATS work… > - [Low] In fa_test_rx_learning() (drivers/net/ethernet/broadcom/bcm-ns- > fa-test.c), the TCP sub-case sets `ip->protocol = IPPROTO_TCP;` (line… > - [Low] fa_test_nat_actions() has three negative assertions that do not > test what their comments say. > - [Low] fa_test_upper_device_rcu() registers two real Ethernet devices in > init_net with alloc_etherdev() and register_netdev(). > > -- > > net: add KUnit coverage for FA and flowtable path validation > > This commit adds KUnit suites for the Northstar flow accelerator, the B53 > FA exception guards and the Broadcom FA tagger. It also adds flowtable > tests for cached-route owner validation, plus a GC test that covers seven > route and xmit scenarios. The tests are compiled into their parent > translation units, and a combined .kunitconfig sits beside the FA backend. > >> diff --git a/drivers/net/ethernet/broadcom/bcm-ns-fa-test.c b/drivers/net/ethernet/broadcom/bcm-ns-fa-test.c >> new file mode 100644 >> index 0000000000000..59406f84809e7 >> --- /dev/null >> +++ b/drivers/net/ethernet/broadcom/bcm-ns-fa-test.c >> @@ -0,0 +1,661 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* Included in bcm-ns-fa.c to exercise private table formats and validation. */ >> +#include >> +#include >> +#include >> +#include >> + >> +static const struct net_device_ops fa_test_netdev_ops; > > [ ... ] > >> + lower->netdev_ops = &fa_test_netdev_ops; >> + upper->netdev_ops = &fa_test_netdev_ops; >> + eth_hw_addr_random(lower); >> + eth_hw_addr_random(upper); >> + KUNIT_ASSERT_EQ(test, register_netdev(lower), 0); >> + KUNIT_ASSERT_EQ(test, register_netdev(upper), 0); > > [Severity: Low] > This isn't a bug, but could these test devices get a minimal > ndo_start_xmit that just drops the skb? > > fa_test_netdev_ops is an empty static struct, so its ndo_start_xmit is > NULL. In fa_test_upper_device_rcu(), both devices are registered in > init_net and show up as eth%d with carrier on while the test runs. > > If something outside the test brings one of them up and transmits on it, > dev_hard_start_xmit() would call the NULL ndo_start_xmit. That could be a > network manager reacting to RTM_NEWLINK, or an AF_PACKET sender. > > The window is short, and re-running the suite after boot needs root > through the KUnit debugfs run file. net/core/dev_addr_lists_test.c > already uses the same pattern, so this is only a hardening suggestion. > > [ ... ] > >> +static void fa_test_nat_actions(struct kunit *test) >> +{ >> + struct fa_rule rule = { .direction = FA_DIR_UNSET, .l4proto = IPPROTO_UDP }; > > [ ... ] > >> + KUNIT_ASSERT_EQ(test, fa_mangle(&rule, &act), 0); >> + KUNIT_EXPECT_EQ(test, rule.remap_port, (u16)0xabcd); >> + KUNIT_EXPECT_EQ(test, rule.action, (u8)3); >> + /* Opposite-side rewrites cannot share a hardware entry. */ >> + act.mangle.mask = (__force u32)cpu_to_be32(0xffff0000); >> + KUNIT_EXPECT_EQ(test, fa_mangle(&rule, &act), -EOPNOTSUPP); >> + /* Partial IPv4 masks and arbitrary offsets must not be accepted. */ >> + act.mangle.htype = FLOW_ACT_MANGLE_HDR_TYPE_IP4; >> + act.mangle.offset = offsetof(struct iphdr, daddr); >> + act.mangle.mask = 1; >> + KUNIT_EXPECT_EQ(test, fa_mangle(&rule, &act), -EOPNOTSUPP); >> + act.mangle.mask = 0; >> + act.mangle.offset = offsetof(struct iphdr, ttl); >> + KUNIT_EXPECT_EQ(test, fa_mangle(&rule, &act), -EOPNOTSUPP); >> +} > > [Severity: Low] > Do these three negative checks test what their comments describe? > > By this point rule.action already has FA_ACT_REMAP_IP | FA_ACT_REMAP_PORT > set and the direction is SNAT. fa_mangle() rejects with: > > if (fa_direction(rule, dir) || (rule->action & FA_ACT_REMAP_IP)) > return -EOPNOTSUPP; > ... > if (fa_direction(rule, dir) || (rule->action & FA_ACT_REMAP_PORT)) > return -EOPNOTSUPP; > > The REMAP_PORT bit alone rejects the opposite-side UDP rewrite, so the > fa_direction() conflict check is never exercised. If the mask and offset > checks were removed from fa_mangle(), the REMAP_IP bit would still reject > both the partial-mask daddr case and the ttl offset case, and this test > would still pass. > > Would running each negative case against a fresh rule exercise each of > those checks in fa_mangle() on its own? > > [ ... ] > >> + tag[2] = 1; >> + bcm_ns_fa_rx(fa, skb); >> + KUNIT_EXPECT_EQ(test, fa->learn_next, 1U); >> + tag[2] = 0; >> + ip->protocol = IPPROTO_TCP; >> + bcm_ns_fa_rx(fa, skb); >> + KUNIT_EXPECT_EQ(test, fa->learn_next, 1U); > > [Severity: Low] > Should ip->check be recomputed here? > > The other sub-cases in fa_test_rx_learning() refresh the checksum with > ip_fast_csum() after editing the header. The IPv4 header checksum covers > the protocol byte, so bcm_ns_fa_rx() drops this frame on the checksum > before it reaches the TCP branch: > > total < ihl || total > skb->len - offset || skb_headlen(skb) < offset + ihl || > ip_compute_csum(ip, ihl)) > return; > if (ip->protocol == IPPROTO_TCP && > fa_receive_tcp_control(fa, ip, total, skb_headlen(skb) - offset, tag[3] & 0x1f)) > > The learn_next == 1 expectation therefore passes because of the checksum > guard. fa_receive_tcp_control() and the TCP learning path never run in > this sub-case. > > [ ... ] > >> +static void fa_test_tcp_control_readiness(struct kunit *test) >> +{ >> + struct bcm_ns_fa *fa = kunit_kzalloc(test, sizeof(*fa), GFP_KERNEL); >> + >> + KUNIT_ASSERT_NOT_NULL(test, fa); >> + fa->regs = (void __iomem *)kunit_kzalloc(test, 0xc0, GFP_KERNEL); > > [Severity: Medium] > Can these fake register windows work on the default KUnit architecture? > > fa_test_tcp_control_readiness(), fa_test_lookup_gate_preserves_tags() and > fa_test_invalidation() all point fa->regs at kunit_kzalloc() memory. They > then call writel()/readl() on it, either directly or through > fa_lookup_update(): > > writel(enabled ? ETH_P_IP | ETH_P_IPV6 << 16 : 0, fa->regs + FA_L2_ETHERTYPE); > readl(fa->regs + FA_L2_ETHERTYPE); > > kunit.py defaults to ARCH=um and merges arch_uml.config, which sets > CONFIG_KUNIT_UML_PCI=y. That selects UML_PCI, then UML_IOMEM_EMULATION, > then INDIRECT_IOMEM, and INDIRECT_IOMEM_FALLBACK stays off. The raw > accessors then go through lib/logic_iomem.c, where get_area() does: > > if (WARN_ON((a & IOREMAP_MASK) != IOREMAP_BIAS)) > return NULL; > > The fallback read then WARNs again and returns ~0. Writes WARN and are > dropped. > > On UML, this would have these effects: > > - fa_test_lookup_gate_preserves_tags() reads 0xffffffff for > FA_L2_ETHERTYPE, FA_CTL and FA_BRCM_HDR, so its expectations fail. > - In fa_test_invalidation(), lookup_stopped = !readl(...) evaluates to > false, so that check fails. > - fa_test_tcp_control_readiness() emits WARN splats that taint the > kernel. > > The new drivers/net/ethernet/broadcom/.kunitconfig enables COMPILE_TEST > and does not restrict the architecture. So running kunit.py with > --kunitconfig drivers/net/ethernet/broadcom seems to build exactly this > configuration. > > Should the MMIO-dependent cases be limited to architectures with direct > MMIO, or should the lookup gate be observed some other way? Also, the > BCM_NS_FA_KUNIT_TEST help text says the tests "do not simulate table > I/O", which doesn't quite match these cases. > > [ ... ] > >> diff --git a/net/netfilter/nf_flow_table_core_test.c b/net/netfilter/nf_flow_table_core_test.c >> index 378a1c60b50b9..5c7645239d2e4 100644 >> --- a/net/netfilter/nf_flow_table_core_test.c >> +++ b/net/netfilter/nf_flow_table_core_test.c >> @@ -72,9 +72,94 @@ static void nf_flow_test_hardware_retirement(struct kunit *test) > > [ ... ] > >> + for (i = 0; i < ARRAY_SIZE(cases); i++) { >> + struct nf_flowtable table = { .type = &type }; > > [ ... ] > >> + flow->ct = ct; >> + flow->timeout = nf_flowtable_time_stamp + NF_FLOW_TIMEOUT; >> + /* Avoid queuing real DELETE/STATS work from this private GC test. */ >> + set_bit(NF_FLOW_HW, &flow->flags); >> + set_bit(NF_FLOW_HW_DYING, &flow->flags); >> + set_bit(IPS_OFFLOAD_BIT, &ct->status); > > [ ... ] > >> + nf_flow_offload_gc_step(&table, flow, NULL); >> + KUNIT_EXPECT_EQ_MSG(test, test_bit(NF_FLOW_TEARDOWN, &flow->flags), >> + cases[i].check, "GC path: %s", cases[i].name); >> + flow_offload_route_release(flow); > > [Severity: Medium] > Do these flags actually prevent STATS work from being queued? > > In the "software direct" and "validation only" cases (check == false), > nf_flow_offload_gc_step() skips the teardown block and reaches: > > } else if (test_bit(NF_FLOW_HW, &flow->flags)) { > nf_flow_offload_stats(flow_table, flow); > } > > That branch does not look at NF_FLOW_HW_DYING. Inside > nf_flow_offload_stats(), only this timing check stops a work item from > being queued: > > delta = nf_flow_timeout_delta(flow->timeout); > if ((delta >= (9 * flow_offload_get_timeout(flow)) / 10)) > return; > > For this ICMP ct the timeout is NF_FLOW_TIMEOUT (30 * HZ). If the test > thread stalls for more than about 3 seconds between setting flow->timeout > and the GC call, nf_flow_offload_work_alloc() will record: > > - offload->flowtable = &table, which is the stack variable above > - offload->flow = flow, which is kunit-managed memory > > This could happen on a loaded QEMU or UML host, or with KASAN enabled. > flow_offload_queue_work() then reads table.net, which is NULL here, and > queues the work on nf_flow_offload_stats_wq. > > Nothing flushes or cancels that work. Could flow_offload_work_handler() > later run against a dead stack frame and freed kunit memory? > > Any of these would avoid it: > > - pre-set NF_FLOW_PENDING so nf_flow_offload_work_alloc() bails out > - leave NF_FLOW_HW clear for the non-hardware cases > - flush nf_flow_offload_stats_wq before the objects go out of scope > > Separately, NF_FLOW_HW is set for every scenario, so the GC step handles > the "software direct" case as a hardware flow. Does this still cover the > "ordinary direct software forwarding" scenario that the commit message > describes? > [Medium] fake register windows Agreed: UML rejects plain memory for readl()/writel(). v2 skips those three cases where MMIO is emulated (CONFIG_INDIRECT_IOMEM); they still run elsewhere, and the Kconfig help is corrected. [Medium] GC test queueing STATS work Agreed. v2 only marks the flows that GC tears down as hardware flows with their DESTROY queued, and leaves the others as software flows, for which GC does nothing. [Low] NAT negatives, TCP learning sub-case, test netdevs Fixed in v2: negative cases use fresh rules, the checksum is recomputed for the TCP case, and the test netdevs have an ndo_start_xmit. pw-bot: cr -- Florian