@@ -93,8 +93,6 @@ typedef unsigned int t_key;
93
93
#define IS_LEAF (n ) (!(n)->bits)
94
94
95
95
struct key_vector {
96
- t_key empty_children ; /* KEYLENGTH bits needed */
97
- t_key full_children ; /* KEYLENGTH bits needed */
98
96
struct key_vector __rcu * parent ;
99
97
100
98
t_key key ;
@@ -111,6 +109,8 @@ struct key_vector {
111
109
112
110
struct tnode {
113
111
struct rcu_head rcu ;
112
+ t_key empty_children ; /* KEYLENGTH bits needed */
113
+ t_key full_children ; /* KEYLENGTH bits needed */
114
114
struct key_vector kv [1 ];
115
115
#define tn_bits kv[0].bits
116
116
};
@@ -309,12 +309,12 @@ static struct tnode *tnode_alloc(int bits)
309
309
310
310
static inline void empty_child_inc (struct key_vector * n )
311
311
{
312
- ++ n -> empty_children ? : ++ n -> full_children ;
312
+ ++ tn_info ( n ) -> empty_children ? : ++ tn_info ( n ) -> full_children ;
313
313
}
314
314
315
315
static inline void empty_child_dec (struct key_vector * n )
316
316
{
317
- n -> empty_children -- ? : n -> full_children -- ;
317
+ tn_info ( n ) -> empty_children -- ? : tn_info ( n ) -> full_children -- ;
318
318
}
319
319
320
320
static struct key_vector * leaf_new (t_key key , struct fib_alias * fa )
@@ -354,9 +354,9 @@ static struct key_vector *tnode_new(t_key key, int pos, int bits)
354
354
return NULL ;
355
355
356
356
if (bits == KEYLENGTH )
357
- tn -> full_children = 1 ;
357
+ tnode -> full_children = 1 ;
358
358
else
359
- tn -> empty_children = 1ul << bits ;
359
+ tnode -> empty_children = 1ul << bits ;
360
360
361
361
tn -> key = (shift < KEYLENGTH ) ? (key >> shift ) << shift : 0 ;
362
362
tn -> pos = pos ;
@@ -396,9 +396,9 @@ static void put_child(struct key_vector *tn, unsigned long i,
396
396
isfull = tnode_full (tn , n );
397
397
398
398
if (wasfull && !isfull )
399
- tn -> full_children -- ;
399
+ tn_info ( tn ) -> full_children -- ;
400
400
else if (!wasfull && isfull )
401
- tn -> full_children ++ ;
401
+ tn_info ( tn ) -> full_children ++ ;
402
402
403
403
if (n && (tn -> slen < n -> slen ))
404
404
tn -> slen = n -> slen ;
@@ -768,8 +768,8 @@ static inline bool should_inflate(struct key_vector *tp, struct key_vector *tn)
768
768
769
769
/* Keep root node larger */
770
770
threshold *= tp ? inflate_threshold : inflate_threshold_root ;
771
- used -= tn -> empty_children ;
772
- used += tn -> full_children ;
771
+ used -= tn_info ( tn ) -> empty_children ;
772
+ used += tn_info ( tn ) -> full_children ;
773
773
774
774
/* if bits == KEYLENGTH then pos = 0, and will fail below */
775
775
@@ -783,7 +783,7 @@ static inline bool should_halve(struct key_vector *tp, struct key_vector *tn)
783
783
784
784
/* Keep root node larger */
785
785
threshold *= tp ? halve_threshold : halve_threshold_root ;
786
- used -= tn -> empty_children ;
786
+ used -= tn_info ( tn ) -> empty_children ;
787
787
788
788
/* if bits == KEYLENGTH then used = 100% on wrap, and will fail below */
789
789
@@ -794,10 +794,10 @@ static inline bool should_collapse(struct key_vector *tn)
794
794
{
795
795
unsigned long used = child_length (tn );
796
796
797
- used -= tn -> empty_children ;
797
+ used -= tn_info ( tn ) -> empty_children ;
798
798
799
799
/* account for bits == KEYLENGTH case */
800
- if ((tn -> bits == KEYLENGTH ) && tn -> full_children )
800
+ if ((tn -> bits == KEYLENGTH ) && tn_info ( tn ) -> full_children )
801
801
used -= KEY_MAX ;
802
802
803
803
/* One child or none, time to drop us from the trie */
@@ -1963,7 +1963,7 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s)
1963
1963
s -> tnodes ++ ;
1964
1964
if (n -> bits < MAX_STAT_DEPTH )
1965
1965
s -> nodesizes [n -> bits ]++ ;
1966
- s -> nullpointers += n -> empty_children ;
1966
+ s -> nullpointers += tn_info ( n ) -> empty_children ;
1967
1967
}
1968
1968
}
1969
1969
rcu_read_unlock ();
@@ -2238,7 +2238,8 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2238
2238
seq_indent (seq , iter -> depth - 1 );
2239
2239
seq_printf (seq , " +-- %pI4/%zu %u %u %u\n" ,
2240
2240
& prf , KEYLENGTH - n -> pos - n -> bits , n -> bits ,
2241
- n -> full_children , n -> empty_children );
2241
+ tn_info (n )-> full_children ,
2242
+ tn_info (n )-> empty_children );
2242
2243
} else {
2243
2244
__be32 val = htonl (n -> key );
2244
2245
struct fib_alias * fa ;
0 commit comments