Commit 0e66c232b7 for frr

commit 0e66c232b7ffe636ecac1603b9b087556c542fa3
Author: Justin Iurman <justin.iurman@6wind.com>
Date:   Tue Nov 10 15:31:39 2026 +0100

    tests: check the flooding mode of a VNI in a VRF in the configuration

    Check that the flooding mode of a VNI stays in the configuration when it
    is the same as the one of the BGP instance of its VRF: add VNI 40 on r1,
    in vrf-red, which has an L3VNI.

    Signed-off-by: Justin Iurman <justin.iurman@6wind.com>

diff --git a/tests/topotests/bgp_evpn_flooding_per_vni/r1/frr.conf b/tests/topotests/bgp_evpn_flooding_per_vni/r1/frr.conf
index 077179eced..d617272733 100644
--- a/tests/topotests/bgp_evpn_flooding_per_vni/r1/frr.conf
+++ b/tests/topotests/bgp_evpn_flooding_per_vni/r1/frr.conf
@@ -1,4 +1,8 @@
 !
+vrf vrf-red
+ vni 1000
+exit-vrf
+!
 int r1-eth0
  ip address 192.168.1.1/24
 !
@@ -21,3 +25,6 @@ router bgp 65001
   exit-vni
  exit-address-family
 !
+router bgp 65001 vrf vrf-red
+ no bgp ebgp-requires-policy
+!
diff --git a/tests/topotests/bgp_evpn_flooding_per_vni/r1/setup.sh b/tests/topotests/bgp_evpn_flooding_per_vni/r1/setup.sh
index 66b2eba3bc..fe902def9f 100644
--- a/tests/topotests/bgp_evpn_flooding_per_vni/r1/setup.sh
+++ b/tests/topotests/bgp_evpn_flooding_per_vni/r1/setup.sh
@@ -24,3 +24,17 @@ for vni in 10 20 30; do
     ip link set "$vxlandev" type bridge_slave learning off neigh_suppress on
     ip link set dev "$vxlandev" up
 done
+
+# VNI 40 in vrf-red, which has L3VNI 1000
+ip link add vrf-red type vrf table 10
+ip link set dev vrf-red up
+for vni in 40 1000; do
+    ip link add name "br$vni" type bridge forward_delay 0 stp_state 0 mcast_snooping 0
+    ip link set dev "br$vni" master vrf-red
+    ip link set dev "br$vni" up
+    ip link add name "vxlan$vni" master "br$vni" type vxlan id "$vni" \
+        dstport 4789 nolearning local 192.168.1.1
+    ip link set "vxlan$vni" addrgenmode none
+    ip link set "vxlan$vni" type bridge_slave learning off neigh_suppress on
+    ip link set dev "vxlan$vni" up
+done
diff --git a/tests/topotests/bgp_evpn_flooding_per_vni/test_bgp_evpn_flooding_per_vni.py b/tests/topotests/bgp_evpn_flooding_per_vni/test_bgp_evpn_flooding_per_vni.py
index 69498e4e3f..1ffe59fff3 100644
--- a/tests/topotests/bgp_evpn_flooding_per_vni/test_bgp_evpn_flooding_per_vni.py
+++ b/tests/topotests/bgp_evpn_flooding_per_vni/test_bgp_evpn_flooding_per_vni.py
@@ -223,6 +223,17 @@ def test_bgp_evpn_flooding_per_vni_local():
             step + ", remote VTEPs learnt again",
         )

+    def _expect_vni_config(vni, line, step):
+        def _check():
+            output = r1.vtysh_cmd("show running-config bgpd")
+            match = re.search(r"\n  vni %d\n(.*?)\n  exit-vni" % vni, output, re.DOTALL)
+            if match and line in match.group(1).splitlines():
+                return None
+            return "no '%s' under vni %d" % (line.strip(), vni)
+
+        _, result = topotest.run_and_expect(_check, None, count=5, wait=1)
+        assert result is None, "%s: %s" % (step, result)
+
     # The mode of VNI 20 must reach zebra although it was configured before
     # the VNIs came up.
     _expect_flooded_vnis([20], "startup")
@@ -362,6 +373,29 @@ def test_bgp_evpn_flooding_per_vni_local():
     )
     _expect_flooded_vnis([20], "initial configuration")

+    # The mode of a VNI is kept in the configuration, even if it is the same
+    # as the one of the BGP instance of the VRF of the VNI (VNI 40 in vrf-red,
+    # which has an L3VNI).
+    _expect_json("show bgp vrf vrf-red vni json", {"l2Vnis": [40]}, "VNI 40 in vrf-red")
+    r1.vtysh_cmd(
+        """
+        configure terminal
+         router bgp 65001
+          address-family l2vpn evpn
+           vni 40
+            flooding head-end-replication
+        """
+    )
+    _expect_vni_config(40, "   flooding head-end-replication", "VNI 40 configuration")
+    r1.vtysh_cmd(
+        """
+        configure terminal
+         router bgp 65001
+          address-family l2vpn evpn
+           no vni 40
+        """
+    )
+

 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]