mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-26 04:54:44 +00:00
tests: add a new BGP AIGP topotest
The topotest verifies that a local route is favored irrespective of its AIGP value. Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
This commit is contained in:
parent
91e157f3ae
commit
1a2c3d684a
@ -18,6 +18,7 @@ router bgp 65001
|
|||||||
neighbor 10.0.0.4 timers connect 1
|
neighbor 10.0.0.4 timers connect 1
|
||||||
neighbor 10.0.0.4 route-reflector-client
|
neighbor 10.0.0.4 route-reflector-client
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
|
network 10.0.1.2/32 route-map set-aigp
|
||||||
neighbor 10.0.0.4 route-map set-nexthop out
|
neighbor 10.0.0.4 route-map set-nexthop out
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
!
|
||||||
@ -25,3 +26,7 @@ route-map set-nexthop permit 10
|
|||||||
set ip next-hop peer-address
|
set ip next-hop peer-address
|
||||||
exit
|
exit
|
||||||
!
|
!
|
||||||
|
route-map set-aigp permit 10
|
||||||
|
set aigp 50
|
||||||
|
set weight 0
|
||||||
|
!
|
||||||
|
@ -7,6 +7,7 @@ router bgp 65001
|
|||||||
neighbor 10.0.0.1 timers connect 1
|
neighbor 10.0.0.1 timers connect 1
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
redistribute connected route-map connected-to-bgp
|
redistribute connected route-map connected-to-bgp
|
||||||
|
network 10.0.1.2/32 route-map set-aigp
|
||||||
neighbor 10.0.0.1 next-hop-self
|
neighbor 10.0.0.1 next-hop-self
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
!
|
||||||
@ -16,3 +17,6 @@ route-map connected-to-bgp permit 10
|
|||||||
match ip address prefix-list p22
|
match ip address prefix-list p22
|
||||||
set aigp 2
|
set aigp 2
|
||||||
!
|
!
|
||||||
|
route-map set-aigp permit 10
|
||||||
|
set aigp 10
|
||||||
|
!
|
||||||
|
@ -101,6 +101,45 @@ def test_bgp_aigp_rr():
|
|||||||
expected = {"paths": [{"aigpMetric": aigp, "valid": True}]}
|
expected = {"paths": [{"aigpMetric": aigp, "valid": True}]}
|
||||||
return topotest.json_cmp(output, expected)
|
return topotest.json_cmp(output, expected)
|
||||||
|
|
||||||
|
def _bgp_check_aigp_bestpath():
|
||||||
|
output = json.loads(r1.vtysh_cmd("show bgp ipv4 unicast 10.0.1.2/32 json"))
|
||||||
|
expected = {
|
||||||
|
"prefix": "10.0.1.2/32",
|
||||||
|
"paths": [
|
||||||
|
{
|
||||||
|
"aigpMetric": 50,
|
||||||
|
"valid": True,
|
||||||
|
"sourced": True,
|
||||||
|
"local": True,
|
||||||
|
"bestpath": {"overall": True, "selectionReason": "Local Route"},
|
||||||
|
"nexthops": [
|
||||||
|
{
|
||||||
|
"ip": "0.0.0.0",
|
||||||
|
"hostname": "r1",
|
||||||
|
"afi": "ipv4",
|
||||||
|
"metric": 0,
|
||||||
|
"accessible": True,
|
||||||
|
"used": True,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"aigpMetric": 10,
|
||||||
|
"valid": True,
|
||||||
|
"nexthops": [
|
||||||
|
{
|
||||||
|
"ip": "10.0.0.2",
|
||||||
|
"hostname": "r2",
|
||||||
|
"afi": "ipv4",
|
||||||
|
"metric": 10,
|
||||||
|
"accessible": True,
|
||||||
|
"used": True,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
return topotest.json_cmp(output, expected)
|
||||||
|
|
||||||
# r2, 10.0.2.2/32 with aigp-metric 2
|
# r2, 10.0.2.2/32 with aigp-metric 2
|
||||||
test_func = functools.partial(_bgp_check_aigp_metric, r2, "10.0.2.2/32", 2)
|
test_func = functools.partial(_bgp_check_aigp_metric, r2, "10.0.2.2/32", 2)
|
||||||
@ -122,6 +161,11 @@ def test_bgp_aigp_rr():
|
|||||||
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
|
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
|
||||||
assert result is None, "aigp-metric for 10.0.2.2/32 is not 12"
|
assert result is None, "aigp-metric for 10.0.2.2/32 is not 12"
|
||||||
|
|
||||||
|
# r1, check if the local route is favored over AIGP comparison
|
||||||
|
test_func = functools.partial(_bgp_check_aigp_bestpath)
|
||||||
|
_, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
|
||||||
|
assert result is None, "Local route is not favored over AIGP in best-path selection"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = ["-s"] + sys.argv[1:]
|
args = ["-s"] + sys.argv[1:]
|
||||||
|
Loading…
Reference in New Issue
Block a user