projects
/
cascardo
/
ovs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/classifier: Fix use of uninitialized memory.
[cascardo/ovs.git]
/
lib
/
classifier.c
diff --git
a/lib/classifier.c
b/lib/classifier.c
index
140d9e3
..
d8aa88e
100644
(file)
--- a/
lib/classifier.c
+++ b/
lib/classifier.c
@@
-173,6
+173,7
@@
static unsigned int trie_lookup(const struct cls_trie *, const struct flow *,
unsigned int *checkbits);
static unsigned int trie_lookup_value(const struct trie_node *,
const ovs_be32 value[],
unsigned int *checkbits);
static unsigned int trie_lookup_value(const struct trie_node *,
const ovs_be32 value[],
+ unsigned int value_bits,
unsigned int *checkbits);
static void trie_destroy(struct trie_node *);
static void trie_insert(struct cls_trie *, const struct cls_rule *, int mlen);
unsigned int *checkbits);
static void trie_destroy(struct trie_node *);
static void trie_insert(struct cls_trie *, const struct cls_rule *, int mlen);
@@
-1825,7
+1826,7
@@
find_match_wc(const struct cls_subtable *subtable, const struct flow *flow,
mask = MINIFLOW_GET_BE32(&subtable->mask.masks, tp_src);
value = ((OVS_FORCE ovs_be32 *)flow)[TP_PORTS_OFS32] & mask;
mask = MINIFLOW_GET_BE32(&subtable->mask.masks, tp_src);
value = ((OVS_FORCE ovs_be32 *)flow)[TP_PORTS_OFS32] & mask;
- trie_lookup_value(subtable->ports_trie, &value, &mbits);
+ trie_lookup_value(subtable->ports_trie, &value,
32,
&mbits);
((OVS_FORCE ovs_be32 *)&wc->masks)[TP_PORTS_OFS32] |=
mask & htonl(~0 << (32 - mbits));
((OVS_FORCE ovs_be32 *)&wc->masks)[TP_PORTS_OFS32] |=
mask & htonl(~0 << (32 - mbits));
@@
-2132,7
+2133,7
@@
trie_next_node(const struct trie_node *node, const ovs_be32 value[],
*/
static unsigned int
trie_lookup_value(const struct trie_node *node, const ovs_be32 value[],
*/
static unsigned int
trie_lookup_value(const struct trie_node *node, const ovs_be32 value[],
- unsigned int *checkbits)
+ unsigned int
n_bits, unsigned int
*checkbits)
{
unsigned int ofs = 0, match_len = 0;
const struct trie_node *prev = NULL;
{
unsigned int ofs = 0, match_len = 0;
const struct trie_node *prev = NULL;
@@
-2151,8
+2152,13
@@
trie_lookup_value(const struct trie_node *node, const ovs_be32 value[],
if (node->n_rules > 0) {
match_len = ofs;
}
if (node->n_rules > 0) {
match_len = ofs;
}
+ if (ofs >= n_bits) {
+ *checkbits = n_bits; /* Full prefix. */
+ return match_len;
+ }
}
}
- /* Dead end, exclude the other branch if it exists. */
+ /* node == NULL. Full match so far, but we came to a dead end.
+ * need to exclude the other branch if it exists. */
*checkbits = !prev || trie_is_leaf(prev) ? ofs : ofs + 1;
return match_len;
}
*checkbits = !prev || trie_is_leaf(prev) ? ofs : ofs + 1;
return match_len;
}
@@
-2169,7
+2175,7
@@
trie_lookup(const struct cls_trie *trie, const struct flow *flow,
if (mf_are_prereqs_ok(mf, flow)) {
return trie_lookup_value(trie->root,
&((ovs_be32 *)flow)[mf->flow_be32ofs],
if (mf_are_prereqs_ok(mf, flow)) {
return trie_lookup_value(trie->root,
&((ovs_be32 *)flow)[mf->flow_be32ofs],
- checkbits);
+
mf->n_bits,
checkbits);
}
*checkbits = 0; /* Value not used in this case. */
return UINT_MAX;
}
*checkbits = 0; /* Value not used in this case. */
return UINT_MAX;