Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 66270
b: refs/heads/master
c: ab66b4a
h: refs/heads/master
v: v3
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Oct 10, 2007
1 parent ac1e7ea commit 0ba9e58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0680191642c27c81c9be4557d9c6aa3487c15f69
refs/heads/master: ab66b4a7a3969077f6e2a18a0d2d849d3b84a337
18 changes: 11 additions & 7 deletions trunk/net/ipv4/fib_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
#define MAX_STAT_DEPTH 32

#define KEYLENGTH (8*sizeof(t_key))
#define MASK_PFX(k, l) (((l)==0)?0:(k >> (KEYLENGTH-l)) << (KEYLENGTH-l))
#define TKEY_GET_MASK(offset, bits) (((bits)==0)?0:((t_key)(-1) << (KEYLENGTH - bits) >> offset))

typedef unsigned int t_key;

Expand Down Expand Up @@ -195,6 +193,11 @@ static inline int tnode_child_length(const struct tnode *tn)
return 1 << tn->bits;
}

static inline t_key mask_pfx(t_key k, unsigned short l)
{
return (l == 0) ? 0 : k >> (KEYLENGTH-l) << (KEYLENGTH-l);
}

static inline t_key tkey_extract_bits(t_key a, int offset, int bits)
{
if (offset < KEYLENGTH)
Expand Down Expand Up @@ -679,7 +682,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn)
inode->pos == oldtnode->pos + oldtnode->bits &&
inode->bits > 1) {
struct tnode *left, *right;
t_key m = TKEY_GET_MASK(inode->pos, 1);
t_key m = ~0U << (KEYLENGTH - 1) >> inode->pos;

left = tnode_new(inode->key&(~m), inode->pos + 1,
inode->bits - 1);
Expand Down Expand Up @@ -1367,7 +1370,8 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
bits = pn->bits;

if (!chopped_off)
cindex = tkey_extract_bits(MASK_PFX(key, current_prefix_length), pos, bits);
cindex = tkey_extract_bits(mask_pfx(key, current_prefix_length),
pos, bits);

n = tnode_get_child(pn, cindex);

Expand Down Expand Up @@ -1453,8 +1457,8 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
* to find a matching prefix.
*/

node_prefix = MASK_PFX(cn->key, cn->pos);
key_prefix = MASK_PFX(key, cn->pos);
node_prefix = mask_pfx(cn->key, cn->pos);
key_prefix = mask_pfx(key, cn->pos);
pref_mismatch = key_prefix^node_prefix;
mp = 0;

Expand Down Expand Up @@ -2330,7 +2334,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)

if (IS_TNODE(n)) {
struct tnode *tn = (struct tnode *) n;
__be32 prf = htonl(MASK_PFX(tn->key, tn->pos));
__be32 prf = htonl(mask_pfx(tn->key, tn->pos));

seq_indent(seq, iter->depth-1);
seq_printf(seq, " +-- %d.%d.%d.%d/%d %d %d %d\n",
Expand Down

0 comments on commit 0ba9e58

Please sign in to comment.