fib: fix adjacency cli command issue
[vpp.git] / src / vnet / adj / adj.c
index bafa336..c601e6b 100644 (file)
@@ -139,6 +139,10 @@ format_ip_adjacency (u8 * s, va_list * args)
 
     adj_index = va_arg (*args, u32);
     fiaf = va_arg (*args, format_ip_adjacency_flags_t);
+
+    if (!adj_is_valid(adj_index))
+      return format(s, "<invalid adjacency>");
+
     adj = adj_get(adj_index);
 
     switch (adj->lookup_next_index)
@@ -178,7 +182,7 @@ format_ip_adjacency (u8 * s, va_list * args)
         s = format (s, "\n   flags:%U", format_adj_flags, adj->ia_flags);
         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  ");
+       s = format(s, "\n delegates:");
         s = adj_delegate_format(s, adj);
 
        s = format(s, "\n children:");
@@ -245,7 +249,7 @@ adj_last_lock_gone (ip_adjacency_t *adj)
     switch (adj->lookup_next_index)
     {
     case IP_LOOKUP_NEXT_MIDCHAIN:
-        dpo_reset(&adj->sub_type.midchain.next_dpo);
+        adj_midchain_teardown(adj);
         /* FALL THROUGH */
     case IP_LOOKUP_NEXT_ARP:
     case IP_LOOKUP_NEXT_REWRITE:
@@ -263,8 +267,10 @@ adj_last_lock_gone (ip_adjacency_t *adj)
        adj_glean_remove(adj->ia_nh_proto,
                         adj->rewrite_header.sw_if_index);
        break;
-    case IP_LOOKUP_NEXT_MCAST:
     case IP_LOOKUP_NEXT_MCAST_MIDCHAIN:
+        adj_midchain_teardown(adj);
+        /* FALL THROUGH */
+    case IP_LOOKUP_NEXT_MCAST:
        adj_mcast_remove(adj->ia_nh_proto,
                         adj->rewrite_header.sw_if_index);
        break;
@@ -401,10 +407,11 @@ adj_feature_update_walk_cb (adj_index_t ai,
     return (ADJ_WALK_RC_CONTINUE);
 }
 
-void
+static void
 adj_feature_update (u32 sw_if_index,
                     u8 arc_index,
-                    u8 is_enable)
+                    u8 is_enable,
+                    void *data)
 {
     /*
      * Walk all the adjacencies on the interface to update the cached
@@ -586,6 +593,8 @@ adj_module_init (vlib_main_t * vm)
     adj_midchain_module_init();
     adj_mcast_module_init();
 
+    vnet_feature_register(adj_feature_update, NULL);
+
     return (NULL);
 }
 
@@ -604,9 +613,7 @@ adj_show (vlib_main_t * vm,
     {
        if (unformat (input, "%d", &ai))
            ;
-       else if (unformat (input, "sum"))
-           summary = 1;
-       else if (unformat (input, "summary"))
+       else if (unformat (input, "summary") || unformat (input, "sum"))
            summary = 1;
        else if (unformat (input, "%U",
                           unformat_vnet_sw_interface, vnet_get_main(),