[ovs-dev] [PATCH v2 1/3] classifier: Change type used for priorities from 'unsigned int' to 'int'.

Ben Pfaff blp at nicira.com
Thu Oct 30 22:36:03 UTC 2014


OpenFlow has priorities in the 16-bit unsigned range, from 0 to 65535.
In the classifier, it is sometimes useful to be able to have values below
and above this range.  With the 'unsigned int' type used for priorities
until now, there were no values below the range, so some code worked
around it by converting priorities to 64-bit signed integers.  This didn't
seem so great to me given that a plain 'int' also had the needed range.
This commit therefore changes the type used for priorities to int.

The interesting parts of this change are in pvector.h and classifier.c,
where one can see the elimination of the use of int64_t.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
v1->v2: Switch priority type to 'int', instead of trying to change all the
  "greater than"s to "greater than or equals" and in later patches doing a
  lot of awkward +1s.
---
 lib/classifier-private.h   |    5 ++---
 lib/classifier.c           |   24 ++++++++++--------------
 lib/classifier.h           |    9 ++++-----
 lib/match.c                |   11 +++++------
 lib/match.h                |    9 ++++-----
 lib/ofp-util.h             |    2 +-
 lib/pvector.c              |   12 +++++++-----
 lib/pvector.h              |   14 ++++++++------
 ofproto/in-band.c          |    4 ++--
 ofproto/ofproto-provider.h |    6 ++----
 ofproto/ofproto.c          |   13 ++++++-------
 tests/test-classifier.c    |   29 ++++++++++++++---------------
 utilities/ovs-ofctl.c      |    6 +++---
 13 files changed, 68 insertions(+), 76 deletions(-)

