aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/mfib
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 /src/vnet/mfib
parent64e96613d27816ed7d24b9ca2ed760d855d76c81 (diff)
fib: Always install all routers mcast addresses
Type: improvement Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: Ia8dff15855a81cf29729bdaa3ff28fbe3254fa97
Diffstat (limited to 'src/vnet/mfib')
-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
3 files changed, 89 insertions, 29 deletions
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", \
}