ip: Fix IP unnumbered dump of one interface
[vpp.git] / src / vnet / ip / ip_api.c
index 4d2f070..322a3ed 100644 (file)
 #include <vnet/fib/ip6_fib.h>
 #include <vnet/fib/fib_path_list.h>
 #include <vnet/ip/ip6_hop_by_hop.h>
-#include <vnet/ip/ip4_reassembly.h>
-#include <vnet/ip/ip6_reassembly.h>
+#include <vnet/ip/reass/ip4_sv_reass.h>
+#include <vnet/ip/reass/ip4_full_reass.h>
+#include <vnet/ip/reass/ip6_sv_reass.h>
+#include <vnet/ip/reass/ip6_full_reass.h>
 #include <vnet/ethernet/arp.h>
 #include <vnet/ip/ip_types_api.h>
 
@@ -66,6 +68,7 @@
 
 #include <vlibapi/api_helper_macros.h>
 
+#include <vnet/format_fns.h>
 
 #define foreach_ip_api_msg                                              \
 _(IP_TABLE_DUMP, ip_table_dump)                                         \
@@ -667,13 +670,8 @@ ip_route_add_del_t_handler (vl_api_ip_route_add_del_t * mp, u32 * stats_index)
   if (0 != rv)
     goto out;
 
-  if (0 == mp->route.n_paths)
-    {
-      rv = VNET_API_ERROR_NO_PATHS_IN_ROUTE;
-      goto out;
-    }
-
-  vec_validate (rpaths, mp->route.n_paths - 1);
+  if (0 != mp->route.n_paths)
+    vec_validate (rpaths, mp->route.n_paths - 1);
 
   for (ii = 0; ii < mp->route.n_paths; ii++)
     {
@@ -690,9 +688,9 @@ ip_route_add_del_t_handler (vl_api_ip_route_add_del_t * mp, u32 * stats_index)
        goto out;
     }
 
-  fib_api_route_add_del (mp->is_add,
-                        mp->is_multipath,
-                        fib_index, &pfx, entry_flags, rpaths);
+  rv = fib_api_route_add_del (mp->is_add,
+                             mp->is_multipath,
+                             fib_index, &pfx, entry_flags, rpaths);
 
   if (mp->is_add && 0 == rv)
     *stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
@@ -991,7 +989,7 @@ vl_api_ip_unnumbered_dump_t_handler (vl_api_ip_unnumbered_dump_t * mp)
 
       si = vnet_get_sw_interface (vnm, ntohl (mp->sw_if_index));
 
-      if (!(si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
+      if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
        {
          send_ip_unnumbered_details (am, reg,
                                      sw_if_index,
@@ -1055,6 +1053,8 @@ vl_api_ip_dump_t_handler (vl_api_ip_dump_t * mp)
        send_ip_details (am, reg, sw_if_index, mp->is_ipv6, mp->context);
       }
   }
+
+  vec_free (sorted_sis);
 }
 
 static void
@@ -2550,7 +2550,7 @@ vl_api_ip_probe_neighbor_t_handler (vl_api_ip_probe_neighbor_t * mp)
 
   BAD_SW_IF_INDEX_LABEL;
 
-  REPLY_MACRO (VL_API_PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY);
+  REPLY_MACRO (VL_API_IP_PROBE_NEIGHBOR_REPLY);
 }
 
 static void
@@ -2738,19 +2738,51 @@ vl_api_ip_reassembly_set_t_handler (vl_api_ip_reassembly_set_t * mp)
 {
   vl_api_ip_reassembly_set_reply_t *rmp;
   int rv = 0;
-  if (mp->is_ip6)
+  switch ((vl_api_ip_reass_type_t) clib_net_to_host_u32 (mp->type))
     {
-      rv = ip6_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
-                         clib_net_to_host_u32 (mp->max_reassemblies),
-                         clib_net_to_host_u32 (mp->max_reassembly_length),
-                         clib_net_to_host_u32 (mp->expire_walk_interval_ms));
-    }
-  else
-    {
-      rv = ip4_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
-                         clib_net_to_host_u32 (mp->max_reassemblies),
-                         clib_net_to_host_u32 (mp->max_reassembly_length),
-                         clib_net_to_host_u32 (mp->expire_walk_interval_ms));
+    case IP_REASS_TYPE_FULL:
+      if (mp->is_ip6)
+       {
+         rv = ip6_full_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
+                                  clib_net_to_host_u32
+                                  (mp->max_reassemblies),
+                                  clib_net_to_host_u32
+                                  (mp->max_reassembly_length),
+                                  clib_net_to_host_u32
+                                  (mp->expire_walk_interval_ms));
+       }
+      else
+       {
+         rv = ip4_full_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
+                                  clib_net_to_host_u32
+                                  (mp->max_reassemblies),
+                                  clib_net_to_host_u32
+                                  (mp->max_reassembly_length),
+                                  clib_net_to_host_u32
+                                  (mp->expire_walk_interval_ms));
+       }
+      break;
+    case IP_REASS_TYPE_SHALLOW_VIRTUAL:
+      if (mp->is_ip6)
+       {
+         rv =
+           ip6_sv_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
+                             clib_net_to_host_u32 (mp->max_reassemblies),
+                             clib_net_to_host_u32
+                             (mp->max_reassembly_length),
+                             clib_net_to_host_u32
+                             (mp->expire_walk_interval_ms));
+       }
+      else
+       {
+         rv = ip4_sv_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
+                                clib_net_to_host_u32 (mp->max_reassemblies),
+                                clib_net_to_host_u32
+                                (mp->max_reassembly_length),
+                                clib_net_to_host_u32
+                                (mp->expire_walk_interval_ms));
+       }
+      break;
     }
 
   REPLY_MACRO (VL_API_IP_REASSEMBLY_SET_REPLY);
