+ Raw(b'\xa5' * 100))
+
+ rx = self.send_and_expect(self.pg2,
+ pkt_tag_to_non_tag * NUM_PKTS,
+ self.pg1)
+ self.assert_same_mac_addr(pkt_tag_to_tag, rx)
+ self.assert_has_no_tag(rx)
+
+ #
+ # Add an output L3 ACL that will block the traffic
+ #
+ rule_1 = ({'is_permit': 0,
+ 'is_ipv6': 0,
+ 'proto': 17,
+ 'srcport_or_icmptype_first': 1234,
+ 'srcport_or_icmptype_last': 1234,
+ 'src_ip_prefix_len': 32,
+ 'src_ip_addr': inet_pton(AF_INET, any_src_addr),
+ 'dstport_or_icmpcode_first': 1234,
+ 'dstport_or_icmpcode_last': 1234,
+ 'dst_ip_prefix_len': 32,
+ 'dst_ip_addr': inet_pton(AF_INET, ip_non_tag_bridged)})
+ acl = self.vapi.acl_add_replace(acl_index=4294967295,
+ r=[rule_1])
+
+ #
+ # Apply the ACL on the output interface
+ #
+ self.vapi.acl_interface_set_acl_list(self.pg1.sw_if_index,
+ 0,
+ [acl.acl_index])
+
+ #
+ # Send packet's that should match the ACL and be dropped
+ #
+ rx = self.send_and_assert_no_replies(self.pg2,
+ pkt_tag_to_non_tag * NUM_PKTS)
+
+ #
+ # cleanup
+ #
+ self.vapi.acl_interface_set_acl_list(self.pg1.sw_if_index,
+ 0, [])
+ self.vapi.acl_del(acl.acl_index)
+
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.pg0.sw_if_index, bd_id=1, enable=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.pg1.sw_if_index, bd_id=1, enable=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=sub_if_on_pg2.sw_if_index, bd_id=1, enable=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=sub_if_on_pg3.sw_if_index, bd_id=1, enable=0)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.loop0.sw_if_index, bd_id=1,
+ port_type=L2_PORT_TYPE.BVI, enable=0)
+
+ #
+ # Do a FIB dump to make sure the paths are correctly reported as DVR
+ #
+ routes = self.vapi.ip_route_dump(0)
+
+ for r in routes:
+ if (ip_tag_bridged == str(r.route.prefix.network_address)):
+ self.assertEqual(r.route.paths[0].sw_if_index,
+ sub_if_on_pg3.sw_if_index)
+ self.assertEqual(r.route.paths[0].type,
+ FibPathType.FIB_PATH_TYPE_DVR)
+ if (ip_non_tag_bridged == str(r.route.prefix.network_address)):
+ self.assertEqual(r.route.paths[0].sw_if_index,
+ self.pg1.sw_if_index)
+ self.assertEqual(r.route.paths[0].type,
+ FibPathType.FIB_PATH_TYPE_DVR)
+
+ #
+ # the explicit route delete is require so it happens before
+ # the sbu-interface delete. subinterface delete is required
+ # because that object type does not use the object registry
+ #
+ route_no_tag.remove_vpp_config()
+ route_with_tag.remove_vpp_config()
+ sub_if_on_pg3.remove_vpp_config()
+ sub_if_on_pg2.remove_vpp_config()
+
+ def test_l2_emulation(self):
+ """ L2 Emulation """
+
+ #
+ # non distinct L3 packets, in the tag/non-tag combos
+ #
+ pkt_no_tag = (Ether(src=self.pg0.remote_mac,
+ dst=self.pg1.remote_mac) /
+ IP(src="2.2.2.2",
+ dst="1.1.1.1") /
+ UDP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 100))
+ pkt_to_tag = (Ether(src=self.pg0.remote_mac,
+ dst=self.pg2.remote_mac) /
+ IP(src="2.2.2.2",
+ dst="1.1.1.2") /
+ UDP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 100))
+ pkt_from_tag = (Ether(src=self.pg3.remote_mac,
+ dst=self.pg2.remote_mac) /
+ Dot1Q(vlan=93) /
+ IP(src="2.2.2.2",
+ dst="1.1.1.1") /
+ UDP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 100))
+ pkt_from_to_tag = (Ether(src=self.pg3.remote_mac,
+ dst=self.pg2.remote_mac) /
+ Dot1Q(vlan=93) /
+ IP(src="2.2.2.2",
+ dst="1.1.1.2") /
+ UDP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 100))
+ pkt_bcast = (Ether(src=self.pg0.remote_mac,
+ dst="ff:ff:ff:ff:ff:ff") /
+ IP(src="2.2.2.2",
+ dst="255.255.255.255") /
+ UDP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 100))
+
+ #
+ # A couple of sub-interfaces for tags
+ #
+ sub_if_on_pg2 = VppDot1QSubint(self, self.pg2, 92)
+ sub_if_on_pg3 = VppDot1QSubint(self, self.pg3, 93)
+ sub_if_on_pg2.admin_up()
+ sub_if_on_pg3.admin_up()