VPP-1507: Added binary api to dump configured ip_punt_redirect
[vpp.git] / src / vnet / srp / interface.c
index 44e2b0d..3c98f41 100644 (file)
@@ -72,7 +72,7 @@ srp_build_rewrite (vnet_main_t * vnm,
   if (dst_address)
     clib_memcpy (h->ethernet.dst_address, dst_address, sizeof (h->ethernet.dst_address));
   else
-    memset (h->ethernet.dst_address, ~0, sizeof (h->ethernet.dst_address)); /* broadcast */
+    clib_memset (h->ethernet.dst_address, ~0, sizeof (h->ethernet.dst_address)); /* broadcast */
 
   h->ethernet.type = clib_host_to_net_u16 (type);
 
@@ -111,63 +111,14 @@ void unserialize_srp_main (serialize_main_t * m, va_list * va)
     }
 }
 
-static void serialize_srp_register_interface_msg (serialize_main_t * m, va_list * va)
-{
-  u32 * hw_if_indices = va_arg (*va, u32 *);
-  serialize_integer (m, hw_if_indices[SRP_SIDE_A], sizeof (hw_if_indices[SRP_SIDE_A]));
-  serialize_integer (m, hw_if_indices[SRP_SIDE_B], sizeof (hw_if_indices[SRP_SIDE_B]));
-}
-
-static void unserialize_srp_register_interface_msg (serialize_main_t * m, va_list * va)
-{
-  CLIB_UNUSED (mc_main_t * mcm) = va_arg (*va, mc_main_t *);
-  u32 hw_if_indices[SRP_N_SIDE];
-  srp_main_t * sm = &srp_main;
-  uword * p;
-
-  unserialize_integer (m, &hw_if_indices[SRP_SIDE_A], sizeof (hw_if_indices[SRP_SIDE_A]));
-  unserialize_integer (m, &hw_if_indices[SRP_SIDE_B], sizeof (hw_if_indices[SRP_SIDE_B]));
-
-  p = hash_get (sm->srp_register_interface_waiting_process_pool_index_by_hw_if_index,
-               hw_if_indices[0]);
-  if (p)
-    {
-      vlib_one_time_waiting_process_t * wp = pool_elt_at_index (sm->srp_register_interface_waiting_process_pool, p[0]);
-      vlib_signal_one_time_waiting_process (mcm->vlib_main, wp);
-      pool_put (sm->srp_register_interface_waiting_process_pool, wp);
-      hash_unset (sm->srp_register_interface_waiting_process_pool_index_by_hw_if_index,
-                 hw_if_indices[0]);
-    }
-  else
-    srp_register_interface_helper (hw_if_indices, /* redistribute */ 0);
-}
-
-MC_SERIALIZE_MSG (srp_register_interface_msg, static) = {
-  .name = "vnet_srp_register_interface",
-  .serialize = serialize_srp_register_interface_msg,
-  .unserialize = unserialize_srp_register_interface_msg,
-};
-
 static void srp_register_interface_helper (u32 * hw_if_indices_by_side, u32 redistribute)
 {
   vnet_main_t * vnm = vnet_get_main();
   srp_main_t * sm = &srp_main;
-  vlib_main_t * vm = sm->vlib_main;
   srp_interface_t * si;
   vnet_hw_interface_t * hws[SRP_N_RING];
   uword s, * p;
 
-  if (vm->mc_main && redistribute)
-    {
-      vlib_one_time_waiting_process_t * wp;
-      mc_serialize (vm->mc_main, &srp_register_interface_msg, hw_if_indices_by_side);
-      pool_get (sm->srp_register_interface_waiting_process_pool, wp);
-      hash_set (sm->srp_register_interface_waiting_process_pool_index_by_hw_if_index,
-               hw_if_indices_by_side[0],
-               wp - sm->srp_register_interface_waiting_process_pool);
-      vlib_current_process_wait_for_one_time_event (vm, wp);
-    }
-
   /* Check if interface has already been registered. */
   p = hash_get (sm->interface_index_by_hw_if_index, hw_if_indices_by_side[0]);
   if (p)
@@ -177,7 +128,7 @@ static void srp_register_interface_helper (u32 * hw_if_indices_by_side, u32 redi
   else
     {
       pool_get (sm->interface_pool, si);
-      memset (si, 0, sizeof (si[0]));
+      clib_memset (si, 0, sizeof (si[0]));
     }
   for (s = 0; s < SRP_N_SIDE; s++)
     {
@@ -298,36 +249,6 @@ VNET_HW_INTERFACE_CLASS (srp_hw_interface_class) = {
   .hw_class_change = srp_interface_hw_class_change,
 };
 
-static void serialize_srp_interface_config_msg (serialize_main_t * m, va_list * va)
-{
-  srp_interface_t * si = va_arg (*va, srp_interface_t *);
-  srp_main_t * sm = &srp_main;
-
-  ASSERT (! pool_is_free (sm->interface_pool, si));
-  serialize_integer (m, si - sm->interface_pool, sizeof (u32));
-  serialize (m, serialize_f64, si->config.wait_to_restore_idle_delay);
-  serialize (m, serialize_f64, si->config.ips_tx_interval);
-}
-
-static void unserialize_srp_interface_config_msg (serialize_main_t * m, va_list * va)
-{
-  CLIB_UNUSED (mc_main_t * mcm) = va_arg (*va, mc_main_t *);
-  srp_main_t * sm = &srp_main;
-  srp_interface_t * si;
-  u32 si_index;
-
-  unserialize_integer (m, &si_index, sizeof (u32));
-  si = pool_elt_at_index (sm->interface_pool, si_index);
-  unserialize (m, unserialize_f64, &si->config.wait_to_restore_idle_delay);
-  unserialize (m, unserialize_f64, &si->config.ips_tx_interval);
-}
-
-MC_SERIALIZE_MSG (srp_interface_config_msg, static) = {
-  .name = "vnet_srp_interface_config",
-  .serialize = serialize_srp_interface_config_msg,
-  .unserialize = unserialize_srp_interface_config_msg,
-};
-
 void srp_interface_get_interface_config (u32 hw_if_index, srp_interface_config_t * c)
 {
   srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index);
@@ -337,22 +258,17 @@ void srp_interface_get_interface_config (u32 hw_if_index, srp_interface_config_t
 
 void srp_interface_set_interface_config (u32 hw_if_index, srp_interface_config_t * c)
 {
-  srp_main_t * sm = &srp_main;
-  vlib_main_t * vm = sm->vlib_main;
   srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index);
   ASSERT (si != 0);
   if (memcmp (&si->config, &c[0], sizeof (c[0])))
     {
       si->config = c[0];
-      if (vm->mc_main)
-       mc_serialize (vm->mc_main, &srp_interface_config_msg, si);
     }
 }
 
 #if DEBUG > 0
 
 #define VNET_SIMULATED_SRP_TX_NEXT_SRP_INPUT VNET_INTERFACE_TX_N_NEXT
-
 /* Echo packets back to srp input. */
 static uword
 simulated_srp_interface_tx (vlib_main_t * vm,
@@ -365,7 +281,7 @@ simulated_srp_interface_tx (vlib_main_t * vm,
   vlib_buffer_t * b;
 
   n_left_from = frame->n_vectors;
-  from = vlib_frame_args (frame);
+  from = vlib_frame_vector_args (frame);
 
   while (n_left_from > 0)
     {
@@ -373,7 +289,7 @@ simulated_srp_interface_tx (vlib_main_t * vm,
 
       n_copy = clib_min (n_left_from, n_left_to_next);
 
-      clib_memcpy (to_next, from, n_copy * sizeof (from[0]));
+      clib_memcpy_fast (to_next, from, n_copy * sizeof (from[0]));
       n_left_to_next -= n_copy;
       n_left_from -= n_copy;
       for (i = 0; i < n_copy; i++)
@@ -414,7 +330,7 @@ create_simulated_srp_interfaces (vlib_main_t * vm,
 
   if (! unformat_user (input, unformat_ethernet_address, &address))
     {
-      memset (address, 0, sizeof (address));
+      clib_memset (address, 0, sizeof (address));
       address[0] = 0xde;
       address[1] = 0xad;
       address[5] = instance;
@@ -432,7 +348,7 @@ create_simulated_srp_interfaces (vlib_main_t * vm,
   hi->min_packet_bytes = 40 + 16;
 
   /* Standard default ethernet MTU. */
-  hi->max_l3_packet_bytes[VLIB_RX] = hi->max_l3_packet_bytes[VLIB_TX] = 1500;
+  vnet_sw_interface_set_mtu (vnm, sw_if_index, 1500);
 
   vec_free (hi->hw_address);
   vec_add (hi->hw_address, address, sizeof (address));