}
static struct cls_rule *
-tcls_lookup(const struct tcls *cls, const flow_t *flow)
+tcls_lookup(const struct tcls *cls, const flow_t *flow, int include)
{
size_t i;
for (i = 0; i < cls->n_rules; i++) {
struct test_rule *pos = cls->rules[i];
- if (match(&pos->cls_rule, flow)) {
+ uint32_t wildcards = pos->cls_rule.wc.wildcards;
+ if (include & (wildcards ? CLS_INC_WILD : CLS_INC_EXACT)
+ && match(&pos->cls_rule, flow)) {
return &pos->cls_rule;
}
}
return rem;
}
+static struct cls_rule *
+lookup_with_include_bits(const struct classifier *cls,
+ const flow_t *flow, int include)
+{
+ switch (include) {
+ case CLS_INC_WILD:
+ return classifier_lookup_wild(cls, flow);
+ case CLS_INC_EXACT:
+ return classifier_lookup_exact(cls, flow);
+ case CLS_INC_WILD | CLS_INC_EXACT:
+ return classifier_lookup(cls, flow);
+ default:
+ abort();
+ }
+}
+
static void
compare_classifiers(struct classifier *cls, struct tcls *tcls)
{
struct cls_rule *cr0, *cr1;
flow_t flow;
unsigned int x;
+ int include;
x = i;
flow.nw_src = nw_src_values[get_value(&x, N_NW_SRC_VALUES)];
flow.nw_proto = nw_proto_values[get_value(&x, N_NW_PROTO_VALUES)];
flow.reserved = 0;
- cr0 = classifier_lookup(cls, &flow);
- cr1 = tcls_lookup(tcls, &flow);
- assert((cr0 == NULL) == (cr1 == NULL));
- if (cr0 != NULL) {
- const struct test_rule *tr0 = test_rule_from_cls_rule(cr0);
- const struct test_rule *tr1 = test_rule_from_cls_rule(cr1);
-
- assert(flow_equal(&cr0->flow, &cr1->flow));
- assert(cr0->wc.wildcards == cr1->wc.wildcards);
- assert(cr0->priority == cr1->priority);
- /* Skip nw_src_mask and nw_dst_mask, because they are derived
- * members whose values are used only for optimization. */
- assert(tr0->aux == tr1->aux);
+ for (include = 1; include <= 3; include++) {
+ cr0 = lookup_with_include_bits(cls, &flow, include);
+ cr1 = tcls_lookup(tcls, &flow, include);
+ assert((cr0 == NULL) == (cr1 == NULL));
+ if (cr0 != NULL) {
+ const struct test_rule *tr0 = test_rule_from_cls_rule(cr0);
+ const struct test_rule *tr1 = test_rule_from_cls_rule(cr1);
+
+ assert(flow_equal(&cr0->flow, &cr1->flow));
+ assert(cr0->wc.wildcards == cr1->wc.wildcards);
+ assert(cr0->priority == cr1->priority);
+ /* Skip nw_src_mask and nw_dst_mask, because they are derived
+ * members whose values are used only for optimization. */
+ assert(tr0->aux == tr1->aux);
+ }
}
}
}