aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2020-03-17 14:25:10 +0000
committerNeale Ranns <nranns@cisco.com>2020-03-17 18:38:29 +0000
commit03c254ec70917290b2fde27de1e7b37abe508ade (patch)
tree47b6807cfd2ac27fc9d460b1f19a0b0fc924786d
parent64e96613d27816ed7d24b9ca2ed760d855d76c81 (diff)
fib: Always install all routers mcast addresses
Type: improvement Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: Ia8dff15855a81cf29729bdaa3ff28fbe3254fa97
-rw-r--r--src/plugins/igmp/test/test_igmp.py6
-rw-r--r--src/plugins/unittest/fib_test.c8
-rw-r--r--src/plugins/unittest/mfib_test.c2
-rw-r--r--src/vnet/ip/ip4_forward.c3
-rw-r--r--src/vnet/ip/ip_punt_drop.c2
-rw-r--r--src/vnet/mfib/ip4_mfib.c109
-rw-r--r--src/vnet/mfib/ip4_mfib.h7
-rw-r--r--src/vnet/mfib/mfib_types.h2
-rw-r--r--test/test_ip4.py2
-rw-r--r--test/test_ip6.py2
10 files changed, 103 insertions, 40 deletions
diff --git a/src/plugins/igmp/test/test_igmp.py b/src/plugins/igmp/test/test_igmp.py
index 1974794f058..01f59bae024 100644
--- a/src/plugins/igmp/test/test_igmp.py
+++ b/src/plugins/igmp/test/test_igmp.py
@@ -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))
diff --git a/src/plugins/unittest/fib_test.c b/src/plugins/unittest/fib_test.c
index 2d75f28a8ca..d86ccb173dc 100644
--- a/src/plugins/unittest/fib_test.c
+++ b/src/plugins/unittest/fib_test.c
@@ -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
*/
diff --git a/src/plugins/unittest/mfib_test.c b/src/plugins/unittest/mfib_test.c
index 2497a299c50..764e1837653 100644
--- a/src/plugins/unittest/mfib_test.c
+++ b/src/plugins/unittest/mfib_test.c
@@ -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));
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index 95db9314d9b..7471a001e7a 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -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,
diff --git a/src/vnet/ip/ip_punt_drop.c b/src/vnet/ip/ip_punt_drop.c
index 01577a472ce..ce1631fd2f1 100644
--- a/src/vnet/ip/ip_punt_drop.c
+++ b/src/vnet/ip/ip_punt_drop.c
@@ -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);
diff --git a/src/vnet/mfib/ip4_mfib.c b/src/vnet/mfib/ip4_mfib.c
index 4da1be61113..6973380ec06 100644
--- a/src/vnet/mfib/ip4_mfib.c
+++ b/src/vnet/mfib/ip4_mfib.c
@@ -18,16 +18,27 @@
#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)
diff --git a/src/vnet/mfib/ip4_mfib.h b/src/vnet/mfib/ip4_mfib.h
index 5b225596469..2e263a497d2 100644
--- a/src/vnet/mfib/ip4_mfib.h
+++ b/src/vnet/mfib/ip4_mfib.h
@@ -56,6 +56,13 @@ extern void ip4_mfib_table_entry_insert(ip4_mfib_t *fib,
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
*/
static inline ip4_mfib_t *
diff --git a/src/vnet/mfib/mfib_types.h b/src/vnet/mfib/mfib_types.h
index 650a7a5c3f9..edc25fe5b99 100644
--- a/src/vnet/mfib/mfib_types.h
+++ b/src/vnet/mfib/mfib_types.h
@@ -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", \
}
diff --git a/test/test_ip4.py b/test/test_ip4.py
index 87059c7361b..18b350dcd2d 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -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):
diff --git a/test/test_ip6.py b/test/test_ip6.py
index b27cfdb4fed..1f00ed32a8c 100644
--- a/test/test_ip6.py
+++ b/test/test_ip6.py
@@ -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