[PATCH net-next v2 5/5] selftests: net: test the vxlan vnifilter VNI limit

From: Ali Firas

Date: Wed Sep 16 2026 - 15:41:37 EST


Extend the vnifilter API test with the largest accepted range and one
VNI more rejected, for both add and delete, and with the 24-bit boundary
the first patch enforces.

The oversized delete is written so that it can only fail on the limit.
If it covered VNIs that were never installed, a kernel without the limit
would reach vxlan_vni_del(), fail with -ENOENT on the first missing VNI,
and iproute2 would map that to the same exit status the test expects, so
the case would pass while the limit was gone. Installing the range first
makes every VNI of the oversized delete exist, leaving the limit as the
only reason for it to fail.

bridge(8) sends one VXLAN_VNIFILTER_ENTRY per message, so these cases
exercise the single-entry path only; the per-message total across
several entries is not reachable from iproute2.

Assisted-by: LLM
Signed-off-by: Ali Firas <alishmery18@xxxxxxxxx>
---
v1: https://lore.kernel.org/netdev/20260909092645.3105263-1-alishmery18@xxxxxxxxx/
.../selftests/net/test_vxlan_vnifiltering.sh | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)

diff --git a/tools/testing/selftests/net/test_vxlan_vnifiltering.sh b/tools/testing/selftests/net/test_vxlan_vnifiltering.sh
index 8deacc565afa..7cd4acc76ed6 100755
--- a/tools/testing/selftests/net/test_vxlan_vnifiltering.sh
+++ b/tools/testing/selftests/net/test_vxlan_vnifiltering.sh
@@ -371,6 +371,40 @@ vxlan_vnifilter_api()
# change vxlan vnifilter flag
run_cmd "ip -netns $testns link set dev vxlan-ext1 type vxlan external novnifilter"
log_test $? 2 "Cannot unset vnifilter flag on a device"
+
+ # a single request may touch at most 4096 vnis in total. bridge(8)
+ # sends one range per message, so these cover the one-entry case; the
+ # total across several entries of one message is not reachable from
+ # iproute2.
+ run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 10000-14095"
+ log_test $? 0 "Add vni range of maximum size"
+
+ run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 10000-14096"
+ log_test $? 255 "Cannot add vni range larger than maximum"
+
+ # install the one vni past that range as well, so that the oversized
+ # delete below can only fail on the limit and not on a missing vni
+ run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 14096"
+ log_test $? 0 "Add the vni past the maximum range"
+
+ run_cmd "bridge -netns $testns vni del dev vxlan-ext1 vni 10000-14096"
+ log_test $? 255 "Cannot delete vni range larger than maximum"
+
+ run_cmd "bridge -netns $testns vni del dev vxlan-ext1 vni 10000-14095"
+ log_test $? 0 "Delete vni range of maximum size"
+
+ run_cmd "bridge -netns $testns vni del dev vxlan-ext1 vni 14096"
+ log_test $? 0 "Delete the vni past the maximum range"
+
+ # the vxlan header carries 24 bits, so a vni above that is rejected
+ run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 16777215"
+ log_test $? 0 "Add the highest vni the vxlan header can carry"
+
+ run_cmd "bridge -netns $testns vni del dev vxlan-ext1 vni 16777215"
+ log_test $? 0 "Delete the highest vni the vxlan header can carry"
+
+ run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 16777216"
+ log_test $? 255 "Cannot add a vni the vxlan header cannot carry"
}

# Sanity test vnifilter datapath
--
2.53.0