mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 14:55:18 +00:00
lib/classifier: Clarify trie_lookup_value().
trie_lookup_value() is easier to read with the local variable 'plen' renamed as 'ofs'. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -2137,26 +2137,26 @@ static unsigned int
|
|||||||
trie_lookup_value(const struct trie_node *node, const ovs_be32 value[],
|
trie_lookup_value(const struct trie_node *node, const ovs_be32 value[],
|
||||||
unsigned int *checkbits)
|
unsigned int *checkbits)
|
||||||
{
|
{
|
||||||
unsigned int plen = 0, match_len = 0;
|
unsigned int ofs = 0, match_len = 0;
|
||||||
const struct trie_node *prev = NULL;
|
const struct trie_node *prev = NULL;
|
||||||
|
|
||||||
for (; node; prev = node, node = trie_next_node(node, value, plen)) {
|
for (; node; prev = node, node = trie_next_node(node, value, ofs)) {
|
||||||
unsigned int eqbits;
|
unsigned int eqbits;
|
||||||
/* Check if this edge can be followed. */
|
/* Check if this edge can be followed. */
|
||||||
eqbits = prefix_equal_bits(node->prefix, node->nbits, value, plen);
|
eqbits = prefix_equal_bits(node->prefix, node->nbits, value, ofs);
|
||||||
plen += eqbits;
|
ofs += eqbits;
|
||||||
if (eqbits < node->nbits) { /* Mismatch, nothing more to be found. */
|
if (eqbits < node->nbits) { /* Mismatch, nothing more to be found. */
|
||||||
/* Bit at offset 'plen' differed. */
|
/* Bit at offset 'ofs' differed. */
|
||||||
*checkbits = plen + 1; /* Includes the first mismatching bit. */
|
*checkbits = ofs + 1; /* Includes the first mismatching bit. */
|
||||||
return match_len;
|
return match_len;
|
||||||
}
|
}
|
||||||
/* Full match, check if rules exist at this prefix length. */
|
/* Full match, check if rules exist at this prefix length. */
|
||||||
if (node->n_rules > 0) {
|
if (node->n_rules > 0) {
|
||||||
match_len = plen;
|
match_len = ofs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Dead end, exclude the other branch if it exists. */
|
/* Dead end, exclude the other branch if it exists. */
|
||||||
*checkbits = !prev || trie_is_leaf(prev) ? plen : plen + 1;
|
*checkbits = !prev || trie_is_leaf(prev) ? ofs : ofs + 1;
|
||||||
return match_len;
|
return match_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user