-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_bgp_as_wide_bgp_identifier.py
113 lines (98 loc) Β· 2.95 KB
/
test_bgp_as_wide_bgp_identifier.py
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
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2022 Nathan Mangar
"""
rfc6286: Autonomous-System-Wide Unique BGP Identifier for BGP-4
Test if 'Bad BGP Identifier' notification is sent only to
internal peers (autonomous-system-wide). eBGP peers are not
affected and should work.
"""
__topotests_file__ = "bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py"
__topotests_gitrev__ = "4953ca977f3a5de8109ee6353ad07f816ca1774c"
# pylint: disable=wildcard-import, unused-wildcard-import
from topotato import *
@topology_fixture()
def topology(topo):
"""
[ r1 ]
|
{ s1 }--[ r3 ]
|
[ r2 ]
"""
topo.router("r1").iface_to("s1").ip4.append("192.168.255.2/24")
topo.router("r2").iface_to("s1").ip4.append("192.168.255.1/24")
topo.router("r3").iface_to("s1").ip4.append("192.168.255.3/24")
class Configs(FRRConfigs):
routers = ["r1", "r2", "r3"]
zebra = """
#% extends "boilerplate.conf"
#% block main
#% for iface in router.ifaces
interface {{ iface.ifname }}
ip address {{ iface.ip4[0] }}
!
#% endfor
ip forwarding
!
#% endblock
"""
bgpd = """
#% block main
#% if router.name == 'r1'
router bgp 65001
bgp router-id 10.10.10.10
no bgp ebgp-requires-policy
neighbor 192.168.255.1 remote-as 65002
neighbor 192.168.255.1 timers 3 10
neighbor 192.168.255.1 timers connect 1
!
#% elif router.name == 'r2'
router bgp 65002
bgp router-id 10.10.10.10
no bgp ebgp-requires-policy
neighbor 192.168.255.2 remote-as 65001
neighbor 192.168.255.2 passive
neighbor 192.168.255.2 timers 3 10
neighbor 192.168.255.2 timers connect 1
neighbor 192.168.255.3 remote-as 65002
neighbor 192.168.255.3 passive
neighbor 192.168.255.3 timers 3 10
neighbor 192.168.255.3 timers connect 1
!
#% elif router.name == 'r3'
router bgp 65002
bgp router-id 10.10.10.10
no bgp ebgp-requires-policy
neighbor 192.168.255.1 remote-as 65002
neighbor 192.168.255.1 timers 3 10
neighbor 192.168.255.1 timers connect 1
!
#% endif
#% endblock
"""
class TestBGPAsWideBGPIdentifier(TestBase, AutoFixture, topo=topology, configs=Configs):
@topotatofunc
def bgp_converge(self, _, r1):
expected = {"192.168.255.1": {"bgpState": "Established"}}
yield from AssertVtysh.make(
r1,
"bgpd",
"show ip bgp neighbor 192.168.255.1 json",
maxwait=2.0,
compare=expected,
)
@topotatofunc
def bgp_failed(self, _, r3):
expected = {
"192.168.255.1": {
"lastNotificationReason": "OPEN Message Error/Bad BGP Identifier"
}
}
yield from AssertVtysh.make(
r3,
"bgpd",
"show ip bgp neighbor 192.168.255.1 json",
maxwait=2.0,
compare=expected,
)