Skip to content

Commit 7f26d45

Browse files
committed
tests: cover unchanged SVD mapping notifications
Add an unrelated VNI to the EVPN MAC move-back SVD setup while its existing mappings remain unchanged. Check local and remote MAC state, MACIP withdrawals, and kernel FDB deletion history so a transient delete and reinstall cannot pass on final state alone. Exercise the same notification with an operational L3VNI and a peer type-5 route. Require its remote next-hop, RMAC, and kernel FDB entry to survive, and reject L3VNI withdrawal messages during the update. Also convert an L3VNI back to L2 while a bond member retains its access-BD. Confirm the next SVD notification restores the cleared binding through the existing update path. This checks the skip is limited to a matching VNI. Use bounded polling and remove temporary mappings and interfaces after each check. Add SVD mapping and access-bond helpers to lib/evpn.py. Use shared config and debug utilities with checked results. Clear the L3VNI before deleting its BGP VRF. With the prior update path, unchanged mappings show MAC and L3VNI churn, while the cleared-binding case passes. The tests ensure the conditional skip suppresses churn only for an exact VNI match and preserves the existing update path when no matching binding exists. Signed-off-by: Nageswara Soma <nsoma@cisco.com>
1 parent 2b04c36 commit 7f26d45

4 files changed

Lines changed: 292 additions & 8 deletions

File tree

‎tests/topotests/bgp_evpn_mac_move_back/common_bgp_evpn_mac_move_back.py‎

Lines changed: 138 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,28 @@
2525
#
2626
# Besides the fix itself, the steps check that the delete zebra now sends for
2727
# the VXLAN device's entry touches nothing else. The move back and the two
28-
# leftover steps run `bridge monitor fdb` and require that the bridge's local
29-
# entry on PE1's access port is never deleted. Every step checks that the same
30-
# MAC in VNI 200 keeps its VXLAN entry to PE2 (on a single VXLAN device both
31-
# entries live in one FDB, told apart by the source VNI).
28+
# leftover steps, plus the SVD mapping update, run `bridge monitor fdb` and
29+
# require that the bridge's local entry on PE1's access port is never
30+
# deleted. Every step checks that the same MAC in VNI 200 keeps its VXLAN
31+
# entry to PE2 (on a single VXLAN device both entries live in one FDB,
32+
# told apart by the source VNI).
3233
#
3334

3435
import functools
3536
import os
3637

3738
from lib import topotest
38-
from lib.common_config import kill_router_daemons, start_router_daemons
39+
from lib.common_config import (
40+
apply_raw_config,
41+
kill_router_daemons,
42+
start_router_daemons,
43+
)
44+
from lib.evpn import (
45+
add_svd_vlan_vni_mapping,
46+
create_evpn_access_bd_bond,
47+
del_svd_vlan_vni_mapping,
48+
evpn_show_vni_json_elide_ifindex,
49+
)
3950
from lib.topogen import Topogen, get_topogen
4051
from lib.topolog import logger
4152