@@ -2770,18 +2802,42 @@ vl_api_ip_reassembly_get_t_handler (vl_api_ip_reassembly_get_t * mp)
   rmp->_vl_msg_id = ntohs (VL_API_IP_REASSEMBLY_GET_REPLY);
   rmp->context = mp->context;
   rmp->retval = 0;
-  if (mp->is_ip6)
+  u32 timeout_ms;
+  u32 max_reassemblies;
+  u32 max_reassembly_length;
+  u32 expire_walk_interval_ms;
+  switch ((vl_api_ip_reass_type_t) clib_net_to_host_u32 (mp->type))
     {
-      rmp->is_ip6 = 1;
-      ip6_reass_get (&rmp->timeout_ms, &rmp->max_reassemblies,
-                    &rmp->expire_walk_interval_ms);
-    }
-  else
-    {
-      rmp->is_ip6 = 0;
-      ip4_reass_get (&rmp->timeout_ms, &rmp->max_reassemblies,
-                    &rmp->max_reassembly_length,
-                    &rmp->expire_walk_interval_ms);
+    case IP_REASS_TYPE_FULL:
+      if (mp->is_ip6)
+       {
+         rmp->is_ip6 = 1;
+         ip6_full_reass_get (&timeout_ms, &max_reassemblies,
+                             &max_reassembly_length,
+                             &expire_walk_interval_ms);
+       }
+      else
+       {
+         rmp->is_ip6 = 0;
+         ip4_full_reass_get (&timeout_ms, &max_reassemblies,
+                             &max_reassembly_length,
+                             &expire_walk_interval_ms);
+       }
+      break;
+    case IP_REASS_TYPE_SHALLOW_VIRTUAL:
+      if (mp->is_ip6)
+       {
+         rmp->is_ip6 = 1;
+         ip6_sv_reass_get (&timeout_ms, &max_reassemblies,
+                           &max_reassembly_length, &expire_walk_interval_ms);
+       }
+      else
+       {
+         rmp->is_ip6 = 0;
+         ip4_sv_reass_get (&timeout_ms, &max_reassemblies,
+                           &max_reassembly_length, &expire_walk_interval_ms);
+       }
+      break;
     }
   rmp->timeout_ms = clib_host_to_net_u32 (rmp->timeout_ms);
   rmp->max_reassemblies = clib_host_to_net_u32 (rmp->max_reassemblies);
@@ -2796,12 +2852,28 @@ void
 {
   vl_api_ip_reassembly_enable_disable_reply_t *rmp;
   int rv = 0;
-  rv = ip4_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
-                                mp->enable_ip4);
-  if (0 == rv)
+  switch ((vl_api_ip_reass_type_t) clib_net_to_host_u32 (mp->type))
     {
-      rv = ip6_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
-                                    mp->enable_ip6);
+    case IP_REASS_TYPE_FULL:
+      rv =
+       ip4_full_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
+                                      mp->enable_ip4);
+      if (0 == rv)
+       rv =
+         ip6_full_reass_enable_disable (clib_net_to_host_u32
+                                        (mp->sw_if_index), mp->enable_ip6);
+      break;
+    case IP_REASS_TYPE_SHALLOW_VIRTUAL:
+      rv =
+       ip4_sv_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
+                                    mp->enable_ip4);
+      if (0 == rv)
+       {
+         rv =
+           ip6_sv_reass_enable_disable (clib_net_to_host_u32
+                                        (mp->sw_if_index), mp->enable_ip6);
+       }
+      break;
     }
 
   REPLY_MACRO (VL_API_IP_REASSEMBLY_ENABLE_DISABLE_REPLY);