VPP-1506: dump local punts and registered punt sockets
[vpp.git] / test / test_l2_flood.py
index 50a692e..9f3ef53 100644 (file)
@@ -5,7 +5,7 @@ import socket
 
 from framework import VppTestCase, VppTestRunner
 from vpp_ip_route import VppIpRoute, VppRoutePath
-from vpp_papi_provider import L2_PORT_TYPE, BRIDGE_FLAGS
+from vpp_l2 import L2_PORT_TYPE, BRIDGE_FLAGS
 
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether
@@ -144,6 +144,39 @@ class TestL2Flood(VppTestCase):
 
         self.vapi.bridge_domain_add_del(1, is_add=0)
 
+    def test_flood_one(self):
+        """ L2 no-Flood Test """
+
+        #
+        # Create a single bridge Domain
+        #
+        self.vapi.bridge_domain_add_del(1)
+
+        #
+        # add 2 interfaces to the BD. this means a flood goes to only
+        # one member
+        #
+        for i in self.pg_interfaces[:2]:
+            self.vapi.sw_interface_set_l2_bridge(i.sw_if_index, 1, 0)
+
+        p = (Ether(dst="ff:ff:ff:ff:ff:ff",
+                   src="00:00:de:ad:be:ef") /
+             IP(src="10.10.10.10", dst="1.1.1.1") /
+             UDP(sport=1234, dport=1234) /
+             Raw('\xa5' * 100))
+
+        #
+        # input on pg0 expect copies on pg1
+        #
+        self.send_and_expect(self.pg0, p*65, self.pg1)
+
+        #
+        # cleanup
+        #
+        for i in self.pg_interfaces[:2]:
+            self.vapi.sw_interface_set_l2_bridge(i.sw_if_index, 1, enable=0)
+        self.vapi.bridge_domain_add_del(1, is_add=0)
+
     def test_uu_fwd(self):
         """ UU Flood """
 
@@ -159,13 +192,18 @@ class TestL2Flood(VppTestCase):
             self.vapi.sw_interface_set_l2_bridge(i.sw_if_index, 1, 0)
 
         #
-        # an unknown unicast packet
+        # an unknown unicast and braodcast packets
         #
         p_uu = (Ether(dst="00:00:00:c1:5c:00",
                       src="00:00:de:ad:be:ef") /
                 IP(src="10.10.10.10", dst="1.1.1.1") /
                 UDP(sport=1234, dport=1234) /
                 Raw('\xa5' * 100))
+        p_bm = (Ether(dst="ff:ff:ff:ff:ff:ff",
+                      src="00:00:de:ad:be:ef") /
+                IP(src="10.10.10.10", dst="1.1.1.1") /
+                UDP(sport=1234, dport=1234) /
+                Raw('\xa5' * 100))
 
         #
         # input on pg0, expected copies on pg1->4
@@ -174,6 +212,13 @@ class TestL2Flood(VppTestCase):
         self.pg_enable_capture(self.pg_interfaces)
         self.pg_start()
 
+        for i in self.pg_interfaces[1:4]:
+            rx0 = i.get_capture(65, timeout=1)
+
+        self.pg0.add_stream(p_bm*65)
+        self.pg_enable_capture(self.pg_interfaces)
+        self.pg_start()
+
         for i in self.pg_interfaces[1:4]:
             rx0 = i.get_capture(65, timeout=1)
 
@@ -195,6 +240,13 @@ class TestL2Flood(VppTestCase):
         for i in self.pg_interfaces[0:4]:
             i.assert_nothing_captured(remark="UU not flooded")
 
+        self.pg0.add_stream(p_bm*65)
+        self.pg_enable_capture(self.pg_interfaces)
+        self.pg_start()
+
+        for i in self.pg_interfaces[1:4]:
+            rx0 = i.get_capture(65, timeout=1)
+
         #
         # remove the uu-fwd interface and expect UU to be flooded again
         #