-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_bgp_disable_addpath_rx.py
153 lines (138 loc) Β· 4.82 KB
/
test_bgp_disable_addpath_rx.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
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
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2022 Nathan Mangar
"""
Test if AddPath RX direction is not negotiated via AddPath capability.
"""
__topotests_file__ = "bgp_disable_addpath_rx/test_disable_addpath_rx.py"
__topotests_gitrev__ = "e82b531df94b9fd7bc456df8a1b7c58f2770eff9"
# pylint: disable=invalid-name, missing-class-docstring, missing-function-docstring, line-too-long, consider-using-f-string, wildcard-import, unused-wildcard-import, f-string-without-interpolation, too-few-public-methods
from topotato import *
@topology_fixture()
def topology(topo):
"""
[ r1 ]
|
{ s1 } [ r3 ]
| |
[ r2 ]--{ s2 }
|
[ r4 ]
"""
topo.router("r3").lo_ip4.append("172.16.16.254/32")
topo.router("r4").lo_ip4.append("172.16.16.254/32")
topo.router("r1").iface_to("s1").ip4.append("192.168.1.1/24")
topo.router("r2").iface_to("s1").ip4.append("192.168.1.2/24")
topo.router("r2").iface_to("s2").ip4.append("192.168.2.2/24")
topo.router("r3").iface_to("s2").ip4.append("192.168.2.3/24")
topo.router("r4").iface_to("s2").ip4.append("192.168.2.4/24")
class Configs(FRRConfigs):
routers = ["r1", "r2", "r3", "r4"]
zebra = """
#% extends "boilerplate.conf"
#% block main
#% if router.name == 'r3'
interface lo
ip address {{ routers.r3.lo_ip4[0] }}
!
#% elif router.name == 'r4'
interface lo
ip address {{ routers.r4.lo_ip4[0] }}
!
#% endif
#% 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
timers bgp 3 10
no bgp ebgp-requires-policy
neighbor {{ routers.r2.iface_to('s1').ip4[0].ip }} remote-as external
neighbor {{ routers.r2.iface_to('s1').ip4[0].ip }} timers connect 5
address-family ipv4 unicast
neighbor {{ routers.r2.iface_to('s1').ip4[0].ip }} disable-addpath-rx
!
#% elif router.name == 'r2'
router bgp 65002
timers bgp 3 10
no bgp ebgp-requires-policy
neighbor {{ routers.r1.iface_to('s1').ip4[0].ip }} remote-as external
neighbor {{ routers.r1.iface_to('s1').ip4[0].ip }} timers connect 5
neighbor {{ routers.r3.iface_to('s2').ip4[0].ip }} remote-as external
neighbor {{ routers.r3.iface_to('s2').ip4[0].ip }} timers connect 5
neighbor {{ routers.r4.iface_to('s2').ip4[0].ip }} remote-as external
neighbor {{ routers.r4.iface_to('s2').ip4[0].ip }} timers connect 5
address-family ipv4 unicast
neighbor {{ routers.r1.iface_to('s1').ip4[0].ip }} addpath-tx-all-paths
!
#% elif router.name == 'r3'
router bgp 65003
timers bgp 3 10
no bgp ebgp-requires-policy
neighbor {{ routers.r2.iface_to('s2').ip4[0].ip }} remote-as external
neighbor {{ routers.r2.iface_to('s2').ip4[0].ip }} timers connect 5
address-family ipv4 unicast
redistribute connected
!
#% elif router.name == 'r4'
router bgp 65004
timers bgp 3 10
no bgp ebgp-requires-policy
neighbor {{ routers.r2.iface_to('s2').ip4[0].ip }} remote-as external
neighbor {{ routers.r2.iface_to('s2').ip4[0].ip }} timers connect 5
address-family ipv4 unicast
redistribute connected
!
#% endif
#% endblock
"""
class BGPDisableAddpathRx(TestBase, AutoFixture, topo=topology, configs=Configs):
@topotatofunc
def check_bgp_advertised_routes(self, _, r1, r2):
expected = {
"advertisedRoutes": {
"172.16.16.254/32": {
"addrPrefix": "172.16.16.254",
"prefixLen": 32,
},
"192.168.2.0/24": {
"addrPrefix": "192.168.2.0",
"prefixLen": 24,
},
},
"totalPrefixCounter": 2,
}
yield from AssertVtysh.make(
r2,
"bgpd",
f"show bgp ipv4 unicast neighbor {r1.iface_to('s1').ip4[0].ip} advertised-routes json",
maxwait=2.0,
compare=expected,
)
@topotatofunc
def check_bgp_disabled_addpath_rx(self, _, r1, r2):
expected = {
str(r2.iface_to("s1").ip4[0].ip): {
"bgpState": "Established",
"neighborCapabilities": {
"addPath": {
"ipv4Unicast": {"txReceived": True, "rxReceived": True}
},
},
"addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 2}},
}
}
yield from AssertVtysh.make(
r1,
"bgpd",
f"show bgp neighbor {r2.iface_to('s1').ip4[0].ip} json",
maxwait=2.0,
compare=expected,
)