build: fix clang-16 build
[vpp.git] / src / vnet / ip / ip6_forward.c
index b9f9892..84ea5a0 100644 (file)
@@ -717,6 +717,15 @@ ip6_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
       }));
       /* *INDENT-ON* */
       ip6_mfib_interface_enable_disable (sw_if_index, 0);
+
+      if (0 != im6->fib_index_by_sw_if_index[sw_if_index])
+       fib_table_bind (FIB_PROTOCOL_IP6, sw_if_index, 0);
+      if (0 != im6->mfib_index_by_sw_if_index[sw_if_index])
+       mfib_table_bind (FIB_PROTOCOL_IP6, sw_if_index, 0);
+
+      /* Erase the lookup tables just in case */
+      im6->fib_index_by_sw_if_index[sw_if_index] = ~0;
+      im6->mfib_index_by_sw_if_index[sw_if_index] = ~0;
     }
 
   vnet_feature_enable_disable ("ip6-unicast", "ip6-not-enabled", sw_if_index,
@@ -1218,14 +1227,11 @@ always_inline u8
 ip6_next_proto_is_tcp_udp (vlib_buffer_t * p0, ip6_header_t * ip0,
                           u32 * udp_offset0)
 {
-  u32 proto0;
-  proto0 = ip6_locate_header (p0, ip0, IP_PROTOCOL_UDP, udp_offset0);
-  if (proto0 != IP_PROTOCOL_UDP)
-    {
-      proto0 = ip6_locate_header (p0, ip0, IP_PROTOCOL_TCP, udp_offset0);
-      proto0 = (proto0 == IP_PROTOCOL_TCP) ? proto0 : 0;
-    }
-  return proto0;
+  int nh = ip6_locate_header (p0, ip0, -1, udp_offset0);
+  if (nh > 0)
+    if (nh == IP_PROTOCOL_UDP || nh == IP_PROTOCOL_TCP)
+      return nh;
+  return 0;
 }
 
 /* *INDENT-OFF* */
@@ -1270,7 +1276,7 @@ ip6_tcp_udp_icmp_bad_length (vlib_main_t * vm, vlib_buffer_t * p0)
     }
 
   n_bytes_left -= n_this_buffer;
-  n_bytes_left -= p0->total_length_not_including_first_buffer;
+  n_bytes_left -= vlib_buffer_length_in_chain (vm, p0) - p0->current_length;
 
   if (n_bytes_left == 0)
     return 0;
@@ -1313,7 +1319,7 @@ ip6_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
          vlib_prefetch_buffer_data (b[3], LOAD);
        }
 
-      ip6_error_t error[2];
+      vl_counter_ip6_enum_t error[2];
       error[0] = IP6_ERROR_UNKNOWN_PROTOCOL;
       error[1] = IP6_ERROR_UNKNOWN_PROTOCOL;
 
@@ -1469,6 +1475,11 @@ ip6_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
            vnet_buffer (b[1])->sw_if_index[VLIB_TX] != ~0 ?
            vnet_buffer (b[1])->sw_if_index[VLIB_TX] :
            vnet_buffer (b[1])->ip.fib_index;
+
+         vnet_buffer (b[0])->ip.rx_sw_if_index =
+           vnet_buffer (b[0])->sw_if_index[VLIB_RX];
+         vnet_buffer (b[1])->ip.rx_sw_if_index =
+           vnet_buffer (b[1])->sw_if_index[VLIB_RX];
          if (is_receive_dpo)
            {
              const receive_dpo_t *rd0, *rd1;
@@ -1476,13 +1487,10 @@ ip6_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
                receive_dpo_get (vnet_buffer (b[0])->ip.adj_index[VLIB_TX]);
              rd1 =
                receive_dpo_get (vnet_buffer (b[1])->ip.adj_index[VLIB_TX]);
-             vnet_buffer (b[0])->ip.rx_sw_if_index = rd0->rd_sw_if_index;
-             vnet_buffer (b[1])->ip.rx_sw_if_index = rd1->rd_sw_if_index;
-           }
-         else
-           {
-             vnet_buffer (b[0])->ip.rx_sw_if_index = ~0;
-             vnet_buffer (b[1])->ip.rx_sw_if_index = ~0;
+             if (rd0->rd_sw_if_index != ~0)
+               vnet_buffer (b[0])->ip.rx_sw_if_index = rd0->rd_sw_if_index;
+             if (rd1->rd_sw_if_index != ~0)
+               vnet_buffer (b[1])->ip.rx_sw_if_index = rd1->rd_sw_if_index;
            }
        }                       /* head_of_feature_arc */
 
