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 v3 3/3] selftests: net: add coverage for fdb nexthop dst port
Date: Wed, 22 Jul 2026 15:58:39 +0300	[thread overview]
Message-ID: <20260722125839.GB2928696@shredder> (raw)
In-Reply-To: <20260721-b4-vxlan-fdb-port-v3-3-9aa0a543a78a@gmail.com>

On Tue, Jul 21, 2026 at 10:29:52PM +0000, Jack Ma wrote:
> Extend the existing fdb nexthop group tests with cases for the new
> per-nexthop VXLAN destination port (NHA_FDB_PORT).
> 
> In fib_nexthops.sh, ipv4_fdb_grp_fcnal() and ipv6_fdb_grp_fcnal() now
> check that a port is accepted on an fdb nexthop that has a gateway and
> echoed back on dump, that it is rejected without a gateway and rejected
> when zero, that a group may hold legs that differ only in UDP port, and
> that a portless fdb nexthop omits the attribute.  The cases SKIP when
> iproute2 lacks the "port" keyword.
> 
> In test_vxlan_nh.sh, basic_tx_common() gains a second fdb nexthop group
> whose nexthop carries a destination port that differs from the VXLAN
> device default, plus a flower filter keyed on that port, to confirm the
> per-nexthop port is used on the wire.
> 
> Signed-off-by: Jack Ma <jack4it@gmail.com>
> ---
>  tools/testing/selftests/net/fib_nexthops.sh  | 59 ++++++++++++++++++++++++++++
>  tools/testing/selftests/net/test_vxlan_nh.sh | 31 +++++++++++++++
>  2 files changed, 90 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh
> index ac868a731694..1ce4f45fa651 100755
> --- a/tools/testing/selftests/net/fib_nexthops.sh
> +++ b/tools/testing/selftests/net/fib_nexthops.sh
> @@ -432,6 +432,15 @@ check_nexthop_fdb_support()
>  	fi
>  }
>  
> +check_nexthop_fdb_port_support()
> +{
> +	$IP nexthop help 2>&1 | grep -q "fdb \[ port"
> +	if [ $? -ne 0 ]; then
> +		echo "SKIP: iproute2 too old, missing fdb nexthop port support"
> +		return $ksft_skip
> +	fi
> +}
> +
>  check_nexthop_res_support()
>  {
>  	$IP nexthop help 2>&1 | grep -q resilient
> @@ -514,6 +523,31 @@ ipv6_fdb_grp_fcnal()
>  	run_cmd "$IP nexthop replace id 72 via 2001:db8:91::2 fdb"
>  	log_test $? 2 "Replace non-FDB nexthop to FDB nexthop while in a group"
>  
> +	# NHA_FDB_PORT: optional per-nexthop VXLAN destination UDP port,
> +	# letting an fdb nexthop group balance a flow across legs that share
> +	# an underlay IP but listen on different UDP ports.
> +	if check_nexthop_fdb_port_support; then
> +		run_cmd "$IP nexthop add id 80 via 2001:db8:91::2 fdb port 4790"
> +		check_nexthop "id 80" "id 80 via 2001:db8:91::2 scope link fdb port 4790"
> +		log_test $? 0 "Fdb nexthop with port"
> +
> +		run_cmd "$IP nexthop add id 81 fdb port 4790"
> +		log_test $? 2 "Fdb nexthop with port but no gateway"
> +
> +		run_cmd "$IP nexthop add id 81 via 2001:db8:91::2 fdb port 0"
> +		log_test $? 2 "Fdb nexthop with port 0"
> +
> +		run_cmd "$IP nexthop add id 82 via 2001:db8:91::2 fdb port 4789"
> +		run_cmd "$IP nexthop add id 83 via 2001:db8:91::3 fdb port 5789"
> +		run_cmd "$IP nexthop add id 106 group 82/83 fdb"
> +		check_nexthop "id 106" "id 106 group 82/83 fdb"
> +		log_test $? 0 "Fdb nexthop group with legs differing in port"
> +
> +		run_cmd "$IP nexthop add id 84 via 2001:db8:91::2 fdb"
> +		check_nexthop "id 84" "id 84 via 2001:db8:91::2 scope link fdb"
> +		log_test $? 0 "Fdb nexthop without port omits port"
> +	fi
> +
>  	run_cmd "$IP link add name vx10 type vxlan id 1010 local 2001:db8:91::9 remote 2001:db8:91::10 dstport 4789 nolearning noudpcsum tos inherit ttl 100"
>  	run_cmd "$BRIDGE fdb add 02:02:00:00:00:13 dev vx10 nhid 102 self"
>  	log_test $? 0 "Fdb mac add with nexthop group"
> @@ -614,6 +648,31 @@ ipv4_fdb_grp_fcnal()
>  	run_cmd "$IP nexthop replace id 20 via 172.16.1.2 fdb"
>  	log_test $? 2 "Replace non-FDB nexthop to FDB nexthop while in a group"
>  
> +	# NHA_FDB_PORT: optional per-nexthop VXLAN destination UDP port,
> +	# letting an fdb nexthop group balance a flow across legs that share
> +	# an underlay IP but listen on different UDP ports.
> +	if check_nexthop_fdb_port_support; then
> +		run_cmd "$IP nexthop add id 30 via 172.16.1.2 fdb port 4790"
> +		check_nexthop "id 30" "id 30 via 172.16.1.2 scope link fdb port 4790"
> +		log_test $? 0 "Fdb nexthop with port"
> +
> +		run_cmd "$IP nexthop add id 31 fdb port 4790"
> +		log_test $? 2 "Fdb nexthop with port but no gateway"
> +
> +		run_cmd "$IP nexthop add id 31 via 172.16.1.2 fdb port 0"
> +		log_test $? 2 "Fdb nexthop with port 0"
> +
> +		run_cmd "$IP nexthop add id 32 via 172.16.1.2 fdb port 4789"
> +		run_cmd "$IP nexthop add id 33 via 172.16.1.3 fdb port 5789"
> +		run_cmd "$IP nexthop add id 105 group 32/33 fdb"
> +		check_nexthop "id 105" "id 105 group 32/33 fdb"
> +		log_test $? 0 "Fdb nexthop group with legs differing in port"
> +
> +		run_cmd "$IP nexthop add id 34 via 172.16.1.2 fdb"
> +		check_nexthop "id 34" "id 34 via 172.16.1.2 scope link fdb"
> +		log_test $? 0 "Fdb nexthop without port omits port"
> +	fi

The indentation is sub-optimal. Maybe move the tests to
ipv4_fdb_port_fcnal() and ipv6_fdb_port_fcnal() (add to IPV4_TESTS and
IPV6_TESTS) that will be skipped if iproute2 is too old?

> +
>  	run_cmd "$IP link add name vx10 type vxlan id 1010 local 10.0.0.1 remote 10.0.0.2 dstport 4789 nolearning noudpcsum tos inherit ttl 100"
>  	run_cmd "$BRIDGE fdb add 02:02:00:00:00:13 dev vx10 nhid 102 self"
>  	log_test $? 0 "Fdb mac add with nexthop group"
> diff --git a/tools/testing/selftests/net/test_vxlan_nh.sh b/tools/testing/selftests/net/test_vxlan_nh.sh
> index 20f3369f776b..34a24a4f95bf 100755
> --- a/tools/testing/selftests/net/test_vxlan_nh.sh
> +++ b/tools/testing/selftests/net/test_vxlan_nh.sh
> @@ -56,6 +56,16 @@ tc_stats_get()
>  	tc_rule_handle_stats_get "dev dummy1 egress" 101 ".packets" "-n $ns1"
>  }
>  
> +nh_stats_get_port()
> +{
> +	ip -n "$ns1" -s -j nexthop show id 20 | jq ".[][\"group_stats\"][][\"packets\"]"
> +}
> +
> +tc_stats_get_port()
> +{
> +	tc_rule_handle_stats_get "dev dummy1 egress" 102 ".packets" "-n $ns1"
> +}
> +
>  basic_tx_common()
>  {
>  	local af_str=$1; shift
> @@ -90,6 +100,27 @@ basic_tx_common()
>  	busywait "$BUSYWAIT_TIMEOUT" until_counter_is "== 1" tc_stats_get > /dev/null
>  	check_err $? "tc filter stats did not increase"
>  
> +	# Add a second FDB nexthop group whose nexthop carries a per-nexthop
> +	# destination port (NHA_FDB_PORT) that differs from the VXLAN device
> +	# default. Matching outer traffic must egress with that port, so a
> +	# separate flower filter keyed on the new port catches it.
> +	if ip nexthop help 2>&1 | grep -q "fdb \[ port"; then
> +		run_cmd "tc -n $ns1 filter add dev dummy1 egress proto $proto pref 1 handle 102 flower ip_proto udp dst_ip $remote_addr dst_port 4790 action pass"
> +
> +		run_cmd "ip -n $ns1 nexthop add id 2 via $remote_addr fdb port 4790"
> +		run_cmd "ip -n $ns1 nexthop add id 20 group 2 fdb"
> +
> +		run_cmd "bridge -n $ns1 fdb add 00:11:22:33:44:66 dev vx0 self static nhid 20"
> +
> +		run_cmd "ip netns exec $ns1 mausezahn vx0 -a own -b 00:11:22:33:44:66 -c 1 -q"
> +
> +		busywait "$BUSYWAIT_TIMEOUT" until_counter_is "== 1" nh_stats_get_port > /dev/null
> +		check_err $? "FDB nexthop group stats did not increase (with port)"
> +
> +		busywait "$BUSYWAIT_TIMEOUT" until_counter_is "== 1" tc_stats_get_port > /dev/null
> +		check_err $? "tc filter stats did not increase (with port)"
> +	fi
> +
>  	log_test "VXLAN FDB nexthop: $af_str basic Tx"
>  }

