Skip to content

Commit

Permalink
tests: bgp_vpnv4_route_leak_basic add del static prefix
Browse files Browse the repository at this point in the history
In bgp_vpnv4_route_leak_basic, remove and add back the static prefix
172.16.3.0/24 on VRF DONNA. Before the previous fixes, the 172.16.3.0/24
prefix re-appeared when it was added back in the VPN table but it was
marked as invalid.

Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Nov 14, 2024
1 parent 4fe7152 commit ad5959e
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/topotests/bgp_vpnv4_route_leak_basic/r1/frr.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
vrf DONNA
ip route 172.16.3.0/24 10.0.0.254
exit-vrf
!
int dummy0
ip address 10.0.4.1/24
no shut
Expand Down Expand Up @@ -46,6 +50,7 @@ router bgp 99 vrf DONNA
no bgp ebgp-requires-policy
address-family ipv4 unicast
redistribute connected
network 172.16.3.0/24
label vpn export 101
rd vpn export 10.0.4.1:1
rt vpn export 10.0.4.1:101
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@
]
}
],
"172.16.3.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "IGP",
"announceNexthopSelf": true,
"nhVrfName": "DONNA",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"172.16.101.0/24": [
{
"valid": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"routerId": "10.0.4.1",
"localAS": 99,
"routes": {
"routeDistinguishers": {
"10.0.4.1:1": {
"10.0.0.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "incomplete",
"announceNexthopSelf": true,
"nhVrfName": "DONNA",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"10.0.1.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "incomplete",
"announceNexthopSelf": true,
"nhVrfName": "EVA",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"10.0.2.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "incomplete",
"announceNexthopSelf": true,
"nhVrfName": "DONNA",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"10.0.3.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "incomplete",
"announceNexthopSelf": true,
"nhVrfName": "EVA",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"10.0.4.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "incomplete",
"announceNexthopSelf": true,
"nhVrfName": "default",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"172.16.3.0/24": null,
"172.16.101.0/24": null
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@
]
}
],
"172.16.3.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "IGP",
"announceNexthopSelf": true,
"nhVrfName": "DONNA",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"172.16.101.0/24": null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@
]
}
],
"172.16.3.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "IGP",
"announceNexthopSelf": true,
"nhVrfName": "DONNA",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"172.16.101.0/24": null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@
]
}
],
"172.16.3.0/24": [
{
"valid": true,
"pathFrom": "external",
"path": "",
"origin": "IGP",
"announceNexthopSelf": true,
"nhVrfName": "DONNA",
"nexthops": [
{
"ip": "0.0.0.0",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
],
"172.16.101.0/24": [
{
"valid": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ def test_vrf_route_leak_donna():
],
},
],
"172.16.3.0/24": [
{
"protocol": "static",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "dummy1",
"active": True,
}
],
},
],
"172.16.101.0/24": None,
}

Expand Down Expand Up @@ -195,6 +208,20 @@ def test_vrf_route_leak_eva():
"protocol": "connected",
}
],
"172.16.3.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "DONNA",
"vrf": "DONNA",
"active": True,
}
],
},
],
"172.16.101.0/24": None,
}

Expand Down Expand Up @@ -249,6 +276,20 @@ def test_vrf_route_leak_default():
"protocol": "connected",
}
],
"172.16.3.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "DONNA",
"vrf": "DONNA",
"active": True,
}
],
},
],
}

test_func = partial(topotest.router_json_cmp, r1, "show ip route json", expect)
Expand Down Expand Up @@ -495,6 +536,93 @@ def test_vrf_route_leak_donna_delete_vrf_zita():
assert result, "BGP IPv4 VPN table check failed:\n{}".format(diff)


def test_vrf_route_leak_default_delete_prefix():
logger.info("Remove BGP static prefix 172.16.3.0/24 from VRF DONNA and ensure that the route is deleted on default")
tgen = get_topogen()
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

r1 = tgen.gears["r1"]
r1.vtysh_cmd(
"""
configure
router bgp 99 vrf DONNA
address-family ipv4 unicast
no network 172.16.3.0/24
"""
)

# Test default VRF.
expect = {
"172.16.3.0/24": None,
}

test_func = partial(
topotest.router_json_cmp, r1, "show ip route json", expect
)
result, diff = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result, "BGP VRF default check failed:\n{}".format(diff)

# check BGP IPv4 VPN table
json_file = "{}/{}/show_bgp_ipv4_vpn_del_donna_prefix.json".format(CWD, r1.name)
expect = json.loads(open(json_file).read())

test_func = partial(topotest.router_json_cmp, r1, "show bgp ipv4 vpn json", expect)
result, diff = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result, "BGP IPv4 VPN table check failed:\n{}".format(diff)


def test_vrf_route_leak_default_prefix_back():
logger.info("Set back BGP static prefix 172.16.3.0/24 to VRF DONNA and ensure that the route is set on default")
tgen = get_topogen()
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

r1 = tgen.gears["r1"]
r1.vtysh_cmd(
"""
configure
router bgp 99 vrf DONNA
address-family ipv4 unicast
network 172.16.3.0/24
"""
)

# Test default VRF.
expect = {
"172.16.3.0/24": [
{
"protocol": "bgp",
"selected": True,
"nexthops": [
{
"fib": True,
"interfaceName": "DONNA",
"vrf": "DONNA",
"active": True,
}
],
},
],
}

test_func = partial(
topotest.router_json_cmp, r1, "show ip route json", expect
)
result, diff = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result, "BGP VRF default check failed:\n{}".format(diff)

# check BGP IPv4 VPN table
json_file = "{}/{}/show_bgp_ipv4_vpn_init.json".format(CWD, r1.name)
expect = json.loads(open(json_file).read())

test_func = partial(topotest.router_json_cmp, r1, "show bgp ipv4 vpn json", expect)
result, diff = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result, "BGP IPv4 VPN table check failed:\n{}".format(diff)


def test_memory_leak():
"Run the memory leak test and report results."
tgen = get_topogen()
Expand Down

0 comments on commit ad5959e

Please sign in to comment.