-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_ospf6_p2xp.py
255 lines (229 loc) Β· 7.24 KB
/
test_ospf6_p2xp.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
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
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
"""
OSPFv3 basic point-to-multipoint test
"""
from topotato.v1 import *
@topology_fixture()
def topology(topo):
"""
{ lan }
{ }---[ r1 ]
{ }
{ }---[ r2 ]
{ }
{ }---[ r3 ]---[ lsdb ]
"""
class Configs(RouterFRR):
zebra = """
#% extends "boilerplate.conf"
#% block main
#% for iface in router.ifaces
interface {{ iface.ifname }}
description {{ iface.other.endpoint.name }}
no link-detect
!
#% endfor
!
ip forwarding
ipv6 forwarding
!
#% endblock
"""
ospf6d = """
#% extends "boilerplate.conf"
#% block main
#% for iface in router.ifaces
interface {{ iface.ifname }}
description {{ iface.other.endpoint.name }}
ipv6 ospf6 area 0.0.0.0
#% if iface.other.endpoint.name == "lan"
ipv6 ospf6 network point-to-multipoint
#% endif
ipv6 ospf6 hello-interval 1
ipv6 ospf6 dead-interval 2
ipv6 ospf6 retransmit-interval 3
#% endfor
!
!
router ospf6
log-adjacency-changes
ospf6 router-id {{ router.lo_ip4[0].ip }}
#% endblock
"""
def requirements(self):
self.require_defun("ipv6_ospf6_network_cmd", "point-to-multipoint")
class Setup(TopotatoNetwork, topo=topology):
r1: Configs
r2: Configs
r3: Configs
lsdb: Configs
class PtMPBasic(TestBase, AutoFixture, setup=Setup):
# intra_64 = connected-prefix include/exclude
def lsdb_reference(self, routers, intra_64=set()):
lsas = [
JSONCompareIgnoreExtraListitems(),
JSONCompareListKeyedDict("advertisingRouter", "type", "linkStateId"),
]
for rtr in routers:
neighbors = []
for other in routers:
if rtr == other:
continue
neighbors.append(
{
"type": "Point-To-Point",
"neighborRouterId": str(other.lo_ip4[0].ip),
}
)
lsas.append(
{
"type": "Router",
"linkStateId": "0.0.0.0",
"advertisingRouter": str(rtr.lo_ip4[0].ip),
"bits": "--------",
"options": "--|-|--|-|-|--|R|-|--|E|V6",
"lsaDescription": neighbors,
}
)
prefixes = [
{
"prefixOption": "--|--|--|LA|--",
"prefix": str(rtr.iface_to("lan").ip6[0].ip) + "/128",
}
]
if rtr.name in intra_64:
prefixes.append(
{
"prefixOption": "--|--|--|--|--",
"prefix": str(rtr.iface_to("lan").ip6[0].network),
}
)
lsas.append(
{
"type": "Intra-Prefix",
"advertisingRouter": str(rtr.lo_ip4[0].ip),
"numberOfPrefix": len(prefixes),
"reference": "Router",
"referenceId": "0.0.0.0",
"prefix": prefixes,
}
)
return {
"areaScopedLinkStateDb": [
JSONCompareIgnoreExtraListitems(),
JSONCompareListKeyedDict("areaId"),
{"areaId": "0.0.0.0", "lsa": lsas},
]
}
@topotatofunc
def bringup(self, topo, r1, r2, r3, lsdb):
"""
Wait for all OSPFv3 neighbors to be up before running actual tests.
This includes P2MP bringup since link-type is included in initial
config.
"""
# "lsdb" router is only used as separate router to check LSDB on
ptmp_routers = [r1, r2, r3]
all_routers = ptmp_routers + [lsdb]
for rtr in ptmp_routers:
ifname = rtr.iface_to("lan").ifname
neighbors = []
for other in ptmp_routers:
if other != rtr:
neighbors.append(
{
"interfaceName": ifname,
"neighborId": str(other.lo_ip4[0].ip),
"state": "Full",
"ifState": "PtMultipoint",
"interfaceState": "PtMultipoint",
}
)
yield from AssertVtysh.make(
rtr,
"ospf6d",
"show ipv6 ospf neighbor json",
{
"neighbors": neighbors,
},
maxwait=5.0,
)
# make sure it's fully up before checking LSDB on "lsdb" router
yield from AssertVtysh.make(
lsdb,
"ospf6d",
"show ipv6 ospf neighbor json",
{
"neighbors": [
{
"interfaceName": lsdb.iface_to("r3").ifname,
"state": "Full",
},
],
},
maxwait=5.0,
)
expected_lsdb = self.lsdb_reference(ptmp_routers)
for rtr in all_routers:
yield from AssertVtysh.make(
rtr,
"ospf6d",
"show ipv6 ospf6 database detail json",
expected_lsdb,
maxwait=10.0,
)
@topotatofunc
def connected_pfx_r1(self, topo, r1, r2, r3, lsdb):
"""
Enable advertising connected prefix on P2MP link on r1 and check result.
"""
ptmp_routers = [r1, r2, r3]
all_routers = ptmp_routers + [lsdb]
# advertise connected prefix on r1
yield from ReconfigureFRR.make(
r1,
"ospf6d",
"\n".join(
[
"interface %s" % r1.iface_to("lan").ifname,
"ipv6 ospf6 p2p-p2mp connected-prefixes include",
]
),
)
expected_lsdb = self.lsdb_reference(ptmp_routers, {"r1"})
for rtr in all_routers:
yield from AssertVtysh.make(
rtr,
"ospf6d",
"show ipv6 ospf6 database detail json",
expected_lsdb,
maxwait=5.0,
)
@topotatofunc
def connected_pfx_r3(self, topo, r1, r2, r3, lsdb):
"""
Enable advertising connected prefix on P2MP link on r3 and check result.
"""
ptmp_routers = [r1, r2, r3]
all_routers = ptmp_routers + [lsdb]
# advertise connected prefix on r1
yield from ReconfigureFRR.make(
r3,
"ospf6d",
"\n".join(
[
"interface %s" % r3.iface_to("lan").ifname,
"ipv6 ospf6 p2p-p2mp connected-prefixes include",
]
),
)
expected_lsdb = self.lsdb_reference(ptmp_routers, {"r1", "r3"})
for rtr in all_routers:
yield from AssertVtysh.make(
rtr,
"ospf6d",
"show ipv6 ospf6 database detail json",
expected_lsdb,
maxwait=3.0,
)