From aebfc285a89be20f68e5599b8d67dda8f20888a5 Mon Sep 17 00:00:00 2001 From: Alexander Chernavin Date: Wed, 20 Oct 2021 13:22:14 +0000 Subject: 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 Change-Id: I4f7e872af3e1c9ffa6c63bcc3984ec76def1bb43 --- src/plugins/linux-cp/lcp_router.c | 95 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'src') 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) { @@ -509,6 +521,22 @@ lcp_router_link_addr_add (struct rtnl_addr *la) lcp_router_link_addr_add_del (la, 0); } +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) { @@ -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 * -- cgit 1.2.3-korg