diff options
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r-- | net/ipv4/fib_trie.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 61e03da3e1f5..ff06b7543d9f 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -920,10 +920,9 @@ nomem: | |||
920 | static struct leaf_info *find_leaf_info(struct leaf *l, int plen) | 920 | static struct leaf_info *find_leaf_info(struct leaf *l, int plen) |
921 | { | 921 | { |
922 | struct hlist_head *head = &l->list; | 922 | struct hlist_head *head = &l->list; |
923 | struct hlist_node *node; | ||
924 | struct leaf_info *li; | 923 | struct leaf_info *li; |
925 | 924 | ||
926 | hlist_for_each_entry_rcu(li, node, head, hlist) | 925 | hlist_for_each_entry_rcu(li, head, hlist) |
927 | if (li->plen == plen) | 926 | if (li->plen == plen) |
928 | return li; | 927 | return li; |
929 | 928 | ||
@@ -943,12 +942,11 @@ static inline struct list_head *get_fa_head(struct leaf *l, int plen) | |||
943 | static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new) | 942 | static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new) |
944 | { | 943 | { |
945 | struct leaf_info *li = NULL, *last = NULL; | 944 | struct leaf_info *li = NULL, *last = NULL; |
946 | struct hlist_node *node; | ||
947 | 945 | ||
948 | if (hlist_empty(head)) { | 946 | if (hlist_empty(head)) { |
949 | hlist_add_head_rcu(&new->hlist, head); | 947 | hlist_add_head_rcu(&new->hlist, head); |
950 | } else { | 948 | } else { |
951 | hlist_for_each_entry(li, node, head, hlist) { | 949 | hlist_for_each_entry(li, head, hlist) { |
952 | if (new->plen > li->plen) | 950 | if (new->plen > li->plen) |
953 | break; | 951 | break; |
954 | 952 | ||
@@ -1354,9 +1352,8 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l, | |||
1354 | { | 1352 | { |
1355 | struct leaf_info *li; | 1353 | struct leaf_info *li; |
1356 | struct hlist_head *hhead = &l->list; | 1354 | struct hlist_head *hhead = &l->list; |
1357 | struct hlist_node *node; | ||
1358 | 1355 | ||
1359 | hlist_for_each_entry_rcu(li, node, hhead, hlist) { | 1356 | hlist_for_each_entry_rcu(li, hhead, hlist) { |
1360 | struct fib_alias *fa; | 1357 | struct fib_alias *fa; |
1361 | 1358 | ||
1362 | if (l->key != (key & li->mask_plen)) | 1359 | if (l->key != (key & li->mask_plen)) |
@@ -1740,10 +1737,10 @@ static int trie_flush_leaf(struct leaf *l) | |||
1740 | { | 1737 | { |
1741 | int found = 0; | 1738 | int found = 0; |
1742 | struct hlist_head *lih = &l->list; | 1739 | struct hlist_head *lih = &l->list; |
1743 | struct hlist_node *node, *tmp; | 1740 | struct hlist_node *tmp; |
1744 | struct leaf_info *li = NULL; | 1741 | struct leaf_info *li = NULL; |
1745 | 1742 | ||
1746 | hlist_for_each_entry_safe(li, node, tmp, lih, hlist) { | 1743 | hlist_for_each_entry_safe(li, tmp, lih, hlist) { |
1747 | found += trie_flush_list(&li->falh); | 1744 | found += trie_flush_list(&li->falh); |
1748 | 1745 | ||
1749 | if (list_empty(&li->falh)) { | 1746 | if (list_empty(&li->falh)) { |
@@ -1895,14 +1892,13 @@ static int fn_trie_dump_leaf(struct leaf *l, struct fib_table *tb, | |||
1895 | struct sk_buff *skb, struct netlink_callback *cb) | 1892 | struct sk_buff *skb, struct netlink_callback *cb) |
1896 | { | 1893 | { |
1897 | struct leaf_info *li; | 1894 | struct leaf_info *li; |
1898 | struct hlist_node *node; | ||
1899 | int i, s_i; | 1895 | int i, s_i; |
1900 | 1896 | ||
1901 | s_i = cb->args[4]; | 1897 | s_i = cb->args[4]; |
1902 | i = 0; | 1898 | i = 0; |
1903 | 1899 | ||
1904 | /* rcu_read_lock is hold by caller */ | 1900 | /* rcu_read_lock is hold by caller */ |
1905 | hlist_for_each_entry_rcu(li, node, &l->list, hlist) { | 1901 | hlist_for_each_entry_rcu(li, &l->list, hlist) { |
1906 | if (i < s_i) { | 1902 | if (i < s_i) { |
1907 | i++; | 1903 | i++; |
1908 | continue; | 1904 | continue; |
@@ -2092,14 +2088,13 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s) | |||
2092 | if (IS_LEAF(n)) { | 2088 | if (IS_LEAF(n)) { |
2093 | struct leaf *l = (struct leaf *)n; | 2089 | struct leaf *l = (struct leaf *)n; |
2094 | struct leaf_info *li; | 2090 | struct leaf_info *li; |
2095 | struct hlist_node *tmp; | ||
2096 | 2091 | ||
2097 | s->leaves++; | 2092 | s->leaves++; |
2098 | s->totdepth += iter.depth; | 2093 | s->totdepth += iter.depth; |
2099 | if (iter.depth > s->maxdepth) | 2094 | if (iter.depth > s->maxdepth) |
2100 | s->maxdepth = iter.depth; | 2095 | s->maxdepth = iter.depth; |
2101 | 2096 | ||
2102 | hlist_for_each_entry_rcu(li, tmp, &l->list, hlist) | 2097 | hlist_for_each_entry_rcu(li, &l->list, hlist) |
2103 | ++s->prefixes; | 2098 | ++s->prefixes; |
2104 | } else { | 2099 | } else { |
2105 | const struct tnode *tn = (const struct tnode *) n; | 2100 | const struct tnode *tn = (const struct tnode *) n; |
@@ -2200,10 +2195,9 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v) | |||
2200 | 2195 | ||
2201 | for (h = 0; h < FIB_TABLE_HASHSZ; h++) { | 2196 | for (h = 0; h < FIB_TABLE_HASHSZ; h++) { |
2202 | struct hlist_head *head = &net->ipv4.fib_table_hash[h]; | 2197 | struct hlist_head *head = &net->ipv4.fib_table_hash[h]; |
2203 | struct hlist_node *node; | ||
2204 | struct fib_table *tb; | 2198 | struct fib_table *tb; |
2205 | 2199 | ||
2206 | hlist_for_each_entry_rcu(tb, node, head, tb_hlist) { | 2200 | hlist_for_each_entry_rcu(tb, head, tb_hlist) { |
2207 | struct trie *t = (struct trie *) tb->tb_data; | 2201 | struct trie *t = (struct trie *) tb->tb_data; |
2208 | struct trie_stat stat; | 2202 | struct trie_stat stat; |
2209 | 2203 | ||
@@ -2245,10 +2239,9 @@ static struct rt_trie_node *fib_trie_get_idx(struct seq_file *seq, loff_t pos) | |||
2245 | 2239 | ||
2246 | for (h = 0; h < FIB_TABLE_HASHSZ; h++) { | 2240 | for (h = 0; h < FIB_TABLE_HASHSZ; h++) { |
2247 | struct hlist_head *head = &net->ipv4.fib_table_hash[h]; | 2241 | struct hlist_head *head = &net->ipv4.fib_table_hash[h]; |
2248 | struct hlist_node *node; | ||
2249 | struct fib_table *tb; | 2242 | struct fib_table *tb; |
2250 | 2243 | ||
2251 | hlist_for_each_entry_rcu(tb, node, head, tb_hlist) { | 2244 | hlist_for_each_entry_rcu(tb, head, tb_hlist) { |
2252 | struct rt_trie_node *n; | 2245 | struct rt_trie_node *n; |
2253 | 2246 | ||
2254 | for (n = fib_trie_get_first(iter, | 2247 | for (n = fib_trie_get_first(iter, |
@@ -2298,7 +2291,7 @@ static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
2298 | /* new hash chain */ | 2291 | /* new hash chain */ |
2299 | while (++h < FIB_TABLE_HASHSZ) { | 2292 | while (++h < FIB_TABLE_HASHSZ) { |
2300 | struct hlist_head *head = &net->ipv4.fib_table_hash[h]; | 2293 | struct hlist_head *head = &net->ipv4.fib_table_hash[h]; |
2301 | hlist_for_each_entry_rcu(tb, tb_node, head, tb_hlist) { | 2294 | hlist_for_each_entry_rcu(tb, head, tb_hlist) { |
2302 | n = fib_trie_get_first(iter, (struct trie *) tb->tb_data); | 2295 | n = fib_trie_get_first(iter, (struct trie *) tb->tb_data); |
2303 | if (n) | 2296 | if (n) |
2304 | goto found; | 2297 | goto found; |
@@ -2381,13 +2374,12 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v) | |||
2381 | } else { | 2374 | } else { |
2382 | struct leaf *l = (struct leaf *) n; | 2375 | struct leaf *l = (struct leaf *) n; |
2383 | struct leaf_info *li; | 2376 | struct leaf_info *li; |
2384 | struct hlist_node *node; | ||
2385 | __be32 val = htonl(l->key); | 2377 | __be32 val = htonl(l->key); |
2386 | 2378 | ||
2387 | seq_indent(seq, iter->depth); | 2379 | seq_indent(seq, iter->depth); |
2388 | seq_printf(seq, " |-- %pI4\n", &val); | 2380 | seq_printf(seq, " |-- %pI4\n", &val); |
2389 | 2381 | ||
2390 | hlist_for_each_entry_rcu(li, node, &l->list, hlist) { | 2382 | hlist_for_each_entry_rcu(li, &l->list, hlist) { |
2391 | struct fib_alias *fa; | 2383 | struct fib_alias *fa; |
2392 | 2384 | ||
2393 | list_for_each_entry_rcu(fa, &li->falh, fa_list) { | 2385 | list_for_each_entry_rcu(fa, &li->falh, fa_list) { |
@@ -2532,7 +2524,6 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) | |||
2532 | { | 2524 | { |
2533 | struct leaf *l = v; | 2525 | struct leaf *l = v; |
2534 | struct leaf_info *li; | 2526 | struct leaf_info *li; |
2535 | struct hlist_node *node; | ||
2536 | 2527 | ||
2537 | if (v == SEQ_START_TOKEN) { | 2528 | if (v == SEQ_START_TOKEN) { |
2538 | seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway " | 2529 | seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway " |
@@ -2541,7 +2532,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) | |||
2541 | return 0; | 2532 | return 0; |
2542 | } | 2533 | } |
2543 | 2534 | ||
2544 | hlist_for_each_entry_rcu(li, node, &l->list, hlist) { | 2535 | hlist_for_each_entry_rcu(li, &l->list, hlist) { |
2545 | struct fib_alias *fa; | 2536 | struct fib_alias *fa; |
2546 | __be32 mask, prefix; | 2537 | __be32 mask, prefix; |
2547 | 2538 | ||