fib: Always install all routers mcast addresses 55/25955/5
authorNeale Ranns <nranns@cisco.com>
Tue, 17 Mar 2020 14:25:10 +0000 (14:25 +0000)
committerNeale Ranns <nranns@cisco.com>
Tue, 17 Mar 2020 18:38:29 +0000 (18:38 +0000)
Type: improvement

Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: Ia8dff15855a81cf29729bdaa3ff28fbe3254fa97

src/plugins/igmp/test/test_igmp.py
src/plugins/unittest/fib_test.c
src/plugins/unittest/mfib_test.c
src/vnet/ip/ip4_forward.c
src/vnet/ip/ip_punt_drop.c
src/vnet/mfib/ip4_mfib.c
src/vnet/mfib/ip4_mfib.h
src/vnet/mfib/mfib_types.h
test/test_ip4.py
test/test_ip6.py

index 1974794..01f59ba 100644 (file)
@@ -90,10 +90,10 @@ class TestIgmp(VppTestCase):
         self.vapi.igmp_enable_disable(self.pg2.sw_if_index, 0, IGMP_MODE.HOST)
         self.vapi.igmp_enable_disable(self.pg3.sw_if_index, 0, IGMP_MODE.HOST)
 
-        self.assertFalse(find_mroute(self, "224.0.0.1", "0.0.0.0", 32))
+        self.assertTrue(find_mroute(self, "224.0.0.1", "0.0.0.0", 32))
         self.assertFalse(find_mroute(self, "224.0.0.22", "0.0.0.0", 32))
-        self.assertFalse(find_mroute(self, "224.0.0.1", "0.0.0.0", 32,
-                                     table_id=1))
+        self.assertTrue(find_mroute(self, "224.0.0.1", "0.0.0.0", 32,
+                                    table_id=1))
         self.assertFalse(find_mroute(self, "224.0.0.22", "0.0.0.0", 32,
                                      table_id=1))
 
index 2d75f28..d86ccb1 100644 (file)
@@ -845,11 +845,11 @@ fib_test_v4 (void)
      * at this stage there are 5 entries in the test FIB (plus 5 in the default),
      * all of which are special sourced and so none of which share path-lists.
      * There are also 2 entries, and 2 non-shared path-lists, in the v6 default
-     * table, and 4 path-lists in the v6 MFIB table
+     * table, and 4 path-lists in the v6 MFIB table and 2 in v4.
      */
 #define ENBR (5+5+2)
 
-    u32 PNBR = 5+5+2+4;
+    u32 PNBR = 5+5+2+4+2;
 
     /*
      * if the IGMP plugin is loaded this adds two more entries to the v4 MFIB
@@ -4441,11 +4441,11 @@ fib_test_v6 (void)
 
     /*
      * At this stage there is one v4 FIB with 5 routes and two v6 FIBs
-     * each with 2 entries and a v6 mfib with 4 path-lists.
+     * each with 2 entries and a v6 mfib with 4 path-lists and v4 mfib with 2.
      * All entries are special so no path-list sharing.
      */
 #define ENPS (5+4)
-    u32 PNPS = (5+4+4);
+    u32 PNPS = (5+4+4+2);
     /*
      * if the IGMP plugin is loaded this adds two more entries to the v4 MFIB
      */
