1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
|
#!/usr/bin/env python
#
# test_bgp_auth.py
# Part of NetDEF Topology Tests
#
# Copyright (c) 2020 by Volta Networks
#
# Permission to use, copy, modify, and/or distribute this software
# for any purpose with or without fee is hereby granted, provided
# that the above copyright notice and this permission notice appear
# in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
#
"""
test_bgp_auth.py: Test BGP Md5 Authentication
+------+
+--------| |--------+
| +------| R1 |------+ |
| | -----| |----+ | |
| | | +------+ | | |
| | | | | |
+------+ +------+
| |------------| |
| R2 |------------| R3 |
| |------------| |
+------+ +------+
setup is 3 routers with 3 links between each each link in a different vrf
Default, blue and red respectively
Tests check various fiddling with passwords and checking that the peer
establishment is as expected and passwords are not leaked across sockets
for bgp instances
"""
import os
import sys
import json
import platform
import pytest
from time import sleep
# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
# Required to instantiate the topology builder class.
ERROR_LIST = ["Malformed", "Failure", "Unknown", "Incomplete"]
pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
class InvalidCLIError(Exception):
"""Raise when the CLI command is wrong"""
def build_topo(tgen):
# Create routers
tgen.add_router("R1")
tgen.add_router("R2")
tgen.add_router("R3")
# R1-R2 1
switch = tgen.add_switch("s1")
switch.add_link(tgen.gears["R1"])
switch.add_link(tgen.gears["R2"])
# R1-R3 1
switch = tgen.add_switch("s2")
switch.add_link(tgen.gears["R1"])
switch.add_link(tgen.gears["R3"])
# R2-R3 1
switch = tgen.add_switch("s3")
switch.add_link(tgen.gears["R2"])
switch.add_link(tgen.gears["R3"])
# R1-R2 2
switch = tgen.add_switch("s4")
switch.add_link(tgen.gears["R1"])
switch.add_link(tgen.gears["R2"])
# R1-R3 2
switch = tgen.add_switch("s5")
switch.add_link(tgen.gears["R1"])
switch.add_link(tgen.gears["R3"])
# R2-R3 2
switch = tgen.add_switch("s6")
switch.add_link(tgen.gears["R2"])
switch.add_link(tgen.gears["R3"])
# R1-R2 3
switch = tgen.add_switch("s7")
switch.add_link(tgen.gears["R1"])
switch.add_link(tgen.gears["R2"])
# R1-R3 2
switch = tgen.add_switch("s8")
switch.add_link(tgen.gears["R1"])
switch.add_link(tgen.gears["R3"])
# R2-R3 2
switch = tgen.add_switch("s9")
switch.add_link(tgen.gears["R2"])
switch.add_link(tgen.gears["R3"])
def setup_module(mod):
"Sets up the pytest environment"
# This function initiates the topology build with Topogen...
tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
tgen.start_topology()
r1 = tgen.gears["R1"]
r2 = tgen.gears["R2"]
r3 = tgen.gears["R3"]
# blue vrf
r1.run("ip link add blue type vrf table 1001")
r1.run("ip link set up dev blue")
r2.run("ip link add blue type vrf table 1001")
r2.run("ip link set up dev blue")
r3.run("ip link add blue type vrf table 1001")
r3.run("ip link set up dev blue")
r1.run("ip link add lo1 type dummy")
r1.run("ip link set lo1 master blue")
r1.run("ip link set up dev lo1")
r2.run("ip link add lo1 type dummy")
r2.run("ip link set up dev lo1")
r2.run("ip link set lo1 master blue")
r3.run("ip link add lo1 type dummy")
r3.run("ip link set up dev lo1")
r3.run("ip link set lo1 master blue")
r1.run("ip link set R1-eth2 master blue")
r1.run("ip link set R1-eth3 master blue")
r2.run("ip link set R2-eth2 master blue")
r2.run("ip link set R2-eth3 master blue")
r3.run("ip link set R3-eth2 master blue")
r3.run("ip link set R3-eth3 master blue")
r1.run("ip link set up dev R1-eth2")
r1.run("ip link set up dev R1-eth3")
r2.run("ip link set up dev R2-eth2")
r2.run("ip link set up dev R2-eth3")
r3.run("ip link set up dev R3-eth2")
r3.run("ip link set up dev R3-eth3")
# red vrf
r1.run("ip link add red type vrf table 1002")
r1.run("ip link set up dev red")
r2.run("ip link add red type vrf table 1002")
r2.run("ip link set up dev red")
r3.run("ip link add red type vrf table 1002")
r3.run("ip link set up dev red")
r1.run("ip link add lo2 type dummy")
r1.run("ip link set lo2 master red")
r1.run("ip link set up dev lo2")
r2.run("ip link add lo2 type dummy")
r2.run("ip link set up dev lo2")
r2.run("ip link set lo2 master red")
r3.run("ip link add lo2 type dummy")
r3.run("ip link set up dev lo2")
r3.run("ip link set lo2 master red")
r1.run("ip link set R1-eth4 master red")
r1.run("ip link set R1-eth5 master red")
r2.run("ip link set R2-eth4 master red")
r2.run("ip link set R2-eth5 master red")
r3.run("ip link set R3-eth4 master red")
r3.run("ip link set R3-eth5 master red")
r1.run("ip link set up dev R1-eth4")
r1.run("ip link set up dev R1-eth5")
r2.run("ip link set up dev R2-eth4")
r2.run("ip link set up dev R2-eth5")
r3.run("ip link set up dev R3-eth4")
r3.run("ip link set up dev R3-eth5")
# This is a sample of configuration loading.
router_list = tgen.routers()
# For all registred routers, load the zebra configuration file
for rname, router in router_list.items():
router.load_config(
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
)
router.load_config(
TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname))
)
router.load_config(
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
)
# After loading the configurations, this function loads configured daemons.
tgen.start_router()
def teardown_module(mod):
"Teardown the pytest environment"
tgen = get_topogen()
# This function tears down the whole topology.
tgen.stop_topology()
def vrf_str(vrf):
if vrf == "":
vrf_str = ""
else:
vrf_str = "vrf {}".format(vrf)
return vrf_str
def peer_name(rtr, prefix, vrf):
"generate VRF string for CLI"
if vrf == "":
vrf_str = ""
else:
vrf_str = "_" + vrf
if prefix == "yes":
if rtr == "R2":
return "TWO_GROUP" + vrf_str
else:
return "THREE_GROUP" + vrf_str
else:
if rtr == "R2":
return "2.2.2.2"
else:
return "3.3.3.3"
def print_diag(vrf):
"print failure disagnostics"
tgen = get_topogen()
router_list = tgen.routers()
for rname, router in router_list.items():
print(rname + ":")
print(router.vtysh_cmd("show run"))
print(router.vtysh_cmd("show ip route {}".format(vrf_str(vrf))))
print(router.vtysh_cmd("show bgp {} neighbor".format(vrf_str(vrf))))
def configure(conf_file):
"configure from a file"
tgen = get_topogen()
router_list = tgen.routers()
for rname, router in router_list.items():
with open(
os.path.join(CWD, "{}/{}").format(router.name, conf_file), "r+"
) as cfg:
new_config = cfg.read()
output = router.vtysh_multicmd(new_config, pretty_output=False)
for out_err in ERROR_LIST:
if out_err.lower() in output.lower():
raise InvalidCLIError("%s" % output)
def clear_bgp():
"clear bgp configuration for a vrf"
tgen = get_topogen()
r1 = tgen.gears["R1"]
r2 = tgen.gears["R2"]
r3 = tgen.gears["R3"]
r1.vtysh_cmd("conf t\nno router bgp 65001")
r2.vtysh_cmd("conf t\nno router bgp 65002")
r3.vtysh_cmd("conf t\nno router bgp 65003")
r1.vtysh_cmd("conf t\nno router bgp 65001 vrf blue")
r2.vtysh_cmd("conf t\nno router bgp 65002 vrf blue")
r3.vtysh_cmd("conf t\nno router bgp 65003 vrf blue")
r1.vtysh_cmd("conf t\nno router bgp 65001 vrf red")
r2.vtysh_cmd("conf t\nno router bgp 65002 vrf red")
r3.vtysh_cmd("conf t\nno router bgp 65003 vrf red")
def configure_bgp(conf_file):
"configure bgp from file"
clear_bgp()
configure(conf_file)
def clear_ospf():
"clear ospf configuration for a vrf"
tgen = get_topogen()
router_list = tgen.routers()
for rname, router in router_list.items():
router.vtysh_cmd("conf t\nno router ospf")
router.vtysh_cmd("conf t\nno router ospf vrf blue")
router.vtysh_cmd("conf t\nno router ospf vrf red")
def configure_ospf(conf_file):
"configure bgp from file"
clear_ospf()
configure(conf_file)
def check_neigh_state(router, peer, state, vrf=""):
"check BGP neighbor state on a router"
count = 0
matched = False
neigh_output = ""
while count < 125:
if vrf == "":
neigh_output = router.vtysh_cmd("show bgp neighbors {} json".format(peer))
else:
neigh_output = router.vtysh_cmd(
"show bgp vrf {} neighbors {} json".format(vrf, peer)
)
neigh_output_json = json.loads(neigh_output)
if peer in neigh_output_json.keys():
if neigh_output_json[peer]["bgpState"] == state:
matched = True
break
count += 1
sleep(1)
assertmsg = "{} could not peer {} state expected {} got {} ".format(
router.name, peer, state, neigh_output_json[peer]["bgpState"]
)
if matched != True:
print_diag(vrf)
assert matched == True, assertmsg
def check_all_peers_established(vrf=""):
"standard check for extablished peers per vrf"
tgen = get_topogen()
r1 = tgen.gears["R1"]
r2 = tgen.gears["R2"]
r3 = tgen.gears["R3"]
# do r1 last as he might be the dynamic one
check_neigh_state(r2, "1.1.1.1", "Established", vrf)
check_neigh_state(r2, "3.3.3.3", "Established", vrf)
check_neigh_state(r3, "1.1.1.1", "Established", vrf)
check_neigh_state(r3, "2.2.2.2", "Established", vrf)
check_neigh_state(r1, "2.2.2.2", "Established", vrf)
check_neigh_state(r1, "3.3.3.3", "Established", vrf)
def check_vrf_peer_remove_passwords(vrf="", prefix="no"):
"selectively remove passwords checking state"
tgen = get_topogen()
r1 = tgen.gears["R1"]
r2 = tgen.gears["R2"]
r3 = tgen.gears["R3"]
check_all_peers_established(vrf)
r1.vtysh_cmd(
"conf t\nrouter bgp 65001 {}\nno neighbor {} password".format(
vrf_str(vrf), peer_name("R2", prefix, vrf)
)
)
check_neigh_state(r2, "1.1.1.1", "Connect", vrf)
check_neigh_state(r2, "3.3.3.3", "Established", vrf)
check_neigh_state(r3, "1.1.1.1", "Established", vrf)
check_neigh_state(r3, "2.2.2.2", "Established", vrf)
# don't check dynamic downed peers - they are removed
if prefix == "no":
check_neigh_state(r1, "2.2.2.2", "Connect", vrf)
check_neigh_state(r1, "3.3.3.3", "Established", vrf)
r2.vtysh_cmd(
"conf t\nrouter bgp 65002 {}\nno neighbor 1.1.1.1 password".format(vrf_str(vrf))
)
check_all_peers_established(vrf)
r1.vtysh_cmd(
"conf t\nrouter bgp 65001 {}\nno neighbor {} password".format(
vrf_str(vrf), peer_name("R3", prefix, vrf)
)
)
check_neigh_state(r2, "1.1.1.1", "Established", vrf)
check_neigh_state(r2, "3.3.3.3", "Established", vrf)
check_neigh_state(r3, "1.1.1.1", "Connect", vrf)
check_neigh_state(r3, "2.2.2.2", "Established", vrf)
check_neigh_state(r1, "2.2.2.2", "Established", vrf)
# don't check dynamic downed peers - they are removed
if prefix == "no":
check_neigh_state(r1, "3.3.3.3", "Connect", vrf)
r3.vtysh_cmd(
"conf t\nrouter bgp 65003 {}\nno neighbor 1.1.1.1 password".format(vrf_str(vrf))
)
check_all_peers_established(vrf)
r2.vtysh_cmd(
"conf t\nrouter bgp 65002 {}\nno neighbor 3.3.3.3 password".format(vrf_str(vrf))
)
check_neigh_state(r2, "1.1.1.1", "Established", vrf)
check_neigh_state(r2, "3.3.3.3", "Connect", vrf)
check_neigh_state(r3, "1.1.1.1", "Established", vrf)
check_neigh_state(r3, "2.2.2.2", "Connect", vrf)
check_neigh_state(r1, "2.2.2.2", "Established", vrf)
check_neigh_state(r1, "3.3.3.3", "Established", vrf)
r3.vtysh_cmd(
"conf t\nrouter bgp 65003 {}\nno neighbor 2.2.2.2 password".format(vrf_str(vrf))
)
check_all_peers_established(vrf)
def check_vrf_peer_change_passwords(vrf="", prefix="no"):
"selectively change passwords checking state"
tgen = get_topogen()
r1 = tgen.gears["R1"]
r2 = tgen.gears["R2"]
r3 = tgen.gears["R3"]
check_all_peers_established(vrf)
r1.vtysh_cmd(
"conf t\nrouter bgp 65001 {}\nneighbor {} password change1".format(
vrf_str(vrf), peer_name("R2", prefix, vrf)
)
)
check_neigh_state(r2, "1.1.1.1", "Connect", vrf)
check_neigh_state(r2, "3.3.3.3", "Established", vrf)
check_neigh_state(r3, "1.1.1.1", "Established", vrf)
check_neigh_state(r3, "2.2.2.2", "Established", vrf)
# don't check dynamic downed peers - they are removed
if prefix == "no":
check_neigh_state(r1, "2.2.2.2", "Connect", vrf)
check_neigh_state(r1, "3.3.3.3", "Established", vrf)
r2.vtysh_cmd(
"conf t\nrouter bgp 65002 {}\nneighbor 1.1.1.1 password change1".format(
vrf_str(vrf)
)
)
check_all_peers_established(vrf)
r1.vtysh_cmd(
"conf t\nrouter bgp 65001 {}\nneighbor {} password change2".format(
vrf_str(vrf), peer_name("R3", prefix, vrf)
)
)
check_neigh_state(r2, "1.1.1.1", "Established", vrf)
check_neigh_state(r2, "3.3.3.3", "Established", vrf)
check_neigh_state(r3, "1.1.1.1", "Connect", vrf)
check_neigh_state(r3, "2.2.2.2", "Established", vrf)
check_neigh_state(r1, "2.2.2.2", "Established", vrf)
# don't check dynamic downed peers - they are removed
if prefix == "no":
check_neigh_state(r1, "3.3.3.3", "Connect", vrf)
r3.vtysh_cmd(
"conf t\nrouter bgp 65003 {}\nneighbor 1.1.1.1 password change2".format(
vrf_str(vrf)
)
)
check_all_peers_established(vrf)
r2.vtysh_cmd(
"conf t\nrouter bgp 65002 {}\nneighbor 3.3.3.3 password change3".format(
vrf_str(vrf)
)
)
check_neigh_state(r2, "1.1.1.1", "Established", vrf)
check_neigh_state(r2, "3.3.3.3", "Connect", vrf)
check_neigh_state(r3, "1.1.1.1", "Established", vrf)
check_neigh_state(r3, "2.2.2.2", "Connect", vrf)
check_neigh_state(r1, "2.2.2.2", "Established", vrf)
check_neigh_state(r1, "3.3.3.3", "Established", vrf)
r3.vtysh_cmd(
"conf t\nrouter bgp 65003 {}\nneighbor 2.2.2.2 password change3".format(
vrf_str(vrf)
)
)
check_all_peers_established(vrf)
def test_default_peer_established():
"default vrf 3 peers same password"
configure_bgp("bgpd.conf")
configure_ospf("ospfd.conf")
check_all_peers_established()
# tgen.mininet_cli()
def test_default_peer_remove_passwords():
"selectively remove passwords checking state"
configure_bgp("bgpd.conf")
configure_ospf("ospfd.conf")
check_vrf_peer_remove_passwords()
def test_default_peer_change_passwords():
"selectively change passwords checking state"
configure_bgp("bgpd.conf")
configure_ospf("ospfd.conf")
check_vrf_peer_change_passwords()
def test_default_prefix_peer_established():
"default vrf 3 peers same password with prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_prefix.conf")
configure_ospf("ospfd.conf")
check_all_peers_established()
# tgen.mininet_cli()
def test_prefix_peer_remove_passwords():
"selectively remove passwords checking state with prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_prefix.conf")
configure_ospf("ospfd.conf")
check_vrf_peer_remove_passwords(prefix="yes")
def test_prefix_peer_change_passwords():
"selecively change passwords checkig state with prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_prefix.conf")
configure_ospf("ospfd.conf")
check_vrf_peer_change_passwords(prefix="yes")
def test_vrf_peer_established():
"default vrf 3 peers same password with VRF config"
# clean routers and load vrf config
configure_bgp("bgpd_vrf.conf")
configure_ospf("ospfd_vrf.conf")
check_all_peers_established("blue")
# tgen.mininet_cli()
def test_vrf_peer_remove_passwords():
"selectively remove passwords checking state with VRF config"
configure_bgp("bgpd_vrf.conf")
configure_ospf("ospfd_vrf.conf")
check_vrf_peer_remove_passwords(vrf="blue")
def test_vrf_peer_change_passwords():
"selectively change passwords checking state with VRF config"
configure_bgp("bgpd_vrf.conf")
configure_ospf("ospfd_vrf.conf")
check_vrf_peer_change_passwords(vrf="blue")
def test_vrf_prefix_peer_established():
"default vrf 3 peers same password with VRF prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_vrf_prefix.conf")
configure_ospf("ospfd_vrf.conf")
check_all_peers_established("blue")
def test_vrf_prefix_peer_remove_passwords():
"selectively remove passwords checking state with VRF prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_vrf_prefix.conf")
configure_ospf("ospfd_vrf.conf")
check_vrf_peer_remove_passwords(vrf="blue", prefix="yes")
def test_vrf_prefix_peer_change_passwords():
"selectively change passwords checking state with VRF prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_vrf_prefix.conf")
configure_ospf("ospfd_vrf.conf")
check_vrf_peer_change_passwords(vrf="blue", prefix="yes")
def test_multiple_vrf_peer_established():
"default vrf 3 peers same password with multiple VRFs"
configure_bgp("bgpd_multi_vrf.conf")
configure_ospf("ospfd_multi_vrf.conf")
check_all_peers_established("blue")
check_all_peers_established("red")
# tgen.mininet_cli()
def test_multiple_vrf_peer_remove_passwords():
"selectively remove passwords checking state with multiple VRFs"
configure_bgp("bgpd_multi_vrf.conf")
configure_ospf("ospfd_multi_vrf.conf")
check_vrf_peer_remove_passwords("blue")
check_all_peers_established("red")
check_vrf_peer_remove_passwords("red")
check_all_peers_established("blue")
# tgen.mininet_cli()
def test_multiple_vrf_peer_change_passwords():
"selectively change passwords checking state with multiple VRFs"
configure_bgp("bgpd_multi_vrf.conf")
configure_ospf("ospfd_multi_vrf.conf")
check_vrf_peer_change_passwords("blue")
check_all_peers_established("red")
check_vrf_peer_change_passwords("red")
check_all_peers_established("blue")
# tgen.mininet_cli()
def test_multiple_vrf_prefix_peer_established():
"default vrf 3 peers same password with multilpe VRFs and prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_multi_vrf_prefix.conf")
configure_ospf("ospfd_multi_vrf.conf")
check_all_peers_established("blue")
check_all_peers_established("red")
# tgen.mininet_cli()
def test_multiple_vrf_prefix_peer_remove_passwords():
"selectively remove passwords checking state with multiple vrfs and prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_multi_vrf_prefix.conf")
configure_ospf("ospfd_multi_vrf.conf")
check_vrf_peer_remove_passwords(vrf="blue", prefix="yes")
check_all_peers_established("red")
check_vrf_peer_remove_passwords(vrf="red", prefix="yes")
check_all_peers_established("blue")
# tgen.mininet_cli()
def test_multiple_vrf_prefix_peer_change_passwords():
"selectively change passwords checking state with multiple vrfs and prefix config"
# only supported in kernel > 5.3
if topotest.version_cmp(platform.release(), "5.3") < 0:
return
configure_bgp("bgpd_multi_vrf_prefix.conf")
configure_ospf("ospfd_multi_vrf.conf")
check_vrf_peer_change_passwords(vrf="blue", prefix="yes")
check_all_peers_established("red")
check_vrf_peer_change_passwords(vrf="red", prefix="yes")
check_all_peers_established("blue")
# tgen.mininet_cli()
def test_memory_leak():
"Run the memory leak test and report results."
tgen = get_topogen()
if not tgen.is_memleak_enabled():
pytest.skip("Memory leak test/report is disabled")
tgen.report_memory_leaks()
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))
|