This file only tests VXLAN with FDB nexthops so we can just do:

diff --git a/tools/testing/selftests/net/test_vxlan_nh.sh b/tools/testing/selftests/net/test_vxlan_nh.sh
index 34a24a4f95bf..ca905e82b7ca 100755
--- a/tools/testing/selftests/net/test_vxlan_nh.sh
+++ b/tools/testing/selftests/net/test_vxlan_nh.sh
@@ -241,8 +241,8 @@ require_command arping
 require_command ndisc6
 require_command jq
 
-if ! ip nexthop help 2>&1 | grep -q "stats"; then
-	echo "SKIP: iproute2 ip too old, missing nexthop stats support"
+if ! ip nexthop help 2>&1 | grep -q "dst_port"; then
+	echo "SKIP: iproute2 ip too old, missing nexthop dst_port support"
 	exit "$ksft_skip"
 fi

  reply	other threads:[~2026-07-22 12:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 22:29 [PATCH net-next v3 0/3] net: nexthop: per-nexthop UDP dst port for fdb (VXLAN) nexthops Jack Ma
2026-07-21 22:29 ` [PATCH net-next v3 1/3] net: nexthop: add NHA_FDB_PORT for fdb nexthops Jack Ma
2026-07-22 11:46   ` Ido Schimmel
2026-07-22 14:43     ` David Ahern
2026-07-22 15:23       ` Ido Schimmel
2026-07-23  1:43         ` Jack Ma
2026-07-21 22:29 ` [PATCH net-next v3 2/3] vxlan: honor per-nexthop fdb destination port Jack Ma
2026-07-21 22:29 ` [PATCH net-next v3 3/3] selftests: net: add coverage for fdb nexthop dst port Jack Ma
2026-07-22 12:58   ` Ido Schimmel [this message]
2026-07-22  1:05 ` [PATCH net-next v3 0/3] net: nexthop: per-nexthop UDP dst port for fdb (VXLAN) nexthops Jakub Kicinski
2026-07-22  3:28   ` 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=20260722125839.GB2928696@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