@@ -415,3 +426,125 @@ def step_leftover_across_restart():
415426
# checks that it comes back
416427
assert_only_vxlan_entry_deleted(mon, vni200_untouched=False)
417428
assert_vni200_intact()
429+
430+
431+
def step_unchanged_svd_mapping_keeps_macs():
432+
"""Adding an SVD mapping must leave the existing mappings' MACs alone."""
433+
tgen = get_topogen()
434+
pe1 = tgen.gears["PE1"]
435+
wait(functools.partial(_mac_is, "PE1", 100, "local", "PE1-eth1"), "PE1 local")
436+
assert_vni200_intact()
437+
mon = FdbMonitor("PE1", "unchanged-mapping")
438+
mark = len(pe1.net.getLog("log", "zebra"))
439+
mapping_added = False
440+
try:
441+
# Adding an unrelated VNI refreshes the SVD mapping table while the
442+
# existing VLAN 10/VNI 100 and VLAN 20/VNI 200 mappings stay the same.
443+
add_svd_vlan_vni_mapping(pe1, 30, 300)
444+
mapping_added = True
445+
wait(
446+
functools.partial(evpn_show_vni_json_elide_ifindex, pe1, 300, {"vni": 300}),
447+
"PE1 added VNI 300",
448+
)
449+
wait(
450+
functools.partial(_mac_is, "PE1", 100, "local", "PE1-eth1"),
451+
"PE1 local after unchanged mapping",
452+
)
453+
assert_vni200_intact()
454+
log = pe1.net.getLog("log", "zebra")[mark:]
455+
withdrawn = [
456+
line
457+
for line in log.splitlines()
458+
if "Send MACIP Del" in line and MAC in line
459+
]
460+
finally:
461+
try:
462+
lines = mon.stop()
463+
finally:
464+
if mapping_added:
465+
del_svd_vlan_vni_mapping(pe1, 30)
466+
467+
assert not withdrawn, f"MAC withdrawn after unchanged mapping: {withdrawn}"
468+
deleted = [line for line in lines if line.startswith(f"Deleted {MAC} ")]
469+
assert not deleted, f"MAC deleted after unchanged mapping: {deleted}"
470+
471+
472+
def step_retained_svd_binding_recovers():
473+
"""Refresh an L2 mapping whose access-BD survived an L3 transition."""
474+
tgen = get_topogen()
475+
pe1 = tgen.gears["PE1"]
476+
wait(
477+
functools.partial(
478+
evpn_show_vni_json_elide_ifindex, pe1, 100, {"vni": 100, "type": "L2"}
479+
),
480+
"Initial VNI 100 is L2",
481+
)
482+
mapping_added = False
483+
try:
484+
create_evpn_access_bd_bond(pe1, "probe-bond", "br0", 10)
485+
486+
def has_member():
487+
actual = pe1.vtysh_cmd("show evpn access-vlan br0 10 json", isjson=True)
488+
return None if actual.get("memberIfCount", 0) > 0 else actual
489+
490+
wait(has_member, "Access BD has a bond member")
491+
pe1.net.add_l3vrf("vrf-probe", 1234)
492+
pe1.net.add_vlan("probe10", "br0", 10)
493+
pe1.net.attach_iface_to_l3vrf("probe10", "vrf-probe")
494+
result = apply_raw_config(
495+
tgen, {"PE1": {"raw_config": ["vrf vrf-probe", "vni 100", "exit-vrf"]}}
496+
)
497+
assert result is True, result
498+
wait(
499+
functools.partial(
500+
evpn_show_vni_json_elide_ifindex,
501+
pe1,
502+
100,
503+
{"vni": 100, "type": "L3", "state": "Up"},
504+
),
505+
"VNI 100 became L3",
506+
)
507+
result = apply_raw_config(
508+
tgen, {"PE1": {"raw_config": ["vrf vrf-probe", "no vni 100", "exit-vrf"]}}
509+
)
510+
assert result is True, result
511+
wait(
512+
functools.partial(
513+
evpn_show_vni_json_elide_ifindex, pe1, 100, {"vni": 100, "type": "L2"}
514+
),
515+
"VNI 100 became L2 again",
516+
)
517+
actual = pe1.vtysh_cmd("show evpn access-vlan br0 10 json", isjson=True)
518+
logger.info("Access BD before refresh: %s", actual)
519+
assert actual.get("memberIfCount", 0) > 0, actual
520+
assert any(
521+
member.get("ifName") == "probe-bond" for member in actual.get("members", [])
522+
), actual
523+
assert not actual.get("vni") and not actual.get("vxlanIf"), actual
524+
add_svd_vlan_vni_mapping(pe1, 30, 300)
525+
mapping_added = True
526+
wait(
527+
functools.partial(evpn_show_vni_json_elide_ifindex, pe1, 300, {"vni": 300}),
528+
"Unrelated VNI 300 added",
529+
)
530+
actual = pe1.vtysh_cmd("show evpn access-vlan br0 10 json", isjson=True)
531+
logger.info("Access BD after refresh: %s", actual)
532+
wait(
533+
functools.partial(
534+
topotest.router_json_cmp,
535+
pe1,
536+
"show evpn access-vlan br0 10 json",
537+
{"vlan": 10, "vni": 100, "vxlanIf": "vxlan0"},
538+
),
539+
"Access BD bound after mapping refresh",
540+
)
541+
finally:
542+
result = apply_raw_config(
543+
tgen, {"PE1": {"raw_config": ["vrf vrf-probe", "no vni 100", "exit-vrf"]}}
544+
)
545+
assert result is True, result
546+
pe1.net.del_iface("probe10")
547+
pe1.net.del_iface("vrf-probe")
548+
pe1.net.del_iface("probe-bond")
549+
if mapping_added:
550+
del_svd_vlan_vni_mapping(pe1, 30)

