L2FIB:fix crash in show with deleted subif entries 09/7109/3
authorEyal Bari <ebari@cisco.com>
Mon, 12 Jun 2017 14:07:22 +0000 (17:07 +0300)
committerDave Barach <openvpp@barachs.net>
Mon, 12 Jun 2017 22:52:35 +0000 (22:52 +0000)
after deleting a sub interface it's l2fib entries are left with a dangling
sw_if_index (while waiting for the ager to delete them).
changed "show l2fib" to reflect that state with "Deleted" as the interface name.

added sleep in test_l2_fib as a workaround for packets still passing after flush
will investigate...

Change-Id: Id998d7d3c6a073ef5005c5f3009e1cfb7febf7db
Signed-off-by: Eyal Bari <ebari@cisco.com>
src/vnet/l2/l2_fib.c
test/test_l2_fib.py

index d4207e3..f17eee2 100644 (file)
@@ -62,10 +62,13 @@ format_vnet_sw_if_index_name_with_NA (u8 * s, va_list * args)
   u32 sw_if_index = va_arg (*args, u32);
   if (sw_if_index == ~0)
     return format (s, "N/A");
-  else
-    return format (s, "%U",
-                  format_vnet_sw_interface_name, vnm,
-                  vnet_get_sw_interface (vnm, sw_if_index));
+
+  vnet_sw_interface_t *swif = vnet_get_sw_interface_safe (vnm, sw_if_index);
+  if (!swif)
+    return format (s, "Deleted");
+
+  return format (s, "%U", format_vnet_sw_interface_name, vnm,
+                vnet_get_sw_interface_safe (vnm, sw_if_index));
 }
 
 void
index 9249a2c..f9a78ef 100644 (file)
@@ -490,6 +490,7 @@ class TestL2fib(VppTestCase):
         self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=10)
         self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=10)
         flushed = self.flush_int(self.pg_interfaces[0].sw_if_index)
+        self.sleep(1)
         self.run_verify_test(bd_id=1, dst_hosts=self.learned_hosts)
         self.run_verify_negat_test(bd_id=1, dst_hosts=flushed)
 
@@ -503,6 +504,7 @@ class TestL2fib(VppTestCase):
         self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=10)
         self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=10)
         flushed = self.flush_bd(bd_id=1)
+        self.sleep(1)
         self.run_verify_negat_test(bd_id=1, dst_hosts=flushed)
         self.run_verify_test(bd_id=2, dst_hosts=self.learned_hosts)
 
@@ -516,6 +518,7 @@ class TestL2fib(VppTestCase):
         self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=10)
         self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=10)
         flushed = self.flush_all()
+        self.sleep(2)
         self.run_verify_negat_test(bd_id=1, dst_hosts=flushed)
         self.run_verify_negat_test(bd_id=2, dst_hosts=flushed)