blob: 2f649bbde5372be5a43c1793f812fba92162a9ec [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Neale Rannsd792d9c2017-10-21 10:53:20 -07002
3import unittest
Neale Rannsd792d9c2017-10-21 10:53:20 -07004
Neale Rannsf0510722018-01-31 11:35:41 -08005from framework import VppTestCase, VppTestRunner, running_extended_tests
Neale Rannsc0a93142018-09-05 15:42:26 -07006from vpp_ip import DpoProto
Paul Vinciguerraa279d9c2019-02-28 09:00:09 -08007from vpp_ip_route import VppIpRoute, VppRoutePath, \
Neale Rannsd792d9c2017-10-21 10:53:20 -07008 VppMplsTable, VppIpMRoute, VppMRoutePath, VppIpTable, \
Neale Ranns990f6942020-10-20 07:20:17 +00009 MPLS_LABEL_INVALID, \
Neale Ranns097fa662018-05-01 05:17:55 -070010 VppMplsLabel, FibPathProto, FibPathType
Paul Vinciguerraa279d9c2019-02-28 09:00:09 -080011from vpp_bier import BIER_HDR_PAYLOAD, VppBierImp, VppBierDispEntry, \
12 VppBierDispTable, VppBierTable, VppBierTableID, VppBierRoute
13from vpp_udp_encap import VppUdpEncap
Neale Ranns990f6942020-10-20 07:20:17 +000014from vpp_papi import VppEnum
Neale Rannsd792d9c2017-10-21 10:53:20 -070015
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -070016import scapy.compat
Neale Rannsd792d9c2017-10-21 10:53:20 -070017from scapy.packet import Raw
18from scapy.layers.l2 import Ether
Paul Vinciguerraa279d9c2019-02-28 09:00:09 -080019from scapy.layers.inet import IP, UDP
Neale Rannsd792d9c2017-10-21 10:53:20 -070020from scapy.layers.inet6 import IPv6
21from scapy.contrib.mpls import MPLS
Paul Vinciguerraa279d9c2019-02-28 09:00:09 -080022from scapy.contrib.bier import BIER, BIERLength, BIFT
Neale Rannsd792d9c2017-10-21 10:53:20 -070023
Paul Vinciguerra4271c972019-05-14 13:25:49 -040024NUM_PKTS = 67
25
Neale Rannsd792d9c2017-10-21 10:53:20 -070026
27class TestBFIB(VppTestCase):
28 """ BIER FIB Test Case """
29
30 def test_bfib(self):
31 """ BFIB Unit Tests """
32 error = self.vapi.cli("test bier")
33
34 if error:
35 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080036 self.assertNotIn("Failed", error)
Neale Rannsd792d9c2017-10-21 10:53:20 -070037
38
39class TestBier(VppTestCase):
40 """ BIER Test Case """
41
42 def setUp(self):
43 super(TestBier, self).setUp()
44
45 # create 2 pg interfaces
46 self.create_pg_interfaces(range(3))
47
48 # create the default MPLS table
49 self.tables = []
50 tbl = VppMplsTable(self, 0)
51 tbl.add_vpp_config()
52 self.tables.append(tbl)
53
54 tbl = VppIpTable(self, 10)
55 tbl.add_vpp_config()
56 self.tables.append(tbl)
57
58 # setup both interfaces
59 for i in self.pg_interfaces:
60 if i == self.pg2:
61 i.set_table_ip4(10)
62 i.admin_up()
63 i.config_ip4()
64 i.resolve_arp()
65 i.enable_mpls()
66
67 def tearDown(self):
68 for i in self.pg_interfaces:
69 i.disable_mpls()
70 i.unconfig_ip4()
71 i.set_table_ip4(0)
72 i.admin_down()
73 super(TestBier, self).tearDown()
74
Neale Rannsf0510722018-01-31 11:35:41 -080075 def bier_midpoint(self, hdr_len_id, n_bytes, max_bp):
Neale Rannsd792d9c2017-10-21 10:53:20 -070076 """BIER midpoint"""
77
78 #
79 # Add a BIER table for sub-domain 0, set 0, and BSL 256
80 #
Neale Rannsf0510722018-01-31 11:35:41 -080081 bti = VppBierTableID(0, 0, hdr_len_id)
Neale Rannsd792d9c2017-10-21 10:53:20 -070082 bt = VppBierTable(self, bti, 77)
83 bt.add_vpp_config()
84
85 #
86 # A packet with no bits set gets dropped
87 #
88 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
89 MPLS(label=77, ttl=255) /
Neale Rannsf0510722018-01-31 11:35:41 -080090 BIER(length=hdr_len_id) /
Neale Rannsd792d9c2017-10-21 10:53:20 -070091 IPv6(src=self.pg0.remote_ip6, dst=self.pg0.remote_ip6) /
92 UDP(sport=1234, dport=1234) /
93 Raw())
94 pkts = [p]
95
96 self.send_and_assert_no_replies(self.pg0, pkts,
97 "Empty Bit-String")
98
99 #
100 # Add a BIER route for each bit-position in the table via a different
101 # next-hop. Testing whether the BIER walk and replicate forwarding
102 # function works for all bit posisitons.
103 #
104 nh_routes = []
105 bier_routes = []
Neale Rannsf0510722018-01-31 11:35:41 -0800106 for i in range(1, max_bp+1):
Neale Rannsd792d9c2017-10-21 10:53:20 -0700107 nh = "10.0.%d.%d" % (i / 255, i % 255)
Neale Ranns31ed7442018-02-23 05:29:09 -0800108 nh_routes.append(
109 VppIpRoute(self, nh, 32,
110 [VppRoutePath(self.pg1.remote_ip4,
111 self.pg1.sw_if_index,
112 labels=[VppMplsLabel(2000+i)])]))
Neale Rannsd792d9c2017-10-21 10:53:20 -0700113 nh_routes[-1].add_vpp_config()
114
Neale Ranns31ed7442018-02-23 05:29:09 -0800115 bier_routes.append(
116 VppBierRoute(self, bti, i,
117 [VppRoutePath(nh, 0xffffffff,
118 labels=[VppMplsLabel(100+i)])]))
Neale Rannsd792d9c2017-10-21 10:53:20 -0700119 bier_routes[-1].add_vpp_config()
120
121 #
Neale Rannsf0510722018-01-31 11:35:41 -0800122 # A packet with all bits set gets replicated once for each bit
Neale Rannsd792d9c2017-10-21 10:53:20 -0700123 #
Neale Rannsf0510722018-01-31 11:35:41 -0800124 pkt_sizes = [64, 1400]
Neale Rannsd792d9c2017-10-21 10:53:20 -0700125
Neale Rannsf0510722018-01-31 11:35:41 -0800126 for pkt_size in pkt_sizes:
127 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
128 MPLS(label=77, ttl=255) /
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700129 BIER(length=hdr_len_id,
130 BitString=scapy.compat.chb(255)*n_bytes) /
Neale Rannsf0510722018-01-31 11:35:41 -0800131 IPv6(src=self.pg0.remote_ip6, dst=self.pg0.remote_ip6) /
132 UDP(sport=1234, dport=1234) /
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700133 Raw(scapy.compat.chb(5) * pkt_size))
Neale Rannsf0510722018-01-31 11:35:41 -0800134 pkts = p
Neale Rannsd792d9c2017-10-21 10:53:20 -0700135
Neale Rannsf0510722018-01-31 11:35:41 -0800136 self.pg0.add_stream(pkts)
137 self.pg_enable_capture(self.pg_interfaces)
138 self.pg_start()
Neale Rannsd792d9c2017-10-21 10:53:20 -0700139
Neale Rannsf0510722018-01-31 11:35:41 -0800140 rx = self.pg1.get_capture(max_bp)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700141
Neale Rannsf0510722018-01-31 11:35:41 -0800142 for rxp in rx:
143 #
144 # The packets are not required to be sent in bit-position order
145 # when we setup the routes above we used the bit-position to
146 # construct the out-label. so use that here to determine the BP
147 #
148 olabel = rxp[MPLS]
149 bp = olabel.label - 2000
Neale Rannsd792d9c2017-10-21 10:53:20 -0700150
Neale Rannsf0510722018-01-31 11:35:41 -0800151 blabel = olabel[MPLS].payload
152 self.assertEqual(blabel.label, 100+bp)
153 self.assertEqual(blabel.ttl, 254)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700154
Neale Rannsf0510722018-01-31 11:35:41 -0800155 bier_hdr = blabel[MPLS].payload
Neale Rannsd792d9c2017-10-21 10:53:20 -0700156
Neale Rannsf0510722018-01-31 11:35:41 -0800157 self.assertEqual(bier_hdr.id, 5)
158 self.assertEqual(bier_hdr.version, 0)
159 self.assertEqual(bier_hdr.length, hdr_len_id)
160 self.assertEqual(bier_hdr.entropy, 0)
161 self.assertEqual(bier_hdr.OAM, 0)
162 self.assertEqual(bier_hdr.RSV, 0)
163 self.assertEqual(bier_hdr.DSCP, 0)
164 self.assertEqual(bier_hdr.Proto, 5)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700165
Neale Rannsf0510722018-01-31 11:35:41 -0800166 # The bit-string should consist only of the BP given by i.
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700167 byte_array = [b'\0'] * (n_bytes)
168 byte_val = scapy.compat.chb(1 << (bp - 1) % 8)
169 byte_pos = n_bytes - (((bp - 1) // 8) + 1)
Neale Rannsf0510722018-01-31 11:35:41 -0800170 byte_array[byte_pos] = byte_val
snaramre5d4b8912019-12-13 23:39:35 +0000171 bitstring = b''.join(byte_array)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700172
Neale Rannsf0510722018-01-31 11:35:41 -0800173 self.assertEqual(len(bitstring), len(bier_hdr.BitString))
174 self.assertEqual(bitstring, bier_hdr.BitString)
175
176 #
177 # cleanup. not strictly necessary, but it's much quicker this way
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700178 # because the bier_fib_dump and ip_fib_dump will be empty when the
Neale Rannsf0510722018-01-31 11:35:41 -0800179 # auto-cleanup kicks in
180 #
181 for br in bier_routes:
182 br.remove_vpp_config()
183 for nhr in nh_routes:
184 nhr.remove_vpp_config()
185
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800186 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Rannsf0510722018-01-31 11:35:41 -0800187 def test_bier_midpoint_1024(self):
188 """BIER midpoint BSL:1024"""
189 self.bier_midpoint(BIERLength.BIER_LEN_1024, 128, 1024)
190
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800191 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Rannsf0510722018-01-31 11:35:41 -0800192 def test_bier_midpoint_512(self):
193 """BIER midpoint BSL:512"""
194 self.bier_midpoint(BIERLength.BIER_LEN_512, 64, 512)
195
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800196 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Rannsf0510722018-01-31 11:35:41 -0800197 def test_bier_midpoint_256(self):
198 """BIER midpoint BSL:256"""
199 self.bier_midpoint(BIERLength.BIER_LEN_256, 32, 256)
200
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800201 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Rannsf0510722018-01-31 11:35:41 -0800202 def test_bier_midpoint_128(self):
203 """BIER midpoint BSL:128"""
204 self.bier_midpoint(BIERLength.BIER_LEN_128, 16, 128)
205
206 def test_bier_midpoint_64(self):
Neale Rannsc819fc62018-02-16 02:44:05 -0800207 """BIER midpoint BSL:64"""
Neale Rannsf0510722018-01-31 11:35:41 -0800208 self.bier_midpoint(BIERLength.BIER_LEN_64, 8, 64)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700209
Neale Rannsef90ed02018-09-13 08:45:12 -0700210 def test_bier_load_balance(self):
211 """BIER load-balance"""
212
213 #
214 # Add a BIER table for sub-domain 0, set 0, and BSL 256
215 #
216 bti = VppBierTableID(0, 0, BIERLength.BIER_LEN_64)
217 bt = VppBierTable(self, bti, 77)
218 bt.add_vpp_config()
219
220 #
221 # packets with varying entropy
222 #
223 pkts = []
224 for ii in range(257):
225 pkts.append((Ether(dst=self.pg0.local_mac,
226 src=self.pg0.remote_mac) /
227 MPLS(label=77, ttl=255) /
228 BIER(length=BIERLength.BIER_LEN_64,
229 entropy=ii,
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700230 BitString=scapy.compat.chb(255)*16) /
Neale Rannsef90ed02018-09-13 08:45:12 -0700231 IPv6(src=self.pg0.remote_ip6,
232 dst=self.pg0.remote_ip6) /
233 UDP(sport=1234, dport=1234) /
234 Raw()))
235
236 #
237 # 4 next hops
238 #
239 nhs = [{'ip': "10.0.0.1", 'label': 201},
240 {'ip': "10.0.0.2", 'label': 202},
241 {'ip': "10.0.0.3", 'label': 203},
242 {'ip': "10.0.0.4", 'label': 204}]
243
244 for nh in nhs:
245 ipr = VppIpRoute(
246 self, nh['ip'], 32,
247 [VppRoutePath(self.pg1.remote_ip4,
248 self.pg1.sw_if_index,
249 labels=[VppMplsLabel(nh['label'])])])
250 ipr.add_vpp_config()
251
252 bier_route = VppBierRoute(
253 self, bti, 1,
254 [VppRoutePath(nhs[0]['ip'], 0xffffffff,
255 labels=[VppMplsLabel(101)]),
256 VppRoutePath(nhs[1]['ip'], 0xffffffff,
257 labels=[VppMplsLabel(101)])])
258 bier_route.add_vpp_config()
259
260 rx = self.send_and_expect(self.pg0, pkts, self.pg1)
261
262 #
263 # we should have recieved a packet from each neighbor
264 #
265 for nh in nhs[:2]:
266 self.assertTrue(sum(p[MPLS].label == nh['label'] for p in rx))
267
268 #
269 # add the other paths
270 #
271 bier_route.update_paths(
272 [VppRoutePath(nhs[0]['ip'], 0xffffffff,
273 labels=[VppMplsLabel(101)]),
274 VppRoutePath(nhs[1]['ip'], 0xffffffff,
275 labels=[VppMplsLabel(101)]),
276 VppRoutePath(nhs[2]['ip'], 0xffffffff,
277 labels=[VppMplsLabel(101)]),
278 VppRoutePath(nhs[3]['ip'], 0xffffffff,
279 labels=[VppMplsLabel(101)])])
280
281 rx = self.send_and_expect(self.pg0, pkts, self.pg1)
Neale Ranns097fa662018-05-01 05:17:55 -0700282
Neale Rannsef90ed02018-09-13 08:45:12 -0700283 for nh in nhs:
284 self.assertTrue(sum(p[MPLS].label == nh['label'] for p in rx))
285
286 #
287 # remove first two paths
288 #
289 bier_route.remove_path(VppRoutePath(nhs[0]['ip'], 0xffffffff,
290 labels=[VppMplsLabel(101)]))
291 bier_route.remove_path(VppRoutePath(nhs[1]['ip'], 0xffffffff,
292 labels=[VppMplsLabel(101)]))
293
294 rx = self.send_and_expect(self.pg0, pkts, self.pg1)
295 for nh in nhs[2:]:
296 self.assertTrue(sum(p[MPLS].label == nh['label'] for p in rx))
297
298 #
299 # remove the last of the paths, deleteing the entry
300 #
301 bier_route.remove_all_paths()
302
303 self.send_and_assert_no_replies(self.pg0, pkts)
304
Neale Rannsd792d9c2017-10-21 10:53:20 -0700305 def test_bier_head(self):
306 """BIER head"""
307
Neale Ranns990f6942020-10-20 07:20:17 +0000308 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
309 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
310
Neale Rannsd792d9c2017-10-21 10:53:20 -0700311 #
312 # Add a BIER table for sub-domain 0, set 0, and BSL 256
313 #
314 bti = VppBierTableID(0, 0, BIERLength.BIER_LEN_256)
315 bt = VppBierTable(self, bti, 77)
316 bt.add_vpp_config()
317
318 #
319 # 2 bit positions via two next hops
320 #
321 nh1 = "10.0.0.1"
322 nh2 = "10.0.0.2"
323 ip_route_1 = VppIpRoute(self, nh1, 32,
324 [VppRoutePath(self.pg1.remote_ip4,
325 self.pg1.sw_if_index,
Neale Ranns31ed7442018-02-23 05:29:09 -0800326 labels=[VppMplsLabel(2001)])])
Neale Rannsd792d9c2017-10-21 10:53:20 -0700327 ip_route_2 = VppIpRoute(self, nh2, 32,
328 [VppRoutePath(self.pg1.remote_ip4,
329 self.pg1.sw_if_index,
Neale Ranns31ed7442018-02-23 05:29:09 -0800330 labels=[VppMplsLabel(2002)])])
Neale Rannsd792d9c2017-10-21 10:53:20 -0700331 ip_route_1.add_vpp_config()
332 ip_route_2.add_vpp_config()
333
Neale Ranns91286372017-12-05 13:24:04 -0800334 bier_route_1 = VppBierRoute(self, bti, 1,
335 [VppRoutePath(nh1, 0xffffffff,
Neale Ranns31ed7442018-02-23 05:29:09 -0800336 labels=[VppMplsLabel(101)])])
Neale Ranns91286372017-12-05 13:24:04 -0800337 bier_route_2 = VppBierRoute(self, bti, 2,
338 [VppRoutePath(nh2, 0xffffffff,
Neale Ranns31ed7442018-02-23 05:29:09 -0800339 labels=[VppMplsLabel(102)])])
Neale Rannsd792d9c2017-10-21 10:53:20 -0700340 bier_route_1.add_vpp_config()
341 bier_route_2.add_vpp_config()
342
343 #
344 # An imposition object with both bit-positions set
345 #
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700346 bi = VppBierImp(self, bti, 333, scapy.compat.chb(0x3) * 32)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700347 bi.add_vpp_config()
348
349 #
350 # Add a multicast route that will forward into the BIER doamin
351 #
352 route_ing_232_1_1_1 = VppIpMRoute(
353 self,
354 "0.0.0.0",
355 "232.1.1.1", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000356 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700357 paths=[VppMRoutePath(self.pg0.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000358 MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
Neale Rannsd792d9c2017-10-21 10:53:20 -0700359 VppMRoutePath(0xffffffff,
Neale Ranns990f6942020-10-20 07:20:17 +0000360 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700361 proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
362 type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700363 bier_imp=bi.bi_index)])
364 route_ing_232_1_1_1.add_vpp_config()
365
366 #
Neale Ranns91286372017-12-05 13:24:04 -0800367 # inject an IP packet. We expect it to be BIER encapped and
Neale Rannsd792d9c2017-10-21 10:53:20 -0700368 # replicated.
369 #
370 p = (Ether(dst=self.pg0.local_mac,
371 src=self.pg0.remote_mac) /
372 IP(src="1.1.1.1", dst="232.1.1.1") /
373 UDP(sport=1234, dport=1234))
374
375 self.pg0.add_stream([p])
376 self.pg_enable_capture(self.pg_interfaces)
377 self.pg_start()
378
379 rx = self.pg1.get_capture(2)
380
Neale Ranns91286372017-12-05 13:24:04 -0800381 #
382 # Encap Stack is; eth, MPLS, MPLS, BIER
383 #
384 igp_mpls = rx[0][MPLS]
385 self.assertEqual(igp_mpls.label, 2001)
386 self.assertEqual(igp_mpls.ttl, 64)
387 self.assertEqual(igp_mpls.s, 0)
388 bier_mpls = igp_mpls[MPLS].payload
389 self.assertEqual(bier_mpls.label, 101)
390 self.assertEqual(bier_mpls.ttl, 64)
391 self.assertEqual(bier_mpls.s, 1)
392 self.assertEqual(rx[0][BIER].length, 2)
393
394 igp_mpls = rx[1][MPLS]
395 self.assertEqual(igp_mpls.label, 2002)
396 self.assertEqual(igp_mpls.ttl, 64)
397 self.assertEqual(igp_mpls.s, 0)
398 bier_mpls = igp_mpls[MPLS].payload
399 self.assertEqual(bier_mpls.label, 102)
400 self.assertEqual(bier_mpls.ttl, 64)
401 self.assertEqual(bier_mpls.s, 1)
402 self.assertEqual(rx[0][BIER].length, 2)
403
Neale Rannsd792d9c2017-10-21 10:53:20 -0700404 def test_bier_tail(self):
405 """BIER Tail"""
406
Neale Ranns990f6942020-10-20 07:20:17 +0000407 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
408 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
409
Neale Rannsd792d9c2017-10-21 10:53:20 -0700410 #
411 # Add a BIER table for sub-domain 0, set 0, and BSL 256
412 #
413 bti = VppBierTableID(0, 0, BIERLength.BIER_LEN_256)
414 bt = VppBierTable(self, bti, 77)
415 bt.add_vpp_config()
416
417 #
418 # disposition table
419 #
420 bdt = VppBierDispTable(self, 8)
421 bdt.add_vpp_config()
422
423 #
424 # BIER route in table that's for-us
425 #
Neale Ranns2303cb12018-02-21 04:57:17 -0800426 bier_route_1 = VppBierRoute(
427 self, bti, 1,
428 [VppRoutePath("0.0.0.0",
429 0xffffffff,
Neale Ranns097fa662018-05-01 05:17:55 -0700430 proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
Neale Ranns2303cb12018-02-21 04:57:17 -0800431 nh_table_id=8)])
Neale Rannsd792d9c2017-10-21 10:53:20 -0700432 bier_route_1.add_vpp_config()
433
434 #
435 # An entry in the disposition table
436 #
437 bier_de_1 = VppBierDispEntry(self, bdt.id, 99,
438 BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
Neale Ranns097fa662018-05-01 05:17:55 -0700439 FibPathProto.FIB_PATH_NH_PROTO_BIER,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700440 "0.0.0.0", 0, rpf_id=8192)
441 bier_de_1.add_vpp_config()
442
443 #
444 # A multicast route to forward post BIER disposition
445 #
446 route_eg_232_1_1_1 = VppIpMRoute(
447 self,
448 "0.0.0.0",
449 "232.1.1.1", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000450 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700451 paths=[VppMRoutePath(self.pg1.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000452 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)])
Neale Rannsd792d9c2017-10-21 10:53:20 -0700453 route_eg_232_1_1_1.add_vpp_config()
454 route_eg_232_1_1_1.update_rpf_id(8192)
455
456 #
457 # A packet with all bits set gets spat out to BP:1
458 #
459 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
460 MPLS(label=77, ttl=255) /
Neale Rannsf0510722018-01-31 11:35:41 -0800461 BIER(length=BIERLength.BIER_LEN_256,
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700462 BitString=scapy.compat.chb(255)*32,
Neale Rannsf0510722018-01-31 11:35:41 -0800463 BFRID=99) /
Neale Rannsd792d9c2017-10-21 10:53:20 -0700464 IP(src="1.1.1.1", dst="232.1.1.1") /
465 UDP(sport=1234, dport=1234) /
466 Raw())
467
468 self.send_and_expect(self.pg0, [p], self.pg1)
469
Neale Rannsceb4d052017-12-13 09:13:41 -0800470 #
471 # A packet that does not match the Disposition entry gets dropped
472 #
473 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
474 MPLS(label=77, ttl=255) /
Neale Rannsf0510722018-01-31 11:35:41 -0800475 BIER(length=BIERLength.BIER_LEN_256,
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700476 BitString=scapy.compat.chb(255)*32,
Neale Rannsf0510722018-01-31 11:35:41 -0800477 BFRID=77) /
Neale Rannsceb4d052017-12-13 09:13:41 -0800478 IP(src="1.1.1.1", dst="232.1.1.1") /
479 UDP(sport=1234, dport=1234) /
480 Raw())
481 self.send_and_assert_no_replies(self.pg0, p*2,
482 "no matching disposition entry")
483
484 #
485 # Add the default route to the disposition table
486 #
487 bier_de_2 = VppBierDispEntry(self, bdt.id, 0,
488 BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
Neale Ranns097fa662018-05-01 05:17:55 -0700489 FibPathProto.FIB_PATH_NH_PROTO_BIER,
Neale Rannsceb4d052017-12-13 09:13:41 -0800490 "0.0.0.0", 0, rpf_id=8192)
491 bier_de_2.add_vpp_config()
492
493 #
494 # now the previous packet is forwarded
495 #
496 self.send_and_expect(self.pg0, [p], self.pg1)
497
Neale Rannsfe4e48f2018-09-24 23:38:37 -0700498 #
499 # A multicast route to forward post BIER disposition that needs
500 # a check against sending back into the BIER core
501 #
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700502 bi = VppBierImp(self, bti, 333, scapy.compat.chb(0x3) * 32)
Neale Rannsfe4e48f2018-09-24 23:38:37 -0700503 bi.add_vpp_config()
504
505 route_eg_232_1_1_2 = VppIpMRoute(
506 self,
507 "0.0.0.0",
508 "232.1.1.2", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000509 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Rannsfe4e48f2018-09-24 23:38:37 -0700510 paths=[VppMRoutePath(0xffffffff,
Neale Ranns990f6942020-10-20 07:20:17 +0000511 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD,
Neale Rannsfe4e48f2018-09-24 23:38:37 -0700512 proto=DpoProto.DPO_PROTO_BIER,
Neale Ranns097fa662018-05-01 05:17:55 -0700513 type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
Neale Rannsfe4e48f2018-09-24 23:38:37 -0700514 bier_imp=bi.bi_index),
515 VppMRoutePath(self.pg1.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000516 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)])
Neale Rannsfe4e48f2018-09-24 23:38:37 -0700517 route_eg_232_1_1_2.add_vpp_config()
518 route_eg_232_1_1_2.update_rpf_id(8192)
519
520 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
521 MPLS(label=77, ttl=255) /
522 BIER(length=BIERLength.BIER_LEN_256,
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700523 BitString=scapy.compat.chb(255)*32,
Neale Rannsfe4e48f2018-09-24 23:38:37 -0700524 BFRID=77) /
525 IP(src="1.1.1.1", dst="232.1.1.2") /
526 UDP(sport=1234, dport=1234) /
527 Raw())
528 self.send_and_expect(self.pg0, [p], self.pg1)
529
Neale Rannsf0510722018-01-31 11:35:41 -0800530 def bier_e2e(self, hdr_len_id, n_bytes, max_bp):
531 """ BIER end-to-end"""
Neale Rannsd792d9c2017-10-21 10:53:20 -0700532
Neale Ranns990f6942020-10-20 07:20:17 +0000533 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
534 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
535
Neale Rannsd792d9c2017-10-21 10:53:20 -0700536 #
537 # Add a BIER table for sub-domain 0, set 0, and BSL 256
538 #
Neale Rannsf0510722018-01-31 11:35:41 -0800539 bti = VppBierTableID(0, 0, hdr_len_id)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700540 bt = VppBierTable(self, bti, 77)
541 bt.add_vpp_config()
542
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700543 lowest = [b'\0'] * (n_bytes)
544 lowest[-1] = scapy.compat.chb(1)
545 highest = [b'\0'] * (n_bytes)
546 highest[0] = scapy.compat.chb(128)
Neale Rannsf0510722018-01-31 11:35:41 -0800547
Neale Rannsd792d9c2017-10-21 10:53:20 -0700548 #
Neale Rannsf0510722018-01-31 11:35:41 -0800549 # Impostion Sets bit strings
Neale Rannsd792d9c2017-10-21 10:53:20 -0700550 #
Neale Rannsf0510722018-01-31 11:35:41 -0800551 bi_low = VppBierImp(self, bti, 333, lowest)
552 bi_low.add_vpp_config()
553 bi_high = VppBierImp(self, bti, 334, highest)
554 bi_high.add_vpp_config()
Neale Rannsd792d9c2017-10-21 10:53:20 -0700555
556 #
557 # Add a multicast route that will forward into the BIER doamin
558 #
559 route_ing_232_1_1_1 = VppIpMRoute(
560 self,
561 "0.0.0.0",
562 "232.1.1.1", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000563 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700564 paths=[VppMRoutePath(self.pg0.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000565 MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
Neale Rannsd792d9c2017-10-21 10:53:20 -0700566 VppMRoutePath(0xffffffff,
Neale Ranns990f6942020-10-20 07:20:17 +0000567 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700568 proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
569 type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
Neale Rannsf0510722018-01-31 11:35:41 -0800570 bier_imp=bi_low.bi_index)])
Neale Rannsd792d9c2017-10-21 10:53:20 -0700571 route_ing_232_1_1_1.add_vpp_config()
Neale Rannsf0510722018-01-31 11:35:41 -0800572 route_ing_232_1_1_2 = VppIpMRoute(
573 self,
574 "0.0.0.0",
575 "232.1.1.2", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000576 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Rannsf0510722018-01-31 11:35:41 -0800577 paths=[VppMRoutePath(self.pg0.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000578 MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
Neale Rannsf0510722018-01-31 11:35:41 -0800579 VppMRoutePath(0xffffffff,
Neale Ranns990f6942020-10-20 07:20:17 +0000580 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700581 proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
582 type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
Neale Rannsf0510722018-01-31 11:35:41 -0800583 bier_imp=bi_high.bi_index)])
584 route_ing_232_1_1_2.add_vpp_config()
Neale Rannsd792d9c2017-10-21 10:53:20 -0700585
586 #
587 # disposition table 8
588 #
589 bdt = VppBierDispTable(self, 8)
590 bdt.add_vpp_config()
591
592 #
Neale Rannsf0510722018-01-31 11:35:41 -0800593 # BIER routes in table that are for-us, resolving through
Neale Rannsd792d9c2017-10-21 10:53:20 -0700594 # disp table 8.
595 #
Neale Ranns2303cb12018-02-21 04:57:17 -0800596 bier_route_1 = VppBierRoute(
597 self, bti, 1,
598 [VppRoutePath("0.0.0.0",
599 0xffffffff,
Neale Ranns097fa662018-05-01 05:17:55 -0700600 proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
Neale Ranns2303cb12018-02-21 04:57:17 -0800601 nh_table_id=8)])
Neale Rannsd792d9c2017-10-21 10:53:20 -0700602 bier_route_1.add_vpp_config()
Neale Rannsf726f532019-03-11 05:34:50 -0700603 bier_route_max = VppBierRoute(
604 self, bti, max_bp,
605 [VppRoutePath("0.0.0.0",
606 0xffffffff,
Neale Ranns097fa662018-05-01 05:17:55 -0700607 proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
608 nh_table_id=8)])
Neale Rannsf0510722018-01-31 11:35:41 -0800609 bier_route_max.add_vpp_config()
Neale Rannsd792d9c2017-10-21 10:53:20 -0700610
611 #
612 # An entry in the disposition table for sender 333
613 # lookup in VRF 10
614 #
615 bier_de_1 = VppBierDispEntry(self, bdt.id, 333,
616 BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
Neale Ranns097fa662018-05-01 05:17:55 -0700617 FibPathProto.FIB_PATH_NH_PROTO_BIER,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700618 "0.0.0.0", 10, rpf_id=8192)
619 bier_de_1.add_vpp_config()
Neale Rannsf0510722018-01-31 11:35:41 -0800620 bier_de_1 = VppBierDispEntry(self, bdt.id, 334,
621 BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
Neale Ranns097fa662018-05-01 05:17:55 -0700622 FibPathProto.FIB_PATH_NH_PROTO_BIER,
Neale Rannsf0510722018-01-31 11:35:41 -0800623 "0.0.0.0", 10, rpf_id=8193)
624 bier_de_1.add_vpp_config()
Neale Rannsd792d9c2017-10-21 10:53:20 -0700625
626 #
Neale Rannsf0510722018-01-31 11:35:41 -0800627 # Add a multicast routes that will forward the traffic
Neale Rannsd792d9c2017-10-21 10:53:20 -0700628 # post-disposition
629 #
630 route_eg_232_1_1_1 = VppIpMRoute(
631 self,
632 "0.0.0.0",
633 "232.1.1.1", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000634 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Rannsd792d9c2017-10-21 10:53:20 -0700635 table_id=10,
636 paths=[VppMRoutePath(self.pg1.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000637 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)])
Neale Rannsd792d9c2017-10-21 10:53:20 -0700638 route_eg_232_1_1_1.add_vpp_config()
639 route_eg_232_1_1_1.update_rpf_id(8192)
Neale Rannsf0510722018-01-31 11:35:41 -0800640 route_eg_232_1_1_2 = VppIpMRoute(
641 self,
642 "0.0.0.0",
643 "232.1.1.2", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000644 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Rannsf0510722018-01-31 11:35:41 -0800645 table_id=10,
646 paths=[VppMRoutePath(self.pg1.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000647 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)])
Neale Rannsf0510722018-01-31 11:35:41 -0800648 route_eg_232_1_1_2.add_vpp_config()
649 route_eg_232_1_1_2.update_rpf_id(8193)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700650
651 #
652 # inject a packet in VRF-0. We expect it to be BIER encapped,
653 # replicated, then hit the disposition and be forwarded
654 # out of VRF 10, i.e. on pg1
655 #
656 p = (Ether(dst=self.pg0.local_mac,
657 src=self.pg0.remote_mac) /
658 IP(src="1.1.1.1", dst="232.1.1.1") /
Neale Rannsf0510722018-01-31 11:35:41 -0800659 UDP(sport=1234, dport=1234) /
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700660 Raw(scapy.compat.chb(5) * 32))
Neale Rannsd792d9c2017-10-21 10:53:20 -0700661
Paul Vinciguerra4271c972019-05-14 13:25:49 -0400662 rx = self.send_and_expect(self.pg0, p*NUM_PKTS, self.pg1)
Neale Ranns91286372017-12-05 13:24:04 -0800663
Neale Ranns91286372017-12-05 13:24:04 -0800664 self.assertEqual(rx[0][IP].src, "1.1.1.1")
665 self.assertEqual(rx[0][IP].dst, "232.1.1.1")
666
Neale Rannsf0510722018-01-31 11:35:41 -0800667 p = (Ether(dst=self.pg0.local_mac,
668 src=self.pg0.remote_mac) /
669 IP(src="1.1.1.1", dst="232.1.1.2") /
670 UDP(sport=1234, dport=1234) /
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700671 Raw(scapy.compat.chb(5) * 512))
Neale Rannsf0510722018-01-31 11:35:41 -0800672
Paul Vinciguerra4271c972019-05-14 13:25:49 -0400673 rx = self.send_and_expect(self.pg0, p*NUM_PKTS, self.pg1)
Neale Rannsf0510722018-01-31 11:35:41 -0800674 self.assertEqual(rx[0][IP].src, "1.1.1.1")
675 self.assertEqual(rx[0][IP].dst, "232.1.1.2")
676
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800677 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Rannsf0510722018-01-31 11:35:41 -0800678 def test_bier_e2e_1024(self):
679 """ BIER end-to-end BSL:1024"""
680 self.bier_e2e(BIERLength.BIER_LEN_1024, 128, 1024)
681
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800682 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Rannsf0510722018-01-31 11:35:41 -0800683 def test_bier_e2e_512(self):
684 """ BIER end-to-end BSL:512"""
685 self.bier_e2e(BIERLength.BIER_LEN_512, 64, 512)
686
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800687 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Rannsf0510722018-01-31 11:35:41 -0800688 def test_bier_e2e_256(self):
689 """ BIER end-to-end BSL:256"""
690 self.bier_e2e(BIERLength.BIER_LEN_256, 32, 256)
691
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800692 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Neale Rannsf0510722018-01-31 11:35:41 -0800693 def test_bier_e2e_128(self):
694 """ BIER end-to-end BSL:128"""
695 self.bier_e2e(BIERLength.BIER_LEN_128, 16, 128)
696
697 def test_bier_e2e_64(self):
698 """ BIER end-to-end BSL:64"""
699 self.bier_e2e(BIERLength.BIER_LEN_64, 8, 64)
700
Neale Ranns91286372017-12-05 13:24:04 -0800701 def test_bier_head_o_udp(self):
702 """BIER head over UDP"""
703
Neale Ranns990f6942020-10-20 07:20:17 +0000704 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
705 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
706
Neale Ranns91286372017-12-05 13:24:04 -0800707 #
708 # Add a BIER table for sub-domain 1, set 0, and BSL 256
709 #
710 bti = VppBierTableID(1, 0, BIERLength.BIER_LEN_256)
711 bt = VppBierTable(self, bti, 77)
712 bt.add_vpp_config()
713
714 #
715 # 1 bit positions via 1 next hops
716 #
717 nh1 = "10.0.0.1"
718 ip_route = VppIpRoute(self, nh1, 32,
719 [VppRoutePath(self.pg1.remote_ip4,
720 self.pg1.sw_if_index,
Neale Ranns31ed7442018-02-23 05:29:09 -0800721 labels=[VppMplsLabel(2001)])])
Neale Ranns91286372017-12-05 13:24:04 -0800722 ip_route.add_vpp_config()
723
Neale Ranns9c0a3c42018-09-07 08:57:41 -0700724 udp_encap = VppUdpEncap(self,
Neale Ranns91286372017-12-05 13:24:04 -0800725 self.pg0.local_ip4,
726 nh1,
727 330, 8138)
728 udp_encap.add_vpp_config()
729
Neale Ranns2303cb12018-02-21 04:57:17 -0800730 bier_route = VppBierRoute(
731 self, bti, 1,
732 [VppRoutePath("0.0.0.0",
733 0xFFFFFFFF,
Neale Ranns097fa662018-05-01 05:17:55 -0700734 type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP,
Neale Ranns9c0a3c42018-09-07 08:57:41 -0700735 next_hop_id=udp_encap.id)])
Neale Ranns91286372017-12-05 13:24:04 -0800736 bier_route.add_vpp_config()
737
738 #
Neale Rannseea537a2018-01-09 04:11:28 -0800739 # An 2 imposition objects with all bit-positions set
740 # only use the second, but creating 2 tests with a non-zero
741 # value index in the route add
Neale Ranns91286372017-12-05 13:24:04 -0800742 #
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700743 bi = VppBierImp(self, bti, 333, scapy.compat.chb(0xff) * 32)
Neale Ranns91286372017-12-05 13:24:04 -0800744 bi.add_vpp_config()
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700745 bi2 = VppBierImp(self, bti, 334, scapy.compat.chb(0xff) * 32)
Neale Rannseea537a2018-01-09 04:11:28 -0800746 bi2.add_vpp_config()
Neale Ranns91286372017-12-05 13:24:04 -0800747
748 #
749 # Add a multicast route that will forward into the BIER doamin
750 #
751 route_ing_232_1_1_1 = VppIpMRoute(
752 self,
753 "0.0.0.0",
754 "232.1.1.1", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000755 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Ranns91286372017-12-05 13:24:04 -0800756 paths=[VppMRoutePath(self.pg0.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000757 MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
Neale Ranns91286372017-12-05 13:24:04 -0800758 VppMRoutePath(0xffffffff,
Neale Ranns990f6942020-10-20 07:20:17 +0000759 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD,
Neale Ranns097fa662018-05-01 05:17:55 -0700760 proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
761 type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
Neale Rannseea537a2018-01-09 04:11:28 -0800762 bier_imp=bi2.bi_index)])
Neale Ranns91286372017-12-05 13:24:04 -0800763 route_ing_232_1_1_1.add_vpp_config()
764
765 #
766 # inject a packet an IP. We expect it to be BIER and UDP encapped,
767 #
768 p = (Ether(dst=self.pg0.local_mac,
769 src=self.pg0.remote_mac) /
770 IP(src="1.1.1.1", dst="232.1.1.1") /
771 UDP(sport=1234, dport=1234))
772
773 self.pg0.add_stream([p])
774 self.pg_enable_capture(self.pg_interfaces)
775 self.pg_start()
776
777 rx = self.pg1.get_capture(1)
778
779 #
780 # Encap Stack is, eth, IP, UDP, BIFT, BIER
781 #
782 self.assertEqual(rx[0][IP].src, self.pg0.local_ip4)
783 self.assertEqual(rx[0][IP].dst, nh1)
784 self.assertEqual(rx[0][UDP].sport, 330)
785 self.assertEqual(rx[0][UDP].dport, 8138)
Neale Ranns9c0a3c42018-09-07 08:57:41 -0700786 self.assertEqual(rx[0][BIFT].bsl, BIERLength.BIER_LEN_256)
Neale Ranns91286372017-12-05 13:24:04 -0800787 self.assertEqual(rx[0][BIFT].sd, 1)
788 self.assertEqual(rx[0][BIFT].set, 0)
789 self.assertEqual(rx[0][BIFT].ttl, 64)
790 self.assertEqual(rx[0][BIER].length, 2)
791
792 def test_bier_tail_o_udp(self):
793 """BIER Tail over UDP"""
794
Neale Ranns990f6942020-10-20 07:20:17 +0000795 MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
796 MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t
797
Neale Ranns91286372017-12-05 13:24:04 -0800798 #
799 # Add a BIER table for sub-domain 0, set 0, and BSL 256
800 #
801 bti = VppBierTableID(1, 0, BIERLength.BIER_LEN_256)
802 bt = VppBierTable(self, bti, MPLS_LABEL_INVALID)
803 bt.add_vpp_config()
804
805 #
806 # disposition table
807 #
808 bdt = VppBierDispTable(self, 8)
809 bdt.add_vpp_config()
810
811 #
812 # BIER route in table that's for-us
813 #
Neale Ranns2303cb12018-02-21 04:57:17 -0800814 bier_route_1 = VppBierRoute(
815 self, bti, 1,
816 [VppRoutePath("0.0.0.0",
817 0xffffffff,
Neale Ranns097fa662018-05-01 05:17:55 -0700818 proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
Neale Ranns2303cb12018-02-21 04:57:17 -0800819 nh_table_id=8)])
Neale Ranns91286372017-12-05 13:24:04 -0800820 bier_route_1.add_vpp_config()
821
822 #
823 # An entry in the disposition table
824 #
825 bier_de_1 = VppBierDispEntry(self, bdt.id, 99,
826 BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
Neale Ranns097fa662018-05-01 05:17:55 -0700827 FibPathProto.FIB_PATH_NH_PROTO_BIER,
Neale Ranns91286372017-12-05 13:24:04 -0800828 "0.0.0.0", 0, rpf_id=8192)
829 bier_de_1.add_vpp_config()
830
831 #
832 # A multicast route to forward post BIER disposition
833 #
834 route_eg_232_1_1_1 = VppIpMRoute(
835 self,
836 "0.0.0.0",
837 "232.1.1.1", 32,
Neale Ranns990f6942020-10-20 07:20:17 +0000838 MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
Neale Ranns91286372017-12-05 13:24:04 -0800839 paths=[VppMRoutePath(self.pg1.sw_if_index,
Neale Ranns990f6942020-10-20 07:20:17 +0000840 MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD)])
Neale Ranns91286372017-12-05 13:24:04 -0800841 route_eg_232_1_1_1.add_vpp_config()
842 route_eg_232_1_1_1.update_rpf_id(8192)
843
844 #
845 # A packet with all bits set gets spat out to BP:1
846 #
847 p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
848 IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
849 UDP(sport=333, dport=8138) /
850 BIFT(sd=1, set=0, bsl=2, ttl=255) /
Neale Rannsf0510722018-01-31 11:35:41 -0800851 BIER(length=BIERLength.BIER_LEN_256,
Paul Vinciguerraa7427ec2019-03-10 10:04:23 -0700852 BitString=scapy.compat.chb(255)*32,
Neale Rannsf0510722018-01-31 11:35:41 -0800853 BFRID=99) /
Neale Ranns91286372017-12-05 13:24:04 -0800854 IP(src="1.1.1.1", dst="232.1.1.1") /
855 UDP(sport=1234, dport=1234) /
856 Raw())
857
858 rx = self.send_and_expect(self.pg0, [p], self.pg1)
Neale Rannsd792d9c2017-10-21 10:53:20 -0700859
860
861if __name__ == '__main__':
862 unittest.main(testRunner=VppTestRunner)