diff --git a/lib/classifier-private.h b/lib/classifier-private.h
index 10d29a5..145efbb 100644
--- a/lib/classifier-private.h
+++ b/lib/classifier-private.h
@@ -33,8 +33,7 @@ struct cls_subtable {
     /* The fields are only used by writers. */
     int n_rules OVS_GUARDED;                /* Number of rules, including
                                              * duplicates. */
-    unsigned int max_priority OVS_GUARDED;  /* Max priority of any rule in
-                                             * the subtable. */
+    int max_priority OVS_GUARDED; /* Max priority of any rule in subtable. */
     unsigned int max_count OVS_GUARDED;     /* Count of max_priority rules. */
 
     /* These fields are accessed by readers who care about wildcarding. */
@@ -72,7 +71,7 @@ struct cls_match {
     struct cls_partition *partition OVS_GUARDED;
 
     /* Accessed by readers interested in wildcarding. */
-    unsigned int priority;      /* Larger numbers are higher priorities. */
+    int priority;               /* Larger numbers are higher priorities. */
     struct cmap_node index_nodes[CLS_MAX_INDICES]; /* Within subtable's
                                                     * 'indices'. */
     /* Accessed by all readers. */
diff --git a/lib/classifier.c b/lib/classifier.c
index 9f306b9..dab43ec 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -114,11 +114,10 @@ static bool mask_prefix_bits_set(const struct flow_wildcards *,
  *
  * The caller must eventually destroy 'rule' with cls_rule_destroy().
  *
- * (OpenFlow uses priorities between 0 and UINT16_MAX, inclusive, but
- * internally Open vSwitch supports a wider range.) */
+ * Clients should not use priority INT_MIN.  (OpenFlow uses priorities between
+ * 0 and UINT16_MAX, inclusive.) */
 void
-cls_rule_init(struct cls_rule *rule,
-              const struct match *match, unsigned int priority)
+cls_rule_init(struct cls_rule *rule, const struct match *match, int priority)
 {
     minimatch_init(&rule->match, match);
     rule->priority = priority;
@@ -128,8 +127,7 @@ cls_rule_init(struct cls_rule *rule,
 /* Same as cls_rule_init() for initialization from a "struct minimatch". */
 void
 cls_rule_init_from_minimatch(struct cls_rule *rule,
-                             const struct minimatch *match,
-                             unsigned int priority)
+                             const struct minimatch *match, int priority)
 {
     minimatch_clone(&rule->match, match);
     rule->priority = priority;
@@ -607,7 +605,7 @@ classifier_remove(struct classifier *cls, struct cls_rule *rule)
                && --subtable->max_count == 0) {
         /* Find the new 'max_priority' and 'max_count'. */
         struct cls_match *head;
-        unsigned int max_priority = 0;
+        int max_priority = INT_MIN;
 
         CMAP_FOR_EACH (head, cmap_node, &subtable->rules) {
             if (head->priority > max_priority) {
@@ -668,7 +666,7 @@ classifier_lookup(const struct classifier *cls, const struct flow *flow,
 {
     const struct cls_partition *partition;
     tag_type tags;
-    int64_t best_priority = -1;
+    int best_priority = INT_MIN;
     const struct cls_match *best;
     struct trie_ctx trie_ctx[CLS_MAX_TRIES];
     struct cls_subtable *subtable;
@@ -717,8 +715,8 @@ classifier_lookup(const struct classifier *cls, const struct flow *flow,
         }
 
         rule = find_match_wc(subtable, flow, trie_ctx, cls->n_tries, wc);
-        if (rule && (int64_t)rule->priority > best_priority) {
-            best_priority = (int64_t)rule->priority;
+        if (rule && rule->priority > best_priority) {
+            best_priority = rule->priority;
             best = rule;
         }
     }
@@ -767,8 +765,7 @@ out:
  * contain an exact match. */
 struct cls_rule *
 classifier_find_match_exactly(const struct classifier *cls,
-                              const struct match *target,
-                              unsigned int priority)
+                              const struct match *target, int priority)
 {
     struct cls_rule *retval;
     struct cls_rule cr;
@@ -789,11 +786,10 @@ classifier_rule_overlaps(const struct classifier *cls,
     OVS_EXCLUDED(cls->mutex)
 {
     struct cls_subtable *subtable;
-    int64_t stop_at_priority = (int64_t)target->priority - 1;
 
     ovs_mutex_lock(&cls->mutex);
     /* Iterate subtables in the descending max priority order. */
-    PVECTOR_FOR_EACH_PRIORITY (subtable, stop_at_priority, 2,
+    PVECTOR_FOR_EACH_PRIORITY (subtable, target->priority - 1, 2,
                                sizeof(struct cls_subtable), &cls->subtables) {
         uint32_t storage[FLOW_U32S];
         struct minimask mask;
diff --git a/lib/classifier.h b/lib/classifier.h
index c910ac4..92be5bf 100644
--- a/lib/classifier.h
+++ b/lib/classifier.h
@@ -258,14 +258,13 @@ struct classifier {
 /* A rule to be inserted to the classifier. */
 struct cls_rule {
     struct minimatch match;      /* Matching rule. */
-    unsigned int priority;       /* Larger numbers are higher priorities. */
+    int priority;                /* Larger numbers are higher priorities. */
     struct cls_match *cls_match; /* NULL if rule is not in a classifier. */
 };
 
-void cls_rule_init(struct cls_rule *, const struct match *,
-                   unsigned int priority);
+void cls_rule_init(struct cls_rule *, const struct match *, int priority);
 void cls_rule_init_from_minimatch(struct cls_rule *, const struct minimatch *,
-                                  unsigned int priority);
+                                  int priority);
 void cls_rule_clone(struct cls_rule *, const struct cls_rule *);
 void cls_rule_move(struct cls_rule *dst, struct cls_rule *src);
 void cls_rule_destroy(struct cls_rule *);
@@ -303,7 +302,7 @@ struct cls_rule *classifier_find_rule_exactly(const struct classifier *,
 
 struct cls_rule *classifier_find_match_exactly(const struct classifier *,
                                                const struct match *,
-                                               unsigned int priority);
+                                               int priority);
 
 /* Iteration. */
 
diff --git a/lib/match.c b/lib/match.c
index 1a28396..9a84546 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -853,7 +853,7 @@ format_flow_tunnel(struct ds *s, const struct match *match)
 /* Appends a string representation of 'match' to 's'.  If 'priority' is
  * different from OFP_DEFAULT_PRIORITY, includes it in 's'. */
 void
-match_format(const struct match *match, struct ds *s, unsigned int priority)
+match_format(const struct match *match, struct ds *s, int priority)
 {
     const struct flow_wildcards *wc = &match->wc;
     size_t start_len = s->length;
@@ -866,7 +866,7 @@ match_format(const struct match *match, struct ds *s, unsigned int priority)
     BUILD_ASSERT_DECL(FLOW_WC_SEQ == 27);
 
     if (priority != OFP_DEFAULT_PRIORITY) {
-        ds_put_format(s, "priority=%u,", priority);
+        ds_put_format(s, "priority=%d,", priority);
     }
 
     format_uint32_masked(s, "pkt_mark", f->pkt_mark, wc->masks.pkt_mark);
@@ -1110,7 +1110,7 @@ match_format(const struct match *match, struct ds *s, unsigned int priority)
  * different from OFP_DEFAULT_PRIORITY, includes it in the string.  The caller
  * must free the string (with free()). */
 char *
-match_to_string(const struct match *match, unsigned int priority)
+match_to_string(const struct match *match, int priority)
 {
     struct ds s = DS_EMPTY_INITIALIZER;
     match_format(match, &s, priority);
@@ -1204,8 +1204,7 @@ minimatch_matches_flow(const struct minimatch *match,
 /* Appends a string representation of 'match' to 's'.  If 'priority' is
  * different from OFP_DEFAULT_PRIORITY, includes it in 's'. */
 void
-minimatch_format(const struct minimatch *match, struct ds *s,
-                 unsigned int priority)
+minimatch_format(const struct minimatch *match, struct ds *s, int priority)
 {
     struct match megamatch;
 
@@ -1217,7 +1216,7 @@ minimatch_format(const struct minimatch *match, struct ds *s,
  * different from OFP_DEFAULT_PRIORITY, includes it in the string.  The caller
  * must free the string (with free()). */
 char *
-minimatch_to_string(const struct minimatch *match, unsigned int priority)
+minimatch_to_string(const struct minimatch *match, int priority)
 {
     struct match megamatch;
 
diff --git a/lib/match.h b/lib/match.h
index af08fc0..7469eaa 100644
--- a/lib/match.h
+++ b/lib/match.h
@@ -141,8 +141,8 @@ uint32_t match_hash(const struct match *, uint32_t basis);
 void match_init_hidden_fields(struct match *);
 bool match_has_default_hidden_fields(const struct match *);
 
-void match_format(const struct match *, struct ds *, unsigned int priority);
-char *match_to_string(const struct match *, unsigned int priority);
+void match_format(const struct match *, struct ds *, int priority);
+char *match_to_string(const struct match *, int priority);
 void match_print(const struct match *);
 
 /* Compressed match. */
@@ -174,8 +174,7 @@ bool minimatch_equal(const struct minimatch *a, const struct minimatch *b);
 
 bool minimatch_matches_flow(const struct minimatch *, const struct flow *);
 
-void minimatch_format(const struct minimatch *, struct ds *,
-                      unsigned int priority);
-char *minimatch_to_string(const struct minimatch *, unsigned int priority);
+void minimatch_format(const struct minimatch *, struct ds *, int priority);
+char *minimatch_to_string(const struct minimatch *, int priority);
 
 #endif /* match.h */
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index af1a2a3..c9900d8 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -271,7 +271,7 @@ struct ofputil_flow_mod {
     struct list list_node;    /* For queuing flow_mods. */
 
     struct match match;
-    unsigned int priority;
+    int priority;
 
     /* Cookie matching.  The flow_mod affects only flows that have cookies that
      * bitwise match 'cookie' bits in positions where 'cookie_mask has 1-bits.
diff --git a/lib/pvector.c b/lib/pvector.c
index e6cb664..3f2e9e8 100644
--- a/lib/pvector.c
+++ b/lib/pvector.c
@@ -69,8 +69,10 @@ pvector_destroy(struct pvector *pvec)
 static int
 pvector_entry_cmp(const void *a_, const void *b_)
 {
-    unsigned int a = ((const struct pvector_entry *)a_)->priority;
-    unsigned int b = ((const struct pvector_entry *)b_)->priority;
+    const struct pvector_entry *ap = a_;
+    const struct pvector_entry *bp = b_;
+    int a = ap->priority;
+    int b = bp->priority;
 
     return a > b ? -1 : a < b;
 }
@@ -85,7 +87,7 @@ pvector_impl_sort(struct pvector_impl *impl)
  * which will be one past the vector if none exists. */
 static int
 pvector_impl_find_priority(struct pvector_impl *impl,
-                           unsigned int target_priority)
+                           int target_priority)
 {
     const struct pvector_entry *entry;
     int index;
@@ -114,7 +116,7 @@ pvector_impl_find(struct pvector_impl *impl, void *target)
 }
 
 void
-pvector_insert(struct pvector *pvec, void *ptr, unsigned int priority)
+pvector_insert(struct pvector *pvec, void *ptr, int priority)
 {
     struct pvector_impl *old, *new;
     int index;
@@ -182,7 +184,7 @@ pvector_remove(struct pvector *pvec, void *ptr)
 
 /* Change entry's 'priority' and keep the vector ordered. */
 void
-pvector_change_priority(struct pvector *pvec, void *ptr, unsigned int priority)
+pvector_change_priority(struct pvector *pvec, void *ptr, int priority)
 {
     struct pvector_impl *old = pvector_impl_get(pvec);
     int index = pvector_impl_find(old, ptr);
diff --git a/lib/pvector.h b/lib/pvector.h
index 61d71b9..40c8e93 100644
--- a/lib/pvector.h
+++ b/lib/pvector.h
@@ -46,10 +46,12 @@
  * 'size', or update the 'priority' value of an entry, but only if that does
  * not change the ordering of the entries.  Writers will never change the 'ptr'
  * values, or decrement the 'size' on a copy that readers have access to.
+ *
+ * Clients should not use priority INT_MIN.
  */
 
 struct pvector_entry {
-    unsigned int priority;
+    int priority;
     void *ptr;
 };
 
@@ -77,8 +79,8 @@ static inline size_t pvector_count(const struct pvector *);
 static inline bool pvector_is_empty(const struct pvector *);
 
 /* Insertion and deletion. */
-void pvector_insert(struct pvector *, void *, unsigned int);
-void pvector_change_priority(struct pvector *, void *, unsigned int);
+void pvector_insert(struct pvector *, void *, int priority);
+void pvector_change_priority(struct pvector *, void *, int priority);
 void pvector_remove(struct pvector *, void *);
 
 /* Iteration.
@@ -135,14 +137,14 @@ static inline struct pvector_cursor pvector_cursor_init(const struct pvector *,
                                                         size_t n_ahead,
                                                         size_t obj_size);
 static inline void *pvector_cursor_next(struct pvector_cursor *,
-                                        int64_t stop_at_priority,
+                                        int stop_at_priority,
                                         size_t n_ahead, size_t obj_size);
 static inline void pvector_cursor_lookahead(const struct pvector_cursor *,
                                             int n, size_t size);
 
 #define PVECTOR_FOR_EACH(PTR, PVECTOR)                                  \
     for (struct pvector_cursor cursor__ = pvector_cursor_init(PVECTOR, 0, 0); \
-         ((PTR) = pvector_cursor_next(&cursor__, -1, 0, 0)) != NULL; )
+         ((PTR) = pvector_cursor_next(&cursor__, INT_MIN, 0, 0)) != NULL; )
 
 /* Loop while priority is higher than 'PRIORITY' and prefetch objects
  * of size 'SZ' 'N' objects ahead from the current object. */
@@ -176,7 +178,7 @@ pvector_cursor_init(const struct pvector *pvec,
 }
 
 static inline void *pvector_cursor_next(struct pvector_cursor *cursor,
-                                        int64_t stop_at_priority,
+                                        int stop_at_priority,
                                         size_t n_ahead, size_t obj_size)
 {
     if (++cursor->entry_idx < cursor->size &&
diff --git a/ofproto/in-band.c b/ofproto/in-band.c
index cbe0d1c..e25a27a 100644
--- a/ofproto/in-band.c
+++ b/ofproto/in-band.c
@@ -83,7 +83,7 @@ enum in_band_op {
 struct in_band_rule {
     struct hmap_node hmap_node; /* In struct in_band's "rules" hmap. */
     struct match match;
-    unsigned int priority;
+    int priority;
     enum in_band_op op;
 };
 
@@ -236,7 +236,7 @@ in_band_must_output_to_local_port(const struct flow *flow)
 }
 
 static void
-add_rule(struct in_band *ib, const struct match *match, unsigned int priority)
+add_rule(struct in_band *ib, const struct match *match, int priority)
 {
     uint32_t hash = match_hash(match, 0);
     struct in_band_rule *rule;
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index 158f86e..14f1cba 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1668,12 +1668,10 @@ int ofproto_class_unregister(const struct ofproto_class *);
 
 int ofproto_flow_mod(struct ofproto *, struct ofputil_flow_mod *)
     OVS_EXCLUDED(ofproto_mutex);
-void ofproto_add_flow(struct ofproto *, const struct match *,
-                      unsigned int priority,
+void ofproto_add_flow(struct ofproto *, const struct match *, int priority,
                       const struct ofpact *ofpacts, size_t ofpacts_len)
     OVS_EXCLUDED(ofproto_mutex);
-void ofproto_delete_flow(struct ofproto *,
-                         const struct match *, unsigned int priority)
+void ofproto_delete_flow(struct ofproto *, const struct match *, int priority)
     OVS_EXCLUDED(ofproto_mutex);
 void ofproto_flush_flows(struct ofproto *);
 
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index b8f0e62..1233164 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -153,8 +153,7 @@ struct rule_criteria {
 };
 
 static void rule_criteria_init(struct rule_criteria *, uint8_t table_id,
-                               const struct match *match,
-                               unsigned int priority,
+                               const struct match *match, int priority,
                                ovs_be64 cookie, ovs_be64 cookie_mask,
                                ofp_port_t out_port, uint32_t out_group);
 static void rule_criteria_require_rw(struct rule_criteria *,
@@ -1882,7 +1881,7 @@ ofproto_port_del(struct ofproto *ofproto, ofp_port_t ofp_port)
 
 static void
 flow_mod_init(struct ofputil_flow_mod *fm,
-              const struct match *match, unsigned int priority,
+              const struct match *match, int priority,
               const struct ofpact *ofpacts, size_t ofpacts_len,
               enum ofp_flow_mod_command command)
 {
@@ -1907,7 +1906,7 @@ flow_mod_init(struct ofputil_flow_mod *fm,
 
 static int
 simple_flow_mod(struct ofproto *ofproto,
-                const struct match *match, unsigned int priority,
+                const struct match *match, int priority,
                 const struct ofpact *ofpacts, size_t ofpacts_len,
                 enum ofp_flow_mod_command command)
 {
@@ -1931,7 +1930,7 @@ simple_flow_mod(struct ofproto *ofproto,
  * This is a helper function for in-band control and fail-open. */
 void
 ofproto_add_flow(struct ofproto *ofproto, const struct match *match,
-                 unsigned int priority,
+                 int priority,
                  const struct ofpact *ofpacts, size_t ofpacts_len)
     OVS_EXCLUDED(ofproto_mutex)
 {
@@ -2018,7 +2017,7 @@ ofproto_flow_mod(struct ofproto *ofproto, struct ofputil_flow_mod *fm)
  * This is a helper function for in-band control and fail-open. */
 void
 ofproto_delete_flow(struct ofproto *ofproto,
-                    const struct match *target, unsigned int priority)
+                    const struct match *target, int priority)
     OVS_EXCLUDED(ofproto_mutex)
 {
     struct classifier *cls = &ofproto->tables[0].cls;
@@ -3510,7 +3509,7 @@ next_matching_table(const struct ofproto *ofproto,
  * supplied as 0. */
 static void
 rule_criteria_init(struct rule_criteria *criteria, uint8_t table_id,
-                   const struct match *match, unsigned int priority,
+                   const struct match *match, int priority,
                    ovs_be64 cookie, ovs_be64 cookie_mask,
                    ofp_port_t out_port, uint32_t out_group)
 {
diff --git a/tests/test-classifier.c b/tests/test-classifier.c
index 85adb0d..9a58a18 100644
--- a/tests/test-classifier.c
+++ b/tests/test-classifier.c
@@ -107,8 +107,7 @@ test_rule_destroy(struct test_rule *rule)
     }
 }
 
-static struct test_rule *make_rule(int wc_fields, unsigned int priority,
-                                   int value_pat);
+static struct test_rule *make_rule(int wc_fields, int priority, int value_pat);
 static void free_rule(struct test_rule *);
 static struct test_rule *clone_rule(const struct test_rule *);
 
@@ -466,10 +465,10 @@ static void
 pvector_verify(const struct pvector *pvec)
 {
     void *ptr OVS_UNUSED;
-    unsigned int priority, prev_priority = UINT_MAX;
+    int prev_priority = INT_MAX;
 
     PVECTOR_FOR_EACH (ptr, pvec) {
-        priority = cursor__.vector[cursor__.entry_idx].priority;
+        int priority = cursor__.vector[cursor__.entry_idx].priority;
         if (priority > prev_priority) {
             ovs_abort(0, "Priority vector is out of order (%u > %u)",
                       priority, prev_priority);
@@ -524,7 +523,7 @@ check_tables(const struct classifier *cls, int n_tables, int n_rules,
     pvector_verify(&cls->subtables);
     CMAP_FOR_EACH (table, cmap_node, &cls->subtables_map) {
         const struct cls_match *head;
-        unsigned int max_priority = 0;
+        int max_priority = INT_MIN;
         unsigned int max_count = 0;
         bool found = false;
         const struct cls_subtable *iter;
@@ -552,7 +551,7 @@ check_tables(const struct classifier *cls, int n_tables, int n_rules,
 
         found_tables++;
         CMAP_FOR_EACH (head, cmap_node, &table->rules) {
-            unsigned int prev_priority = UINT_MAX;
+            int prev_priority = INT_MAX;
             const struct cls_match *rule;
 
             if (head->priority > max_priority) {
@@ -597,7 +596,7 @@ check_tables(const struct classifier *cls, int n_tables, int n_rules,
 }
 
 static struct test_rule *
-make_rule(int wc_fields, unsigned int priority, int value_pat)
+make_rule(int wc_fields, int priority, int value_pat)
 {
     const struct cls_field *f;
     struct test_rule *rule;
@@ -642,7 +641,7 @@ make_rule(int wc_fields, unsigned int priority, int value_pat)
     }
 
     rule = xzalloc(sizeof *rule);
-    cls_rule_init(&rule->cls_rule, &match, wc_fields ? priority : UINT_MAX);
+    cls_rule_init(&rule->cls_rule, &match, wc_fields ? priority : INT_MAX);
     return rule;
 }
 
@@ -665,11 +664,11 @@ free_rule(struct test_rule *rule)
 }
 
 static void
-shuffle(unsigned int *p, size_t n)
+shuffle(int *p, size_t n)
 {
     for (; n > 1; n--, p++) {
-        unsigned int *q = &p[random_range(n)];
-        unsigned int tmp = *p;
+        int *q = &p[random_range(n)];
+        int tmp = *p;
         *p = *q;
         *q = tmp;
     }
@@ -996,7 +995,7 @@ test_many_rules_in_one_table(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         tcls_init(&tcls);
 
         for (i = 0; i < N_RULES; i++) {
-            unsigned int priority = random_uint32();
+            int priority = random_range(INT_MAX);
 
             do {
                 value_pats[i] = random_uint32() & value_mask;
@@ -1043,13 +1042,13 @@ test_many_rules_in_n_tables(int n_tables)
     }
 
     for (iteration = 0; iteration < 30; iteration++) {
-        unsigned int priorities[MAX_RULES];
+        int priorities[MAX_RULES];
         struct classifier cls;
         struct tcls tcls;
 
         random_set_seed(iteration + 1);
         for (i = 0; i < MAX_RULES; i++) {
-            priorities[i] = i * 129;
+            priorities[i] = (i * 129) & INT_MAX;
         }
         shuffle(priorities, ARRAY_SIZE(priorities));
 
@@ -1059,7 +1058,7 @@ test_many_rules_in_n_tables(int n_tables)
 
         for (i = 0; i < MAX_RULES; i++) {
             struct test_rule *rule;
-            unsigned int priority = priorities[i];
+            int priority = priorities[i];
             int wcf = wcfs[random_range(n_tables)];
             int value_pat = random_uint32() & ((1u << CLS_N_FIELDS) - 1);
             rule = make_rule(wcf, priority, value_pat);
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index b6b775f..f0ea15f 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -989,8 +989,8 @@ compare_flows(const void *afs_, const void *bfs_)
         int ret;
 
         if (!f) {
-            unsigned int a_pri = afs->priority;
-            unsigned int b_pri = bfs->priority;
+            int a_pri = afs->priority;
+            int b_pri = bfs->priority;
             ret = a_pri < b_pri ? -1 : a_pri > b_pri;
         } else {
             bool ina, inb;
@@ -2355,7 +2355,7 @@ fte_free_all(struct classifier *cls)
  * Takes ownership of 'version'. */
 static void
 fte_insert(struct classifier *cls, const struct match *match,
-           unsigned int priority, struct fte_version *version, int index)
+           int priority, struct fte_version *version, int index)
 {
     struct fte *old, *fte;
 
-- 
1.7.10.4




More information about the dev mailing list