vcl: RX event may lost when accept session repeatedly
[vpp.git] / src / vnet / ip / ip6_neighbor.c
old mode 100755 (executable)
new mode 100644 (file)
index 86b1800..5b8085d
@@ -264,7 +264,7 @@ ip6_neighbor_get_link_local_address (u32 sw_if_index)
 
 /**
  * @brief publish wildcard arp event
- * @param sw_if_index The interface on which the ARP entires are acted
+ * @param sw_if_index The interface on which the ARP entries are acted
  */
 static int
 vnet_nd_wc_publish (u32 sw_if_index,
@@ -342,31 +342,19 @@ format_ip6_neighbor_ip6_entry (u8 * s, va_list * va)
   ip6_neighbor_t *n = va_arg (*va, ip6_neighbor_t *);
   vnet_main_t *vnm = vnet_get_main ();
   vnet_sw_interface_t *si;
-  u8 *flags = 0;
 
   if (!n)
     return format (s, "%=12s%=45s%=6s%=20s%=40s", "Time", "Address", "Flags",
                   "Link layer", "Interface");
 
-  if (n->flags & IP_NEIGHBOR_FLAG_DYNAMIC)
-    flags = format (flags, "D");
-
-  if (n->flags & IP_NEIGHBOR_FLAG_STATIC)
-    flags = format (flags, "S");
-
-  if (n->flags & IP_NEIGHBOR_FLAG_NO_FIB_ENTRY)
-    flags = format (flags, "N");
-
   si = vnet_get_sw_interface (vnm, n->key.sw_if_index);
-  s = format (s, "%=12U%=45U%=6s%=20U%=40U",
-             format_vlib_time, vm, n->time_last_updated,
-             format_ip6_address, &n->key.ip6_address,
-             flags ? (char *) flags : "",
-             format_mac_address_t, &n->mac,
-             format_vnet_sw_interface_name, vnm, si);
-
-  vec_free (flags);
-  return s;
+
+  return format (s, "%=12U%=45U%=6U%=20U%=40U",
+                format_vlib_time, vm, n->time_last_updated,
+                format_ip6_address, &n->key.ip6_address,
+                format_ip_neighbor_flags, n->flags,
+                format_mac_address_t, &n->mac,
+                format_vnet_sw_interface_name, vnm, si);
 }
 
 static void
@@ -687,7 +675,7 @@ ip6_ethernet_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai)
         * Complete the remaining fields of the adj's rewrite to direct the
         * complete of the rewrite at switch time by copying in the IP
         * dst address's bytes.
-        * Ofset is 2 bytes into the desintation address.
+        * Ofset is 2 bytes into the destintation address.
         */
        offset = vec_len (rewrite) - 2;
        adj_mcast_update_rewrite (ai, rewrite, offset);
@@ -819,7 +807,10 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm,
            return -2;
        }
       else
-       pool_get (nm->neighbor_pool, n);
+       {
+         pool_get (nm->neighbor_pool, n);
+         memset (n, 0, sizeof (*n));
+       }
 
       mhash_set (&nm->neighbor_index_by_key, &k, n - nm->neighbor_pool,
                 /* old value */ 0);
@@ -1796,6 +1787,14 @@ icmp6_router_solicitation (vlib_main_t * vm,
                               }
                             h.unused  = 0;
 
+                            clib_warning ("Prefix %U valid %u preferred %u",
+                                          format_ip6_address, &pr_info->prefix,
+                                          ntohl(h.valid_time),
+                                          ntohl(h.preferred_time));
+
+                            if (h.valid_time == 0)
+                              clib_warning ("WARNING: valid_time 0!!!");
+
                             clib_memcpy(&h.dst_address, &pr_info->prefix,  sizeof(ip6_address_t));
 
                             payload_length += sizeof( icmp6_neighbor_discovery_prefix_information_option_t);
@@ -1866,7 +1865,7 @@ icmp6_router_solicitation (vlib_main_t * vm,
                      else
                        {
                          adj_index0 = radv_info->mcast_adj_index;
-                         if (adj_index0 == 0)
+                         if (adj_index0 == ADJ_INDEX_INVALID)
                            error0 = ICMP6_ERROR_DST_LOOKUP_MISS;
                          else
                            {
@@ -2545,6 +2544,7 @@ ip6_neighbor_add_mld_prefix (ip6_radv_t * radv_info, ip6_address_t * addr)
       /* add */
       u32 mi;
       pool_get (radv_info->mldp_group_pool, mcast_group_info);
+      memset (mcast_group_info, 0, sizeof (*mcast_group_info));
 
       mi = mcast_group_info - radv_info->mldp_group_pool;
       mhash_set (&radv_info->address_to_mldp_index, addr, mi,  /* old_value */
@@ -2663,6 +2663,7 @@ ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm,
       if (is_add)
        {
          pool_get (nm->if_radv_pool, a);
+         memset (a, 0, sizeof (*a));
 
          ri = a - nm->if_radv_pool;
          nm->if_radv_pool_index_by_sw_if_index[sw_if_index] = ri;
@@ -2701,7 +2702,7 @@ ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm,
          clib_memcpy (a->link_layer_address, eth_if0->address, 6);
 
          /* fill in default link-local address  (this may be overridden) */
-         ip6_link_local_address_from_ethernet_address
+         ip6_link_local_address_from_ethernet_mac_address
            (&a->link_local_address, eth_if0->address);
 
          mhash_init (&a->address_to_prefix_index, sizeof (uword),
@@ -3564,6 +3565,7 @@ ip6_neighbor_ra_prefix (vlib_main_t * vm, u32 sw_if_index,
          /* add */
          u32 pi;
          pool_get (radv_info->adv_prefixes_pool, prefix);
+         memset (prefix, 0, sizeof (*prefix));
          pi = prefix - radv_info->adv_prefixes_pool;
          mhash_set (&radv_info->address_to_prefix_index, prefix_addr, pi,
                     /* old_value */ 0);
@@ -4670,6 +4672,7 @@ vnet_register_ip6_neighbor_resolution_event (vnet_main_t * vnm,
   pending_resolution_t *pr;
 
   pool_get (nm->pending_resolutions, pr);
+  memset (pr, 0, sizeof (*pr));
 
   pr->next_index = ~0;
   pr->node_index = node_index;
@@ -4719,6 +4722,7 @@ vnet_add_del_ip6_nd_change_event (vnet_main_t * vnm,
        return VNET_API_ERROR_ENTRY_ALREADY_EXISTS;
 
       pool_get (nm->mac_changes, mc);
+      memset (mc, 0, sizeof (*mc));
       /* *INDENT-OFF* */
       *mc = (pending_resolution_t)
       {