aboutsummaryrefslogtreecommitdiffstats
path: root/net/l2tp
diff options
context:
space:
mode:
authorSasha Levin <sasha.levin@oracle.com>2013-02-27 20:06:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:24 -0500
commitb67bfe0d42cac56c512dd5da4b1b347a23f4b70a (patch)
tree3d465aea12b97683f26ffa38eba8744469de9997 /net/l2tp
parent1e142b29e210b5dfb2deeb6ce2210b60af16d2a6 (diff)
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived list_for_each_entry(pos, head, member) The hlist ones were greedy and wanted an extra parameter: hlist_for_each_entry(tpos, pos, head, member) Why did they need an extra pos parameter? I'm not quite sure. Not only they don't really need it, it also prevents the iterator from looking exactly like the list iterator, which is unfortunate. Besides the semantic patch, there was some manual work required: - Fix up the actual hlist iterators in linux/list.h - Fix up the declaration of other iterators based on the hlist ones. - A very small amount of places were using the 'node' parameter, this was modified to use 'obj->member' instead. - Coccinelle didn't handle the hlist_for_each_entry_safe iterator properly, so those had to be fixed up manually. The semantic patch which is mostly the work of Peter Senna Tschudin is here: @@ iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host; type T; expression a,c,d,e; identifier b; statement S; @@ -T b; <+... when != b ( hlist_for_each_entry(a, - b, c, d) S | hlist_for_each_entry_continue(a, - b, c) S | hlist_for_each_entry_from(a, - b, c) S | hlist_for_each_entry_rcu(a, - b, c, d) S | hlist_for_each_entry_rcu_bh(a, - b, c, d) S | hlist_for_each_entry_continue_rcu_bh(a, - b, c) S | for_each_busy_worker(a, c, - b, d) S | ax25_uid_for_each(a, - b, c) S | ax25_for_each(a, - b, c) S | inet_bind_bucket_for_each(a, - b, c) S | sctp_for_each_hentry(a, - b, c) S | sk_for_each(a, - b, c) S | sk_for_each_rcu(a, - b, c) S | sk_for_each_from -(a, b) +(a) S + sk_for_each_from(a) S | sk_for_each_safe(a, - b, c, d) S | sk_for_each_bound(a, - b, c) S | hlist_for_each_entry_safe(a, - b, c, d, e) S | hlist_for_each_entry_continue_rcu(a, - b, c) S | nr_neigh_for_each(a, - b, c) S | nr_neigh_for_each_safe(a, - b, c, d) S | nr_node_for_each(a, - b, c) S | nr_node_for_each_safe(a, - b, c, d) S | - for_each_gfn_sp(a, c, d, b) S + for_each_gfn_sp(a, c, d) S | - for_each_gfn_indirect_valid_sp(a, c, d, b) S + for_each_gfn_indirect_valid_sp(a, c, d) S | for_each_host(a, - b, c) S | for_each_host_safe(a, - b, c, d) S | for_each_mesh_entry(a, - b, c, d) S ) ...+> [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c] [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c] [akpm@linux-foundation.org: checkpatch fixes] [akpm@linux-foundation.org: fix warnings] [akpm@linux-foudnation.org: redo intrusive kvm changes] Tested-by: Peter Senna Tschudin <peter.senna@gmail.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Gleb Natapov <gleb@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/l2tp')
-rw-r--r--net/l2tp/l2tp_core.c12
-rw-r--r--net/l2tp/l2tp_ip.c3
-rw-r--r--net/l2tp/l2tp_ip6.c3
3 files changed, 6 insertions, 12 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index dcfd64e83ab7..d36875f3427e 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -221,10 +221,9 @@ static struct l2tp_session *l2tp_session_find_2(struct net *net, u32 session_id)
221 struct hlist_head *session_list = 221 struct hlist_head *session_list =
222 l2tp_session_id_hash_2(pn, session_id); 222 l2tp_session_id_hash_2(pn, session_id);
223 struct l2tp_session *session; 223 struct l2tp_session *session;
224 struct hlist_node *walk;
225 224
226 rcu_read_lock_bh(); 225 rcu_read_lock_bh();
227 hlist_for_each_entry_rcu(session, walk, session_list, global_hlist) { 226 hlist_for_each_entry_rcu(session, session_list, global_hlist) {
228 if (session->session_id == session_id) { 227 if (session->session_id == session_id) {
229 rcu_read_unlock_bh(); 228 rcu_read_unlock_bh();
230 return session; 229 return session;
@@ -253,7 +252,6 @@ struct l2tp_session *l2tp_session_find(struct net *net, struct l2tp_tunnel *tunn
253{ 252{
254 struct hlist_head *session_list; 253 struct hlist_head *session_list;
255 struct l2tp_session *session; 254 struct l2tp_session *session;
256 struct hlist_node *walk;
257 255
258 /* In L2TPv3, session_ids are unique over all tunnels and we 256 /* In L2TPv3, session_ids are unique over all tunnels and we
259 * sometimes need to look them up before we know the 257 * sometimes need to look them up before we know the
@@ -264,7 +262,7 @@ struct l2tp_session *l2tp_session_find(struct net *net, struct l2tp_tunnel *tunn
264 262
265 session_list = l2tp_session_id_hash(tunnel, session_id); 263 session_list = l2tp_session_id_hash(tunnel, session_id);
266 read_lock_bh(&tunnel->hlist_lock); 264 read_lock_bh(&tunnel->hlist_lock);
267 hlist_for_each_entry(session, walk, session_list, hlist) { 265 hlist_for_each_entry(session, session_list, hlist) {
268 if (session->session_id == session_id) { 266 if (session->session_id == session_id) {
269 read_unlock_bh(&tunnel->hlist_lock); 267 read_unlock_bh(&tunnel->hlist_lock);
270 return session; 268 return session;
@@ -279,13 +277,12 @@ EXPORT_SYMBOL_GPL(l2tp_session_find);
279struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth) 277struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth)
280{ 278{
281 int hash; 279 int hash;
282 struct hlist_node *walk;
283 struct l2tp_session *session; 280 struct l2tp_session *session;
284 int count = 0; 281 int count = 0;
285 282
286 read_lock_bh(&tunnel->hlist_lock); 283 read_lock_bh(&tunnel->hlist_lock);
287 for (hash = 0; hash < L2TP_HASH_SIZE; hash++) { 284 for (hash = 0; hash < L2TP_HASH_SIZE; hash++) {
288 hlist_for_each_entry(session, walk, &tunnel->session_hlist[hash], hlist) { 285 hlist_for_each_entry(session, &tunnel->session_hlist[hash], hlist) {
289 if (++count > nth) { 286 if (++count > nth) {
290 read_unlock_bh(&tunnel->hlist_lock); 287 read_unlock_bh(&tunnel->hlist_lock);
291 return session; 288 return session;
@@ -306,12 +303,11 @@ struct l2tp_session *l2tp_session_find_by_ifname(struct net *net, char *ifname)
306{ 303{
307 struct l2tp_net *pn = l2tp_pernet(net); 304 struct l2tp_net *pn = l2tp_pernet(net);
308 int hash; 305 int hash;
309 struct hlist_node *walk;
310 struct l2tp_session *session; 306 struct l2tp_session *session;
311 307
312 rcu_read_lock_bh(); 308 rcu_read_lock_bh();
313 for (hash = 0; hash < L2TP_HASH_SIZE_2; hash++) { 309 for (hash = 0; hash < L2TP_HASH_SIZE_2; hash++) {
314 hlist_for_each_entry_rcu(session, walk, &pn->l2tp_session_hlist[hash], global_hlist) { 310 hlist_for_each_entry_rcu(session, &pn->l2tp_session_hlist[hash], global_hlist) {
315 if (!strcmp(session->ifname, ifname)) { 311 if (!strcmp(session->ifname, ifname)) {
316 rcu_read_unlock_bh(); 312 rcu_read_unlock_bh();
317 return session; 313 return session;
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index f7ac8f42fee2..7f41b7051269 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -49,10 +49,9 @@ static inline struct l2tp_ip_sock *l2tp_ip_sk(const struct sock *sk)
49 49
50static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif, u32 tunnel_id) 50static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif, u32 tunnel_id)
51{ 51{
52 struct hlist_node *node;
53 struct sock *sk; 52 struct sock *sk;
54 53
55 sk_for_each_bound(sk, node, &l2tp_ip_bind_table) { 54 sk_for_each_bound(sk, &l2tp_ip_bind_table) {
56 struct inet_sock *inet = inet_sk(sk); 55 struct inet_sock *inet = inet_sk(sk);
57 struct l2tp_ip_sock *l2tp = l2tp_ip_sk(sk); 56 struct l2tp_ip_sock *l2tp = l2tp_ip_sk(sk);
58 57
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index 8ee4a86ae996..41f2f8126ebc 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -60,10 +60,9 @@ static struct sock *__l2tp_ip6_bind_lookup(struct net *net,
60 struct in6_addr *laddr, 60 struct in6_addr *laddr,
61 int dif, u32 tunnel_id) 61 int dif, u32 tunnel_id)
62{ 62{
63 struct hlist_node *node;
64 struct sock *sk; 63 struct sock *sk;
65 64
66 sk_for_each_bound(sk, node, &l2tp_ip6_bind_table) { 65 sk_for_each_bound(sk, &l2tp_ip6_bind_table) {
67 struct in6_addr *addr = inet6_rcv_saddr(sk); 66 struct in6_addr *addr = inet6_rcv_saddr(sk);
68 struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk); 67 struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk);
69 68