[IPV4]: fib_trie RCU refinements

* This patch is from Paul McKenney's RCU reviewing.

Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Robert Olsson and committed by David S. Miller 772cb712 1d25cd6c

+10 -11
+10 -11
net/ipv4/fib_trie.c
··· 43 * 2 of the License, or (at your option) any later version. 44 */ 45 46 - #define VERSION "0.403" 47 48 #include <linux/config.h> 49 #include <asm/uaccess.h> ··· 224 Consider a node 'n' and its parent 'tp'. 225 226 If n is a leaf, every bit in its key is significant. Its presence is 227 - necessitaded by path compression, since during a tree traversal (when 228 searching for a leaf - unless we are doing an insertion) we will completely 229 ignore all skipped bits we encounter. Thus we need to verify, at the end of 230 a potentially successful search, that we have indeed been walking the ··· 836 #endif 837 } 838 839 - /* readside most use rcu_read_lock currently dump routines 840 via get_fa_head and dump */ 841 842 - static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen) 843 { 844 struct hlist_node *node; 845 struct leaf_info *li; 846 ··· 854 855 static inline struct list_head * get_fa_head(struct leaf *l, int plen) 856 { 857 - struct leaf_info *li = find_leaf_info(&l->list, plen); 858 859 if (!li) 860 return NULL; ··· 1249 } 1250 1251 1252 - /* should be clalled with rcu_read_lock */ 1253 static inline int check_leaf(struct trie *t, struct leaf *l, 1254 t_key key, int *plen, const struct flowi *flp, 1255 struct fib_result *res) ··· 1591 rtmsg_fib(RTM_DELROUTE, htonl(key), fa, plen, tb->tb_id, nlhdr, req); 1592 1593 l = fib_find_node(t, key); 1594 - li = find_leaf_info(&l->list, plen); 1595 1596 list_del_rcu(&fa->fa_list); 1597 ··· 1715 1716 t->revision++; 1717 1718 - rcu_read_lock(); 1719 for (h = 0; (l = nextleaf(t, l)) != NULL; h++) { 1720 found += trie_flush_leaf(t, l); 1721 ··· 1722 trie_leaf_remove(t, ll->key); 1723 ll = l; 1724 } 1725 - rcu_read_unlock(); 1726 1727 if (ll && hlist_empty(&ll->list)) 1728 trie_leaf_remove(t, ll->key); ··· 2287 seq_indent(seq, iter->depth); 2288 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); 2289 for (i = 32; i >= 0; i--) { 2290 - struct leaf_info *li = find_leaf_info(&l->list, i); 2291 if (li) { 2292 struct fib_alias *fa; 2293 list_for_each_entry_rcu(fa, &li->falh, fa_list) { ··· 2383 return 0; 2384 2385 for (i=32; i>=0; i--) { 2386 - struct leaf_info *li = find_leaf_info(&l->list, i); 2387 struct fib_alias *fa; 2388 u32 mask, prefix; 2389
··· 43 * 2 of the License, or (at your option) any later version. 44 */ 45 46 + #define VERSION "0.404" 47 48 #include <linux/config.h> 49 #include <asm/uaccess.h> ··· 224 Consider a node 'n' and its parent 'tp'. 225 226 If n is a leaf, every bit in its key is significant. Its presence is 227 + necessitated by path compression, since during a tree traversal (when 228 searching for a leaf - unless we are doing an insertion) we will completely 229 ignore all skipped bits we encounter. Thus we need to verify, at the end of 230 a potentially successful search, that we have indeed been walking the ··· 836 #endif 837 } 838 839 + /* readside must use rcu_read_lock currently dump routines 840 via get_fa_head and dump */ 841 842 + static struct leaf_info *find_leaf_info(struct leaf *l, int plen) 843 { 844 + struct hlist_head *head = &l->list; 845 struct hlist_node *node; 846 struct leaf_info *li; 847 ··· 853 854 static inline struct list_head * get_fa_head(struct leaf *l, int plen) 855 { 856 + struct leaf_info *li = find_leaf_info(l, plen); 857 858 if (!li) 859 return NULL; ··· 1248 } 1249 1250 1251 + /* should be called with rcu_read_lock */ 1252 static inline int check_leaf(struct trie *t, struct leaf *l, 1253 t_key key, int *plen, const struct flowi *flp, 1254 struct fib_result *res) ··· 1590 rtmsg_fib(RTM_DELROUTE, htonl(key), fa, plen, tb->tb_id, nlhdr, req); 1591 1592 l = fib_find_node(t, key); 1593 + li = find_leaf_info(l, plen); 1594 1595 list_del_rcu(&fa->fa_list); 1596 ··· 1714 1715 t->revision++; 1716 1717 for (h = 0; (l = nextleaf(t, l)) != NULL; h++) { 1718 found += trie_flush_leaf(t, l); 1719 ··· 1722 trie_leaf_remove(t, ll->key); 1723 ll = l; 1724 } 1725 1726 if (ll && hlist_empty(&ll->list)) 1727 trie_leaf_remove(t, ll->key); ··· 2288 seq_indent(seq, iter->depth); 2289 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); 2290 for (i = 32; i >= 0; i--) { 2291 + struct leaf_info *li = find_leaf_info(l, i); 2292 if (li) { 2293 struct fib_alias *fa; 2294 list_for_each_entry_rcu(fa, &li->falh, fa_list) { ··· 2384 return 0; 2385 2386 for (i=32; i>=0; i--) { 2387 + struct leaf_info *li = find_leaf_info(l, i); 2388 struct fib_alias *fa; 2389 u32 mask, prefix; 2390