Skip to content

Commit 373be27

Browse files
committed
topotests: add test to check for correct wide srv6 func used
Add a test that checks that if a sid manager uses the wide func range, then BGP detects it and changes the BGP update and ZEBRA route function length settings accordingly. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
1 parent 5a10caf commit 373be27

File tree

3 files changed

+124
-10
lines changed

3 files changed

+124
-10
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"2001:db8:3:fff7:fe4b::/128":[
3+
{
4+
"prefix":"2001:db8:3:fff7:fe4b::/128",
5+
"prefixLen":128,
6+
"protocol":"bgp",
7+
"selected":true,
8+
"destSelected":true,
9+
"distance":20,
10+
"metric":0,
11+
"installed":true,
12+
"table":254,
13+
"nexthops":[
14+
{
15+
"flags":3,
16+
"fib":true,
17+
"directlyConnected":true,
18+
"interfaceName":"Vrf10",
19+
"active":true,
20+
"weight":1,
21+
"seg6local":{
22+
"action":"uDT46",
23+
"sidStructure":{
24+
"blockLen":32,
25+
"nodeLen":16,
26+
"funcLen":32,
27+
"argLen":0
28+
}
29+
}
30+
}
31+
]
32+
}
33+
]
34+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"65003:10":{
3+
"prefix":"192.168.3.0/24",
4+
"advertisedTo":{
5+
"2001:db8:13::1":{
6+
"hostname":"r1"
7+
}
8+
},
9+
"pathCount":1,
10+
"paths":[
11+
{
12+
"aspath":{
13+
"string":"Local",
14+
"segments":[
15+
],
16+
"length":0
17+
},
18+
"nhVrfName":"Vrf10",
19+
"announceNexthopSelf":true,
20+
"origin":"incomplete",
21+
"metric":0,
22+
"weight":32768,
23+
"valid":true,
24+
"sourced":true,
25+
"local":true,
26+
"bestpath":{
27+
"overall":true,
28+
"selectionReason":"First path received"
29+
},
30+
"extendedCommunity":{
31+
"string":"RT:0:10"
32+
},
33+
"originatorId":"192.0.2.3",
34+
"remoteLabel":3,
35+
"remoteTransposedSid":"2001:db8:3:fff7:fe4b::",
36+
"remoteSid":"2001:db8:3:fff7:fe4b::",
37+
"remoteSidStructure":{
38+
"locatorBlockLen": 32,
39+
"locatorNodeLen":16,
40+
"functionLen":32,
41+
"argumentLen":0,
42+
"transpositionLen":0,
43+
"transpositionOffset":0
44+
},
45+
"nexthops":[
46+
{
47+
"ip":"0.0.0.0",
48+
"hostname":"r3",
49+
"afi":"ipv4",
50+
"metric":0,
51+
"accessible":true,
52+
"used":true
53+
}
54+
],
55+
"peer":{
56+
"peerId":"0.0.0.0",
57+
"routerId":"192.0.2.3"
58+
}
59+
}
60+
]
61+
}
62+
}

tests/topotests/bgp_srv6_sid_explicit/test_bgp_srv6_sid_explicit.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,17 @@ def check_explicit_srv6_sid_allocated(router, expected_file, exact=False):
9797
assert result is None, "Failed"
9898

9999

100-
def _check_sent_bgp_vpn_srv6_sid(router, expected_route_file):
100+
def _check_sent_bgp_vpn_srv6_sid(router, expected_route_file, prefix):
101101
logger.info("checking bgp vpn route with SRv6 SIDs in sending end")
102-
output = json.loads(router.vtysh_cmd("show bgp ipv4 vpn 192.168.1.0/24 json"))
102+
output = json.loads(router.vtysh_cmd(f"show bgp ipv4 vpn {prefix} json"))
103103
expected = open_json_file("{}/{}".format(CWD, expected_route_file))
104104
return topotest.json_cmp(output, expected)
105105

106106

107-
def check_sent_bgp_vpn_srv6_sid(router, expected_file):
108-
func = functools.partial(_check_sent_bgp_vpn_srv6_sid, router, expected_file)
107+
def check_sent_bgp_vpn_srv6_sid(router, expected_file, prefix="192.168.1.0/24"):
108+
func = functools.partial(
109+
_check_sent_bgp_vpn_srv6_sid, router, expected_file, prefix
110+
)
109111
_, result = topotest.run_and_expect(func, None, count=15, wait=1)
110112
assert result is None, "Failed"
111113

@@ -144,22 +146,28 @@ def check_rcvd_bgp_vrf_srv6_sid(router, vrf_name, expected_file):
144146
assert result is None, "Failed"
145147

146148

147-
def _check_rcvd_zebra_vrf_srv6_sid(router, vrf_name, expected_route_file):
149+
def _check_rcvd_zebra_vrf_srv6_sid(
150+
router, vrf_name, expected_route_file, prefix, family
151+
):
148152
logger.info(
149-
"checking zebra vrf {} ipv4 route with SRv6 SIDs in receiving end".format(
150-
vrf_name
153+
"checking zebra vrf {} {} route with SRv6 SIDs in receiving end".format(
154+
vrf_name, family
151155
)
152156
)
153157
output = json.loads(
154-
router.vtysh_cmd("show ip route vrf {} 192.168.1.0/24 json".format(vrf_name))
158+
router.vtysh_cmd(
159+
"show {} route vrf {} {} json".format(family, vrf_name, prefix)
160+
)
155161
)
156162
expected = open_json_file("{}/{}".format(CWD, expected_route_file))
157163
return topotest.json_cmp(output, expected)
158164

159165

160-
def check_rcvd_zebra_vrf_srv6_sid(router, vrf_name, expected_file):
166+
def check_rcvd_zebra_vrf_srv6_sid(
167+
router, vrf_name, expected_file, prefix="192.168.1.0/24", family="ip"
168+
):
161169
func = functools.partial(
162-
_check_rcvd_zebra_vrf_srv6_sid, router, vrf_name, expected_file
170+
_check_rcvd_zebra_vrf_srv6_sid, router, vrf_name, expected_file, prefix, family
163171
)
164172
_, result = topotest.run_and_expect(func, None, count=15, wait=1)
165173
assert result is None, "Failed"
@@ -430,6 +438,16 @@ def test_explicit_srv6_sid_explicit_wide_index_1():
430438
check_explicit_srv6_sid_allocated(
431439
router, "expected_explicit_srv6_sid_wide_allocated_1.json"
432440
)
441+
check_rcvd_zebra_vrf_srv6_sid(
442+
router,
443+
"default",
444+
"expected_allocated_srv6_sid_seg6local_wide_1.json",
445+
"2001:db8:3:fff7:fe4b::/128",
446+
"ipv6",
447+
)
448+
check_sent_bgp_vpn_srv6_sid(
449+
router, "expected_sent_bgp_vpn_srv6_sid_wide_1.json", "192.168.3.0/24"
450+
)
433451

434452

435453
# Configure 'sid vpn per-vrf export explicit X:X::X:X'

0 commit comments

Comments
 (0)