From: Ben Pfaff Date: Thu, 14 Oct 2010 20:25:36 +0000 (-0700) Subject: classifier: Change classifier_find_rule_exactly() to take a cls_rule *. X-Git-Tag: v1.1.0~949 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=76ecc721793b29c8bae44b10a065ec9ac07a9e4b;p=sliver-openvswitch.git classifier: Change classifier_find_rule_exactly() to take a cls_rule *. There's no benefit to spelling out all of the components of a cls_rule separately. Just use cls_rule itself. --- diff --git a/lib/classifier.c b/lib/classifier.c index 779c7e88c..091e0ca1f 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -266,31 +266,31 @@ classifier_lookup(const struct classifier *cls, const struct flow *flow, struct cls_rule * classifier_find_rule_exactly(const struct classifier *cls, - const struct flow *target, uint32_t wildcards, - unsigned int priority) + const struct cls_rule *target) { struct cls_bucket *bucket; int table_idx; uint32_t hash; - if (!wildcards) { - /* Ignores 'priority'. */ - return search_exact_table(cls, flow_hash(target, 0), target); + if (!target->wc.wildcards) { + /* Ignores 'target->priority'. */ + return search_exact_table(cls, flow_hash(&target->flow, 0), + &target->flow); } - assert(wildcards == (wildcards & OVSFW_ALL)); - table_idx = table_idx_from_wildcards(wildcards); - hash = hash_fields(target, table_idx); + assert(target->wc.wildcards == (target->wc.wildcards & OVSFW_ALL)); + table_idx = table_idx_from_wildcards(target->wc.wildcards); + hash = hash_fields(&target->flow, table_idx); HMAP_FOR_EACH_WITH_HASH (bucket, hmap_node, hash, &cls->tables[table_idx]) { - if (equal_fields(&bucket->fixed, target, table_idx)) { + if (equal_fields(&bucket->fixed, &target->flow, table_idx)) { struct cls_rule *pos; LIST_FOR_EACH (pos, node.list, &bucket->rules) { - if (pos->priority < priority) { + if (pos->priority < target->priority) { return NULL; - } else if (pos->priority == priority && - pos->wc.wildcards == wildcards && - flow_equal(target, &pos->flow)) { + } else if (pos->priority == target->priority && + pos->wc.wildcards == target->wc.wildcards && + flow_equal(&target->flow, &pos->flow)) { return pos; } } diff --git a/lib/classifier.h b/lib/classifier.h index 28be2471a..46df77d7f 100644 --- a/lib/classifier.h +++ b/lib/classifier.h @@ -158,9 +158,7 @@ void classifier_for_each_match(const struct classifier *, const struct cls_rule *, int include, cls_cb_func *, void *aux); struct cls_rule *classifier_find_rule_exactly(const struct classifier *, - const struct flow *target, - uint32_t wildcards, - unsigned int priority); + const struct cls_rule *); #define CLASSIFIER_FOR_EACH_EXACT_RULE(RULE, MEMBER, CLS) \ HMAP_FOR_EACH (RULE, MEMBER.node.hmap, &(CLS)->exact_table) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 727f39605..4d2172e55 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1323,11 +1323,12 @@ void ofproto_delete_flow(struct ofproto *ofproto, const struct flow *flow, uint32_t wildcards, unsigned int priority) { + struct cls_rule target; struct rule *rule; + cls_rule_from_flow(flow, wildcards, priority, &target); rule = rule_from_cls_rule(classifier_find_rule_exactly(&ofproto->cls, - flow, wildcards, - priority)); + &target)); if (rule) { rule_remove(ofproto, rule); } @@ -3652,14 +3653,11 @@ add_flow(struct ofproto *p, struct ofconn *ofconn, static struct rule * find_flow_strict(struct ofproto *p, const struct ofp_flow_mod *ofm) { - uint32_t wildcards; - struct flow flow; + struct cls_rule target; - flow_from_match(&ofm->match, p->tun_id_from_cookie, ofm->cookie, - &flow, &wildcards); - return rule_from_cls_rule(classifier_find_rule_exactly( - &p->cls, &flow, wildcards, - ntohs(ofm->priority))); + cls_rule_from_match(&ofm->match, ntohs(ofm->priority), + p->tun_id_from_cookie, ofm->cookie, &target); + return rule_from_cls_rule(classifier_find_rule_exactly(&p->cls, &target)); } static int @@ -4299,13 +4297,15 @@ ofproto_update_used(struct ofproto *p) for (i = 0; i < n_flows; i++) { struct odp_flow *f = &flows[i]; + struct cls_rule target; struct rule *rule; struct flow flow; odp_flow_key_to_flow(&f->key, &flow); + cls_rule_from_flow(&flow, 0, UINT16_MAX, &target); - rule = rule_from_cls_rule( - classifier_find_rule_exactly(&p->cls, &flow, 0, UINT16_MAX)); + rule = rule_from_cls_rule(classifier_find_rule_exactly(&p->cls, + &target)); if (rule && rule->installed) { update_time(p, rule, &f->stats);