Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: florian.fainelli@broadcom.com
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
Subject: Re: [PATCH net-next 2/9] netfilter: flowtable: reject non-host IPv4 packets before lookup
Date: Tue, 17 Nov 2026 23:29:17 +0000	[thread overview]
Message-ID: <179495815781.3136.11457762484354834526@kernel.org> (raw)
In-Reply-To: <20261116222519.1416501-3-florian.fainelli@broadcom.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 0 · 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).

- [High] The new early return in nf_flow_offload_ip_hook()
  (net/netfilter/nf_flow_table_ip.c:915) checks skb->pkt_type at netdev…
- [High] The fix only covers IPv4.
- [Low] The commit trailer reads 'Signed-off-by: FLorian Fainelli
  <florian.fainelli@broadcom.com>', but the author is 'Florian Fainelli'…

--

netfilter: flowtable: reject non-host IPv4 packets before lookup

This commit makes nf_flow_offload_ip_hook() return early when pkt_type is
not PACKET_HOST. Those packets then go to the normal IPv4 stack before the
flowtable lookup. The goal is to apply the same PACKET_HOST check that the
classic IPv4 forwarding path uses.

> Fixes: 97add9f0d66d ("netfilter: flow table support for IPv4")
>
> Signed-off-by: FLorian Fainelli <florian.fainelli@broadcom.com>

[Severity: Low]
This isn't a bug, but the Signed-off-by name has a typo ("FLorian") and
does not match the author name ("Florian Fainelli"). There is also an
extra blank line between the Fixes: tag and the Signed-off-by: tag.

> diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
> index 19cafae748abe..98bade1b82994 100644
> --- a/net/netfilter/nf_flow_table_ip.c
> +++ b/net/netfilter/nf_flow_table_ip.c
> @@ -911,6 +911,10 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
>  	};
>  	int ret;
>  
> +	/* The ingress hook runs before IPv4 rejects non-host Ethernet frames. */
> +	if (unlikely(skb->pkt_type != PACKET_HOST))
> +		return NF_ACCEPT;

[Severity: High]
Could this turn off the software fast path for flows that pass through a
bridge or VLAN upper device?

This hook runs at netdev ingress on the lower device. At that point
pkt_type still holds what eth_type_trans() set by comparing h_dest with
the lower device's own MAC. In __netif_receive_skb_core(), nf_ingress()
runs before both places that reclassify the frame:

__netif_receive_skb_core()
    nf_ingress()          <- nf_flow_offload_ip_hook() runs here
    vlan_do_receive()
    rx_handler()          <- br_handle_frame()

net/8021q/vlan_core.c:vlan_do_receive() {
    ...
	if (unlikely(skb->pkt_type == PACKET_OTHERHOST)) {
		/* ... */
		if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest, vlan_dev->dev_addr))
			skb->pkt_type = PACKET_HOST;
	}
    ...
}

net/bridge/br_input.c:br_handle_frame() {
    ...
	if (ether_addr_equal(p->br->dev->dev_addr, dest))
		skb->pkt_type = PACKET_HOST;
    ...
}

The flowtable supports DEV_PATH_BRIDGE and DEV_PATH_VLAN paths.
nft_dev_path_info() puts the upper device's dev_addr in h_source, but the
ingress ifindex is the lower port. Hosts therefore send routed traffic to
the bridge or VLAN MAC.

Two setups hit this:

  - A bridge port whose MAC differs from the bridge MAC. This is common in
    a multi-port bridge, because the bridge takes one port's MAC.
  - A VLAN device with its own MAC.

In both cases, every packet of an offloaded flow would be PACKET_OTHERHOST
at this hook. It would return NF_ACCEPT before nf_flow_offload_lookup().
The IPv4 stack later sees PACKET_HOST and forwards these packets.

Given that, does the patch keep "the IPv4 input path's forwarding
decision", as the commit message says? Would it work better to compare
h_dest with the address the flow expects (for example after the tuple
lookup) rather than test the lower device's raw pkt_type?

> +
>  	if (!nf_flow_skb_encap_protocol(&ctx, skb))
>  		return NF_ACCEPT;
>  

[Severity: High]
Is the same bypass still open for IPv6? In the same file,
nf_flow_offload_ipv6_hook() has no pkt_type check. It goes straight to the
lookup, forward and nf_flow_queue_xmit6() steps:

net/netfilter/nf_flow_table_ip.c:nf_flow_offload_ipv6_hook() {
    ...
	if (!nf_flow_skb_encap_protocol(&ctx, skb))
		return NF_ACCEPT;

	if (unlikely(ctx.ether_type != htons(ETH_P_IPV6)))
		return NF_ACCEPT;

	tuplehash = nf_flow_offload_ipv6_lookup(&ctx, flow_table, skb);
    ...
}

Classic IPv6 forwarding drops these frames:

net/ipv6/ip6_output.c:ip6_forward() {
    ...
	if (skb->pkt_type != PACKET_HOST)
		goto drop;
    ...
}

nf_flow_offload_inet_hook() sends ETH_P_IPV6 to the unpatched hook. With
this patch, an inet flowtable would reject non-host frames for IPv4. For
IPv6 it would still forward frames sent to an unrelated unicast,
broadcast or multicast MAC, as long as the 5-tuple matches an installed
flow.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116222519.1416501-1-florian.fainelli%40broadcom.com

  reply	other threads:[~2026-11-17 23:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 22:25 [PATCH net-next 0/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload Florian Fainelli
2026-11-16 22:25 ` [PATCH net-next 1/9] net: ethernet: bgmac: validate RX length against the DMA packet capacity Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko
2026-11-17 23:43     ` Florian Fainelli
2026-11-16 22:25 ` [PATCH net-next 2/9] netfilter: flowtable: reject non-host IPv4 packets before lookup Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko [this message]
2026-11-16 22:25 ` [PATCH net-next 3/9] netfilter: flowtable: retain offload ownership until deletion completes Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 4/9] dt-bindings: net: describe the Northstar flow accelerator Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 5/9] net: dsa: add Broadcom FA metadata and IPv4 exception paths Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 6/9] net: flow_offload: allow drivers to validate and invalidate cached paths Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 7/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 8/9] net: add KUnit coverage for FA and flowtable path validation Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko
2026-11-16 22:25 ` [PATCH net-next 9/9] docs: net: document Northstar FA setup and NAT qualification Florian Fainelli
2026-11-17 23:29   ` netdev-bot+sashiko
2026-11-16 22:38 ` [PATCH net-next 0/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload netdev-bot+sinfo
2026-11-16 22:45   ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179495815781.3136.11457762484354834526@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=jonas.gorski@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=rafal@milecki.pl \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox