arp: checks for null in add neighbor 45/43045/12
authorAnna Neiman <[email protected]>
Tue, 27 May 2025 12:28:53 +0000 (15:28 +0300)
committerBenoit Ganne <[email protected]>
Mon, 16 Jun 2025 08:04:37 +0000 (08:04 +0000)
Type: fix

Details:

I have the situation that ip_neighbor_learn  is called for an already deleted interface.
The reproduction sequence is following
1.  arp_input -> arp_reply  on some worker
2.  call ip_neighbor_learn_dp , so request to perform  ip_neighbor_learn on the vpp_main thread
3.  the vpp_main thread is very busy - at the same moment we remove most of l2 interfaces and vrfs under barrier sync, including the TX interface of arp_reply
4.  call ip_neighbor_learn in the  main thread , when the appropriate interface is already deleted

Change-Id: I69b167ba919d57f19d6b941260243bca889c31c1
Signed-off-by: Anna Neiman <[email protected]>
src/vnet/ip-neighbor/ip_neighbor.c

index 73fa0b3..ab3bd7e 100644 (file)
@@ -335,6 +335,8 @@ ip_neighbor_adj_fib_add (ip_neighbor_t * ipn, u32 fib_index)
     }
   else
     {
+      if (INDEX_INVALID == fib_index)
+       return;
       fib_protocol_t fproto;
 
       fproto = ip_address_family_to_fib_proto (af);
@@ -552,6 +554,9 @@ ip_neighbor_add (const ip_address_t * ip,
   /* main thread only */
   ASSERT (0 == vlib_get_thread_index ());
 
+  if (!vnet_sw_interface_is_valid (vnet_get_main (), sw_if_index))
+    return 0;
+
   fproto = ip_address_family_to_fib_proto (ip_addr_version (ip));
 
   const ip_neighbor_key_t key = {