-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
from vpp_ip_route import VppIpRoute, VppRoutePath, \
VppMplsTable, VppIpMRoute, VppMRoutePath, VppIpTable, \
MRouteEntryFlags, MRouteItfFlags, MPLS_LABEL_INVALID, \
- VppMplsLabel
+ VppMplsLabel, FibPathProto, FibPathType
from vpp_bier import BIER_HDR_PAYLOAD, VppBierImp, VppBierDispEntry, \
VppBierDispTable, VppBierTable, VppBierTableID, VppBierRoute
from vpp_udp_encap import VppUdpEncap
from scapy.contrib.mpls import MPLS
from scapy.contrib.bier import BIER, BIERLength, BIFT
+NUM_PKTS = 67
+
class TestBFIB(VppTestCase):
""" BIER FIB Test Case """
byte_val = scapy.compat.chb(1 << (bp - 1) % 8)
byte_pos = n_bytes - (((bp - 1) // 8) + 1)
byte_array[byte_pos] = byte_val
- bitstring = ''.join([scapy.compat.chb(x) for x in byte_array])
+ bitstring = b''.join([scapy.compat.chb(x) for x in byte_array])
self.assertEqual(len(bitstring), len(bier_hdr.BitString))
self.assertEqual(bitstring, bier_hdr.BitString)
labels=[VppMplsLabel(101)])])
rx = self.send_and_expect(self.pg0, pkts, self.pg1)
+
for nh in nhs:
self.assertTrue(sum(p[MPLS].label == nh['label'] for p in rx))
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi.bi_index)])
route_ing_232_1_1_1.add_vpp_config()
self, bti, 1,
[VppRoutePath("0.0.0.0",
0xffffffff,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
nh_table_id=8)])
bier_route_1.add_vpp_config()
#
bier_de_1 = VppBierDispEntry(self, bdt.id, 99,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 0, rpf_id=8192)
bier_de_1.add_vpp_config()
#
bier_de_2 = VppBierDispEntry(self, bdt.id, 0,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 0, rpf_id=8192)
bier_de_2.add_vpp_config()
paths=[VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
proto=DpoProto.DPO_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi.bi_index),
VppMRoutePath(self.pg1.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi_low.bi_index)])
route_ing_232_1_1_1.add_vpp_config()
route_ing_232_1_1_2 = VppIpMRoute(
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi_high.bi_index)])
route_ing_232_1_1_2.add_vpp_config()
self, bti, 1,
[VppRoutePath("0.0.0.0",
0xffffffff,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
nh_table_id=8)])
bier_route_1.add_vpp_config()
- bier_route_max = VppBierRoute(self, bti, max_bp,
- [VppRoutePath("0.0.0.0",
- 0xffffffff,
- nh_table_id=8)])
+ bier_route_max = VppBierRoute(
+ self, bti, max_bp,
+ [VppRoutePath("0.0.0.0",
+ 0xffffffff,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ nh_table_id=8)])
bier_route_max.add_vpp_config()
#
#
bier_de_1 = VppBierDispEntry(self, bdt.id, 333,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 10, rpf_id=8192)
bier_de_1.add_vpp_config()
bier_de_1 = VppBierDispEntry(self, bdt.id, 334,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 10, rpf_id=8193)
bier_de_1.add_vpp_config()
UDP(sport=1234, dport=1234) /
Raw(scapy.compat.chb(5) * 32))
- rx = self.send_and_expect(self.pg0, p*65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p*NUM_PKTS, self.pg1)
self.assertEqual(rx[0][IP].src, "1.1.1.1")
self.assertEqual(rx[0][IP].dst, "232.1.1.1")
UDP(sport=1234, dport=1234) /
Raw(scapy.compat.chb(5) * 512))
- rx = self.send_and_expect(self.pg0, p*65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p*NUM_PKTS, self.pg1)
self.assertEqual(rx[0][IP].src, "1.1.1.1")
self.assertEqual(rx[0][IP].dst, "232.1.1.2")
self, bti, 1,
[VppRoutePath("0.0.0.0",
0xFFFFFFFF,
- is_udp_encap=1,
+ type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP,
next_hop_id=udp_encap.id)])
bier_route.add_vpp_config()
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi2.bi_index)])
route_ing_232_1_1_1.add_vpp_config()
self, bti, 1,
[VppRoutePath("0.0.0.0",
0xffffffff,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
nh_table_id=8)])
bier_route_1.add_vpp_config()
#
bier_de_1 = VppBierDispEntry(self, bdt.id, 99,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 0, rpf_id=8192)
bier_de_1.add_vpp_config()