classifier_insert_exact(struct classifier *cls, struct cls_rule *rule)
{
hmap_insert(&cls->exact_table, &rule->node.hmap,
- flow_hash(&rule->flow, 0));
+ flow_hash_headers(&rule->flow, 0));
cls->n_rules++;
}
classifier_lookup_exact(const struct classifier *cls, const flow_t *flow)
{
return (!hmap_is_empty(&cls->exact_table)
- ? search_exact_table(cls, flow_hash(flow, 0), flow)
+ ? search_exact_table(cls, flow_hash_headers(flow, 0), flow)
: NULL);
}
if (!target->wildcards) {
/* Ignores 'priority'. */
- return search_exact_table(cls, flow_hash(target, 0), target);
+ return search_exact_table(cls, flow_hash_headers(target, 0), target);
}
assert(target->wildcards == (target->wildcards & OVSFW_ALL));
return NULL;
} else if (pos->flow.priority == target->priority &&
pos->flow.wildcards == target->wildcards &&
- flow_equal(target, &pos->flow)) {
+ flow_equal_headers(target, &pos->flow)) {
return pos;
}
}
const struct hmap *tbl;
if (!target->wildcards) {
- return search_exact_table(cls, flow_hash(target, 0), target) ?
+ return search_exact_table(cls, flow_hash_headers(target, 0), target) ?
true : false;
}
} else {
/* Optimization: there can be at most one match in the exact
* table. */
- size_t hash = flow_hash(&target.flow, 0);
+ size_t hash = flow_hash_headers(&target.flow, 0);
struct cls_rule *rule = search_exact_table(cls, hash,
&target.flow);
if (rule) {
struct cls_rule *old_rule;
size_t hash;
- hash = flow_hash(&rule->flow, 0);
+ hash = flow_hash_headers(&rule->flow, 0);
old_rule = search_exact_table(cls, hash, &rule->flow);
if (old_rule) {
hmap_remove(&cls->exact_table, &old_rule->node.hmap);
HMAP_FOR_EACH_WITH_HASH (rule, struct cls_rule, node.hmap,
hash, &cls->exact_table) {
- if (flow_equal(&rule->flow, target)) {
+ if (flow_equal_headers(&rule->flow, target)) {
return rule;
}
}
char *flow_to_string(const flow_t *);
void flow_format(struct ds *, const flow_t *);
void flow_print(FILE *, const flow_t *);
-static inline int flow_compare(const flow_t *, const flow_t *);
-static inline bool flow_equal(const flow_t *, const flow_t *);
-static inline size_t flow_hash(const flow_t *, uint32_t basis);
+static inline int flow_compare_headers(const flow_t *, const flow_t *);
+static inline bool flow_equal_headers(const flow_t *, const flow_t *);
+static inline size_t flow_hash_headers(const flow_t *, uint32_t basis);
/* Compares members of 'a' and 'b' except for 'wildcards' and 'priority' and
* returns a strcmp()-like return value. */
static inline int
-flow_compare(const flow_t *a, const flow_t *b)
+flow_compare_headers(const flow_t *a, const flow_t *b)
{
/* Assert that 'wildcards' and 'priority' are leading 32-bit fields. */
BUILD_ASSERT_DECL(offsetof(struct flow, wildcards) == 0);
/* Returns true if all members of 'a' and 'b' are equal except for 'wildcards'
* and 'priority', false otherwise. */
static inline bool
-flow_equal(const flow_t *a, const flow_t *b)
+flow_equal_headers(const flow_t *a, const flow_t *b)
{
- return !flow_compare(a, b);
+ return !flow_compare_headers(a, b);
}
/* Returns a hash value for 'flow' that does not include 'wildcards' or
* 'priority', folding 'basis' into the hash value. */
static inline size_t
-flow_hash(const flow_t *flow, uint32_t basis)
+flow_hash_headers(const flow_t *flow, uint32_t basis)
{
/* Assert that 'wildcards' and 'priority' are leading 32-bit fields. */
BUILD_ASSERT_DECL(offsetof(struct flow, wildcards) == 0);
* port simply because the xflow actions were composed for the wrong
* scenario. */
if (rule->wr.cr.flow.wildcards
- || !flow_equal(flow, &rule->wr.cr.flow))
+ || !flow_equal_headers(flow, &rule->wr.cr.flow))
{
struct wx_rule *super = rule->super ? rule->super : rule;
if (wx_xlate_actions(wx, super->wr.actions, super->wr.n_actions, flow,
const struct cls_rule *pos = &tcls->rules[i]->cls_rule;
if (pos->flow.priority == priority
&& pos->flow.wildcards == rule->cls_rule.flow.wildcards
- && flow_equal(&pos->flow, &rule->cls_rule.flow)) {
- /* Exact match.
- * XXX flow_equal should ignore wildcarded fields */
+ && flow_equal_headers(&pos->flow, &rule->cls_rule.flow)) {
+ /* Exact match. */
free(tcls->rules[i]);
tcls->rules[i] = xmemdup(rule, sizeof *rule);
return tcls->rules[i];
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(flow_equal_headers(&cr0->flow, &cr1->flow));
assert(cr0->flow.wildcards == cr1->flow.wildcards);
assert(cr0->flow.priority == cr1->flow.priority);
/* Skip nw_src_mask, nw_dst_mask, and dl_tci_mask, because they