ARP proxy dumps
[vpp.git] / src / vnet / adj / adj.c
index 36dfe50..abfe872 100644 (file)
@@ -64,6 +64,7 @@ adj_alloc (fib_protocol_t proto)
     adj->ia_nh_proto = proto;
     adj->ia_flags = 0;
     adj->rewrite_header.sw_if_index = ~0;
+    adj->rewrite_header.flags = 0;
     adj->lookup_next_index = 0;
     adj->ia_delegates = NULL;
 
@@ -71,9 +72,6 @@ adj_alloc (fib_protocol_t proto)
     memset(&adj->sub_type.midchain.next_dpo, 0,
            sizeof(adj->sub_type.midchain.next_dpo));
 
-    ip4_main.lookup_main.adjacency_heap = adj_pool;
-    ip6_main.lookup_main.adjacency_heap = adj_pool;
-
     return (adj);
 }
 
@@ -131,21 +129,20 @@ format_ip_adjacency (u8 * s, va_list * args)
 
     if (fiaf & FORMAT_IP_ADJACENCY_DETAIL)
     {
-        adj_delegate_type_t adt;
-        adj_delegate_t *aed;
         vlib_counter_t counts;
 
         vlib_get_combined_counter(&adjacency_counters, adj_index, &counts);
-        s = format (s, "\n counts:[%Ld:%Ld]", counts.packets, counts.bytes);
-       s = format (s, "\n locks:%d", adj->ia_node.fn_locks);
+        s = format (s, "\n   counts:[%Ld:%Ld]", counts.packets, counts.bytes);
+       s = format (s, "\n   locks:%d", adj->ia_node.fn_locks);
        s = format(s, "\n delegates:\n  ");
-        FOR_EACH_ADJ_DELEGATE(adj, adt, aed,
-        {
-            s = format(s, "  %U\n", format_adj_deletegate, aed);
-        });
+        adj_delegate_format(s, adj);
 
-       s = format(s, "\n children:\n  ");
-       s = fib_node_children_format(adj->ia_node.fn_children, s);
+       s = format(s, "\n children:");
+        if (fib_node_list_get_size(adj->ia_node.fn_children))
+        {
+            s = format(s, "\n  ");
+            s = fib_node_children_format(adj->ia_node.fn_children, s);
+        }
     }
 
     return s;
@@ -164,6 +161,8 @@ adj_last_lock_gone (ip_adjacency_t *adj)
     ASSERT(0 == fib_node_list_get_size(adj->ia_node.fn_children));
     ADJ_DBG(adj, "last-lock-gone");
 
+    adj_delegate_adj_deleted(adj);
+
     vlib_worker_thread_barrier_sync (vm);
 
     switch (adj->lookup_next_index)
@@ -210,6 +209,16 @@ adj_last_lock_gone (ip_adjacency_t *adj)
     pool_put(adj_pool, adj);
 }
 
+u32
+adj_dpo_get_urpf (const dpo_id_t *dpo)
+{
+    ip_adjacency_t *adj;
+
+    adj = adj_get(dpo->dpoi_index);
+
+    return (adj->rewrite_header.sw_if_index);
+}
+
 void
 adj_lock (adj_index_t adj_index)
 {
@@ -330,6 +339,45 @@ adj_feature_update (u32 sw_if_index,
     adj_walk (sw_if_index, adj_feature_update_walk_cb, &ctx);
 }
 
+static adj_walk_rc_t
+adj_mtu_update_walk_cb (adj_index_t ai,
+                        void *arg)
+{
+    ip_adjacency_t *adj;
+
+    adj = adj_get(ai);
+
+    vnet_rewrite_update_mtu (vnet_get_main(),
+                             &adj->rewrite_header);
+
+    return (ADJ_WALK_RC_CONTINUE);
+}
+
+static walk_rc_t
+adj_sw_mtu_update (vnet_main_t * vnm,
+                   u32 sw_if_index,
+                   void *ctx)
+{
+    /*
+     * Walk all the adjacencies on the interface to update the cached MTU
+     */
+    adj_walk (sw_if_index, adj_mtu_update_walk_cb, NULL);
+
+    return (WALK_CONTINUE);
+}
+
+void
+adj_mtu_update (u32 hw_if_index)
+{
+    /*
+     * Walk all the SW interfaces on the HW interface to update the cached MTU
+     */
+    vnet_hw_interface_walk_sw(vnet_get_main(),
+                              hw_if_index,
+                              adj_sw_mtu_update,
+                              NULL);
+}
+
 /**
  * @brief Walk the Adjacencies on a given interface
  */
@@ -383,24 +431,7 @@ adj_get_sw_if_index (adj_index_t ai)
 int
 adj_is_up (adj_index_t ai)
 {
-    const adj_delegate_t *aed;
-
-    aed = adj_delegate_get(adj_get(ai), ADJ_DELEGATE_BFD);
-
-    if (NULL == aed)
-    {
-        /*
-         * no BFD tracking - resolved
-         */
-        return (!0);
-    }
-    else
-    {
-        /*
-         * defer to the state of the BFD tracking
-         */
-        return (ADJ_BFD_STATE_UP == aed->ad_bfd_state);
-    }
+    return (adj_bfd_is_up(ai));
 }
 
 /**