88 while (*s && *s !=
',')
123 char **feature_start_nodes,
124 int num_feature_start_nodes,
127 first_const_set,
char ***in_feature_nodes)
129 uword *index_by_name;
134 char **these_constraints;
135 char *this_constraint_c;
136 u8 **constraints = 0;
137 u8 *constraint_tuple;
139 u8 **orig, **closure;
143 int a_index, b_index;
148 char **feature_nodes = 0;
150 u8 **keys_to_delete = 0;
155 this_reg = first_reg;
160 node_name =
format (0,
"%s%c", this_reg->node_name, 0);
167 these_constraints = this_reg->runs_before;
168 while (these_constraints && these_constraints[0])
170 this_constraint_c = these_constraints[0];
172 constraint_tuple =
format (0,
"%s,%s%c", node_name,
173 this_constraint_c, 0);
174 vec_add1 (constraints, constraint_tuple);
178 these_constraints = this_reg->runs_after;
179 while (these_constraints && these_constraints[0])
181 this_constraint_c = these_constraints[0];
183 constraint_tuple =
format (0,
"%s,%s%c",
184 this_constraint_c, node_name, 0);
185 vec_add1 (constraints, constraint_tuple);
189 this_reg = this_reg->next_in_arc;
193 this_const_set = first_const_set;
194 while (this_const_set)
196 these_constraints = this_const_set->node_names;
200 while (these_constraints && these_constraints[0])
202 this_constraint_c = these_constraints[0];
207 (
"bulk constraint feature node '%s' not found for arc '%s'",
215 prev_name = this_constraint_c;
220 constraint_tuple =
format (0,
"%s,%s%c", prev_name,
221 this_constraint_c, 0);
222 vec_add1 (constraints, constraint_tuple);
223 prev_name = this_constraint_c;
227 this_const_set = this_const_set->next_in_arc;
230 n_features =
vec_len (node_names);
233 for (i = 0; i <
vec_len (constraints); i++)
235 this_constraint = constraints[
i];
237 if (
comma_split (this_constraint, &a_name, &b_name))
249 clib_warning (
"feature node '%s' not found (before '%s', arc '%s')",
250 a_name, b_name, first_reg->arc_name);
258 clib_warning (
"feature node '%s' not found (after '%s', arc '%s')",
259 b_name, a_name, first_reg->arc_name);
265 orig[a_index][b_index] = 1;
274 for (i = 0; i < n_features; i++)
276 for (j = 0; j < n_features; j++)
279 goto item_constrained;
284 for (k = 0; k < n_features; k++)
298 if (vec_len (result) != n_features)
300 (0,
"Arc '%s': failed to find a suitable feature order!",
301 first_reg->arc_name);
311 for (i = n_features - 1; i >= 0; i--)
313 p =
hash_get (reg_by_index, result[i]);
316 if (this_reg->feature_index_ptr)
317 *this_reg->feature_index_ptr = n_features - (i + 1);
318 this_reg->feature_index = n_features - (i + 1);
319 vec_add1 (feature_nodes, this_reg->node_name);
325 num_feature_start_nodes,
326 feature_nodes, vec_len (feature_nodes));
329 *in_feature_nodes = feature_nodes;
339 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)
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, vnet_feature_registration_t *first_reg, vnet_feature_constraint_registration_t *first_const_set, char ***in_feature_nodes)
Initialize a feature graph arc.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
u8 ** clib_ptclosure(u8 **orig)
#define hash_get_mem(h, key)
struct _vnet_feature_registration vnet_feature_registration_t
feature registration object