1 from lutil
import luCommand
2 from bgprib
import bgpribRequireVpnRoutes
,bgpribRequireUnicastRoutes
4 ########################################################################
5 # CE routers: contain routes they originate
6 ########################################################################
9 # ce1 vtysh -c "show bgp ipv4 uni"
10 # ce2 vtysh -c "show bgp ipv4 uni"
11 # ce3 vtysh -c "show bgp ipv4 uni"
12 # ce4 vtysh -c "show bgp ipv4 uni"
15 {'p':'5.1.0.0/24', 'n':'99.0.0.1'},
16 {'p':'5.1.1.0/24', 'n':'99.0.0.1'},
17 {'p':'99.0.0.1/32', 'n':'0.0.0.0'},
19 bgpribRequireUnicastRoutes('ce1','ipv4','','Cust 1 routes in ce1',want
)
22 {'p':'5.1.0.0/24', 'n':'99.0.0.2'},
23 {'p':'5.1.1.0/24', 'n':'99.0.0.2'},
24 {'p':'99.0.0.2/32', 'n':'0.0.0.0'},
26 bgpribRequireUnicastRoutes('ce2','ipv4','','Cust 2 routes in ce1',want
)
29 {'p':'5.1.2.0/24', 'n':'99.0.0.3'},
30 {'p':'5.1.3.0/24', 'n':'99.0.0.3'},
31 {'p':'99.0.0.3/32', 'n':'0.0.0.0'},
33 bgpribRequireUnicastRoutes('ce3','ipv4','','Cust 3 routes in ce1',want
)
36 {'p':'5.4.2.0/24', 'n':'99.0.0.4'},
37 {'p':'5.4.3.0/24', 'n':'99.0.0.4'},
38 {'p':'99.0.0.4/32', 'n':'0.0.0.0'},
40 bgpribRequireUnicastRoutes('ce4','ipv4','','Cust 4 routes in ce1',want
)
43 ########################################################################
44 # PE routers: VRFs contain routes from locally-attached customer nets
45 ########################################################################
47 # r1 vtysh -c "show bgp vrf r1-cust1 ipv4"
49 want_r1_cust1_routes
= [
50 {'p':'5.1.0.0/24', 'n':'99.0.0.1'},
51 {'p':'5.1.1.0/24', 'n':'99.0.0.1'},
52 {'p':'99.0.0.1/32', 'n':'192.168.1.2'},
54 bgpribRequireUnicastRoutes('r1','ipv4','r1-cust1','Customer 1 routes in r1 vrf',want_r1_cust1_routes
)
56 want_r3_cust1_routes
= [
57 {'p':'5.1.0.0/24', 'n':'99.0.0.2'},
58 {'p':'5.1.1.0/24', 'n':'99.0.0.2'},
59 {'p':'99.0.0.2/32', 'n':'192.168.1.2'},
61 bgpribRequireUnicastRoutes('r3','ipv4','r3-cust1','Customer 1 routes in r3 vrf',want_r3_cust1_routes
)
63 want_r4_cust1_routes
= [
64 {'p':'5.1.2.0/24', 'n':'99.0.0.3'},
65 {'p':'5.1.3.0/24', 'n':'99.0.0.3'},
66 {'p':'99.0.0.3/32', 'n':'192.168.1.2'},
68 bgpribRequireUnicastRoutes('r4','ipv4','r4-cust1','Customer 1 routes in r4 vrf',want_r4_cust1_routes
)
70 want_r4_cust2_routes
= [
71 {'p':'5.4.2.0/24', 'n':'99.0.0.4'},
72 {'p':'5.4.3.0/24', 'n':'99.0.0.4'},
73 {'p':'99.0.0.4/32', 'n':'192.168.2.2'},
75 bgpribRequireUnicastRoutes('r4','ipv4','r4-cust2','Customer 2 routes in r4 vrf',want_r4_cust2_routes
)
77 ########################################################################
78 # PE routers: core unicast routes are empty
79 ########################################################################
81 luCommand('r1','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Core Unicast SAFI clean')
82 luCommand('r2','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Core Unicast SAFI clean')
83 luCommand('r3','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Core Unicast SAFI clean')
84 luCommand('r4','vtysh -c "show bgp ipv4 uni"','No BGP prefixes displayed','pass','Core Unicast SAFI clean')
86 ########################################################################
87 # PE routers: local ce-originated routes are leaked to vpn
88 ########################################################################
90 # nhzero is for the new code that sets nh of locally-leaked routes to 0
95 luCommand('r1','vtysh -c "show bgp ipv4 vpn"',
96 'Distinguisher: *10:1.*5.1.0.0/24 *0.0.0.0 .*5.1.1.0/24 *0.0.0.0 .*99.0.0.1/32 *0.0.0.0 ',
97 'pass','vrf->vpn routes')
98 luCommand('r3','vtysh -c "show bgp ipv4 vpn"',
99 'Distinguisher: *10:3.*5.1.0.0/24 *0.0.0.0 .*5.1.1.0/24 *0.0.0.0 .*99.0.0.2/32 *0.0.0.0 ',
100 'pass','vrf->vpn routes')
102 {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'0.0.0.0'},
103 {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'0.0.0.0'},
104 {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'0.0.0.0'},
106 {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'0.0.0.0'},
107 {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'0.0.0.0'},
108 {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'0.0.0.0'},
110 bgpribRequireVpnRoutes('r4','vrf->vpn routes',want
)
113 luCommand('r1','vtysh -c "show bgp ipv4 vpn"',
114 'Distinguisher: *10:1.*5.1.0.0/24 *1.1.1.1 .*5.1.1.0/24 *1.1.1.1 .*99.0.0.1/32 *1.1.1.1 ',
115 'pass','vrf->vpn routes')
116 luCommand('r3','vtysh -c "show bgp ipv4 vpn"',
117 'Distinguisher: *10:3.*5.1.0.0/24 *3.3.3.3 .*5.1.1.0/24 *3.3.3.3 .*99.0.0.2/32 *3.3.3.3 ',
118 'pass','vrf->vpn routes')
120 {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'4.4.4.4'},
121 {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'4.4.4.4'},
122 {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'4.4.4.4'},
124 {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'4.4.4.4'},
125 {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'4.4.4.4'},
126 {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'4.4.4.4'},
128 bgpribRequireVpnRoutes('r4','vrf->vpn routes',want
)
130 ########################################################################
131 # PE routers: exporting vrfs set MPLS vrf labels in kernel
132 ########################################################################
134 luCommand('r1','vtysh -c "show mpls table"',' 101 *BGP *r1-cust1','pass','vrf labels')
135 luCommand('r3','vtysh -c "show mpls table"',' 103 *BGP *r3-cust1','pass','vrf labels')
136 luCommand('r4','vtysh -c "show mpls table"',' 1041 *BGP *r4-cust1 .*1042 *BGP *r4-cust2','pass','vrf labels')
138 ########################################################################
139 # Core VPN router: all customer routes
140 ########################################################################
143 {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'},
144 {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'},
145 {'rd':'10:1', 'p':'99.0.0.1/32', 'n':'1.1.1.1'},
147 {'rd':'10:3', 'p':'5.1.0.0/24', 'n':'3.3.3.3'},
148 {'rd':'10:3', 'p':'5.1.0.0/24', 'n':'3.3.3.3'},
149 {'rd':'10:3', 'p':'99.0.0.2/32', 'n':'3.3.3.3'},
151 {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'4.4.4.4'},
152 {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'4.4.4.4'},
153 {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'4.4.4.4'},
155 {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'4.4.4.4'},
156 {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'4.4.4.4'},
157 {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'4.4.4.4'},
159 bgpribRequireVpnRoutes('r2','Customer routes in provider vpn core',want_rd_routes
)
161 ########################################################################
162 # PE routers: VPN routes from remote customers
163 ########################################################################
165 # r1 vtysh -c "show bgp ipv4 vpn"
167 want_r1_remote_vpn_routes
= [
168 {'rd':'10:3', 'p':'5.1.0.0/24', 'n':'3.3.3.3'},
169 {'rd':'10:3', 'p':'5.1.1.0/24', 'n':'3.3.3.3'},
170 {'rd':'10:3', 'p':'99.0.0.2/32', 'n':'3.3.3.3'},
172 {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'4.4.4.4'},
173 {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'4.4.4.4'},
174 {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'4.4.4.4'},
176 {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'4.4.4.4'},
177 {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'4.4.4.4'},
178 {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'4.4.4.4'},
180 bgpribRequireVpnRoutes('r1','Remote Customer routes in R1 vpn',want_r1_remote_vpn_routes
)
182 want_r3_remote_vpn_routes
= [
183 {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'},
184 {'rd':'10:1', 'p':'5.1.1.0/24', 'n':'1.1.1.1'},
185 {'rd':'10:1', 'p':'99.0.0.1/32', 'n':'1.1.1.1'},
187 {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'4.4.4.4'},
188 {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'4.4.4.4'},
189 {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'4.4.4.4'},
191 {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'4.4.4.4'},
192 {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'4.4.4.4'},
193 {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'4.4.4.4'},
195 bgpribRequireVpnRoutes('r3','Remote Customer routes in R3 vpn',want_r3_remote_vpn_routes
)
197 want_r4_remote_vpn_routes
= [
198 {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'},
199 {'rd':'10:1', 'p':'5.1.1.0/24', 'n':'1.1.1.1'},
200 {'rd':'10:1', 'p':'99.0.0.1/32', 'n':'1.1.1.1'},
202 {'rd':'10:3', 'p':'5.1.0.0/24', 'n':'3.3.3.3'},
203 {'rd':'10:3', 'p':'5.1.1.0/24', 'n':'3.3.3.3'},
204 {'rd':'10:3', 'p':'99.0.0.2/32', 'n':'3.3.3.3'},
206 bgpribRequireVpnRoutes('r4','Remote Customer routes in R4 vpn',want_r4_remote_vpn_routes
)
210 # r1 vtysh -c "show bgp vrf r1-cust1 ipv4"
212 ########################################################################
213 # PE routers: VRFs contain routes from remote customer nets
214 ########################################################################
215 want_r1_remote_cust1_routes
= [
216 {'p':'5.1.0.0/24', 'n':'0.0.0.0'},
217 {'p':'5.1.1.0/24', 'n':'0.0.0.0'},
218 {'p':'99.0.0.2/32', 'n':'0.0.0.0'},
220 {'p':'5.1.2.0/24', 'n':'0.0.0.0'},
221 {'p':'5.1.3.0/24', 'n':'0.0.0.0'},
222 {'p':'99.0.0.3/32', 'n':'0.0.0.0'},
224 {'p':'5.4.2.0/24', 'n':'0.0.0.0'},
225 {'p':'5.4.3.0/24', 'n':'0.0.0.0'},
226 {'p':'99.0.0.3/32', 'n':'0.0.0.0'},
228 bgpribRequireUnicastRoutes('r1','ipv4','r1-cust1','Customer 1 routes in r1 vrf',want_r1_remote_cust1_routes
)
230 want_r3_remote_cust1_routes
= [
231 {'p':'5.1.0.0/24', 'n':'0.0.0.0'},
232 {'p':'5.1.1.0/24', 'n':'0.0.0.0'},
233 {'p':'99.0.0.1/32', 'n':'0.0.0.0'},
235 {'p':'5.1.2.0/24', 'n':'0.0.0.0'},
236 {'p':'5.1.3.0/24', 'n':'0.0.0.0'},
237 {'p':'99.0.0.3/32', 'n':'0.0.0.0'},
239 {'p':'5.4.2.0/24', 'n':'0.0.0.0'},
240 {'p':'5.4.3.0/24', 'n':'0.0.0.0'},
241 {'p':'99.0.0.3/32', 'n':'0.0.0.0'},
243 bgpribRequireUnicastRoutes('r3','ipv4','r3-cust1','Customer 1 routes in r3 vrf',want_r3_remote_cust1_routes
)
245 want_r4_remote_cust1_routes
= [
246 {'p':'5.1.0.0/24', 'n':'0.0.0.0'},
247 {'p':'5.1.1.0/24', 'n':'0.0.0.0'},
248 {'p':'99.0.0.1/32', 'n':'0.0.0.0'},
249 {'p':'99.0.0.2/32', 'n':'0.0.0.0'},
251 bgpribRequireUnicastRoutes('r4','ipv4','r4-cust1','Customer 1 routes in r4 vrf',want_r4_remote_cust1_routes
)
253 want_r4_remote_cust2_routes
= [
254 {'p':'5.1.0.0/24', 'n':'0.0.0.0'},
255 {'p':'5.1.1.0/24', 'n':'0.0.0.0'},
256 {'p':'99.0.0.1/32', 'n':'0.0.0.0'},
257 {'p':'99.0.0.2/32', 'n':'0.0.0.0'},
259 bgpribRequireUnicastRoutes('r4','ipv4','r4-cust2','Customer 2 routes in r4 vrf',want_r4_remote_cust2_routes
)
262 #########################################################################
263 # CE routers: contain routes from remote customer nets
264 #########################################################################
265 # ce1 vtysh -c "show bgp ipv4 uni"
266 # r1 vtysh -c "show bgp vrf r1-cust1 ipv4"
267 # r1 vtysh -c "show bgp vrf r1-cust1 ipv4 5.1.2.0/24"
270 {'p':'5.1.2.0/24', 'n':'192.168.1.1'},
271 {'p':'5.1.3.0/24', 'n':'192.168.1.1'},
272 {'p':'5.4.2.0/24', 'n':'192.168.1.1'},
273 {'p':'5.4.3.0/24', 'n':'192.168.1.1'},
275 bgpribRequireUnicastRoutes('ce1','ipv4','','Cust 1 routes from remote',want
)
278 {'p':'5.1.0.0/24', 'n':'192.168.1.1'},
279 {'p':'5.1.1.0/24', 'n':'192.168.1.1'},
280 {'p':'5.1.2.0/24', 'n':'192.168.1.1'},
281 {'p':'5.1.3.0/24', 'n':'192.168.1.1'},
282 {'p':'5.4.2.0/24', 'n':'192.168.1.1'},
283 {'p':'5.4.3.0/24', 'n':'192.168.1.1'},
285 bgpribRequireUnicastRoutes('ce2','ipv4','','Cust 1 routes from remote',want
)
288 {'p':'5.1.0.0/24', 'n':'192.168.1.1'},
289 {'p':'5.1.1.0/24', 'n':'192.168.1.1'},
290 {'p':'5.4.2.0/24', 'n':'192.168.1.1'},
291 {'p':'5.4.3.0/24', 'n':'192.168.1.1'},
293 bgpribRequireUnicastRoutes('ce3','ipv4','','Cust 1 routes from remote',want
)
296 {'p':'5.1.0.0/24', 'n':'192.168.2.1'},
297 {'p':'5.1.1.0/24', 'n':'192.168.2.1'},
298 {'p':'5.1.2.0/24', 'n':'192.168.2.1'},
299 {'p':'5.1.3.0/24', 'n':'192.168.2.1'},
301 bgpribRequireUnicastRoutes('ce4','ipv4','','Cust 2 routes from remote',want
)