linux-cp: do not lock table when it's not needed 36/43036/7
authorStanislav Zaikin <[email protected]>
Mon, 26 May 2025 07:52:57 +0000 (09:52 +0200)
committerMatthew Smith <[email protected]>
Tue, 8 Jul 2025 16:13:56 +0000 (16:13 +0000)
Do not lock table when lcp is not installing routes (e.g. zero nexthops
or ipv6 multicast routes), otherwise it will stay locked forever.

Type: fix

Signed-off-by: Stanislav Zaikin <[email protected]>
Change-Id: I4070ce0e0823b5afbd56c5cd79ae39a02c7d4300

src/plugins/linux-cp/lcp_router.c

index 27f5335..4c13c36 100644 (file)
@@ -1332,7 +1332,6 @@ lcp_router_route_add (struct rtnl_route *rr, int is_replace)
   lcp_router_route_mk_prefix (rr, &pfx);
   entry_flags = lcp_router_route_mk_entry_flags (rtype, table_id, rproto);
 
-  nlt = lcp_router_table_add_or_lock (table_id, pfx.fp_proto);
   /* Skip any kernel routes and IPv6 LL or multicast routes */
   if (rproto == RTPROT_KERNEL ||
       (FIB_PROTOCOL_IP6 == pfx.fp_proto &&
@@ -1360,6 +1359,8 @@ lcp_router_route_add (struct rtnl_route *rr, int is_replace)
 
   if (0 != vec_len (np.paths))
     {
+      nlt = lcp_router_table_add_or_lock (table_id, pfx.fp_proto);
+
       if (rtype == RTN_MULTICAST)
        {
          /* it's not clear to me how linux expresses the RPF paramters
@@ -1423,6 +1424,16 @@ lcp_router_route_add (struct rtnl_route *rr, int is_replace)
       LCP_ROUTER_DBG ("no paths for route: %d:%U %U",
                      rtnl_route_get_table (rr), format_fib_prefix, &pfx,
                      format_fib_entry_flags, entry_flags);
+
+      nlt =
+       lcp_router_table_find (lcp_router_table_k2f (table_id), pfx.fp_proto);
+
+      if (is_replace && nlt)
+       {
+         fib_source_t fib_src;
+         fib_src = lcp_router_proto_fib_source (rproto);
+         fib_table_entry_delete (nlt->nlt_fib_index, &pfx, fib_src);
+       }
     }
   vec_free (np.paths);
 }