The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: Jack Ma <jack4it@gmail.com>
Cc: David Ahern <dsahern@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/3] net: nexthop: add NHA_FDB_PORT for fdb nexthops
Date: Tue, 21 Jul 2026 18:17:41 +0300	[thread overview]
Message-ID: <20260721151741.GA2667735@shredder> (raw)
In-Reply-To: <20260717-b4-vxlan-fdb-port-v2-1-f4862e8fe867@gmail.com>

On Fri, Jul 17, 2026 at 06:45:16AM +0000, Jack Ma wrote:
> Commit 1274e1cc4226 ("vxlan: ecmp support for mac fdb entries") lets a
> single inner MAC be reached through a group of remote VTEPs, with the
> kernel flow-hashing across the group members.  Each member carries its
> own remote IP, but the UDP destination port is always taken from the
> VXLAN device (vxlan->cfg.dst_port) and cannot be set per member.
> 
> Some deployments pack several receivers behind one underlay IP and tell
> them apart by UDP port, so they need a per-nexthop destination port to
> spread flows across (IP, port) tuples rather than IP alone.
> 
> Add a netlink attribute NHA_FDB_PORT (__be16, mirroring NDA_PORT) that
> carries an optional UDP destination port on an fdb nexthop.  It is only
> accepted together with NHA_FDB and NHA_GATEWAY; it is stored in struct
> nh_info and echoed back on dump.  This patch is control-plane plumbing
> only; the VXLAN datapath is wired up in a follow-up patch, so behaviour
> is unchanged for now.
> 
> Signed-off-by: Jack Ma <jack4it@gmail.com>
> ---
>  include/net/nexthop.h        |  2 ++
>  include/uapi/linux/nexthop.h |  3 +++
>  net/ipv4/nexthop.c           | 20 +++++++++++++++++++-
>  3 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/nexthop.h b/include/net/nexthop.h
> index 572e69cda..9c8227996 100644
> --- a/include/net/nexthop.h
> +++ b/include/net/nexthop.h
> @@ -28,6 +28,7 @@ struct nh_config {
>  	u8		nh_protocol;
>  	u8		nh_blackhole;
>  	u8		nh_fdb;
> +	__be16		nh_fdb_port;
>  	u32		nh_flags;
>  
>  	int		nh_ifindex;
> @@ -63,6 +64,7 @@ struct nh_info {
>  	u8			family;
>  	bool			reject_nh;
>  	bool			fdb_nh;
> +	__be16			fdb_port;
>  
>  	union {
>  		struct fib_nh_common	fib_nhc;
> diff --git a/include/uapi/linux/nexthop.h b/include/uapi/linux/nexthop.h
> index bc49baf4a..e587bbf3b 100644
> --- a/include/uapi/linux/nexthop.h
> +++ b/include/uapi/linux/nexthop.h
> @@ -83,6 +83,9 @@ enum {
>  	/* u32; read-only; whether any driver collects HW stats */
>  	NHA_HW_STATS_USED,
>  
> +	/* be16; UDP destination port for an fdb nexthop (e.g. VXLAN) */
> +	NHA_FDB_PORT,
> +
>  	__NHA_MAX,
>  };
>  
> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> index 6205bd57a..5b27cc9a9 100644
> --- a/net/ipv4/nexthop.c
> +++ b/net/ipv4/nexthop.c
> @@ -39,6 +39,7 @@ static const struct nla_policy rtm_nh_policy_new[] = {
>  	[NHA_ENCAP_TYPE]	= { .type = NLA_U16 },
>  	[NHA_ENCAP]		= { .type = NLA_NESTED },
>  	[NHA_FDB]		= { .type = NLA_FLAG },
> +	[NHA_FDB_PORT]		= { .type = NLA_U16 },

Maybe NLA_POLICY_MIN(NLA_BE16, 1) given that it's BE16 and that we don't
dump / use a destination port of 0?

>  	[NHA_RES_GROUP]		= { .type = NLA_NESTED },
>  	[NHA_HW_STATS_ENABLE]	= NLA_POLICY_MAX(NLA_U32, true),
>  };
> @@ -956,6 +957,9 @@ static int nh_fill_node(struct sk_buff *skb, struct nexthop *nh,
>  	} else if (nhi->fdb_nh) {
>  		if (nla_put_flag(skb, NHA_FDB))
>  			goto nla_put_failure;
> +		if (nhi->fdb_port &&
> +		    nla_put_be16(skb, NHA_FDB_PORT, nhi->fdb_port))
> +			goto nla_put_failure;
>  	} else {
>  		const struct net_device *dev;
>  
> @@ -1055,6 +1059,9 @@ static size_t nh_nlmsg_size_single(struct nexthop *nh)
>  		break;
>  	}
>  
> +	if (nhi->fdb_nh)

Why not nhi->fdb_port ?

> +		sz += nla_total_size(2);	/* NHA_FDB_PORT */
> +
>  	if (nhi->fib_nhc.nhc_lwtstate) {
>  		sz += lwtunnel_get_encap_size(nhi->fib_nhc.nhc_lwtstate);
>  		sz += nla_total_size(2);  /* NHA_ENCAP_TYPE */
> @@ -2956,8 +2963,10 @@ static struct nexthop *nexthop_create(struct net *net, struct nh_config *cfg,
>  	nhi->family = cfg->nh_family;
>  	nhi->fib_nhc.nhc_scope = RT_SCOPE_LINK;
>  
> -	if (cfg->nh_fdb)
> +	if (cfg->nh_fdb) {
>  		nhi->fdb_nh = 1;
> +		nhi->fdb_port = cfg->nh_fdb_port;
> +	}
>  
>  	if (cfg->nh_blackhole) {
>  		nhi->reject_nh = 1;
> @@ -3147,6 +3156,15 @@ static int rtm_to_nh_config(struct net *net, struct sk_buff *skb,
>  		cfg->nh_fdb = nla_get_flag(tb[NHA_FDB]);
>  	}
>  
> +	if (tb[NHA_FDB_PORT]) {
> +		if (!tb[NHA_FDB] || !tb[NHA_GATEWAY]) {
> +			NL_SET_ERR_MSG(extack,
> +				       "FDB port can only be set on fdb nexthops that have a gateway");
> +			goto out;
> +		}
> +		cfg->nh_fdb_port = nla_get_be16(tb[NHA_FDB_PORT]);
> +	}
> +
>  	if (tb[NHA_GROUP]) {
>  		if (nhm->nh_family != AF_UNSPEC) {
>  			NL_SET_ERR_MSG(extack, "Invalid family for group");
> 
> -- 
> 2.43.0
> 

  reply	other threads:[~2026-07-21 15:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  6:45 [PATCH net-next v2 0/3] net: nexthop: per-nexthop UDP dst port for fdb (VXLAN) nexthops Jack Ma
2026-07-17  6:45 ` [PATCH net-next v2 1/3] net: nexthop: add NHA_FDB_PORT for fdb nexthops Jack Ma
2026-07-21 15:17   ` Ido Schimmel [this message]
2026-07-21 22:19     ` Jack Ma
2026-07-17  6:45 ` [PATCH net-next v2 2/3] vxlan: honor per-nexthop fdb destination port Jack Ma
2026-07-21 15:18   ` Ido Schimmel
2026-07-21 22:19     ` Jack Ma
2026-07-17  6:45 ` [PATCH net-next v2 3/3] selftests: net: add coverage for fdb nexthop dst port Jack Ma
2026-07-21 15:20   ` Ido Schimmel
2026-07-21 22:19     ` Jack Ma

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=20260721151741.GA2667735@shredder \
    --to=idosch@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jack4it@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@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