88 while (*s && *s !=
',')
123 char **feature_start_nodes,
124 int num_feature_start_nodes,
128 first_const_set,
char ***in_feature_nodes)
130 uword *index_by_name;
135 char **these_constraints;
136 char *this_constraint_c;
137 u8 **constraints = 0;
138 u8 *constraint_tuple;
140 u8 **orig, **closure;
144 int a_index, b_index;
149 char **feature_nodes = 0;
151 u8 **keys_to_delete = 0;
156 this_reg = first_reg;
164 if (
clib_strcmp (this_reg->node_name, last_in_arc))
170 constraint_tuple =
format (0,
"%s,%s%c", this_reg->node_name,
172 vec_add1 (constraints, constraint_tuple);
174 this_reg = this_reg->next_in_arc;
176 this_reg = first_reg;
182 node_name =
format (0,
"%s%c", this_reg->node_name, 0);
189 these_constraints = this_reg->runs_before;
190 while (these_constraints && these_constraints[0])
192 this_constraint_c = these_constraints[0];
194 constraint_tuple =
format (0,
"%s,%s%c", node_name,
195 this_constraint_c, 0);
196 vec_add1 (constraints, constraint_tuple);
200 these_constraints = this_reg->runs_after;
201 while (these_constraints && these_constraints[0])
203 this_constraint_c = these_constraints[0];
205 constraint_tuple =
format (0,
"%s,%s%c",
206 this_constraint_c, node_name, 0);
207 vec_add1 (constraints, constraint_tuple);
211 this_reg = this_reg->next_in_arc;
215 this_const_set = first_const_set;
216 while (this_const_set)
218 these_constraints = this_const_set->node_names;
222 while (these_constraints && these_constraints[0])
224 this_constraint_c = these_constraints[0];
229 (
"bulk constraint feature node '%s' not found for arc '%s'",
237 prev_name = this_constraint_c;
242 constraint_tuple =
format (0,
"%s,%s%c", prev_name,
243 this_constraint_c, 0);
244 vec_add1 (constraints, constraint_tuple);
245 prev_name = this_constraint_c;
249 this_const_set = this_const_set->next_in_arc;
252 n_features =
vec_len (node_names);
255 for (i = 0; i <
vec_len (constraints); i++)
257 this_constraint = constraints[
i];
259 if (
comma_split (this_constraint, &a_name, &b_name))
271 clib_warning (
"feature node '%s' not found (before '%s', arc '%s')",
272 a_name, b_name, first_reg->arc_name);
280 clib_warning (
"feature node '%s' not found (after '%s', arc '%s')",
281 b_name, a_name, first_reg->arc_name);
287 orig[a_index][b_index] = 1;
296 for (i = 0; i < n_features; i++)
298 for (j = 0; j < n_features; j++)
301 goto item_constrained;
306 for (k = 0; k < n_features; k++)
320 if (vec_len (result) != n_features)
322 (0,
"Arc '%s': failed to find a suitable feature order!",
323 first_reg->arc_name);
333 for (i = n_features - 1; i >= 0; i--)
335 p =
hash_get (reg_by_index, result[i]);
338 if (this_reg->feature_index_ptr)
339 *this_reg->feature_index_ptr = n_features - (i + 1);
340 this_reg->feature_index = n_features - (i + 1);
341 vec_add1 (feature_nodes, this_reg->node_name);
347 num_feature_start_nodes,
348 feature_nodes, vec_len (feature_nodes));
351 *in_feature_nodes = feature_nodes;
361 for (i = 0; i <
vec_len (keys_to_delete); i++)
#define hash_set(h, key, value)
struct _vnet_feature_constraint_registration vnet_feature_constraint_registration_t
constraint registration object
void vnet_config_init(vlib_main_t *vm, vnet_config_main_t *cm, char *start_node_names[], int n_start_node_names, char *feature_node_names[], int n_feature_node_names)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define hash_set_mem(h, key, value)
#define clib_error_return(e, args...)
#define hash_create_string(elts, value_bytes)
u8 ** clib_ptclosure_alloc(int n)
void clib_ptclosure_free(u8 **ptc)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
#define hash_create(elts, value_bytes)
static int comma_split(u8 *s, u8 **a, u8 **b)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vnet_feature_arc_init(vlib_main_t *vm, vnet_config_main_t *vcm, char **feature_start_nodes, int num_feature_start_nodes, char *last_in_arc, vnet_feature_registration_t *first_reg, vnet_feature_constraint_registration_t *first_const_set, char ***in_feature_nodes)
Initialize a feature graph arc.
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
u8 ** clib_ptclosure(u8 **orig)
#define hash_get_mem(h, key)
#define clib_strcmp(s1, s2)
struct _vnet_feature_registration vnet_feature_registration_t
feature registration object