aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_semantics.c
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/ipv4/fib_semantics.c
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/ipv4/fib_semantics.c')
-rw-r--r--net/ipv4/fib_semantics.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 4797a800faf8..8f6cb7a87cd6 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -298,14 +298,13 @@ static inline unsigned int fib_info_hashfn(const struct fib_info *fi)
298static struct fib_info *fib_find_info(const struct fib_info *nfi) 298static struct fib_info *fib_find_info(const struct fib_info *nfi)
299{ 299{
300 struct hlist_head *head; 300 struct hlist_head *head;
301 struct hlist_node *node;
302 struct fib_info *fi; 301 struct fib_info *fi;
303 unsigned int hash; 302 unsigned int hash;
304 303
305 hash = fib_info_hashfn(nfi); 304 hash = fib_info_hashfn(nfi);
306 head = &fib_info_hash[hash]; 305 head = &fib_info_hash[hash];
307 306
308 hlist_for_each_entry(fi, node, head, fib_hash) { 307 hlist_for_each_entry(fi, head, fib_hash) {
309 if (!net_eq(fi->fib_net, nfi->fib_net)) 308 if (!net_eq(fi->fib_net, nfi->fib_net))
310 continue; 309 continue;
311 if (fi->fib_nhs != nfi->fib_nhs) 310 if (fi->fib_nhs != nfi->fib_nhs)
@@ -331,7 +330,6 @@ static struct fib_info *fib_find_info(const struct fib_info *nfi)
331int ip_fib_check_default(__be32 gw, struct net_device *dev) 330int ip_fib_check_default(__be32 gw, struct net_device *dev)
332{ 331{
333 struct hlist_head *head; 332 struct hlist_head *head;
334 struct hlist_node *node;
335 struct fib_nh *nh; 333 struct fib_nh *nh;
336 unsigned int hash; 334 unsigned int hash;
337 335
@@ -339,7 +337,7 @@ int ip_fib_check_default(__be32 gw, struct net_device *dev)
339 337
340 hash = fib_devindex_hashfn(dev->ifindex); 338 hash = fib_devindex_hashfn(dev->ifindex);
341 head = &fib_info_devhash[hash]; 339 head = &fib_info_devhash[hash];
342 hlist_for_each_entry(nh, node, head, nh_hash) { 340 hlist_for_each_entry(nh, head, nh_hash) {
343 if (nh->nh_dev == dev && 341 if (nh->nh_dev == dev &&
344 nh->nh_gw == gw && 342 nh->nh_gw == gw &&
345 !(nh->nh_flags & RTNH_F_DEAD)) { 343 !(nh->nh_flags & RTNH_F_DEAD)) {
@@ -721,10 +719,10 @@ static void fib_info_hash_move(struct hlist_head *new_info_hash,
721 719
722 for (i = 0; i < old_size; i++) { 720 for (i = 0; i < old_size; i++) {
723 struct hlist_head *head = &fib_info_hash[i]; 721 struct hlist_head *head = &fib_info_hash[i];
724 struct hlist_node *node, *n; 722 struct hlist_node *n;
725 struct fib_info *fi; 723 struct fib_info *fi;
726 724
727 hlist_for_each_entry_safe(fi, node, n, head, fib_hash) { 725 hlist_for_each_entry_safe(fi, n, head, fib_hash) {
728 struct hlist_head *dest; 726 struct hlist_head *dest;
729 unsigned int new_hash; 727 unsigned int new_hash;
730 728
@@ -739,10 +737,10 @@ static void fib_info_hash_move(struct hlist_head *new_info_hash,
739 737
740 for (i = 0; i < old_size; i++) { 738 for (i = 0; i < old_size; i++) {
741 struct hlist_head *lhead = &fib_info_laddrhash[i]; 739 struct hlist_head *lhead = &fib_info_laddrhash[i];
742 struct hlist_node *node, *n; 740 struct hlist_node *n;
743 struct fib_info *fi; 741 struct fib_info *fi;
744 742
745 hlist_for_each_entry_safe(fi, node, n, lhead, fib_lhash) { 743 hlist_for_each_entry_safe(fi, n, lhead, fib_lhash) {
746 struct hlist_head *ldest; 744 struct hlist_head *ldest;
747 unsigned int new_hash; 745 unsigned int new_hash;
748 746
@@ -1096,13 +1094,12 @@ int fib_sync_down_addr(struct net *net, __be32 local)
1096 int ret = 0; 1094 int ret = 0;
1097 unsigned int hash = fib_laddr_hashfn(local); 1095 unsigned int hash = fib_laddr_hashfn(local);
1098 struct hlist_head *head = &fib_info_laddrhash[hash]; 1096 struct hlist_head *head = &fib_info_laddrhash[hash];
1099 struct hlist_node *node;
1100 struct fib_info *fi; 1097 struct fib_info *fi;
1101 1098
1102 if (fib_info_laddrhash == NULL || local == 0) 1099 if (fib_info_laddrhash == NULL || local == 0)
1103 return 0; 1100 return 0;
1104 1101
1105 hlist_for_each_entry(fi, node, head, fib_lhash) { 1102 hlist_for_each_entry(fi, head, fib_lhash) {
1106 if (!net_eq(fi->fib_net, net)) 1103 if (!net_eq(fi->fib_net, net))
1107 continue; 1104 continue;
1108 if (fi->fib_prefsrc == local) { 1105 if (fi->fib_prefsrc == local) {
@@ -1120,13 +1117,12 @@ int fib_sync_down_dev(struct net_device *dev, int force)
1120 struct fib_info *prev_fi = NULL; 1117 struct fib_info *prev_fi = NULL;
1121 unsigned int hash = fib_devindex_hashfn(dev->ifindex); 1118 unsigned int hash = fib_devindex_hashfn(dev->ifindex);
1122 struct hlist_head *head = &fib_info_devhash[hash]; 1119 struct hlist_head *head = &fib_info_devhash[hash];
1123 struct hlist_node *node;
1124 struct fib_nh *nh; 1120 struct fib_nh *nh;
1125 1121
1126 if (force) 1122 if (force)
1127 scope = -1; 1123 scope = -1;
1128 1124
1129 hlist_for_each_entry(nh, node, head, nh_hash) { 1125 hlist_for_each_entry(nh, head, nh_hash) {
1130 struct fib_info *fi = nh->nh_parent; 1126 struct fib_info *fi = nh->nh_parent;
1131 int dead; 1127 int dead;
1132 1128
@@ -1232,7 +1228,6 @@ int fib_sync_up(struct net_device *dev)
1232 struct fib_info *prev_fi; 1228 struct fib_info *prev_fi;
1233 unsigned int hash; 1229 unsigned int hash;
1234 struct hlist_head *head; 1230 struct hlist_head *head;
1235 struct hlist_node *node;
1236 struct fib_nh *nh; 1231 struct fib_nh *nh;
1237 int ret; 1232 int ret;
1238 1233
@@ -1244,7 +1239,7 @@ int fib_sync_up(struct net_device *dev)
1244 head = &fib_info_devhash[hash]; 1239 head = &fib_info_devhash[hash];
1245 ret = 0; 1240 ret = 0;
1246 1241
1247 hlist_for_each_entry(nh, node, head, nh_hash) { 1242 hlist_for_each_entry(nh, head, nh_hash) {
1248 struct fib_info *fi = nh->nh_parent; 1243 struct fib_info *fi = nh->nh_parent;
1249 int alive; 1244 int alive;
1250 1245