Fix 'ip probe' on /32
[vpp.git] / src / vnet / ip / ip6_forward.c
index 0ad96d0..17a4a6d 100644 (file)
@@ -347,24 +347,20 @@ ip6_add_interface_routes (vnet_main_t * vnm, u32 sw_if_index,
     .fp_addr.ip6 = *address,
   };
 
-  a->neighbor_probe_adj_index = ~0;
   if (a->address_length < 128)
     {
-      fib_node_index_t fei;
-
-      fei = fib_table_entry_update_one_path (fib_index,
-                                            &pfx,
-                                            FIB_SOURCE_INTERFACE,
-                                            (FIB_ENTRY_FLAG_CONNECTED |
-                                             FIB_ENTRY_FLAG_ATTACHED),
-                                            FIB_PROTOCOL_IP6,
-                                            /* No next-hop address */
-                                            NULL, sw_if_index,
-                                            /* invalid FIB index */
-                                            ~0, 1,
-                                            /* no label stack */
-                                            NULL, FIB_ROUTE_PATH_FLAG_NONE);
-      a->neighbor_probe_adj_index = fib_entry_get_adj (fei);
+      fib_table_entry_update_one_path (fib_index,
+                                      &pfx,
+                                      FIB_SOURCE_INTERFACE,
+                                      (FIB_ENTRY_FLAG_CONNECTED |
+                                       FIB_ENTRY_FLAG_ATTACHED),
+                                      FIB_PROTOCOL_IP6,
+                                      /* No next-hop address */
+                                      NULL, sw_if_index,
+                                      /* invalid FIB index */
+                                      ~0, 1,
+                                      /* no label stack */
+                                      NULL, FIB_ROUTE_PATH_FLAG_NONE);
     }
 
   pfx.fp_len = 128;
@@ -444,12 +440,11 @@ ip6_sw_interface_enable_disable (u32 sw_if_index, u32 is_enable)
        return;
     }
 
-  vnet_feature_enable_disable ("ip6-unicast", "ip6-lookup", sw_if_index,
-                              is_enable, 0, 0);
-
-  vnet_feature_enable_disable ("ip6-multicast", "ip6-mfib-forward-lookup",
-                              sw_if_index, is_enable, 0, 0);
+  vnet_feature_enable_disable ("ip6-unicast", "ip6-drop", sw_if_index,
+                              !is_enable, 0, 0);
 
+  vnet_feature_enable_disable ("ip6-multicast", "ip6-drop", sw_if_index,
+                              !is_enable, 0, 0);
 }
 
 /* get first interface address */
@@ -624,17 +619,17 @@ VNET_FEATURE_INIT (ip6_vxlan_bypass, static) =
   .runs_before = VNET_FEATURES ("ip6-lookup"),
 };
 
-VNET_FEATURE_INIT (ip6_lookup, static) =
+VNET_FEATURE_INIT (ip6_drop, static) =
 {
   .arc_name = "ip6-unicast",
-  .node_name = "ip6-lookup",
-  .runs_before = VNET_FEATURES ("ip6-drop"),
+  .node_name = "ip6-drop",
+  .runs_before = VNET_FEATURES ("ip6-lookup"),
 };
 
-VNET_FEATURE_INIT (ip6_drop, static) =
+VNET_FEATURE_INIT (ip6_lookup, static) =
 {
   .arc_name = "ip6-unicast",
-  .node_name = "ip6-drop",
+  .node_name = "ip6-lookup",
   .runs_before = 0,  /*last feature*/
 };
 
@@ -652,15 +647,15 @@ VNET_FEATURE_INIT (ip6_vpath_mc, static) = {
   .runs_before = VNET_FEATURES ("ip6-mfib-forward-lookup"),
 };
 
-VNET_FEATURE_INIT (ip6_mc_lookup, static) = {
+VNET_FEATURE_INIT (ip6_drop_mc, static) = {
   .arc_name = "ip6-multicast",
-  .node_name = "ip6-mfib-forward-lookup",
-  .runs_before = VNET_FEATURES ("ip6-drop"),
+  .node_name = "ip6-drop",
+  .runs_before = VNET_FEATURES ("ip6-mfib-forward-lookup"),
 };
 
-VNET_FEATURE_INIT (ip6_drop_mc, static) = {
+VNET_FEATURE_INIT (ip6_mc_lookup, static) = {
   .arc_name = "ip6-multicast",
-  .node_name = "ip6-drop",
+  .node_name = "ip6-mfib-forward-lookup",
   .runs_before = 0, /* last feature */
 };
 
@@ -688,15 +683,17 @@ VNET_FEATURE_INIT (ip6_interface_output, static) = {
 clib_error_t *
 ip6_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
 {
+  ip6_main_t *im = &ip6_main;
+
+  vec_validate (im->fib_index_by_sw_if_index, sw_if_index);
+  vec_validate (im->mfib_index_by_sw_if_index, sw_if_index);
+
   vnet_feature_enable_disable ("ip6-unicast", "ip6-drop", sw_if_index,
                               is_add, 0, 0);
 
   vnet_feature_enable_disable ("ip6-multicast", "ip6-drop", sw_if_index,
                               is_add, 0, 0);
 
-  vnet_feature_enable_disable ("ip6-output", "interface-output", sw_if_index,
-                              is_add, 0, 0);
-
   return /* no error */ 0;
 }
 
@@ -1853,6 +1850,7 @@ ip6_probe_neighbor (vlib_main_t * vm, ip6_address_t * dst, u32 sw_if_index)
   vnet_hw_interface_t *hi;
   vnet_sw_interface_t *si;
   vlib_buffer_t *b;
+  adj_index_t ai;
   u32 bi = 0;
   int bogus_length;
 
@@ -1905,7 +1903,14 @@ ip6_probe_neighbor (vlib_main_t * vm, ip6_address_t * dst, u32 sw_if_index)
     vnet_buffer (b)->sw_if_index[VLIB_TX] = sw_if_index;
 
   /* Add encapsulation string for software interface (e.g. ethernet header). */
-  adj = adj_get (ia->neighbor_probe_adj_index);
+  ip46_address_t nh = {
+    .ip6 = *dst,
+  };
+
+  ai = adj_nbr_add_or_lock (FIB_PROTOCOL_IP6,
+                           VNET_LINK_IP6, &nh, sw_if_index);
+  adj = adj_get (ai);
+
   vnet_rewrite_one_header (adj[0], h, sizeof (ethernet_header_t));
   vlib_buffer_advance (b, -adj->rewrite_header.data_bytes);
 
@@ -1917,6 +1922,7 @@ ip6_probe_neighbor (vlib_main_t * vm, ip6_address_t * dst, u32 sw_if_index)
     vlib_put_frame_to_node (vm, hi->output_node_index, f);
   }
 
+  adj_unlock (ai);
   return /* no error */ 0;
 }