From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, lorenzo.bianconi@oss.qualcomm.com
Subject: Re: [PATCH nf-next 2/7] net: netfilter: add ether_type to net_device_path_ctx and use it
Date: Fri, 7 Aug 2026 11:00:27 +0200 [thread overview]
Message-ID: <anWeq32DcHjUwMfV@lore-desk> (raw)
In-Reply-To: <20260806223535.523098-3-pablo@netfilter.org>
[-- Attachment #1: Type: text/plain, Size: 3210 bytes --]
> Add an ether_type field to struct net_device_path_ctx to reject IPv4
> over IPv6 and vice-versa, this is currently not support. Otherwise,
> incorrect dst_entry family can be reached from datapath.
>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> include/linux/netdevice.h | 1 +
> net/ipv4/ipip.c | 3 +++
> net/ipv6/ip6_tunnel.c | 3 +++
> net/netfilter/nf_flow_table_path.c | 6 ++++--
> 4 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 4319b949f405..d9962c50bd60 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -939,6 +939,7 @@ struct net_device_path_stack {
> struct net_device_path_ctx {
> const struct net_device *dev;
> u8 daddr[ETH_ALEN];
> + __be16 ether_type;
>
> int num_vlans;
> struct {
> diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
> index fb7d96f99b06..62a374079bfc 100644
> --- a/net/ipv4/ipip.c
> +++ b/net/ipv4/ipip.c
> @@ -360,6 +360,9 @@ static int ipip_fill_forward_path(struct net_device_path_ctx *ctx,
> const struct iphdr *tiph = &tunnel->parms.iph;
> struct rtable *rt;
>
> + if (ctx->ether_type != cpu_to_be16(ETH_P_IP))
> + return -EOPNOTSUPP;
> +
> if (tunnel->collect_md)
> return -EOPNOTSUPP;
>
> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index d80020bc2620..3bfaa98e7f33 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -1849,6 +1849,9 @@ static int ip6_tnl_fill_forward_path(struct net_device_path_ctx *ctx,
> struct flowi6 fl6;
> int err;
>
> + if (ctx->ether_type != cpu_to_be16(ETH_P_IPV6))
> + return -EOPNOTSUPP;
> +
> if (t->parms.flags & (IP6_TNL_F_USE_ORIG_TCLASS |
> IP6_TNL_F_USE_ORIG_FLOWLABEL |
> IP6_TNL_F_USE_ORIG_FWMARK))
> diff --git a/net/netfilter/nf_flow_table_path.c b/net/netfilter/nf_flow_table_path.c
> index 0cbde535b8ba..5f166da3b09b 100644
> --- a/net/netfilter/nf_flow_table_path.c
> +++ b/net/netfilter/nf_flow_table_path.c
> @@ -44,13 +44,15 @@ static bool nft_is_valid_ether_device(const struct net_device *dev)
>
> static int nft_dev_fill_forward_path(const struct dst_entry *dst_cache,
> const struct nf_conn *ct,
> - enum ip_conntrack_dir dir, u8 *ha,
> + enum ip_conntrack_dir dir,
> + u8 *ha, __be16 ether_type,
> struct net_device_path_stack *stack)
> {
> const void *daddr = &ct->tuplehash[!dir].tuple.src.u3;
> struct net_device *dev = dst_cache->dev;
> struct net_device_path_ctx ctx = {
> .dev = dev,
> + .ether_type = ether_type,
> };
> struct neighbour *n;
> u8 nud_state;
> @@ -228,7 +230,7 @@ static int nft_dev_forward_path(const struct nft_pktinfo *pkt,
> unsigned char ha[ETH_ALEN];
> int i;
>
> - if (nft_dev_fill_forward_path(dst, ct, dir, ha, &stack) < 0 ||
> + if (nft_dev_fill_forward_path(dst, ct, dir, ha, pkt->ethertype, &stack) < 0 ||
> nft_dev_path_info(&stack, &info, ha, ft) < 0)
> return -ENOENT;
>
> --
> 2.47.3
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-08-07 9:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 22:35 [PATCH nf-next 0/7] flowtable preparation for IPv4 over IPv6 and SIT Pablo Neira Ayuso
2026-08-06 22:35 ` [PATCH nf-next 1/7] net: pass net_device_path_ctx to dev_fill_forward_path() Pablo Neira Ayuso
2026-08-06 22:35 ` [PATCH nf-next 2/7] net: netfilter: add ether_type to net_device_path_ctx and use it Pablo Neira Ayuso
2026-08-07 9:00 ` Lorenzo Bianconi [this message]
2026-08-06 22:35 ` [PATCH nf-next 3/7] netfilter: flowtable: rename tun.l3_proto to tun.inner_proto Pablo Neira Ayuso
2026-08-07 9:01 ` Lorenzo Bianconi
2026-08-06 22:35 ` [PATCH nf-next 4/7] netfilter: flowtable: rename ctx.tun.proto to ctx.tun.inner_proto Pablo Neira Ayuso
2026-08-07 9:02 ` Lorenzo Bianconi
2026-08-06 22:35 ` [PATCH nf-next 5/7] netfilter: flowtable: store ethertype in flowtable context Pablo Neira Ayuso
2026-08-07 9:10 ` Lorenzo Bianconi
2026-08-06 22:35 ` [PATCH nf-next 6/7] netfilter: flowtable: move ipv4 and ipv6 xmit path to function Pablo Neira Ayuso
2026-08-07 9:13 ` Lorenzo Bianconi
2026-08-06 22:35 ` [PATCH nf-next 7/7] netfilter: flowtable: detach layer 2 encapsulation parser from lookup Pablo Neira Ayuso
2026-08-07 9:15 ` Lorenzo Bianconi
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=anWeq32DcHjUwMfV@lore-desk \
--to=lorenzo@kernel.org \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.