Commit 6129dc9eb4 for frr
commit 6129dc9eb42c0eb200eb0e4d7816bcc257482c1b
Author: Nageswara Soma <nsoma@cisco.com>
Date: Mon Nov 23 14:43:20 2026 -0800
tests: cover zero router MAC EVPN imports
Import an L2-only VNI's Type-2 MAC/IP route into a
VRF and check host-prefix tracking and withdrawal.
Wait for a subsequently queued static kernel route
before checking for a zero-MAC BUM flood entry.
Verify a valid RMAC from the same VTEP still works.
Factor bridge/VXLAN creation into a shared helper
for L2 and L3 VNI setup. Extend the existing FDB
lookup to support per-VNI devices whose rows omit
src_vni.
Signed-off-by: Nageswara Soma <nsoma@cisco.com>
diff --git a/tests/topotests/bgp_evpn_zero_rmac/__init__.py b/tests/topotests/bgp_evpn_zero_rmac/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/topotests/bgp_evpn_zero_rmac/r1/frr.conf b/tests/topotests/bgp_evpn_zero_rmac/r1/frr.conf
new file mode 100644
index 0000000000..ce988c4398
--- /dev/null
+++ b/tests/topotests/bgp_evpn_zero_rmac/r1/frr.conf
@@ -0,0 +1,26 @@
+vrf vrf-101
+ vni 101
+exit-vrf
+!
+interface r1-eth0
+ ip address 192.0.2.1/24
+!
+interface br100
+ ip address 10.0.100.1/24
+!
+router bgp 65000
+ bgp router-id 192.0.2.1
+ no bgp default ipv4-unicast
+ neighbor 192.0.2.2 remote-as internal
+ address-family l2vpn evpn
+ neighbor 192.0.2.2 activate
+ advertise-all-vni
+ advertise-svi-ip
+ exit-address-family
+!
+router bgp 65000 vrf vrf-101
+ bgp router-id 192.0.2.1
+ no bgp network import-check
+ address-family l2vpn evpn
+ advertise ipv4 unicast
+ exit-address-family
diff --git a/tests/topotests/bgp_evpn_zero_rmac/r2/frr.conf b/tests/topotests/bgp_evpn_zero_rmac/r2/frr.conf
new file mode 100644
index 0000000000..e12747b343
--- /dev/null
+++ b/tests/topotests/bgp_evpn_zero_rmac/r2/frr.conf
@@ -0,0 +1,22 @@
+vrf vrf-101
+ vni 101
+exit-vrf
+!
+interface r2-eth0
+ ip address 192.0.2.2/24
+!
+router bgp 65000
+ bgp router-id 192.0.2.2
+ no bgp default ipv4-unicast
+ neighbor 192.0.2.1 remote-as internal
+ address-family l2vpn evpn
+ neighbor 192.0.2.1 activate
+ advertise-all-vni
+ exit-address-family
+!
+router bgp 65000 vrf vrf-101
+ bgp router-id 192.0.2.2
+ address-family l2vpn evpn
+ route-target import 65000:100
+ route-target import 65000:101
+ exit-address-family
diff --git a/tests/topotests/bgp_evpn_zero_rmac/test_bgp_evpn_zero_rmac.py b/tests/topotests/bgp_evpn_zero_rmac/test_bgp_evpn_zero_rmac.py
new file mode 100644
index 0000000000..af62c5d77a
--- /dev/null
+++ b/tests/topotests/bgp_evpn_zero_rmac/test_bgp_evpn_zero_rmac.py
@@ -0,0 +1,169 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
+
+"""Import an L2-only VNI's Type-2 route into a VRF without creating a BUM entry.
+
+r1 and r2 peer over s1 and have L3VNI 101. r1 also has L2VNI 100 outside
+the VRF, so its SVI MAC/IP advertisement has no Router MAC extended
+community. r2 imports that route into vrf-101 using its L2 route target.
+"""
+
+import json
+import os
+import sys
+from functools import partial
+
+import pytest
+
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
+from lib import topotest
+from lib.common_config import configure_interface_mac, create_static_routes
+from lib.evpn import (
+ evpn_kernel_vxlan_fdb_entry,
+ evpn_plumb_l2vni,
+ evpn_plumb_l3vni,
+ get_remote_macs,
+)
+from lib.kernel_routes import kernel_routes
+from lib.topogen import Topogen, get_topogen
+
+pytestmark = [pytest.mark.bgpd, pytest.mark.evpn]
+
+ZERO_MAC = "00:00:00:00:00:00"
+REMOTE_RMAC = "52:54:00:00:01:65"
+
+
+def build_topo(tgen):
+ for name in ("r1", "r2"):
+ tgen.add_router(name)
+ switch = tgen.add_switch("s1")
+ for router in tgen.routers().values():
+ switch.add_link(router)
+
+
+def setup_module(mod):
+ tgen = Topogen(build_topo, mod.__name__)
+ tgen.start_topology()
+ for index, router in enumerate(tgen.routers().values(), start=1):
+ evpn_plumb_l3vni(router, "vrf-101", 101, 101, "192.0.2.{}".format(index))
+ result = configure_interface_mac(
+ tgen, {router.name: {"br101": "52:54:00:00:0{}:65".format(index)}}
+ )
+ assert result is True, result
+ evpn_plumb_l2vni(tgen.gears["r1"], 100, "192.0.2.1")
+ for name, router in tgen.routers().items():
+ router.load_frr_config(os.path.join(CWD, name, "frr.conf"))
+ tgen.start_router()
+
+
+def teardown_module(_mod):
+ get_topogen().stop_topology()
+
+
+def _wait_json(router, command, expected):
+ def check():
+ output = json.loads(router.vtysh_cmd(command, raises=True))
+ return topotest.json_cmp(output, expected)
+
+ _, result = topotest.run_and_expect(check, None, count=30, wait=1)
+ assert result is None, "{}\n{}\n{}".format(
+ command, result, router.vtysh_cmd(command)
+ )
+
+
+def test_zero_rmac_is_not_a_flood_destination():
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r2 = tgen.gears["r2"]
+ # Wait for the imported host in zebra's nexthop table, rather than
+ # allowing an empty RMAC table before BGP convergence to pass.
+ _wait_json(
+ r2,
+ "show bgp vrf vrf-101 ipv4 unicast json",
+ {"routes": {"10.0.100.1/32": [{"valid": True}]}},
+ )
+ _wait_json(
+ r2,
+ "show evpn next-hops vni 101 ip 192.0.2.1 json",
+ {
+ "ip": "192.0.2.1",
+ "routerMac": ZERO_MAC,
+ "refCount": 1,
+ "prefixList": [{"prefix": "10.0.100.1/32", "pathCount": 1}],
+ },
+ )
+
+ # The imported route is not installed in the kernel. Queue a static
+ # route after its nexthop update and wait for it in the kernel, so earlier
+ # RMAC installs have completed before checking for the zero-MAC entry.
+ result = create_static_routes(
+ tgen,
+ {
+ "r2": {
+ "static_routes": [
+ {
+ "network": "203.0.113.254/32",
+ "next_hop": "Null0",
+ "vrf": "vrf-101",
+ }
+ ]
+ }
+ },
+ )
+ assert result is True, result
+
+ def check_kernel_route():
+ return topotest.json_cmp(
+ kernel_routes(r2, vrf="vrf-101"),
+ [{"dst": "203.0.113.254", "type": "blackhole"}],
+ )
+
+ _, result = topotest.run_and_expect(check_kernel_route, None, count=30, wait=1)
+ assert result is None, "Static route is missing from the kernel: {}".format(result)
+
+ check_rmacs = partial(get_remote_macs, r2, 101)
+ _, result = topotest.run_and_expect(check_rmacs, [], count=30, wait=1)
+ assert result == [], "Unexpected remote RMACs: {}".format(result)
+ result = evpn_kernel_vxlan_fdb_entry(r2, ZERO_MAC, None, "vxlan101")
+ assert result is None, "Zero RMAC created a BUM flood destination: {}".format(
+ result
+ )
+
+ # Withdrawal must also work when there was no RMAC entry to delete.
+ tgen.gears["r1"].vtysh_cmd(
+ """configure terminal
+router bgp 65000
+ address-family l2vpn evpn
+ no advertise-svi-ip
+"""
+ )
+ _wait_json(r2, "show evpn next-hops vni 101 json", {"192.0.2.1": None})
+
+ # The guard must still permit a real RMAC from the same VTEP.
+ tgen.gears["r1"].vtysh_cmd(
+ """configure terminal
+router bgp 65000 vrf vrf-101
+ address-family ipv4 unicast
+ network 198.51.100.1/32
+"""
+ )
+ _, result = topotest.run_and_expect(check_rmacs, [REMOTE_RMAC], count=30, wait=1)
+ assert result == [REMOTE_RMAC], "Unexpected remote RMACs: {}".format(result)
+
+ def real_rmac_installed():
+ fdb = evpn_kernel_vxlan_fdb_entry(r2, REMOTE_RMAC, None, "vxlan101")
+ return fdb is not None and fdb["dst"] == "192.0.2.1"
+
+ _, result = topotest.run_and_expect(real_rmac_installed, True, count=30, wait=1)
+ assert result, "Nonzero RMAC was not installed in the kernel FDB"
+
+
+def test_memory_leak():
+ tgen = get_topogen()
+ if not tgen.is_memleak_enabled():
+ pytest.skip("Memory leak testing is disabled")
+ tgen.report_memory_leaks()
diff --git a/tests/topotests/lib/evpn.py b/tests/topotests/lib/evpn.py
index 88a23fb4ea..443e004cbc 100644
--- a/tests/topotests/lib/evpn.py
+++ b/tests/topotests/lib/evpn.py
@@ -2571,29 +2571,41 @@ def evpn_type5_prefix_key(prefix):
return "[5]:[0]:[{}]:[{}]".format(prefixlen, address)
+def evpn_plumb_l2vni(router, vni, local_vtep):
+ """Create an L2VNI bridge and VXLAN device outside a VRF."""
+ evpn_plumb_vni(router, vni, local_vtep, vrf=None)
+
+
def evpn_plumb_l3vni(router, vrf, table, vni, local_vtep):
"""Create a VRF-lite L3VNI (bridge + VXLAN) so Type-5 can be originated.
``local_vtep`` must already be configured on an interface. Returns None.
"""
+ router.net.add_l3vrf(vrf, table)
+ evpn_plumb_vni(router, vni, local_vtep, vrf=vrf)
+
+
+def evpn_plumb_vni(router, vni, local_vtep, vrf=None):
+ """Create a bridge and per-VNI VXLAN device, optionally in a VRF."""
br = "br{}".format(vni)
vxlan = "vxlan{}".format(vni)
- cmds = [
- "ip link add {} type vrf table {}".format(vrf, table),
- "ip link set dev {} up".format(vrf),
- "ip link add {} type bridge stp_state 0".format(br),
- "ip link set dev {} master {}".format(br, vrf),
- "ip link set dev {} up".format(br),
- (
- "ip link add {} type vxlan id {} dstport 4789 local {} "
- "nolearning".format(vxlan, vni, local_vtep)
- ),
- "ip link set dev {} master {}".format(vxlan, br),
- (
- "ip link set dev {} up type bridge_slave learning off "
- "flood off mcast_flood off".format(vxlan)
- ),
- ]
+ cmds = ["ip link add {} type bridge stp_state 0".format(br)]
+ if vrf:
+ cmds.append("ip link set dev {} master {}".format(br, vrf))
+ cmds.extend(
+ [
+ "ip link set dev {} up".format(br),
+ (
+ "ip link add {} type vxlan id {} dstport 4789 local {} "
+ "nolearning".format(vxlan, vni, local_vtep)
+ ),
+ "ip link set dev {} master {}".format(vxlan, br),
+ (
+ "ip link set dev {} up type bridge_slave learning off "
+ "flood off mcast_flood off".format(vxlan)
+ ),
+ ]
+ )
for cmd in cmds:
router.cmd_raises(cmd)
@@ -3975,13 +3987,16 @@ def evpn_kernel_vxlan_fdb_entry(dut, mac, vni, vxlan="vxlan48"):
Returns {"dst", "nhid", "line"}. A single-VTEP entry has dst and no nhid;
an ES MAC has nhid and no dst. Entries of other VNIs are ignored.
+ Pass vni=None for a per-VNI VXLAN device with no src_vni in its rows.
"""
out = dut.run(
f"bridge -d fdb show dev {vxlan} | grep -i -F -- {shlex.quote(mac)} || true"
)
for line in str(out).splitlines():
parts = line.split()
- if "self" not in parts or _fdb_token(parts, "src_vni") != str(int(vni)):
+ if "self" not in parts:
+ continue
+ if vni is not None and _fdb_token(parts, "src_vni") != str(int(vni)):
continue
if not parts or parts[0].lower() != mac.lower():
continue