summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAlexander Chernavin <achernavin@netgate.com>2021-10-20 13:22:14 +0000
committerMatthew Smith <mgsmith@netgate.com>2022-03-03 19:07:18 +0000
commitaebfc285a89be20f68e5599b8d67dda8f20888a5 (patch)
treeaddde3494d0c3243301825943c224c9c250a7c2d /src/plugins
parent6db19a9f48e281f4bbeb49559fe1ffb7f7ff3e0d (diff)
linux-cp: detect and delete stale entries after sync
Type: improvement During synchronization, only the current actual set of entries is loaded. If some entries are no longer present in the set being loaded but present in VPP, they should be removed to fully syncronize. With this change, add handlers for sync begin and end events. Begin handlers will mark the entries as stale. End handlers will remove the entries that are still marked as stale. Signed-off-by: Alexander Chernavin <achernavin@netgate.com> Change-Id: I4f7e872af3e1c9ffa6c63bcc3984ec76def1bb43
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/linux-cp/lcp_router.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/plugins/linux-cp/lcp_router.c b/src/plugins/linux-cp/lcp_router.c
index d99de9ca24d..6392e2a16f4 100644
--- a/src/plugins/linux-cp/lcp_router.c
+++ b/src/plugins/linux-cp/lcp_router.c
@@ -419,6 +419,18 @@ lcp_router_link_add (struct rtnl_link *rl, void *ctx)
rtnl_link_get_name (rl));
}
+static void
+lcp_router_link_sync_begin (void)
+{
+ LCP_ROUTER_INFO ("Begin synchronization of interface configurations");
+}
+
+static void
+lcp_router_link_sync_end (void)
+{
+ LCP_ROUTER_INFO ("End synchronization of interface configurations");
+}
+
static fib_protocol_t
lcp_router_proto_k2f (uint32_t k)
{
@@ -510,6 +522,22 @@ lcp_router_link_addr_add (struct rtnl_addr *la)
}
static void
+lcp_router_link_addr_sync_begin (void)
+{
+ ip_interface_address_mark ();
+
+ LCP_ROUTER_INFO ("Begin synchronization of interface addresses");
+}
+
+static void
+lcp_router_link_addr_sync_end (void)
+{
+ ip_interface_address_sweep ();
+
+ LCP_ROUTER_INFO ("End synchronization of interface addresses");
+}
+
+static void
lcp_router_mk_mac_addr (const struct nl_addr *rna, mac_address_t *mac)
{
mac_address_from_bytes (mac, nl_addr_get_binary_addr (rna));
@@ -609,6 +637,24 @@ lcp_router_neigh_add (struct rtnl_neigh *rn)
rtnl_neigh_get_ifindex (rn));
}
+static void
+lcp_router_neigh_sync_begin (void)
+{
+ ip_neighbor_mark (AF_IP4);
+ ip_neighbor_mark (AF_IP6);
+
+ LCP_ROUTER_INFO ("Begin synchronization of neighbors");
+}
+
+static void
+lcp_router_neigh_sync_end (void)
+{
+ ip_neighbor_sweep (AF_IP4);
+ ip_neighbor_sweep (AF_IP6);
+
+ LCP_ROUTER_INFO ("End synchronization of neighbors");
+}
+
static lcp_router_table_t *
lcp_router_table_find (uint32_t id, fib_protocol_t fproto)
{
@@ -1011,15 +1057,64 @@ lcp_router_route_add (struct rtnl_route *rr)
}
}
+static void
+lcp_router_route_sync_begin (void)
+{
+ lcp_router_table_t *nlt;
+
+ pool_foreach (nlt, lcp_router_table_pool)
+ {
+ fib_table_mark (nlt->nlt_fib_index, nlt->nlt_proto, lcp_rt_fib_src);
+ fib_table_mark (nlt->nlt_fib_index, nlt->nlt_proto,
+ lcp_rt_fib_src_dynamic);
+
+ LCP_ROUTER_INFO ("Begin synchronization of %U routes in table %u",
+ format_fib_protocol, nlt->nlt_proto,
+ nlt->nlt_fib_index);
+ }
+}
+
+static void
+lcp_router_route_sync_end (void)
+{
+ lcp_router_table_t *nlt;
+
+ pool_foreach (nlt, lcp_router_table_pool)
+ {
+ fib_table_sweep (nlt->nlt_fib_index, nlt->nlt_proto, lcp_rt_fib_src);
+ fib_table_sweep (nlt->nlt_fib_index, nlt->nlt_proto,
+ lcp_rt_fib_src_dynamic);
+
+ LCP_ROUTER_INFO ("End synchronization of %U routes in table %u",
+ format_fib_protocol, nlt->nlt_proto,
+ nlt->nlt_fib_index);
+ }
+}
+
const nl_vft_t lcp_router_vft = {
.nvl_rt_link_add = { .is_mp_safe = 0, .cb = lcp_router_link_add },
.nvl_rt_link_del = { .is_mp_safe = 0, .cb = lcp_router_link_del },
+ .nvl_rt_link_sync_begin = { .is_mp_safe = 0,
+ .cb = lcp_router_link_sync_begin },
+ .nvl_rt_link_sync_end = { .is_mp_safe = 0, .cb = lcp_router_link_sync_end },
.nvl_rt_addr_add = { .is_mp_safe = 0, .cb = lcp_router_link_addr_add },
.nvl_rt_addr_del = { .is_mp_safe = 0, .cb = lcp_router_link_addr_del },
+ .nvl_rt_addr_sync_begin = { .is_mp_safe = 0,
+ .cb = lcp_router_link_addr_sync_begin },
+ .nvl_rt_addr_sync_end = { .is_mp_safe = 0,
+ .cb = lcp_router_link_addr_sync_end },
.nvl_rt_neigh_add = { .is_mp_safe = 0, .cb = lcp_router_neigh_add },
.nvl_rt_neigh_del = { .is_mp_safe = 0, .cb = lcp_router_neigh_del },
+ .nvl_rt_neigh_sync_begin = { .is_mp_safe = 0,
+ .cb = lcp_router_neigh_sync_begin },
+ .nvl_rt_neigh_sync_end = { .is_mp_safe = 0,
+ .cb = lcp_router_neigh_sync_end },
.nvl_rt_route_add = { .is_mp_safe = 1, .cb = lcp_router_route_add },
.nvl_rt_route_del = { .is_mp_safe = 1, .cb = lcp_router_route_del },
+ .nvl_rt_route_sync_begin = { .is_mp_safe = 0,
+ .cb = lcp_router_route_sync_begin },
+ .nvl_rt_route_sync_end = { .is_mp_safe = 0,
+ .cb = lcp_router_route_sync_end },
};
static clib_error_t *