aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthew Smith <mgsmith@netgate.com>2021-12-21 09:00:05 -0600
committerMatthew Smith <mgsmith@netgate.com>2022-01-03 15:45:43 -0600
commitfa74a64def2132fb0c81e981547ac65888751aa9 (patch)
tree6fafb6f327c086fba7bc0f5edd41afcbcfd39c2e /src
parenta3d8c2c21472c3088fb770d60d111fd5c55d9225 (diff)
vrrp: fix support for VRs in different FIBs
Type: fix Fixes: 4b1b13315a3c When adding or deleting a VR, multicast routes can be added or deleted. When the first VR is added, a local (dpo-receive) route is added. The route is deleted when the last VR is deleted. Perform the check on whether to add or delete the route on a per-FIB basis. Otherwise, if the route is only added after the first VR is added without regards to the FIB being used and a second VR is added later on an interface attached to a different FIB, the necessary route will not be added to the FIB used by the second interface. Change-Id: Ib30925ecf45c714cfe3ac6a223754bea918f10e3 Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/vrrp/vrrp.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/plugins/vrrp/vrrp.c b/src/plugins/vrrp/vrrp.c
index b6817b8a55c..dbc122c5bd9 100644
--- a/src/plugins/vrrp/vrrp.c
+++ b/src/plugins/vrrp/vrrp.c
@@ -384,10 +384,9 @@ static int
vrrp_intf_enable_disable_mcast (u8 enable, u32 sw_if_index, u8 is_ipv6)
{
vrrp_main_t *vrm = &vrrp_main;
- vrrp_vr_t *vr;
vrrp_intf_t *intf;
- u32 fib_index;
- u32 n_vrs = 0;
+ u32 fib_index, i;
+ u32 n_vrs_in_fib = 0;
const mfib_prefix_t *vrrp_prefix;
fib_protocol_t proto;
vnet_link_t link_type;
@@ -422,20 +421,19 @@ vrrp_intf_enable_disable_mcast (u8 enable, u32 sw_if_index, u8 is_ipv6)
via_itf.frp_proto = fib_proto_to_dpo (proto);
fib_index = mfib_table_get_index_for_sw_if_index (proto, sw_if_index);
- /* *INDENT-OFF* */
- pool_foreach (vr, vrm->vrs)
- {
- if (vrrp_vr_is_ipv6 (vr) == is_ipv6)
- n_vrs++;
- }
- /* *INDENT-ON* */
+ vec_foreach_index (i, vrm->vrrp_intfs)
+ {
+ if (mfib_table_get_index_for_sw_if_index (proto, i) != fib_index)
+ continue;
+
+ n_vrs_in_fib += vrrp_intf_num_vrs (i, is_ipv6);
+ }
if (enable)
{
- /* If this is the first VR configured, add the local mcast routes */
- if (n_vrs == 1)
- mfib_table_entry_path_update (fib_index, vrrp_prefix, MFIB_SOURCE_API,
- MFIB_ENTRY_FLAG_NONE, &for_us);
+ /* ensure that the local mcast route exists */
+ mfib_table_entry_path_update (fib_index, vrrp_prefix, MFIB_SOURCE_API,
+ MFIB_ENTRY_FLAG_NONE, &for_us);
mfib_table_entry_path_update (fib_index, vrrp_prefix, MFIB_SOURCE_API,
MFIB_ENTRY_FLAG_NONE, &via_itf);
@@ -445,7 +443,7 @@ vrrp_intf_enable_disable_mcast (u8 enable, u32 sw_if_index, u8 is_ipv6)
else
{
/* Remove mcast local routes if this is the last VR being deleted */
- if (n_vrs == 0)
+ if (n_vrs_in_fib == 0)
mfib_table_entry_path_remove (fib_index, vrrp_prefix, MFIB_SOURCE_API,
&for_us);