Use rte_mempool private data for storing vlib_buffer_t
[vpp.git] / vnet / vnet / ip / ip6_forward.c
index f0065e9..a478bab 100644 (file)
@@ -265,6 +265,14 @@ void ip6_add_del_route (ip6_main_t * im, ip6_add_del_route_args_t * a)
       BV(clib_bihash_add_del) (&im->ip6_lookup_table, &kv, 1 /* is_add */);
     }
 
+  /* Avoid spurious reference count increments */
+  if (old_adj_index == adj_index)
+    {
+      ip_adjacency_t * adj = ip_get_adjacency (lm, adj_index);
+      if (adj->share_count > 0)
+        adj->share_count --;
+    }
+
   /* Delete old adjacency index if present and changed. */
   {
     if (! (a->flags & IP6_ROUTE_FLAG_KEEP_OLD_ADJACENCY)
@@ -1181,6 +1189,7 @@ typedef struct {
   /* Adjacency taken. */
   u32 adj_index;
   u32 flow_hash;
+  u32 fib_index;
 
   /* Packet data, possibly *after* rewrite. */
   u8 packet_data[64 - 1*sizeof(u32)];
@@ -1197,8 +1206,8 @@ static u8 * format_ip6_forward_next_trace (u8 * s, va_list * args)
   uword indent = format_get_indent (s);
 
   adj = ip_get_adjacency (&im->lookup_main, t->adj_index);
-  s = format (s, "adjacency: %U flow hash: 0x%08x",
-             format_ip_adjacency,
+  s = format (s, "fib %d adj-idx %d : %U flow hash: 0x%08x",
+             t->fib_index, t->adj_index, format_ip_adjacency,
              vnm, &im->lookup_main, t->adj_index, t->flow_hash);
   switch (adj->lookup_next_index)
     {
@@ -1225,6 +1234,7 @@ ip6_forward_next_trace (vlib_main_t * vm,
                        vlib_rx_or_tx_t which_adj_index)
 {
   u32 * from, n_left;
+  ip6_main_t * im = &ip6_main;
 
   n_left = frame->n_vectors;
   from = vlib_frame_vector_args (frame);
@@ -1250,6 +1260,8 @@ ip6_forward_next_trace (vlib_main_t * vm,
          t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
          t0->adj_index = vnet_buffer (b0)->ip.adj_index[which_adj_index];
           t0->flow_hash = vnet_buffer (b0)->ip.flow_hash;
+         t0->fib_index = vec_elt (im->fib_index_by_sw_if_index, 
+                             vnet_buffer(b0)->sw_if_index[VLIB_RX]);
          memcpy (t0->packet_data,
                  vlib_buffer_get_current (b0),
                  sizeof (t0->packet_data));
@@ -1259,6 +1271,8 @@ ip6_forward_next_trace (vlib_main_t * vm,
          t1 = vlib_add_trace (vm, node, b1, sizeof (t1[0]));
          t1->adj_index = vnet_buffer (b1)->ip.adj_index[which_adj_index];
           t1->flow_hash = vnet_buffer (b1)->ip.flow_hash;
+         t1->fib_index = vec_elt (im->fib_index_by_sw_if_index, 
+                             vnet_buffer(b1)->sw_if_index[VLIB_RX]);
          memcpy (t1->packet_data,
                  vlib_buffer_get_current (b1),
                  sizeof (t1->packet_data));
@@ -1282,6 +1296,8 @@ ip6_forward_next_trace (vlib_main_t * vm,
          t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
          t0->adj_index = vnet_buffer (b0)->ip.adj_index[which_adj_index];
           t0->flow_hash = vnet_buffer (b0)->ip.flow_hash;
+         t0->fib_index = vec_elt (im->fib_index_by_sw_if_index, 
+                             vnet_buffer(b0)->sw_if_index[VLIB_RX]);
          memcpy (t0->packet_data,
                  vlib_buffer_get_current (b0),
                  sizeof (t0->packet_data));
@@ -1429,7 +1445,7 @@ u16 ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0, ip6
 #if DPDK > 0
   if (p0) 
   {
-    struct rte_mbuf *mb = ((struct rte_mbuf *)p0)-1;
+    struct rte_mbuf *mb = rte_mbuf_from_vlib_buffer(p0);
     u8 nb_segs = mb->nb_segs;
 
     n_this_buffer = (p0->current_length > headers_size ?
@@ -1613,7 +1629,6 @@ ip6_local (vlib_main_t * vm,
          error1 = len_diff1 < 0 ? IP6_ERROR_UDP_LENGTH : error1;
 
          ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_UDP == IP6_ERROR_UDP_CHECKSUM);
-         ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_TCP == IP6_ERROR_TCP_CHECKSUM);
          ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_ICMP == IP6_ERROR_ICMP_CHECKSUM);
          error0 = (! good_l4_checksum0
                    ? IP6_ERROR_UDP_CHECKSUM + type0
@@ -1705,7 +1720,6 @@ ip6_local (vlib_main_t * vm,
          error0 = len_diff0 < 0 ? IP6_ERROR_UDP_LENGTH : error0;
 
          ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_UDP == IP6_ERROR_UDP_CHECKSUM);
-         ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_TCP == IP6_ERROR_TCP_CHECKSUM);
          ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_ICMP == IP6_ERROR_ICMP_CHECKSUM);
          error0 = (! good_l4_checksum0
                    ? IP6_ERROR_UDP_CHECKSUM + type0
@@ -1746,7 +1760,6 @@ VLIB_REGISTER_NODE (ip6_local_node,static) = {
   .next_nodes = {
     [IP_LOCAL_NEXT_DROP] = "error-drop",
     [IP_LOCAL_NEXT_PUNT] = "error-punt",
-    // [IP_LOCAL_NEXT_TCP_LOOKUP] = "ip6-tcp-lookup",
     [IP_LOCAL_NEXT_UDP_LOOKUP] = "ip6-udp-lookup",
     [IP_LOCAL_NEXT_ICMP] = "ip6-icmp-input",
   },