ARP learning fixes (VPP-843)
[vpp.git] / src / vnet / ip / ip6_neighbor.c
index 42edb79..4fd078d 100644 (file)
@@ -273,7 +273,8 @@ ip6_neighbor_sw_interface_up_down (vnet_main_t * vnm,
        {
          n = pool_elt_at_index (nm->neighbor_pool, to_delete[i]);
          mhash_unset (&nm->neighbor_index_by_key, &n->key, 0);
-         fib_table_entry_delete_index (n->fib_entry_index, FIB_SOURCE_ADJ);
+         if (FIB_NODE_INDEX_INVALID != n->fib_entry_index)
+           fib_table_entry_delete_index (n->fib_entry_index, FIB_SOURCE_ADJ);
          pool_put (nm->neighbor_pool, n);
        }
 
@@ -610,6 +611,7 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm,
       mhash_set (&nm->neighbor_index_by_key, &k, n - nm->neighbor_pool,
                 /* old value */ 0);
       n->key = k;
+      n->fib_entry_index = FIB_NODE_INDEX_INVALID;
 
       clib_memcpy (n->link_layer_address,
                   link_layer_address, n_bytes_link_layer_address);
@@ -630,10 +632,13 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm,
          n->fib_entry_index =
            fib_table_entry_update_one_path (fib_index, &pfx,
                                             FIB_SOURCE_ADJ,
-                                            FIB_ENTRY_FLAG_NONE,
+                                            FIB_ENTRY_FLAG_ATTACHED,
                                             FIB_PROTOCOL_IP6, &pfx.fp_addr,
                                             n->key.sw_if_index, ~0, 1, NULL,
                                             FIB_ROUTE_PATH_FLAG_NONE);
+       }
+      else
+       {
          n->flags |= IP6_NEIGHBOR_FLAG_NO_FIB_ENTRY;
        }
     }
@@ -747,7 +752,9 @@ vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm,
   adj_nbr_walk_nh6 (sw_if_index,
                    &n->key.ip6_address, ip6_nd_mk_incomplete_walk, NULL);
 
-  fib_table_entry_delete_index (n->fib_entry_index, FIB_SOURCE_ADJ);
+
+  if (FIB_NODE_INDEX_INVALID != n->fib_entry_index)
+    fib_table_entry_delete_index (n->fib_entry_index, FIB_SOURCE_ADJ);
   pool_put (nm->neighbor_pool, n);
 
 out:
@@ -1027,7 +1034,7 @@ icmp6_neighbor_solicitation_or_advertisement (vlib_main_t * vm,
 
          /* If src address unspecified or link local, donot learn neighbor MAC */
          if (PREDICT_TRUE (error0 == ICMP6_ERROR_NONE && o0 != 0 &&
-                           !ip6_sadd_unspecified && !ip6_sadd_link_local))
+                           !ip6_sadd_unspecified))
            {
              ip6_neighbor_main_t *nm = &ip6_neighbor_main;
              if (nm->limit_neighbor_cache_size &&
@@ -1040,7 +1047,7 @@ icmp6_neighbor_solicitation_or_advertisement (vlib_main_t * vm,
                                              &h0->target_address,
                                              o0->ethernet_address,
                                              sizeof (o0->ethernet_address),
-                                             0, 0);
+                                             0, ip6_sadd_link_local);
            }
 
          if (is_solicitation && error0 == ICMP6_ERROR_NONE)