‎tests/topotests/bgp_evpn_mac_move_back/test_bgp_evpn_mac_move_back_svd.py‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
# behind) is removed as soon as zebra sees it, and the MAC stays local.
2020
# 4. The same leftover in the kernel when zebra and bgpd start: the MAC is
2121
# local after the restart and PE2 reaches it through PE1.
22+
# 5. Adding an unrelated VNI preserves the existing mappings' MACs without
23+
# withdrawing their routes or deleting their FDB entries.
24+
# 6. A mapping refresh restores an access-BD binding cleared by an L3-to-L2
25+
# transition while a bond member keeps the access-BD alive.
2226
#
23-
# The move back (1) and the two leftover steps (3, 4) also watch the FDB and
24-
# check that the bridge's local entry on PE1's access port is never deleted.
25-
# Every step checks that the same MAC in VNI 200 keeps its vxlan entry to PE2.
27+
# The move back (1), leftover steps (3, 4), and mapping update (5) watch the
28+
# FDB and check that PE1's local access-port entry is never deleted.
29+
# The MAC checks also verify that VNI 200 keeps its vxlan entry to PE2.
2630
#
2731

2832
import os
@@ -43,6 +47,8 @@
4347
step_leftover_seen_live_is_removed,
4448
step_mac_home_on_pe1,
4549
step_move_to_pe2_and_back,
50+
step_retained_svd_binding_recovers,
51+
step_unchanged_svd_mapping_keeps_macs,
4652
teardown,
4753
)
4854

@@ -82,6 +88,14 @@ def test_leftover_across_restart():
8288
step_leftover_across_restart()
8389

8490

91+
def test_unchanged_svd_mapping_keeps_macs():
92+
step_unchanged_svd_mapping_keeps_macs()
93+
94+
95+
def test_retained_svd_binding_recovers():
96+
step_retained_svd_binding_recovers()
97+
98+
8599
def test_memory_leak():
86100
tgen = get_topogen()
87101
if not tgen.is_memleak_enabled():

‎tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py‎

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,23 @@
4141
# Import topogen and topotest helpers
4242
from lib import topotest
4343
from lib.evpn import (
44+
add_svd_vlan_vni_mapping,
45+
del_svd_vlan_vni_mapping,
4446
evpn_check_vni_macs_present,
4547
evpn_ip_learn_test,
4648
evpn_mac_learn_test,
4749
evpn_mac_test_local_remote,
4850
evpn_show_vni_json_elide_ifindex,
51+
evpn_verify_bgp_vrf_l3vni,
52+
evpn_verify_l3vni_nexthops,
53+
evpn_verify_l3vni_rmacs,
4954
)
5055
from lib.topogen import Topogen, TopoRouter, get_topogen
5156
from lib.topolog import logger
5257
from lib.common_config import (
58+
apply_raw_config,
5359
create_address_on_interface,
60+
create_debug_log_config,
5461
required_linux_kernel_version,
5562
shutdown_bringup_interface_in_kernel,
5663
)
@@ -547,6 +554,117 @@ def test_pe_advertise_aggr_evpn_route():
547554
assert result is None, assertmsg
548555

549556

