Re: [PATCH net-next 6/9] net: flow_offload: allow drivers to validate and invalidate cached paths
From: Pablo Neira Ayuso
Date: Sat Nov 21 2026 - 20:00:22 EST
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.