netfilter: flowtable: detach layer 2 encapsulation parser from lookup

Move the layer 2 encapsulation header parser out of the lookup function
to prepare for IPv4 over IPv6 and SIT.

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
Pablo Neira Ayuso
2026-08-06 23:54:06 +02:00
parent 609268d93d
commit 0e42d4039c

View File

@@ -459,12 +459,6 @@ nf_flow_offload_lookup(struct nf_flowtable_ctx *ctx,
{
struct flow_offload_tuple tuple = {};
if (!nf_flow_skb_encap_protocol(ctx, skb))
return NULL;
if (unlikely(ctx->ether_type != htons(ETH_P_IP)))
return NULL;
if (nf_flow_tuple_ip(ctx, skb, &tuple) < 0)
return NULL;
@@ -877,6 +871,12 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
};
int ret;
if (!nf_flow_skb_encap_protocol(&ctx, skb))
return NF_ACCEPT;
if (unlikely(ctx.ether_type != htons(ETH_P_IP)))
return NF_ACCEPT;
tuplehash = nf_flow_offload_lookup(&ctx, flow_table, skb);
if (!tuplehash)
return NF_ACCEPT;
@@ -1117,12 +1117,6 @@ nf_flow_offload_ipv6_lookup(struct nf_flowtable_ctx *ctx,
{
struct flow_offload_tuple tuple = {};
if (!nf_flow_skb_encap_protocol(ctx, skb))
return NULL;
if (unlikely(ctx->ether_type != htons(ETH_P_IPV6)))
return NULL;
if (nf_flow_tuple_ipv6(ctx, skb, &tuple) < 0)
return NULL;
@@ -1206,6 +1200,12 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,
};
int ret;
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);
if (!tuplehash)
return NF_ACCEPT;