Clean-up unused context arrays in UDP and GRE nodes 93/2593/2
authorAlex Popovsky <[email protected]>
Fri, 2 Sep 2016 00:38:09 +0000 (17:38 -0700)
committerJohn Lo <[email protected]>
Fri, 2 Sep 2016 03:50:00 +0000 (03:50 +0000)
Removed unused sparse_index_by_next_index vector in local context
of UDP and GRE nodes. Most probably copy paste leftovers from PPP
implementation where it is realy used

Change-Id: I97e81035e2fd451c6f5a7bc31df96db9e6d2cebf
Signed-off-by: Alex Popovsky <[email protected]>
vnet/vnet/gre/node.c
vnet/vnet/ip/udp_local.c

index e33b2b0..d226c2f 100644 (file)
@@ -57,8 +57,6 @@ typedef struct {
   /* Sparse vector mapping gre protocol in network byte order
      to next index. */
   u16 * next_by_protocol;
-
-  u32 * sparse_index_by_next_index;
 } gre_input_runtime_t;
 
 static uword
@@ -68,7 +66,7 @@ gre_input (vlib_main_t * vm,
 {
   gre_main_t * gm = &gre_main;
   gre_input_runtime_t * rt = (void *) node->runtime_data;
-  __attribute__((unused)) u32 n_left_from, next_index, i_next, * from, * to_next;
+  __attribute__((unused)) u32 n_left_from, next_index, * from, * to_next;
   u64 cached_tunnel_key = (u64) ~0;
   u32 cached_tunnel_sw_if_index = 0, tunnel_sw_if_index;
   u32 cached_tunnel_fib_index = 0, tunnel_fib_index;
@@ -79,7 +77,6 @@ gre_input (vlib_main_t * vm,
   n_left_from = from_frame->n_vectors;
 
   next_index = node->cached_next_index;
-  i_next = vec_elt (rt->sparse_index_by_next_index, next_index);
 
   while (n_left_from > 0)
     {
@@ -445,7 +442,6 @@ gre_register_input_protocol (vlib_main_t * vm,
   gre_protocol_info_t * pi;
   gre_input_runtime_t * rt;
   u16 * n;
-  u32 i;
 
   {
     clib_error_t * error = vlib_call_init_function (vm, gre_input_init);
@@ -464,12 +460,6 @@ gre_register_input_protocol (vlib_main_t * vm,
   n = sparse_vec_validate (rt->next_by_protocol, 
                            clib_host_to_net_u16 (protocol));
   n[0] = pi->next_index;
-
-  /* Rebuild next index -> sparse index inverse mapping when sparse vector
-     is updated. */
-  vec_validate (rt->sparse_index_by_next_index, pi->next_index);
-  for (i = 1; i < vec_len (rt->next_by_protocol); i++)
-    rt->sparse_index_by_next_index[rt->next_by_protocol[i]] = i;
 }
 
 static void
@@ -503,13 +493,6 @@ static clib_error_t * gre_input_init (vlib_main_t * vm)
     (/* elt bytes */ sizeof (rt->next_by_protocol[0]),
      /* bits in index */ BITS (((gre_header_t *) 0)->protocol));
 
-  vec_validate (rt->sparse_index_by_next_index, GRE_INPUT_NEXT_DROP);
-  vec_validate (rt->sparse_index_by_next_index, GRE_INPUT_NEXT_PUNT);
-  rt->sparse_index_by_next_index[GRE_INPUT_NEXT_DROP]
-    = SPARSE_VEC_INVALID_INDEX;
-  rt->sparse_index_by_next_index[GRE_INPUT_NEXT_PUNT]
-    = SPARSE_VEC_INVALID_INDEX;
-
   /* These could be moved to the supported protocol input node defn's */
   ip4_input = vlib_get_node_by_name (vm, (u8 *)"ip4-input");
   ASSERT(ip4_input);
index 4928d55..9940323 100644 (file)
@@ -59,8 +59,6 @@ typedef struct {
   /* Sparse vector mapping udp dst_port in network byte order
      to next index. */
   u16 * next_by_dst_port;
-
-  u32 * sparse_index_by_next_index;
 } udp_input_runtime_t;
 
 vlib_node_registration_t udp4_input_node;
@@ -75,14 +73,13 @@ udp46_input_inline (vlib_main_t * vm,
   udp_input_runtime_t * rt = is_ip4 ?
     (void *) vlib_node_get_runtime_data (vm, udp4_input_node.index)
     : (void *) vlib_node_get_runtime_data (vm, udp6_input_node.index);
-  __attribute__((unused)) u32 n_left_from, next_index, i_next, * from, * to_next;
+  __attribute__((unused)) u32 n_left_from, next_index, * from, * to_next;
   word n_no_listener = 0;
 
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
 
   next_index = node->cached_next_index;
-  i_next = vec_elt (rt->sparse_index_by_next_index, next_index);
 
   while (n_left_from > 0)
     {
@@ -466,7 +463,6 @@ udp_register_dst_port (vlib_main_t * vm,
   udp_dst_port_info_t * pi;
   udp_input_runtime_t * rt;
   u16 * n;
-  u32 i;
 
   {
     clib_error_t * error = vlib_call_init_function (vm, udp_local_init);
@@ -494,12 +490,6 @@ udp_register_dst_port (vlib_main_t * vm,
   n = sparse_vec_validate (rt->next_by_dst_port, 
                            clib_host_to_net_u16 (dst_port));
   n[0] = pi->next_index;
-
-  /* Rebuild next index -> sparse index inverse mapping when sparse vector
-     is updated. */
-  vec_validate (rt->sparse_index_by_next_index, pi->next_index);
-  for (i = 1; i < vec_len (rt->next_by_dst_port); i++)
-    rt->sparse_index_by_next_index[rt->next_by_dst_port[i]] = i;
 }
 
 /* Parse a UDP header. */
@@ -570,13 +560,6 @@ clib_error_t * udp_local_init (vlib_main_t * vm)
     (/* elt bytes */ sizeof (rt->next_by_dst_port[0]),
      /* bits in index */ BITS (((udp_header_t *) 0)->dst_port));
 
-  vec_validate (rt->sparse_index_by_next_index, UDP_INPUT_NEXT_DROP);
-  vec_validate (rt->sparse_index_by_next_index, UDP_INPUT_NEXT_PUNT);
-  rt->sparse_index_by_next_index[UDP_INPUT_NEXT_DROP]
-    = SPARSE_VEC_INVALID_INDEX;
-  rt->sparse_index_by_next_index[UDP_INPUT_NEXT_PUNT]
-    = SPARSE_VEC_INVALID_INDEX;
-
 #define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 1 /* is_ip4 */);
   foreach_udp4_dst_port
 #undef _
@@ -587,13 +570,6 @@ clib_error_t * udp_local_init (vlib_main_t * vm)
     (/* elt bytes */ sizeof (rt->next_by_dst_port[0]),
      /* bits in index */ BITS (((udp_header_t *) 0)->dst_port));
 
-  vec_validate (rt->sparse_index_by_next_index, UDP_INPUT_NEXT_DROP);
-  vec_validate (rt->sparse_index_by_next_index, UDP_INPUT_NEXT_PUNT);
-  rt->sparse_index_by_next_index[UDP_INPUT_NEXT_DROP]
-    = SPARSE_VEC_INVALID_INDEX;
-  rt->sparse_index_by_next_index[UDP_INPUT_NEXT_PUNT]
-    = SPARSE_VEC_INVALID_INDEX;
-
 #define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 0 /* is_ip4 */);
   foreach_udp6_dst_port
 #undef _