@@ -1505,16 +1513,16 @@ ip6_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
            {
              u32 next32 = next[0];
              vnet_feature_arc_start (arc_index,
-                                     vnet_buffer (b[0])->sw_if_index
-                                     [VLIB_RX], &next32, b[0]);
+                                     vnet_buffer (b[0])->ip.rx_sw_if_index,
+                                     &next32, b[0]);
              next[0] = next32;
            }
          if (PREDICT_TRUE (ip6_unknown[1]))
            {
              u32 next32 = next[1];
              vnet_feature_arc_start (arc_index,
-                                     vnet_buffer (b[1])->sw_if_index
-                                     [VLIB_RX], &next32, b[1]);
+                                     vnet_buffer (b[1])->ip.rx_sw_if_index,
+                                     &next32, b[1]);
              next[1] = next32;
            }
        }
@@ -1611,14 +1619,16 @@ ip6_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
            vnet_buffer (b[0])->sw_if_index[VLIB_TX] != ~0 ?
            vnet_buffer (b[0])->sw_if_index[VLIB_TX] :
            vnet_buffer (b[0])->ip.fib_index;
+
+         vnet_buffer (b[0])->ip.rx_sw_if_index =
+           vnet_buffer (b[0])->sw_if_index[VLIB_RX];
          if (is_receive_dpo)
            {
              receive_dpo_t *rd;
              rd = receive_dpo_get (vnet_buffer (b[0])->ip.adj_index[VLIB_TX]);
-             vnet_buffer (b[0])->ip.rx_sw_if_index = rd->rd_sw_if_index;
+             if (rd->rd_sw_if_index != ~0)
+               vnet_buffer (b[0])->ip.rx_sw_if_index = rd->rd_sw_if_index;
            }
-         else
-           vnet_buffer (b[0])->ip.rx_sw_if_index = ~0;
        }                       /* head_of_feature_arc */
 
       next[0] = lm->local_next_by_ip_protocol[ip->protocol];
@@ -1633,8 +1643,8 @@ ip6_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
            {
              u32 next32 = next[0];
              vnet_feature_arc_start (arc_index,
-                                     vnet_buffer (b[0])->sw_if_index
-                                     [VLIB_RX], &next32, b[0]);
+                                     vnet_buffer (b[0])->ip.rx_sw_if_index,
+                                     &next32, b[0]);
              next[0] = next32;
            }
        }
@@ -1661,6 +1671,8 @@ VLIB_REGISTER_NODE (ip6_local_node) =
   .name = "ip6-local",
   .vector_size = sizeof (u32),
   .format_trace = format_ip6_forward_next_trace,
+  .n_errors = IP6_N_ERROR,
+  .error_counters = ip6_error_counters,
   .n_next_nodes = IP_LOCAL_N_NEXT,
   .next_nodes =
   {
@@ -1668,7 +1680,7 @@ VLIB_REGISTER_NODE (ip6_local_node) =
     [IP_LOCAL_NEXT_PUNT] = "ip6-punt",
     [IP_LOCAL_NEXT_UDP_LOOKUP] = "ip6-udp-lookup",
     [IP_LOCAL_NEXT_ICMP] = "ip6-icmp-input",
-    [IP_LOCAL_NEXT_REASSEMBLY] = "ip6-full-reassembly",
+    [IP_LOCAL_NEXT_REASSEMBLY] = "ip6-local-full-reassembly",
   },
 };
 
@@ -2232,19 +2244,20 @@ VLIB_NODE_FN (ip6_mcast_midchain_node) (vlib_main_t * vm,
 }
 
 /* *INDENT-OFF* */
-VLIB_REGISTER_NODE (ip6_midchain_node) =
-{
+VLIB_REGISTER_NODE (ip6_midchain_node) = {
   .name = "ip6-midchain",
   .vector_size = sizeof (u32),
   .format_trace = format_ip6_forward_next_trace,
   .sibling_of = "ip6-rewrite",
-  };
+};
 
 VLIB_REGISTER_NODE (ip6_rewrite_node) =
 {
   .name = "ip6-rewrite",
   .vector_size = sizeof (u32),
   .format_trace = format_ip6_rewrite_trace,
+  .n_errors = IP6_N_ERROR,
+  .error_counters = ip6_error_counters,
   .n_next_nodes = IP6_REWRITE_N_NEXT,
   .next_nodes =
   {