Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Pablo Neira Ayuso
Sun, 22 Nov 2026 01:00
Re: [PATCH net-next 6/9] net: flow_offload: allow drivers to validate and invalidate cached paths
Author: Pablo Neira Ayuso
Date: Sun, 22 Nov 2026 01:00
Date: Sun, 22 Nov 2026 01:00
45 lines
10654 bytes
10654 bytes
On Mon, Nov 16, 2026 at 02:25:16PM -0800, Florian Fainelli wrote:
[...]
> +static int nf_flow_offload_validate(unsigned long cookie)
> +{
> + struct flow_offload *flow = nf_flow_offload_cookie_flow(cookie);
> + unsigned int dir;
> +
> + for (dir = 0; dir < FLOW_OFFLOAD_DIR_MAX; dir++) {
> + struct flow_offload_tuple *tuple = &flow->tuplehash[dir].tuple;
> + struct flow_offload_tuple *other = &flow->tuplehash[!dir].tuple;
> + struct dst_entry *dst = tuple->dst_cache;
> + struct neighbour *neigh;
> + u8 mac[ETH_ALEN];
> + bool valid;
> +
> + if (!dst)
> + return -EOPNOTSUPP;
> + /* This is the actual route selected with the packet's policy
> + * context, including mark, DSCP and the reverse lookup's oif.
> + */
> + if (!dst_check(dst, tuple->dst_cookie))
> + return -ESTALE;
> + if (tuple->xmit_type != FLOW_OFFLOAD_XMIT_DIRECT)
> + continue;
> + /* A stacked path may have a different final Ethernet neighbour.
> + * Do not mistake that unsupported context for a stale owner.
> + */
> + if (dst->dev->ifindex != tuple->out.ifidx)
> + return -EOPNOTSUPP;
> + neigh = dst_neigh_lookup(dst, &other->src_v4);
> + if (!neigh)
> + return -ESTALE;
> + neigh_ha_snapshot(mac, neigh, dst->dev);
> + valid = (READ_ONCE(neigh->nud_state) & NUD_VALID) &&
> + ether_addr_equal(mac, tuple->out.h_dest);
> + neigh_release(neigh);
> + if (!valid)
> + return -ESTALE;
> + }
> + return 0;
This validation to catch for stale entries looks very similar to what
I'm working on. I guess there is a chance to consolidate all this in
common infrastructure for both software and hardware modes.
Re: [PATCH net-next 6/9] net: flow_offload: allow drivers to validate and invalidate cached paths
Author: Pablo Neira Ayuso
Date: Wed, 25 Nov 2026 00:30
Date: Wed, 25 Nov 2026 00:30
111 lines
15350 bytes
15350 bytes
Hi Florian,
On Mon, Nov 23, 2026 at 08:10:16AM -0800, Florian Fainelli wrote:
>
>
> On 11/21/2026 5:00 PM, Pablo Neira Ayuso wrote:
> > On Mon, Nov 16, 2026 at 02:25:16PM -0800, Florian Fainelli wrote:
> > [...]
> > > +static int nf_flow_offload_validate(unsigned long cookie)
> > > +{
> > > + struct flow_offload *flow = nf_flow_offload_cookie_flow(cookie);
> > > + unsigned int dir;
> > > +
> > > + for (dir = 0; dir < FLOW_OFFLOAD_DIR_MAX; dir++) {
> > > + struct flow_offload_tuple *tuple = &flow->tuplehash[dir].tuple;
> > > + struct flow_offload_tuple *other = &flow->tuplehash[!dir].tuple;
> > > + struct dst_entry *dst = tuple->dst_cache;
> > > + struct neighbour *neigh;
> > > + u8 mac[ETH_ALEN];
> > > + bool valid;
> > > +
> > > + if (!dst)
> > > + return -EOPNOTSUPP;
> > > + /* This is the actual route selected with the packet's policy
> > > + * context, including mark, DSCP and the reverse lookup's oif.
> > > + */
> > > + if (!dst_check(dst, tuple->dst_cookie))
> > > + return -ESTALE;
> > > + if (tuple->xmit_type != FLOW_OFFLOAD_XMIT_DIRECT)
> > > + continue;
> > > + /* A stacked path may have a different final Ethernet neighbour.
> > > + * Do not mistake that unsupported context for a stale owner.
> > > + */
> > > + if (dst->dev->ifindex != tuple->out.ifidx)
> > > + return -EOPNOTSUPP;
> > > + neigh = dst_neigh_lookup(dst, &other->src_v4);
> > > + if (!neigh)
> > > + return -ESTALE;
> > > + neigh_ha_snapshot(mac, neigh, dst->dev);
> > > + valid = (READ_ONCE(neigh->nud_state) & NUD_VALID) &&
> > > + ether_addr_equal(mac, tuple->out.h_dest);
> > > + neigh_release(neigh);
> > > + if (!valid)
> > > + return -ESTALE;
> > > + }
> > > + return 0;
> >
> > This validation to catch for stale entries looks very similar to what
> > I'm working on. I guess there is a chance to consolidate all this in
> > common infrastructure for both software and hardware modes.
>
> Excellent, happy to point you to an off the shelf device where you could be
> testing this on, if you would like to?
I have a setup with Banana pi r64 and openwrt, I have this large
series of backports to synchronize with with current upstream trees:
patches/generic-backport/951-netfilter-flowtable-inline-vlan-encapsulation-in-xmi.patch
patches/generic-backport/952-netfilter-flowtable-inline-pppoe-encapsulation-in-xm.patch
patches/generic-backport/953-netfilter-flowtable-remove-hw_ifidx.patch
patches/generic-backport/953-netfilter-flowtable-use-tuple-address-to-calculate-n.patch
patches/generic-backport/954-netfilter-flowtable-Add-IPIP-rx-sw-acceleration.patch
patches/generic-backport/955-netfilter-flowtable-Add-IPIP-tx-sw-acceleration.patch
patches/generic-backport/956-netfilter-always-set-route-tuple-out-ifindex.patch
patches/generic-backport/957-netfilter-Add-ctx-pointer-in-nf_flow_skb_encap_proto.patch
patches/generic-backport/958-netfilter-Introduce-tunnel-metadata-info-in-nf_flowt.patch
patches/generic-backport/959-netfilter-flowtable-Add-IP6IP6-rx-sw-acceleration.patch
patches/generic-backport/960-netfilter-flowtable-Add-IP6IP6-tx-sw-acceleration.patch
patches/generic-backport/961-netfilter-flowtable-dedicated-slab-for-flow-entry.patch
patches/generic-backport/962-netfilter-nf_flow_table_ip-reset-mac-header-before-v.patch
patches/generic-backport/963-netfilter-replace-skb_try_make_writable-by-skb_ensur.patch
patches/generic-backport/964-netfilter-flowtable-fix-inline-vlan-encapsulation-in.patch
patches/generic-backport/965-netfilter-fix-inline-pppoe-encapsulation-i.patch
patches/generic-backport/966-flowtable-use-skb_pull_rcsum-to-pop-vlan-p.patch
patches/generic-backport/967-netfilter-flowtable-avoid-num_encaps-underflow-on-br.patch
patches/generic-backport/967-netfilter-flowtable-bail-out-if-forward-path-cannot-.patch
patches/generic-backport/968-netfilter-flowtable-fix-and-simplify-IP6IP6-tunnel-h.patch
patches/generic-backport/969-netfilter-flowtable-use-dst-in-this-direction-when-p.patch
patches/generic-backport/970-netfilter-flowtable-Validate-iph-ihl-in-nf_flow_ip4_.patch
patches/generic-backport/971-netfilter-flowtable-IPIP-tunnel-hardware-offload-is-.patch
patches/generic-backport/972-netfilter-flowtable-support-IPIP-tunnel-with-direct-.patch
patches/generic-backport/973-netfilter-flowtable-use-correct-direction-to-set-up-.patch
patches/generic-backport/974-netfilter-flowtable-tear-down-flow-entries-with-stal.patch
patches/generic-backport/975-netfilter-flowtable-consolidate-net_device-field-in-.patch
patches/generic-backport/976-netfilter-flowtable-consolidate-flowtable-device-che.patch
patches/generic-backport/977-net-dsa-stop-at-the-user-device-in-.fill_forward_pat.patch
patches/generic-backport/978-net-do-not-advance-stack-index-from-dev_fwd_path.patch
patches/generic-backport/979-net-pass-dst-via-net_device_path-in-dev_fill_forward.patch
patches/generic-backport/980-netfilter-flowtable-release-tunnel-route-on-error-wh.patch
patches/generic-backport/981-net-pass-net_device_path_ctx-to-dev_fill_forward_pat.patch
patches/generic-backport/982-net-remove-WARN_ON_ONCE-from-the-dev_fill_forward_pa.patch
patches/generic-backport/982-0001-netfilter-flowtable-generalize-pending-status-bit.patch
patches/generic-backport/983-netfilter-nft_meta-add-double-tagged-vlan-and-pppoe-.patch
patches/generic-backport/984-net-netfilter-add-ether_type-to-net_device_path_ctx-.patch
patches/generic-backport/985-netfilter-flowtable-rename-tun.l3_proto-to-tun.inner.patch
patches/generic-backport/986-netfilter-flowtable-rename-ctx.tun.proto-to-ctx.tun..patch
patches/generic-backport/987--netfilter-flowtable-store-ethertype-in-flowtable-con.patch
patches/generic-backport/987-netfilter-flowtable-move-ipv4-and-ipv6-xmit-path-to-.patch
patches/generic-backport/988-netfilter-flowtable-detach-layer-2-encapsulation-par.patch
I guess this should be fine for testing this patch, maybe there is a
better way.
I still have to automate testing more classic scenarios in the real
hardware, such as PPPoE (I have configuration to make this local),
vlan, ipip tunnels, wireguard, etc.
If there's anything else I'm missing, please, let me know.
Thanks.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads