[ovs-dev] [generic tci mask 3/8] flow: New function flow_wildcards_is_exact().
Justin Pettit
jpettit at nicira.com
Fri Nov 19 22:33:36 UTC 2010
Looks good.
--Justin
On Nov 10, 2010, at 3:37 PM, Ben Pfaff wrote:
> ---
> lib/classifier.c | 2 +-
> lib/flow.c | 8 ++++++++
> lib/flow.h | 2 ++
> tests/test-classifier.c | 3 ++-
> 4 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/lib/classifier.c b/lib/classifier.c
> index 4bf354e..811283f 100644
> --- a/lib/classifier.c
> +++ b/lib/classifier.c
> @@ -478,7 +478,7 @@ classifier_find_rule_exactly(const struct classifier *cls,
> }
>
> head = find_equal(table, &target->flow, flow_hash(&target->flow, 0));
> - if (!target->wc.wildcards) {
> + if (flow_wildcards_is_exact(&target->wc)) {
> return head;
> }
> FOR_EACH_RULE_IN_LIST (rule, head) {
> diff --git a/lib/flow.c b/lib/flow.c
> index b562389..082a1df 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -417,6 +417,14 @@ flow_wildcards_init_exact(struct flow_wildcards *wc)
> memset(wc->reg_masks, 0xff, sizeof wc->reg_masks);
> }
>
> +/* Returns true if 'wc' is exact-match, false if 'wc' wildcards any bits or
> + * fields. */
> +bool
> +flow_wildcards_is_exact(const struct flow_wildcards *wc)
> +{
> + return !wc->wildcards;
> +}
> +
> static inline uint32_t
> combine_nw_bits(uint32_t wb1, uint32_t wb2, int shift)
> {
> diff --git a/lib/flow.h b/lib/flow.h
> index f17c98c..1099f9f 100644
> --- a/lib/flow.h
> +++ b/lib/flow.h
> @@ -148,6 +148,8 @@ ovs_be32 flow_nw_bits_to_mask(uint32_t wildcards, int shift);
> void flow_wildcards_init(struct flow_wildcards *, uint32_t wildcards);
> void flow_wildcards_init_exact(struct flow_wildcards *);
>
> +bool flow_wildcards_is_exact(const struct flow_wildcards *);
> +
> bool flow_wildcards_set_nw_src_mask(struct flow_wildcards *, ovs_be32);
> bool flow_wildcards_set_nw_dst_mask(struct flow_wildcards *, ovs_be32);
> void flow_wildcards_set_reg_mask(struct flow_wildcards *,
> diff --git a/tests/test-classifier.c b/tests/test-classifier.c
> index 581b6ef..3049810 100644
> --- a/tests/test-classifier.c
> +++ b/tests/test-classifier.c
> @@ -136,7 +136,8 @@ tcls_insert(struct tcls *tcls, const struct test_rule *rule)
> {
> size_t i;
>
> - assert(rule->cls_rule.wc.wildcards || rule->cls_rule.priority == UINT_MAX);
> + assert(!flow_wildcards_is_exact(&rule->cls_rule.wc)
> + || rule->cls_rule.priority == UINT_MAX);
> for (i = 0; i < tcls->n_rules; i++) {
> const struct cls_rule *pos = &tcls->rules[i]->cls_rule;
> if (cls_rule_equal(pos, &rule->cls_rule)) {
> --
> 1.7.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
More information about the dev
mailing list