ip: add support for buffer offload metadata in ip midchain
[vpp.git] / src / vnet / adj / adj.c
index d389022..201561f 100644 (file)
@@ -20,6 +20,7 @@
 #include <vnet/adj/adj_mcast.h>
 #include <vnet/adj/adj_delegate.h>
 #include <vnet/fib/fib_node_list.h>
+#include <vnet/fib/fib_walk.h>
 
 /* Adjacency packet/byte counters indexed by adjacency index. */
 vlib_combined_counter_main_t adjacency_counters = {
@@ -32,6 +33,11 @@ vlib_combined_counter_main_t adjacency_counters = {
  */
 ip_adjacency_t *adj_pool;
 
+/**
+ * The adjacency logger
+ */
+vlib_log_class_t adj_logger;
+
 /**
  * @brief Global Config for enabling per-adjacency counters.
  * By default these are disabled.
@@ -63,14 +69,12 @@ ip_adjacency_t *
 adj_alloc (fib_protocol_t proto)
 {
     ip_adjacency_t *adj;
-    u8 need_barrier_sync = 0;
+    u8 need_barrier_sync = pool_get_will_expand (adj_pool);
     vlib_main_t *vm;
     vm = vlib_get_main();
 
     ASSERT (vm->thread_index == 0);
 
-    pool_get_aligned_will_expand (adj_pool, need_barrier_sync,
-                                  CLIB_CACHE_LINE_BYTES);
     /* If the adj_pool will expand, stop the parade. */
     if (need_barrier_sync)
         vlib_worker_thread_barrier_sync (vm);
@@ -308,12 +312,12 @@ adj_last_lock_gone (ip_adjacency_t *adj)
        break;
     }
 
-    vlib_worker_thread_barrier_release(vm);
 
     fib_node_deinit(&adj->ia_node);
     ASSERT(0 == vec_len(adj->ia_delegates));
     vec_free(adj->ia_delegates);
     pool_put(adj_pool, adj);
+    vlib_worker_thread_barrier_release(vm);
 }
 
 u32
@@ -326,6 +330,16 @@ adj_dpo_get_urpf (const dpo_id_t *dpo)
     return (adj->rewrite_header.sw_if_index);
 }
 
+u16
+adj_dpo_get_mtu (const dpo_id_t *dpo)
+{
+    ip_adjacency_t *adj;
+
+    adj = adj_get(dpo->dpoi_index);
+
+    return (adj->rewrite_header.max_l3_packet_bytes);
+}
+
 void
 adj_lock (adj_index_t adj_index)
 {
@@ -339,7 +353,6 @@ adj_lock (adj_index_t adj_index)
     adj = adj_get(adj_index);
     ASSERT(adj);
 
-    ADJ_DBG(adj, "lock");
     fib_node_lock(&adj->ia_node);
 }
 
@@ -356,9 +369,6 @@ adj_unlock (adj_index_t adj_index)
     adj = adj_get(adj_index);
     ASSERT(adj);
 
-    ADJ_DBG(adj, "unlock");
-    ASSERT(adj);
-
     fib_node_unlock(&adj->ia_node);
 }
 
@@ -465,6 +475,19 @@ adj_mtu_update_walk_cb (adj_index_t ai,
 
     vnet_rewrite_update_mtu (vnet_get_main(), adj->ia_link,
                              &adj->rewrite_header);
+    adj_delegate_adj_modified(adj);
+
+    /**
+     * Backwalk to all Path MTU trackers, casual like ..
+     */
+    {
+       fib_node_back_walk_ctx_t bw_ctx = {
+           .fnbw_reason = FIB_NODE_BW_REASON_FLAG_ADJ_MTU,
+       };
+
+       fib_walk_async(FIB_NODE_TYPE_ADJ, ai,
+                       FIB_WALK_PRIORITY_LOW, &bw_ctx);
+    }
 
     return (ADJ_WALK_RC_CONTINUE);
 }
@@ -626,6 +649,8 @@ adj_module_init (vlib_main_t * vm)
 
     vnet_feature_register(adj_feature_update, NULL);
 
+    adj_logger = vlib_log_register_class("adj", "adj");
+
     return (NULL);
 }
 
@@ -679,7 +704,6 @@ adj_show (vlib_main_t * vm,
         }
         else
         {
-            /* *INDENT-OFF* */
             pool_foreach_index (ai, adj_pool)
              {
                 if (~0 != sw_if_index &&
@@ -694,7 +718,6 @@ adj_show (vlib_main_t * vm,
                                      FORMAT_IP_ADJACENCY_NONE);
                 }
             }
-            /* *INDENT-ON* */
         }
     }
     return 0;