features: don't break linked list, create separate one for arc 31/11631/1
authorDamjan Marion <damarion@cisco.com>
Mon, 9 Apr 2018 18:59:53 +0000 (20:59 +0200)
committerDamjan Marion <damarion@cisco.com>
Mon, 9 Apr 2018 19:09:21 +0000 (21:09 +0200)
We need to keep original linked list so destructire can remove entries.

Change-Id: I5ff5ca0e1a417d88707255207725bba46433c943
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vlib/init.h
src/vnet/feature/feature.c
src/vnet/feature/feature.h
src/vnet/feature/registration.c

index 1eddbb1..f163ee2 100644 (file)
@@ -81,20 +81,22 @@ typedef struct vlib_config_function_runtime_t
 
 #define VLIB_REMOVE_FROM_LINKED_LIST(first,p,next)              \
 {                                                               \
+  ASSERT (first);                                               \
   if (first == p)                                               \
       first = (p)->next;                                        \
   else                                                          \
     {                                                           \
       __typeof__ (p) current = first;                           \
-       while (current->next)                                   \
-         {                                                     \
-           if (current->next == p)                             \
-             {                                                 \
-               current->next = current->next->next;            \
-               break;                                          \
-             }                                                 \
-           current = current->next;                            \
-         }                                                     \
+      while (current->next)                                     \
+       {                                                       \
+         if (current->next == p)                               \
+           {                                                   \
+             current->next = current->next->next;              \
+             break;                                            \
+           }                                                   \
+         current = current->next;                              \
+       }                                                       \
+      ASSERT (current);                                         \
     }                                                           \
 }
 
index 89a1951..9710004 100644 (file)
@@ -75,7 +75,7 @@ vnet_feature_init (vlib_main_t * vm)
       arc_index = areg->feature_arc_index;
 
       next = freg->next;
-      freg->next = fm->next_feature_by_arc[arc_index];
+      freg->next_in_arc = fm->next_feature_by_arc[arc_index];
       fm->next_feature_by_arc[arc_index] = freg;
 
       /* next */
@@ -110,7 +110,7 @@ vnet_feature_init (vlib_main_t * vm)
        {
          hash_set_mem (fm->next_feature_by_name[arc_index],
                        freg->node_name, pointer_to_uword (freg));
-         freg = freg->next;
+         freg = freg->next_in_arc;
        }
 
       /* next */
@@ -273,7 +273,7 @@ show_features_command_fn (vlib_main_t * vm,
       while (freg)
        {
          vlib_cli_output (vm, "  %s\n", freg->node_name);
-         freg = freg->next;
+         freg = freg->next_in_arc;
        }
 
 
index 70a456e..f6b1d12 100644 (file)
@@ -43,7 +43,7 @@ typedef clib_error_t *(vnet_feature_enable_disable_function_t)
 typedef struct _vnet_feature_registration
 {
   /** next registration in list of all registrations*/
-  struct _vnet_feature_registration *next;
+  struct _vnet_feature_registration *next, *next_in_arc;
   /** Feature arc name */
   char *arc_name;
   /** Graph node name */
index 872a196..61024ca 100644 (file)
@@ -180,7 +180,7 @@ vnet_feature_arc_init (vlib_main_t * vm,
          these_constraints++;
        }
 
-      this_reg = this_reg->next;
+      this_reg = this_reg->next_in_arc;
     }
 
   n_features = vec_len (node_names);