2 # SPDX-License-Identifier: ISC
4 # test_bgp_vpnv6_per_nexthop_label.py
6 # Copyright 2023 6WIND S.A.
10 test_bgp_vpnv6_per_nexthop_label.py: Test the FRR BGP daemon using EBGP peering
11 Let us exchange VPNv6 updates between both devices
12 Updates from r1 will originate from the same RD, but will have separate
18 | | | +----+--------+ +----------+
19 +----------+ | 192::2::1 |vrf | r1 |192:168::/112 | r2 |
20 +-------------------+ | 1+--------------+ |
21 +----------+ | |VRF1|AS65500 | | AS65501 |
22 | r12 | | +--------------+ | VPNV4| |VPNV4 |
23 |192::2:12 +---+ |192:168::255:1+-+--+--------+ +----------+
37 from functools
import partial
41 # Save the Current Working Directory to find configuration files.
42 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
43 sys
.path
.append(os
.path
.join(CWD
, "../"))
45 # pylint: disable=C0413
46 # Import topogen and topotest helpers
47 from lib
import topotest
48 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
49 from lib
.topolog
import logger
52 pytestmark
= [pytest
.mark
.bgpd
]
54 PREFIXES_R11
= ["172:31::11/128", "172:31::20/128", "172:31::111/128"]
55 PREFIXES_R12
= ["172:31::12/128"]
56 PREFIXES_REDIST_R12
= ["172:31::15/128"]
57 PREFIXES_R13
= ["172:31::13/128"]
58 PREFIXES_REDIST_R14
= ["172:31::14/128"]
59 PREFIXES_CONNECTED
= ["192:168::255/112", "192:2::/64"]
68 tgen
.add_router("r11")
69 tgen
.add_router("r12")
70 tgen
.add_router("r13")
71 tgen
.add_router("r14")
74 switch
= tgen
.add_switch("s1")
75 switch
.add_link(tgen
.gears
["r1"])
76 switch
.add_link(tgen
.gears
["r2"])
78 switch
= tgen
.add_switch("s2")
79 switch
.add_link(tgen
.gears
["r1"])
80 switch
.add_link(tgen
.gears
["r11"])
81 switch
.add_link(tgen
.gears
["r12"])
82 switch
.add_link(tgen
.gears
["rr"])
84 switch
= tgen
.add_switch("s3")
85 switch
.add_link(tgen
.gears
["r2"])
87 switch
= tgen
.add_switch("s4")
88 switch
.add_link(tgen
.gears
["r1"])
89 switch
.add_link(tgen
.gears
["r13"])
91 switch
= tgen
.add_switch("s5")
92 switch
.add_link(tgen
.gears
["r1"])
93 switch
.add_link(tgen
.gears
["r14"])
96 def _populate_iface():
99 "ip link add vrf1 type vrf table 10",
100 "echo 100000 > /proc/sys/net/mpls/platform_labels",
101 "ip link set dev vrf1 up",
102 "ip link set dev {0}-eth1 master vrf1",
103 "echo 1 > /proc/sys/net/mpls/conf/{0}-eth0/input",
106 "ip link set dev {0}-eth2 master vrf1",
109 "ip link set dev {0}-eth0 down",
110 "echo 1 > /proc/sys/net/ipv6/conf/{0}-eth0/addr_gen_mode",
111 "ip link set dev {0}-eth0 up",
114 for cmd
in cmds_list
:
115 input = cmd
.format("r1")
116 logger
.info("input: " + cmd
)
117 output
= tgen
.net
["r1"].cmd(cmd
.format("r1"))
118 logger
.info("output: " + output
)
120 for cmd
in cmds_list_plus
:
121 input = cmd
.format("r1")
122 logger
.info("input: " + cmd
)
123 output
= tgen
.net
["r1"].cmd(cmd
.format("r1"))
124 logger
.info("output: " + output
)
126 for cmd
in cmds_list
:
127 input = cmd
.format("r2")
128 logger
.info("input: " + cmd
)
129 output
= tgen
.net
["r2"].cmd(cmd
.format("r2"))
130 logger
.info("output: " + output
)
132 for rtr
in ("r11", "r13"):
133 for cmd
in cmd_no_ll
:
134 input = cmd
.format(rtr
)
135 logger
.info("input: " + cmd
)
136 output
= tgen
.net
[rtr
].cmd(cmd
.format(rtr
))
137 logger
.info("output: " + output
)
140 def setup_module(mod
):
141 "Sets up the pytest environment"
142 tgen
= Topogen(build_topo
, mod
.__name
__)
143 tgen
.start_topology()
145 router_list
= tgen
.routers()
148 for rname
, router
in router_list
.items():
150 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
153 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
156 # Initialize all routers.
160 def teardown_module(_mod
):
161 "Teardown the pytest environment"
167 def bgp_vpnv6_table_check(router
, group
, label_list
=None, label_value_expected
=None):
169 Dump and check that vpnv6 entries have the same MPLS label value
170 * 'router': the router to check
171 * 'group': the list of prefixes to check. a single label value for the group has to be found
172 * 'label_list': check that the label values are not present in the vpnv6 entries
173 * that list is updated with the present label value
174 * 'label_value_expected': check that the mpls label read is the same as that value
177 stored_label_inited
= False
179 dump
= router
.vtysh_cmd("show bgp ipv6 vpn {} json".format(prefix
), isjson
=True)
180 for rd
, pathes
in dump
.items():
181 for path
in pathes
["paths"]:
183 "remoteLabel" in path
.keys()
184 ), "{0}, {1}, remoteLabel not present".format(router
.name
, prefix
)
186 "{0}, {1}, label value is {2}".format(
187 router
.name
, prefix
, path
["remoteLabel"]
190 if stored_label_inited
:
192 path
["remoteLabel"] == stored_label
193 ), "{0}, {1}, label value not expected one (expected {2}, observed {3}".format(
194 router
.name
, prefix
, stored_label
, path
["remoteLabel"]
197 stored_label
= path
["remoteLabel"]
198 stored_label_inited
= True
199 if label_list
is not None:
201 stored_label
not in label_list
202 ), "{0}, {1}, label already detected in a previous prefix".format(
205 label_list
.add(stored_label
)
207 if label_value_expected
:
209 path
["remoteLabel"] == label_value_expected
210 ), "{0}, {1}, label value not expected (expected {2}, observed {3}".format(
211 router
.name
, prefix
, label_value_expected
, path
["remoteLabel"]
215 def bgp_vpnv6_table_check_all(router
, label_list
=None, same
=False):
217 Dump and check that vpnv6 entries are correctly configured with specific label values
218 * 'router': the router to check
219 * 'label_list': check that the label values are not present in the vpnv6 entries
220 * that list is updated with the present label value found.
221 * 'same': by default, set to False. Addresses groups are classified by addresses.
222 * if set to True, all entries of all groups should have a unique label value
225 bgp_vpnv6_table_check(
229 + PREFIXES_REDIST_R12
231 + PREFIXES_REDIST_R14
232 + PREFIXES_CONNECTED
,
233 label_list
=label_list
,
244 bgp_vpnv6_table_check(router
, group
=group
, label_list
=label_list
)
247 def mpls_table_check(router
, blacklist
=None, label_list
=None, whitelist
=None):
249 Dump and check 'show mpls table json' output. An assert is triggered in case test fails
250 * 'router': the router to check
251 * 'blacklist': the list of nexthops (IP or interface) that should not be on output
252 * 'label_list': the list of labels that should be in inLabel value
253 * 'whitelist': the list of nexthops (IP or interface) that should be on output
257 nexthop_list
.append(blacklist
)
258 logger
.info("Checking MPLS labels on {}".format(router
.name
))
259 dump
= router
.vtysh_cmd("show mpls table json", isjson
=True)
260 for in_label
, label_info
in dump
.items():
261 if label_list
is not None:
262 label_list
.add(in_label
)
263 for nh
in label_info
["nexthops"]:
265 nh
["installed"] == True and nh
["type"] == "BGP"
266 ), "{}, show mpls table, nexthop is not installed".format(router
.name
)
267 if "nexthop" in nh
.keys():
269 nh
["nexthop"] not in nexthop_list
270 ), "{}, show mpls table, duplicated or blacklisted nexthop address".format(
273 nexthop_list
.append(nh
["nexthop"])
274 elif "interface" in nh
.keys():
276 nh
["interface"] not in nexthop_list
277 ), "{}, show mpls table, duplicated or blacklisted nexthop interface".format(
280 nexthop_list
.append(nh
["interface"])
284 ), "{}, show mpls table, entry with neither nexthop nor interface".format(
289 for entry
in whitelist
:
291 entry
in nexthop_list
292 ), "{}, show mpls table, entry with nexthop {} not present in nexthop list".format(
297 def check_show_bgp_vpn_prefix_not_found(router
, ipversion
, prefix
, rd
, label
=None):
299 router
.vtysh_cmd("show bgp {} vpn {} json".format(ipversion
, prefix
))
302 expected
= {rd
: {"prefix": prefix
, "paths": [{"remoteLabel": label
}]}}
304 expected
= {rd
: {"prefix": prefix
}}
305 ret
= topotest
.json_cmp(output
, expected
)
311 def check_show_bgp_vpn_prefix_found(router
, ipversion
, prefix
, rd
):
313 router
.vtysh_cmd("show bgp {} vpn {} json".format(ipversion
, prefix
))
315 expected
= {rd
: {"prefix": prefix
}}
316 return topotest
.json_cmp(output
, expected
)
319 def check_show_mpls_table_entry_label_found(router
, inlabel
, interface
):
320 output
= json
.loads(router
.vtysh_cmd("show mpls table {} json".format(inlabel
)))
324 "nexthops": [{"interface": interface
}],
326 return topotest
.json_cmp(output
, expected
)
329 def check_show_mpls_table_entry_label_not_found(router
, inlabel
):
330 output
= json
.loads(router
.vtysh_cmd("show mpls table {} json".format(inlabel
)))
331 expected
= {"inlabel": inlabel
, "installed": True}
332 ret
= topotest
.json_cmp(output
, expected
)
338 def mpls_entry_get_interface(router
, label
):
340 Assert that the label is in MPLS table
341 Assert an outgoing interface is programmed
342 return the outgoing interface
344 outgoing_interface
= None
346 logger
.info("Checking MPLS labels on {}".format(router
.name
))
347 dump
= router
.vtysh_cmd("show mpls table {} json".format(label
), isjson
=True)
348 assert dump
, "{}, show mpls table, inLabel {} not found".format(router
.name
, label
)
350 for nh
in dump
["nexthops"]:
352 "interface" in nh
.keys()
353 ), "{}, show mpls table, nexthop interface not present for MPLS entry {}".format(
357 outgoing_interface
= nh
["interface"]
359 return outgoing_interface
362 def test_protocols_convergence():
364 Assert that all protocols have converged
365 statuses as they depend on it.
368 if tgen
.routers_have_failure():
369 pytest
.skip(tgen
.errors
)
371 # Check BGP IPv6 routing tables on VRF1 of r1
372 logger
.info("Checking BGP IPv6 routes for convergence on r1 VRF1")
373 router
= tgen
.gears
["r1"]
374 json_file
= "{}/{}/bgp_ipv6_routes_vrf1.json".format(CWD
, router
.name
)
376 expected
= json
.loads(open(json_file
).read())
378 topotest
.router_json_cmp
,
380 "show bgp vrf vrf1 ipv6 json",
383 _
, result
= topotest
.run_and_expect(test_func
, None, count
=20, wait
=0.5)
384 assertmsg
= '"{}" JSON output mismatches'.format(router
.name
)
385 assert result
is None, assertmsg
387 logger
.info("Checking BGP VPNv6 routes for convergence on r2")
388 router
= tgen
.gears
["r2"]
389 json_file
= "{}/{}/bgp_vpnv6_routes.json".format(CWD
, router
.name
)
390 expected
= json
.loads(open(json_file
).read())
392 topotest
.router_json_cmp
,
394 "show bgp ipv6 vpn json",
397 _
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
398 assertmsg
= '"{}" JSON output mismatches'.format(router
.name
)
399 assert result
is None, assertmsg
401 # Check BGP labels received on r2
402 logger
.info("Checking BGP VPNv6 labels on r2")
404 bgp_vpnv6_table_check_all(tgen
.gears
["r2"], label_list
)
406 # Check MPLS labels received on r1
407 mpls_table_check(tgen
.gears
["r1"], label_list
)
410 def test_flapping_bgp_vrf_down():
412 Turn down a remote BGP session
415 if tgen
.routers_have_failure():
416 pytest
.skip(tgen
.errors
)
417 logger
.info("Unpeering BGP on r11")
418 tgen
.gears
["r11"].vtysh_cmd(
419 "configure terminal\nrouter bgp 65500\nno neighbor 192:2::100\n",
423 def _bgp_prefix_not_found(router
, vrf
, ipversion
, prefix
):
426 "show bgp vrf {} {} {} json".format(vrf
, ipversion
, prefix
)
429 expected
= {"prefix": prefix
}
430 ret
= topotest
.json_cmp(output
, expected
)
435 # Check prefix from r11 is not present
436 test_func
= functools
.partial(
437 _bgp_prefix_not_found
, tgen
.gears
["r1"], "vrf1", "ipv6", "172:31::11/128"
439 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
442 ), "r1, prefix 172:31::11/128 from r11 did not disappear. r11 still connected to rr ?"
444 # Check BGP updated received on r2 are not from r11
445 logger
.info("Checking BGP VPNv6 labels on r2")
446 for entry
in PREFIXES_R11
:
447 dump
= tgen
.gears
["r2"].vtysh_cmd(
448 "show bgp ipv6 vpn {} json".format(entry
), isjson
=True
451 assert False, "r2, {}, route distinguisher {} present".format(entry
, rd
)
453 mpls_table_check(tgen
.gears
["r1"], blacklist
=["192:2::11"])
456 def test_flapping_bgp_vrf_up():
458 Turn up a remote BGP session
461 if tgen
.routers_have_failure():
462 pytest
.skip(tgen
.errors
)
463 logger
.info("Peering BGP on r11")
464 tgen
.gears
["r11"].vtysh_cmd(
465 "configure terminal\nrouter bgp 65500\nneighbor 192:2::100 remote-as 65500\n",
468 tgen
.gears
["r11"].vtysh_cmd(
469 "configure terminal\nrouter bgp 65500\naddress-family ipv6 unicast\nneighbor 192:2::100 activate\n",
473 # Check r2 gets prefix 172:31::11/128
474 test_func
= functools
.partial(
475 check_show_bgp_vpn_prefix_found
,
481 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
484 ), "r2, prefix 172:31::11/128 from r11 not present. r11 still disconnected from rr ?"
485 bgp_vpnv6_table_check_all(tgen
.gears
["r2"])
488 def test_recursive_route():
490 Test static recursive route redistributed over BGP
493 if tgen
.routers_have_failure():
494 pytest
.skip(tgen
.errors
)
496 logger
.info("Enabling recursive static route")
497 tgen
.gears
["r1"].vtysh_cmd(
498 "configure terminal\nvrf vrf1\nipv6 route 172:31::30/128 172:31::20\n",
501 logger
.info("Checking BGP VPNv6 labels on r2")
502 # that route should be sent along with label for 192.0.2.11
504 def _prefix30_not_found(router
):
505 output
= json
.loads(router
.vtysh_cmd("show bgp ipv6 vpn 172:31::30/128 json"))
506 expected
= {"444:1": {"prefix": "172:31::30/128"}}
507 ret
= topotest
.json_cmp(output
, expected
)
512 def _prefix30_found(router
):
513 output
= json
.loads(router
.vtysh_cmd("show bgp ipv6 vpn 172:31::30/128 json"))
514 expected
= {"444:1": {"prefix": "172:31::30/128"}}
515 return topotest
.json_cmp(output
, expected
)
517 # Check r2 received vpnv6 update with 172:31::30
518 test_func
= functools
.partial(_prefix30_found
, tgen
.gears
["r2"])
519 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
520 assert success
, "r2, VPNv6 update 172:31::30 not found"
522 # that route should be sent along with label for 192::2:11
523 bgp_vpnv6_table_check(
525 group
=PREFIXES_R11
+ ["172:31::30/128"],
529 logger
.info("Dumping label nexthop table")
530 tgen
.gears
["r1"].vtysh_cmd("show bgp vrf vrf1 label-nexthop detail", isjson
=False)
531 logger
.info("Dumping nexthop table")
532 tgen
.gears
["r1"].vtysh_cmd("show bgp vrf vrf1 nexthop detail", isjson
=False)
534 logger
.info("Disabling recursive static route")
535 tgen
.gears
["r1"].vtysh_cmd(
536 "configure terminal\nvrf vrf1\nno ipv6 route 172:31::30/128 172:31::20\n",
540 # Check r2 removed 172:31::30 vpnv6 update
541 test_func
= functools
.partial(_prefix30_not_found
, tgen
.gears
["r2"])
542 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
543 assert success
, "r2, VPNv6 update 172:31::30 still present"
546 def test_prefix_changes_interface():
548 Test BGP update for a given prefix learnt on different interface
551 if tgen
.routers_have_failure():
552 pytest
.skip(tgen
.errors
)
554 logger
.info("Enabling a 172:31::50/128 prefix for r11")
555 tgen
.gears
["r11"].vtysh_cmd(
556 "configure terminal\nrouter bgp\naddress-family ipv6 unicast\nnetwork 172:31::50/128",
560 # Check r2 received vpnv6 update with 172:31::50
561 test_func
= functools
.partial(
562 check_show_bgp_vpn_prefix_found
,
568 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
569 assert success
, "r2, VPNv6 update 172:31::50 not found"
572 logger
.info("Dumping label nexthop table")
573 tgen
.gears
["r1"].vtysh_cmd("show bgp vrf vrf1 label-nexthop detail", isjson
=False)
576 bgp_vpnv6_table_check(
578 group
=PREFIXES_R11
+ ["172:31::50/128"],
579 label_list
=label_list
,
584 ), "Multiple Label values found for updates from r11 found"
586 oldlabel
= label_list
.pop()
587 logger
.info("r1, getting the outgoing interface used by label {}".format(oldlabel
))
588 old_outgoing_interface
= mpls_entry_get_interface(tgen
.gears
["r1"], oldlabel
)
590 "r1, outgoing interface used by label {} is {}".format(
591 oldlabel
, old_outgoing_interface
595 logger
.info("Moving the 172:31::50/128 prefix from r11 to r13")
596 tgen
.gears
["r11"].vtysh_cmd(
597 "configure terminal\nrouter bgp\naddress-family ipv6 unicast\nno network 172:31::50/128",
600 tgen
.gears
["r13"].vtysh_cmd(
601 "configure terminal\nrouter bgp\naddress-family ipv6 unicast\nnetwork 172:31::50/128",
605 # Check r2 removed 172:31::50 vpnv6 update with old label
606 test_func
= functools
.partial(
607 check_show_bgp_vpn_prefix_not_found
,
614 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
617 ), "r2, vpnv6 update 172:31::50 with old label {0} still present".format(oldlabel
)
620 logger
.info("Dumping label nexthop table")
621 tgen
.gears
["r1"].vtysh_cmd("show bgp vrf vrf1 label-nexthop detail", isjson
=False)
623 # Check r2 received new 172:31::50 vpnv6 update
624 test_func
= functools
.partial(
625 check_show_bgp_vpn_prefix_found
,
631 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
632 assert success
, "r2, vpnv6 update 172:31::50 not found"
635 bgp_vpnv6_table_check(
637 group
=["172:31::13/128", "172:31::50/128"],
638 label_list
=label_list
,
642 ), "Multiple Label values found for updates from r13 found"
644 newlabel
= label_list
.pop()
645 logger
.info("r1, getting the outgoing interface used by label {}".format(newlabel
))
646 new_outgoing_interface
= mpls_entry_get_interface(tgen
.gears
["r1"], newlabel
)
648 "r1, outgoing interface used by label {} is {}".format(
649 newlabel
, new_outgoing_interface
652 if old_outgoing_interface
== new_outgoing_interface
:
653 assert 0, "r1, outgoing interface did not change whereas BGP update moved"
655 logger
.info("Restoring state by removing the 172:31::50/128 prefix from r13")
656 tgen
.gears
["r13"].vtysh_cmd(
657 "configure terminal\nrouter bgp\naddress-family ipv6 unicast\nno network 172:31::50/128",
662 def test_changing_default_label_value():
664 Change the MPLS default value
665 Check that r1 VPNv6 entries have the 222 label value
666 Check that MPLS entry with old label value is no more present
667 Check that MPLS entry for local traffic has inLabel set to 222
670 if tgen
.routers_have_failure():
671 pytest
.skip(tgen
.errors
)
673 router
= tgen
.gears
["r1"]
675 # counting the number of labels used in the VPNv6 table
677 logger
.info("r1, VPNv6 table, check the number of labels used before modification")
678 bgp_vpnv6_table_check_all(router
, label_list
)
679 old_len
= len(label_list
)
682 ), "r1, number of labels used should be greater than 1, oberved {} ".format(old_len
)
684 logger
.info("r1, vrf1, changing the default MPLS label value to export to 222")
686 "configure terminal\nrouter bgp 65500 vrf vrf1\naddress-family ipv6 unicast\nlabel vpn export 222\n",
690 # Check r1 updated the MPLS entry with the 222 label value
692 "r1, mpls table, check that MPLS entry with inLabel set to 222 has vrf1 interface"
694 test_func
= functools
.partial(
695 check_show_mpls_table_entry_label_found
, router
, 222, "vrf1"
697 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
698 assert success
, "r1, mpls entry with label 222 not found"
700 # check label repartition is ok
701 logger
.info("r1, VPNv6 table, check the number of labels used after modification")
703 bgp_vpnv6_table_check_all(router
, label_list
)
704 new_len
= len(label_list
)
707 ), "r1, number of labels after modification differ from previous, observed {}, expected {} ".format(
712 "r1, VPNv6 table, check that prefixes that were using the vrf label have refreshed the label value to 222"
714 bgp_vpnv6_table_check(router
, group
=PREFIXES_CONNECTED
, label_value_expected
=222)
717 def test_unconfigure_allocation_mode_nexthop():
719 Test unconfiguring allocation mode per nexthop
720 Check on r2 that new MPLS label values have been propagated
721 Check that show mpls table has no entry with label 17 (previously used)
722 Check that all VPN updates on r1 should have label value moved to 222
723 Check that show mpls table will only have 222 label value
726 if tgen
.routers_have_failure():
727 pytest
.skip(tgen
.errors
)
729 logger
.info("Unconfiguring allocation mode per nexthop")
730 router
= tgen
.gears
["r1"]
731 dump
= router
.vtysh_cmd(
732 "configure terminal\nrouter bgp 65500 vrf vrf1\naddress-family ipv6 unicast\nno label vpn export allocation-mode per-nexthop\n",
736 # Check r1 updated the MPLS entry with the 222 label value
738 "r1, mpls table, check that MPLS entry with inLabel set to 17 is not present"
740 test_func
= functools
.partial(
741 check_show_mpls_table_entry_label_not_found
, router
, 17
743 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
744 assert success
, "r1, mpls entry with label 17 still present"
746 # Check vpnv6 routes from r1
747 logger
.info("Checking VPNv6 routes on r1")
749 bgp_vpnv6_table_check_all(router
, label_list
=label_list
, same
=True)
750 assert len(label_list
) == 1, "r1, multiple Label values found for VPNv6 updates"
752 new_label
= label_list
.pop()
755 ), "r1, wrong label value in VPNv6 table, expected 222, observed {}".format(
759 # Check mpls table with 222 value
760 logger
.info("Checking MPLS values on show mpls table of r1")
763 mpls_table_check(router
, label_list
=label_list
)
766 def test_reconfigure_allocation_mode_nexthop():
768 Test re-configuring allocation mode per nexthop
769 Check that show mpls table has no entry with label 17
770 Check that all VPN updates on r1 should have multiple label values and not only 222
771 Check that show mpls table will have multiple label values and not only 222
774 if tgen
.routers_have_failure():
775 pytest
.skip(tgen
.errors
)
777 logger
.info("Reconfiguring allocation mode per nexthop")
778 router
= tgen
.gears
["r1"]
779 dump
= router
.vtysh_cmd(
780 "configure terminal\nrouter bgp 65500 vrf vrf1\naddress-family ipv6 unicast\nlabel vpn export allocation-mode per-nexthop\n",
784 # Check that show mpls table has no entry with label 17
786 "r1, mpls table, check that MPLS entry with inLabel set to 17 is present"
788 test_func
= functools
.partial(
789 check_show_mpls_table_entry_label_not_found
, router
, 17
791 success
, result
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
792 assert success
, "r1, mpls entry with label 17 still present"
794 # Check vpnv6 routes from r1
795 logger
.info("Checking VPNv6 routes on r1")
797 bgp_vpnv6_table_check_all(router
, label_list
=label_list
)
798 assert len(label_list
) != 1, "r1, only 1 label values found for VPNv6 updates"
800 # Check mpls table with all values
801 logger
.info("Checking MPLS values on show mpls table of r1")
802 mpls_table_check(router
, label_list
=label_list
)
805 def test_memory_leak():
806 "Run the memory leak test and report results."
808 if not tgen
.is_memleak_enabled():
809 pytest
.skip("Memory leak test/report is disabled")
811 tgen
.report_memory_leaks()
814 if __name__
== "__main__":
815 args
= ["-s"] + sys
.argv
[1:]
816 sys
.exit(pytest
.main(args
))