linux-cp: sync addr and neigh only for lcp interfaces 36/36036/2
authorStanislav Zaikin <zstaseg@gmail.com>
Mon, 25 Apr 2022 17:11:36 +0000 (19:11 +0200)
committerMatthew Smith <mgsmith@netgate.com>
Tue, 26 Apr 2022 21:55:01 +0000 (21:55 +0000)
Type: fix

Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
Change-Id: I792467b73449074e59c4232b1f82d134c399624c

src/plugins/linux-cp/lcp_router.c
src/vnet/ip-neighbor/ip_neighbor.c
src/vnet/ip-neighbor/ip_neighbor.h
src/vnet/ip/ip_interface.c
src/vnet/ip/ip_interface.h

index af01b54..acf0a03 100644 (file)
@@ -662,10 +662,25 @@ lcp_router_link_addr_add (struct rtnl_addr *la)
   lcp_router_link_addr_add_del (la, 0);
 }
 
+static walk_rc_t
+lcp_router_address_mark (index_t index, void *ctx)
+{
+  vnet_main_t *vnm = vnet_get_main ();
+
+  lcp_itf_pair_t *lip = lcp_itf_pair_get (index);
+  if (!lip)
+    return WALK_CONTINUE;
+
+  ip_interface_address_mark_one_interface (
+    vnm, vnet_get_sw_interface (vnm, lip->lip_phy_sw_if_index), 0);
+
+  return WALK_CONTINUE;
+}
+
 static void
 lcp_router_link_addr_sync_begin (void)
 {
-  ip_interface_address_mark ();
+  lcp_itf_pair_walk (lcp_router_address_mark, 0);
 
   LCP_ROUTER_INFO ("Begin synchronization of interface addresses");
 }
@@ -795,11 +810,23 @@ lcp_router_neigh_add (struct rtnl_neigh *rn)
                     rtnl_neigh_get_ifindex (rn));
 }
 
+static walk_rc_t
+lcp_router_neighbor_mark (index_t index, void *ctx)
+{
+  lcp_itf_pair_t *lip = lcp_itf_pair_get (index);
+  if (!lip)
+    return WALK_CONTINUE;
+
+  ip_neighbor_walk (AF_IP4, lip->lip_phy_sw_if_index, ip_neighbor_mark_one, 0);
+  ip_neighbor_walk (AF_IP6, lip->lip_phy_sw_if_index, ip_neighbor_mark_one, 0);
+
+  return WALK_CONTINUE;
+}
+
 static void
 lcp_router_neigh_sync_begin (void)
 {
-  ip_neighbor_mark (AF_IP4);
-  ip_neighbor_mark (AF_IP6);
+  lcp_itf_pair_walk (lcp_router_neighbor_mark, 0);
 
   LCP_ROUTER_INFO ("Begin synchronization of neighbors");
 }
index 6c97356..6ba191a 100644 (file)
@@ -1204,7 +1204,7 @@ ip_neighbor_flush (ip_address_family_t af, u32 sw_if_index)
   vec_free (ipnis);
 }
 
-static walk_rc_t
+walk_rc_t
 ip_neighbor_mark_one (index_t ipni, void *ctx)
 {
   ip_neighbor_t *ipn;
index 064569b..1702801 100644 (file)
@@ -60,6 +60,7 @@ extern void ip_neighbor_probe_dst (u32 sw_if_index,
 
 extern void ip_neighbor_mark (ip_address_family_t af);
 extern void ip_neighbor_sweep (ip_address_family_t af);
+extern walk_rc_t ip_neighbor_mark_one (index_t ipni, void *ctx);
 
 /**
  * From the watcher to the API to publish a new neighbor
index 48c20a6..d5ee7fd 100644 (file)
@@ -203,9 +203,9 @@ ip_interface_get_first_ip (u32 sw_if_index, u8 is_ip4)
   return 0;
 }
 
-static walk_rc_t
-ip_interface_address_mark_one_interface (vnet_main_t * vnm,
-                                        vnet_sw_interface_t * si, void *ctx)
+walk_rc_t
+ip_interface_address_mark_one_interface (vnet_main_t *vnm,
+                                        vnet_sw_interface_t *si, void *ctx)
 {
   ip_lookup_main_t *lm4 = &ip4_main.lookup_main;
   ip_lookup_main_t *lm6 = &ip6_main.lookup_main;
index b48eebd..f0474c1 100644 (file)
@@ -38,6 +38,9 @@ void ip_interface_address_sweep (void);
 u32 ip_interface_address_find (ip_lookup_main_t * lm,
                               void *addr_fib, u32 address_length);
 u8 ip_interface_has_address (u32 sw_if_index, ip46_address_t * ip, u8 is_ip4);
+walk_rc_t ip_interface_address_mark_one_interface (vnet_main_t *vnm,
+                                                  vnet_sw_interface_t *si,
+                                                  void *ctx);
 
 always_inline void *
 ip_interface_address_get_address (ip_lookup_main_t * lm,