[ovs-dev] [PATCH v4 6/9] classifier: Do not use mf_value.

Jarno Rajahalme jrajahalme at nicira.com
Fri Aug 7 23:57:39 UTC 2015


mf_value has grown bigger than needed for storing the biggest
supported prefix (IPv6 address length).  Define a new type to be used
instead of mf_value.

This makes classifier lookups a bit faster.

Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
 lib/classifier.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/classifier.c b/lib/classifier.c
index 4adee2d..040d04f 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -138,12 +138,18 @@ next_visible_rule_in_list(const struct cls_match *rule, cls_version_t version)
     return rule;
 }
 
+/* Type with maximum supported prefix length. */
+typedef union {
+    struct in6_addr ipv6;  /* For sizing. */
+    ovs_be32 be32;         /* For access. */
+} trie_prefix_t;
+
 static unsigned int minimask_get_prefix_len(const struct minimask *,
                                             const struct mf_field *);
 static void trie_init(struct classifier *cls, int trie_idx,
                       const struct mf_field *);
 static unsigned int trie_lookup(const struct cls_trie *, const struct flow *,
-                                union mf_value *plens);
+                                trie_prefix_t *plens);
 static unsigned int trie_lookup_value(const rcu_trie_ptr *,
                                       const ovs_be32 value[], ovs_be32 plens[],
                                       unsigned int value_bits);
@@ -913,7 +919,7 @@ struct trie_ctx {
     bool lookup_done;        /* Status of the lookup. */
     uint8_t be32ofs;         /* U32 offset of the field in question. */
     unsigned int maskbits;   /* Prefix length needed to avoid false matches. */
-    union mf_value match_plens; /* Bitmask of prefix lengths with possible
+    trie_prefix_t match_plens;  /* Bitmask of prefix lengths with possible
                                  * matches. */
 };
 
@@ -2181,7 +2187,7 @@ trie_lookup_value(const rcu_trie_ptr *trie, const ovs_be32 value[],
 
 static unsigned int
 trie_lookup(const struct cls_trie *trie, const struct flow *flow,
-            union mf_value *plens)
+            trie_prefix_t *plens)
 {
     const struct mf_field *mf = trie->field;
 
@@ -2314,7 +2320,7 @@ static void
 trie_remove_prefix(rcu_trie_ptr *root, const ovs_be32 *prefix, int mlen)
 {
     struct trie_node *node;
-    rcu_trie_ptr *edges[sizeof(union mf_value) * 8];
+    rcu_trie_ptr *edges[sizeof(trie_prefix_t) * CHAR_BIT];
     int depth = 0, ofs = 0;
 
     /* Walk the tree. */
-- 
2.1.4




More information about the dev mailing list