index 2497a29..764e183 100644 (file)
@@ -1279,7 +1279,7 @@ mfib_test_i (fib_protocol_t PROTO,
     /*
      * Unlock the table - it's the last lock so should be gone thereafter
      */
-    MFIB_TEST(((PROTO == FIB_PROTOCOL_IP4 ? 1 : 5) ==
+    MFIB_TEST(((PROTO == FIB_PROTOCOL_IP4 ? 3 : 5) ==
                mfib_table_get_n_routes(fib_index, PROTO)),
               "1 = %d route left in the FIB",
               mfib_table_get_n_routes(fib_index, PROTO));
index 95db931..7471a00 100644 (file)
@@ -49,6 +49,7 @@
 #include <vnet/fib/fib_entry.h>        /* for FIB table and entry creation */
 #include <vnet/fib/fib_urpf_list.h>    /* for FIB uRPF check */
 #include <vnet/fib/ip4_fib.h>
+#include <vnet/mfib/ip4_mfib.h>
 #include <vnet/dpo/load_balance.h>
 #include <vnet/dpo/load_balance_map.h>
 #include <vnet/dpo/classify_dpo.h>
@@ -761,6 +762,7 @@ ip4_add_del_interface_address_internal (vlib_main_t * vm,
     goto done;
 
   ip4_sw_interface_enable_disable (sw_if_index, !is_del);
+  ip4_mfib_interface_enable_disable (sw_if_index, !is_del);
 
   /* intf addr routes are added/deleted on admin up/down */
   if (vnet_sw_interface_is_admin_up (vnm, sw_if_index))
@@ -1061,6 +1063,7 @@ ip4_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
         ip4_add_del_interface_address(vm, sw_if_index, address, ia->address_length, 1);
       }));
       /* *INDENT-ON* */
+      ip4_mfib_interface_enable_disable (sw_if_index, 0);
     }
 
   vnet_feature_enable_disable ("ip4-unicast", "ip4-not-enabled", sw_if_index,
index 01577a4..ce1631f 100644 (file)
@@ -29,7 +29,7 @@ format_ip_punt_redirect_trace (u8 * s, va_list * args)
   ip_punt_redirect_trace_t *t = va_arg (*args, ip_punt_redirect_trace_t *);
 
   if (INDEX_INVALID == t->rrxi)
-    s = format (s, "drop");
+    s = format (s, "ignore");
   else
     s = format (s, "via redirect:%d", t->rrxi);
 
index 4da1be6..6973380 100644 (file)
 #include <vnet/mfib/mfib_table.h>
 #include <vnet/mfib/mfib_entry.h>
 
-static const mfib_prefix_t ip4_specials[] = {
+static const mfib_prefix_t all_zeros =
+{
+    .fp_proto = FIB_PROTOCOL_IP4,
+};
+static const mfib_prefix_t ip4_specials[] =
+{
+    /* ALL prefixes are in network order */
     {
-        /* (*,*)/0 */
-        .fp_src_addr = {
-            .ip4.data_u32 = 0,
+        /* (*,224.0.0.1)/32 - all hosts */
+        .fp_grp_addr = {
+            .ip4.data_u32 = 0x010000e0,
         },
+        .fp_len = 32,
+        .fp_proto = FIB_PROTOCOL_IP4,
+    },
+    {
+        /* (*,224.0.0.2)/32 - all routers */
         .fp_grp_addr = {
-            .ip4.data_u32 = 0,
+            .ip4.data_u32 = 0x020000e0,
         },
-        .fp_len  = 0,
+        .fp_len = 32,
         .fp_proto = FIB_PROTOCOL_IP4,
     },
 };
@@ -57,24 +68,31 @@ ip4_create_mfib_with_table_id (u32 table_id,
     mfib_table_lock(mfib_table->mft_index, FIB_PROTOCOL_IP4, src);
 
     /*
-     * add the special entries into the new FIB
+     * add the default route into the new FIB
      */
+    mfib_table_entry_update(mfib_table->mft_index,
+                            &all_zeros,
+                            MFIB_SOURCE_DEFAULT_ROUTE,
+                            MFIB_RPF_ID_NONE,
+                            MFIB_ENTRY_FLAG_DROP);
+
+    const fib_route_path_t path = {
+        .frp_proto = DPO_PROTO_IP4,
+        .frp_addr = zero_addr,
+        .frp_sw_if_index = ~0,
+        .frp_fib_index = ~0,
+        .frp_weight = 1,
+        .frp_flags = FIB_ROUTE_PATH_LOCAL,
+        .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD,
+    };
     int ii;
 
     for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
     {
-        mfib_prefix_t prefix = ip4_specials[ii];
-
-        prefix.fp_src_addr.ip4.data_u32 =
-            clib_host_to_net_u32(prefix.fp_src_addr.ip4.data_u32);
-        prefix.fp_grp_addr.ip4.data_u32 =
-            clib_host_to_net_u32(prefix.fp_grp_addr.ip4.data_u32);
-
-        mfib_table_entry_update(mfib_table->mft_index,
-                                &prefix,
-                                MFIB_SOURCE_DEFAULT_ROUTE,
-                                MFIB_RPF_ID_NONE,
-                                MFIB_ENTRY_FLAG_DROP);
+        mfib_table_entry_path_update(mfib_table->mft_index,
+                                     &ip4_specials[ii],
+                                     MFIB_SOURCE_SPECIAL,
+                                     &path);
     }
 
     return (mfib_table->mft_index);
@@ -89,18 +107,15 @@ ip4_mfib_table_destroy (ip4_mfib_t *mfib)
     /*
      * remove all the specials we added when the table was created.
      */
+    mfib_table_entry_delete(mfib_table->mft_index,
+                            &all_zeros,
+                            MFIB_SOURCE_DEFAULT_ROUTE);
+
     for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
     {
-        fib_node_index_t mfei;
-        mfib_prefix_t prefix = ip4_specials[ii];
-
-        prefix.fp_src_addr.ip4.data_u32 =
-            clib_host_to_net_u32(prefix.fp_src_addr.ip4.data_u32);
-        prefix.fp_grp_addr.ip4.data_u32 =
-            clib_host_to_net_u32(prefix.fp_grp_addr.ip4.data_u32);
-
-        mfei = mfib_table_lookup(mfib_table->mft_index, &prefix);
-        mfib_table_entry_delete_index(mfei, MFIB_SOURCE_DEFAULT_ROUTE);
+        mfib_table_entry_delete(mfib_table->mft_index,
+                                &ip4_specials[ii],
+                                MFIB_SOURCE_SPECIAL);
     }
 
     /*
@@ -113,6 +128,42 @@ ip4_mfib_table_destroy (ip4_mfib_t *mfib)
     pool_put(ip4_main.mfibs, mfib_table);
 }
 
+void
+ip4_mfib_interface_enable_disable (u32 sw_if_index, int is_enable)
+{
+    const fib_route_path_t path = {
+        .frp_proto = DPO_PROTO_IP4,
+        .frp_addr = zero_addr,
+        .frp_sw_if_index = sw_if_index,
+        .frp_fib_index = ~0,
+        .frp_weight = 1,
+        .frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT,
+    };
+    u32 mfib_index;
+    int ii;
+
+    vec_validate (ip4_main.mfib_index_by_sw_if_index, sw_if_index);
+    mfib_index = ip4_mfib_table_get_index_for_sw_if_index(sw_if_index);
+
+    for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
+    {
+        if (is_enable)
+        {
+            mfib_table_entry_path_update(mfib_index,
+                                         &ip4_specials[ii],
+                                         MFIB_SOURCE_SPECIAL,
+                                         &path);
+        }
+        else
+        {
+            mfib_table_entry_path_remove(mfib_index,
+                                         &ip4_specials[ii],
+                                         MFIB_SOURCE_SPECIAL,
+                                         &path);
+        }
+    }
+}
+
 u32
 ip4_mfib_table_find_or_create_and_lock (u32 table_id,
                                         mfib_source_t src)
index 5b22559..2e263a4 100644 (file)
@@ -55,6 +55,13 @@ extern void ip4_mfib_table_entry_insert(ip4_mfib_t *fib,
                                         fib_node_index_t fib_entry_index);
 extern void ip4_mfib_table_destroy(ip4_mfib_t *fib);
 
+/**
+ * @brief
+ *  Add/remove the interface from the accepting list of the special MFIB entries
+ */
+extern void ip4_mfib_interface_enable_disable(u32 sw_if_index,
+                                              int is_enable);
+
 /**
  * @brief Get the FIB at the given index
  */
index 650a7a5..edc25fe 100644 (file)
@@ -172,6 +172,7 @@ typedef enum mfib_source_t_
     MFIB_SOURCE_GENEVE,
     MFIB_SOURCE_IGMP,
     MFIB_SOURCE_VXLAN_GBP,
+    MFIB_SOURCE_PLUGIN_LOW,
     MFIB_SOURCE_RR,
     MFIB_SOURCE_DEFAULT_ROUTE,
 } mfib_source_t;
@@ -189,6 +190,7 @@ typedef enum mfib_source_t_
     [MFIB_SOURCE_GENEVE] = "Geneve",               \
     [MFIB_SOURCE_IGMP] = "IGMP",                   \
     [MFIB_SOURCE_VXLAN_GBP] = "VXLAN-GBP",         \
+    [MFIB_SOURCE_PLUGIN_LOW] = "plugin-low",       \
     [MFIB_SOURCE_RR] = "Recursive-resolution",     \
     [MFIB_SOURCE_DEFAULT_ROUTE] = "Default Route", \
 }
index 87059c7..18b350d 100644 (file)
@@ -2089,7 +2089,7 @@ class TestIPReplace(VppTestCase):
         for t in self.tables:
             t.flush()
             self.assertEqual(len(t.dump()), 5)
-            self.assertEqual(len(t.mdump()), 1)
+            self.assertEqual(len(t.mdump()), 3)
 
 
 class TestIPCover(VppTestCase):
index b27cfdb..1f00ed3 100644 (file)
@@ -960,7 +960,7 @@ class TestIPv6(TestIPv6ND):
         subitf.admin_up()
         subitf.config_ip6()
 
-        rxs = self.pg1._get_capture(timeout=2, filter_out_fn=None)
+        rxs = self.pg1._get_capture(timeout=4, filter_out_fn=None)
 
         #
         # hunt for the MLD on vlan 99