aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/rculist.h29
-rw-r--r--net/ipv6/addrconf.c16
2 files changed, 37 insertions, 8 deletions
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index 004908b104d5..4ec3b38ce9c5 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -429,6 +429,23 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
429 pos = rcu_dereference_raw(pos->next)) 429 pos = rcu_dereference_raw(pos->next))
430 430
431/** 431/**
432 * hlist_for_each_entry_rcu_bh - iterate over rcu list of given type
433 * @tpos: the type * to use as a loop cursor.
434 * @pos: the &struct hlist_node to use as a loop cursor.
435 * @head: the head for your list.
436 * @member: the name of the hlist_node within the struct.
437 *
438 * This list-traversal primitive may safely run concurrently with
439 * the _rcu list-mutation primitives such as hlist_add_head_rcu()
440 * as long as the traversal is guarded by rcu_read_lock().
441 */
442#define hlist_for_each_entry_rcu_bh(tpos, pos, head, member) \
443 for (pos = rcu_dereference_bh((head)->first); \
444 pos && ({ prefetch(pos->next); 1; }) && \
445 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
446 pos = rcu_dereference_bh(pos->next))
447
448/**
432 * hlist_for_each_entry_continue_rcu - iterate over a hlist continuing after current point 449 * hlist_for_each_entry_continue_rcu - iterate over a hlist continuing after current point
433 * @tpos: the type * to use as a loop cursor. 450 * @tpos: the type * to use as a loop cursor.
434 * @pos: the &struct hlist_node to use as a loop cursor. 451 * @pos: the &struct hlist_node to use as a loop cursor.
@@ -440,6 +457,18 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
440 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \ 457 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
441 pos = rcu_dereference(pos->next)) 458 pos = rcu_dereference(pos->next))
442 459
460/**
461 * hlist_for_each_entry_continue_rcu_bh - iterate over a hlist continuing after current point
462 * @tpos: the type * to use as a loop cursor.
463 * @pos: the &struct hlist_node to use as a loop cursor.
464 * @member: the name of the hlist_node within the struct.
465 */
466#define hlist_for_each_entry_continue_rcu_bh(tpos, pos, member) \
467 for (pos = rcu_dereference_bh((pos)->next); \
468 pos && ({ prefetch(pos->next); 1; }) && \
469 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
470 pos = rcu_dereference_bh(pos->next))
471
443 472
444#endif /* __KERNEL__ */ 473#endif /* __KERNEL__ */
445#endif 474#endif
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 34d2d649e396..3984f52181f4 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1346,7 +1346,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add
1346 struct hlist_node *node; 1346 struct hlist_node *node;
1347 1347
1348 rcu_read_lock_bh(); 1348 rcu_read_lock_bh();
1349 hlist_for_each_entry_rcu(ifp, node, &inet6_addr_lst[hash], addr_lst) { 1349 hlist_for_each_entry_rcu_bh(ifp, node, &inet6_addr_lst[hash], addr_lst) {
1350 if (!net_eq(dev_net(ifp->idev->dev), net)) 1350 if (!net_eq(dev_net(ifp->idev->dev), net))
1351 continue; 1351 continue;
1352 if (ipv6_addr_equal(&ifp->addr, addr)) { 1352 if (ipv6_addr_equal(&ifp->addr, addr)) {
@@ -2959,7 +2959,7 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq)
2959 2959
2960 for (state->bucket = 0; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) { 2960 for (state->bucket = 0; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) {
2961 struct hlist_node *n; 2961 struct hlist_node *n;
2962 hlist_for_each_entry_rcu(ifa, n, &inet6_addr_lst[state->bucket], 2962 hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket],
2963 addr_lst) 2963 addr_lst)
2964 if (net_eq(dev_net(ifa->idev->dev), net)) 2964 if (net_eq(dev_net(ifa->idev->dev), net))
2965 return ifa; 2965 return ifa;
@@ -2974,12 +2974,12 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
2974 struct net *net = seq_file_net(seq); 2974 struct net *net = seq_file_net(seq);
2975 struct hlist_node *n = &ifa->addr_lst; 2975 struct hlist_node *n = &ifa->addr_lst;
2976 2976
2977 hlist_for_each_entry_continue_rcu(ifa, n, addr_lst) 2977 hlist_for_each_entry_continue_rcu_bh(ifa, n, addr_lst)
2978 if (net_eq(dev_net(ifa->idev->dev), net)) 2978 if (net_eq(dev_net(ifa->idev->dev), net))
2979 return ifa; 2979 return ifa;
2980 2980
2981 while (++state->bucket < IN6_ADDR_HSIZE) { 2981 while (++state->bucket < IN6_ADDR_HSIZE) {
2982 hlist_for_each_entry(ifa, n, 2982 hlist_for_each_entry_rcu_bh(ifa, n,
2983 &inet6_addr_lst[state->bucket], addr_lst) { 2983 &inet6_addr_lst[state->bucket], addr_lst) {
2984 if (net_eq(dev_net(ifa->idev->dev), net)) 2984 if (net_eq(dev_net(ifa->idev->dev), net))
2985 return ifa; 2985 return ifa;
@@ -3000,7 +3000,7 @@ static struct inet6_ifaddr *if6_get_idx(struct seq_file *seq, loff_t pos)
3000} 3000}
3001 3001
3002static void *if6_seq_start(struct seq_file *seq, loff_t *pos) 3002static void *if6_seq_start(struct seq_file *seq, loff_t *pos)
3003 __acquires(rcu) 3003 __acquires(rcu_bh)
3004{ 3004{
3005 rcu_read_lock_bh(); 3005 rcu_read_lock_bh();
3006 return if6_get_idx(seq, *pos); 3006 return if6_get_idx(seq, *pos);
@@ -3016,7 +3016,7 @@ static void *if6_seq_next(struct seq_file *seq, void *v, loff_t *pos)
3016} 3016}
3017 3017
3018static void if6_seq_stop(struct seq_file *seq, void *v) 3018static void if6_seq_stop(struct seq_file *seq, void *v)
3019 __releases(rcu) 3019 __releases(rcu_bh)
3020{ 3020{
3021 rcu_read_unlock_bh(); 3021 rcu_read_unlock_bh();
3022} 3022}
@@ -3093,7 +3093,7 @@ int ipv6_chk_home_addr(struct net *net, struct in6_addr *addr)
3093 unsigned int hash = ipv6_addr_hash(addr); 3093 unsigned int hash = ipv6_addr_hash(addr);
3094 3094
3095 rcu_read_lock_bh(); 3095 rcu_read_lock_bh();
3096 hlist_for_each_entry_rcu(ifp, n, &inet6_addr_lst[hash], addr_lst) { 3096 hlist_for_each_entry_rcu_bh(ifp, n, &inet6_addr_lst[hash], addr_lst) {
3097 if (!net_eq(dev_net(ifp->idev->dev), net)) 3097 if (!net_eq(dev_net(ifp->idev->dev), net))
3098 continue; 3098 continue;
3099 if (ipv6_addr_equal(&ifp->addr, addr) && 3099 if (ipv6_addr_equal(&ifp->addr, addr) &&
@@ -3127,7 +3127,7 @@ static void addrconf_verify(unsigned long foo)
3127 3127
3128 for (i = 0; i < IN6_ADDR_HSIZE; i++) { 3128 for (i = 0; i < IN6_ADDR_HSIZE; i++) {
3129restart: 3129restart:
3130 hlist_for_each_entry_rcu(ifp, node, 3130 hlist_for_each_entry_rcu_bh(ifp, node,
3131 &inet6_addr_lst[i], addr_lst) { 3131 &inet6_addr_lst[i], addr_lst) {
3132 unsigned long age; 3132 unsigned long age;
3133 3133