557+
def test_unchanged_svd_l3_mapping_keeps_state():
558+
"""An unrelated SVD mapping must not bounce an operational L3VNI."""
559+
tgen = get_topogen()
560+
if tgen.routers_have_failure():
561+
pytest.skip(tgen.errors)
562+
pe1 = tgen.gears["PE1"]
563+
result = create_debug_log_config(
564+
tgen, {"PE1": {"debug": {"enable": {"zebra": ["debug zebra vxlan"]}}}}
565+
)
566+
assert result is True, result
567+
mapping_added = False
568+
try:
569+
# Both PEs already have vlan400 on their SVD and in vrf-purple.
570+
# Originate a peer type-5 route so PE1 has an RMAC and next hop
571+
# whose state must survive the mapping-table refresh.
572+
result = apply_raw_config(
573+
tgen,
574+
{
575+
"PE2": {
576+
"raw_config": [
577+
"vrf vrf-purple",
578+
"vni 4000",
579+
"exit-vrf",
580+
"router bgp 65000 vrf vrf-purple",
581+
"bgp router-id 10.30.30.30",
582+
"no bgp network import-check",
583+
"address-family ipv4 unicast",
584+
"network 203.0.113.2/32",
585+
"exit-address-family",
586+
"address-family l2vpn evpn",
587+
"advertise ipv4 unicast",
588+
"exit-address-family",
589+
]
590+
}
591+
},
592+
)
593+
assert result is True, result
594+
595+
def l3_state():
596+
checks = (
597+
partial(
598+
evpn_show_vni_json_elide_ifindex,
599+
pe1,
600+
4000,
601+
{
602+
"vni": 4000,
603+
"type": "L3",
604+
"state": "Up",
605+
"tenantVrf": "vrf-purple",
606+
},
607+
),
608+
partial(evpn_verify_l3vni_nexthops, pe1, [4000], ["10.30.30.30"]),
609+
partial(evpn_verify_l3vni_rmacs, pe1, [4000], ["10.30.30.30"]),
610+
)
611+
for check in checks:
612+
result = check()
613+
if result is not None:
614+
return result
615+
return None
616+
617+
_, result = topotest.run_and_expect(l3_state, None, count=30, wait=1)
618+
assert result is None, f"Initial L3VNI state: {result}"
619+
mark = len(pe1.net.getLog("log", "zebra"))
620+
add_svd_vlan_vni_mapping(pe1, 600, 600)
621+
mapping_added = True
622+
_, result = topotest.run_and_expect(
623+
partial(evpn_show_vni_json_elide_ifindex, pe1, 600, {"vni": 600}),
624+
None,
625+
count=30,
626+
wait=1,
627+
)
628+
assert result is None, f"New VNI 600 not processed: {result}"
629+
_, result = topotest.run_and_expect(l3_state, None, count=30, wait=1)
630+
assert result is None, f"L3VNI state after mapping refresh: {result}"
631+
log = pe1.net.getLog("log", "zebra")[mark:]
632+
down = [line for line in log.splitlines() if "Send L3VNI DEL 4000 " in line]
633+
assert not down, f"Unchanged L3VNI sent down to BGP: {down}"
634+
finally:
635+
result = apply_raw_config(
636+
tgen,
637+
{
638+
"PE2": {
639+
"raw_config": [
640+
"vrf vrf-purple",
641+
"no vni 4000",
642+
"exit-vrf",
643+
]
644+
}
645+
},
646+
)
647+
assert result is True, result
648+
_, result = topotest.run_and_expect(
649+
partial(evpn_verify_bgp_vrf_l3vni, tgen.gears["PE2"], "vrf-purple", 0),
650+
None,
651+
count=30,
652+
wait=1,
653+
)
654+
assert result is None, f"PE2 L3VNI not cleared during cleanup: {result}"
655+
result = apply_raw_config(
656+
tgen,
657+
{"PE2": {"raw_config": ["no router bgp 65000 vrf vrf-purple"]}},
658+
)
659+
assert result is True, result
660+
result = create_debug_log_config(
661+
tgen, {"PE1": {"debug": {"disable": {"zebra": ["debug zebra vxlan"]}}}}
662+
)
663+
assert result is True, result
664+
if mapping_added:
665+
del_svd_vlan_vni_mapping(pe1, 600)
666+
667+
550668
def test_memory_leak():
551669
"Run the memory leak test and report results."
552670
tgen = get_topogen()

‎tests/topotests/lib/evpn.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,25 @@ def get_l3vni_bridge_vlan(dut, vni):
16191619
return bridge, vxlan, vlan
16201620

16211621

1622+
def add_svd_vlan_vni_mapping(dut, vlan, vni, vxlan="vxlan0"):
1623+
"""Add an SVD VLAN-to-VNI mapping to a VXLAN device."""
1624+
dut.cmd_raises(f"bridge vlan add dev {vxlan} vid {vlan}")
1625+
dut.cmd_raises(f"bridge vlan add dev {vxlan} vid {vlan} tunnel_info id {vni}")
1626+
1627+
1628+
def del_svd_vlan_vni_mapping(dut, vlan, vxlan="vxlan0"):
1629+
"""Delete an SVD VLAN mapping from a VXLAN device."""
1630+
dut.cmd_raises(f"bridge vlan del dev {vxlan} vid {vlan}")
1631+
1632+
1633+
def create_evpn_access_bd_bond(dut, bond, bridge, vlan):
1634+
"""Create a bond as a member of an EVPN access bridge VLAN."""
1635+
dut.cmd_raises(f"ip link add {bond} type bond mode active-backup")
1636+
dut.cmd_raises(f"ip link set dev {bond} master {bridge}")
1637+
dut.cmd_raises(f"bridge vlan add dev {bond} vid {vlan}")
1638+
dut.cmd_raises(f"ip link set dev {bond} up")
1639+
1640+
16221641
def bridge_fdb_flush_cmd(bridge, vlan=0):
16231642
"""
16241643
Return a `bridge fdb flush dev <bridge> [vlan <vid>]` command.

0 commit comments

Comments
 (0)