diff options
author | Amerigo Wang <amwang@redhat.com> | 2012-11-11 16:52:34 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-14 18:49:50 -0500 |
commit | e086cadc08e259150b2ab8f7f4a16dbf9e3c2f22 (patch) | |
tree | 38ef29e21c125dcb9f8fd75749416e4839c84469 /net/ipv6 | |
parent | aa0010f880ab542da3ad0e72992f2dc518ac68a0 (diff) |
net: unify for_each_ip_tunnel_rcu()
The defitions of for_each_ip_tunnel_rcu() are same,
so unify it. Also, don't hide the parameter 't'.
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ip6_gre.c | 14 | ||||
-rw-r--r-- | net/ipv6/sit.c | 13 |
2 files changed, 7 insertions, 20 deletions
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 672101db71ee..823fd64d0136 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -109,12 +109,6 @@ static u32 HASH_ADDR(const struct in6_addr *addr) | |||
109 | #define tunnels_r tunnels[2] | 109 | #define tunnels_r tunnels[2] |
110 | #define tunnels_l tunnels[1] | 110 | #define tunnels_l tunnels[1] |
111 | #define tunnels_wc tunnels[0] | 111 | #define tunnels_wc tunnels[0] |
112 | /* | ||
113 | * Locking : hash tables are protected by RCU and RTNL | ||
114 | */ | ||
115 | |||
116 | #define for_each_ip_tunnel_rcu(start) \ | ||
117 | for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) | ||
118 | 112 | ||
119 | static struct rtnl_link_stats64 *ip6gre_get_stats64(struct net_device *dev, | 113 | static struct rtnl_link_stats64 *ip6gre_get_stats64(struct net_device *dev, |
120 | struct rtnl_link_stats64 *tot) | 114 | struct rtnl_link_stats64 *tot) |
@@ -172,7 +166,7 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, | |||
172 | ARPHRD_ETHER : ARPHRD_IP6GRE; | 166 | ARPHRD_ETHER : ARPHRD_IP6GRE; |
173 | int score, cand_score = 4; | 167 | int score, cand_score = 4; |
174 | 168 | ||
175 | for_each_ip_tunnel_rcu(ign->tunnels_r_l[h0 ^ h1]) { | 169 | for_each_ip_tunnel_rcu(t, ign->tunnels_r_l[h0 ^ h1]) { |
176 | if (!ipv6_addr_equal(local, &t->parms.laddr) || | 170 | if (!ipv6_addr_equal(local, &t->parms.laddr) || |
177 | !ipv6_addr_equal(remote, &t->parms.raddr) || | 171 | !ipv6_addr_equal(remote, &t->parms.raddr) || |
178 | key != t->parms.i_key || | 172 | key != t->parms.i_key || |
@@ -197,7 +191,7 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, | |||
197 | } | 191 | } |
198 | } | 192 | } |
199 | 193 | ||
200 | for_each_ip_tunnel_rcu(ign->tunnels_r[h0 ^ h1]) { | 194 | for_each_ip_tunnel_rcu(t, ign->tunnels_r[h0 ^ h1]) { |
201 | if (!ipv6_addr_equal(remote, &t->parms.raddr) || | 195 | if (!ipv6_addr_equal(remote, &t->parms.raddr) || |
202 | key != t->parms.i_key || | 196 | key != t->parms.i_key || |
203 | !(t->dev->flags & IFF_UP)) | 197 | !(t->dev->flags & IFF_UP)) |
@@ -221,7 +215,7 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, | |||
221 | } | 215 | } |
222 | } | 216 | } |
223 | 217 | ||
224 | for_each_ip_tunnel_rcu(ign->tunnels_l[h1]) { | 218 | for_each_ip_tunnel_rcu(t, ign->tunnels_l[h1]) { |
225 | if ((!ipv6_addr_equal(local, &t->parms.laddr) && | 219 | if ((!ipv6_addr_equal(local, &t->parms.laddr) && |
226 | (!ipv6_addr_equal(local, &t->parms.raddr) || | 220 | (!ipv6_addr_equal(local, &t->parms.raddr) || |
227 | !ipv6_addr_is_multicast(local))) || | 221 | !ipv6_addr_is_multicast(local))) || |
@@ -247,7 +241,7 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, | |||
247 | } | 241 | } |
248 | } | 242 | } |
249 | 243 | ||
250 | for_each_ip_tunnel_rcu(ign->tunnels_wc[h1]) { | 244 | for_each_ip_tunnel_rcu(t, ign->tunnels_wc[h1]) { |
251 | if (t->parms.i_key != key || | 245 | if (t->parms.i_key != key || |
252 | !(t->dev->flags & IFF_UP)) | 246 | !(t->dev->flags & IFF_UP)) |
253 | continue; | 247 | continue; |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index ffe83ef70cf7..5bce2f698044 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -81,13 +81,6 @@ struct sit_net { | |||
81 | struct net_device *fb_tunnel_dev; | 81 | struct net_device *fb_tunnel_dev; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | /* | ||
85 | * Locking : hash tables are protected by RCU and RTNL | ||
86 | */ | ||
87 | |||
88 | #define for_each_ip_tunnel_rcu(start) \ | ||
89 | for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) | ||
90 | |||
91 | static struct rtnl_link_stats64 *ipip6_get_stats64(struct net_device *dev, | 84 | static struct rtnl_link_stats64 *ipip6_get_stats64(struct net_device *dev, |
92 | struct rtnl_link_stats64 *tot) | 85 | struct rtnl_link_stats64 *tot) |
93 | { | 86 | { |
@@ -133,20 +126,20 @@ static struct ip_tunnel *ipip6_tunnel_lookup(struct net *net, | |||
133 | struct ip_tunnel *t; | 126 | struct ip_tunnel *t; |
134 | struct sit_net *sitn = net_generic(net, sit_net_id); | 127 | struct sit_net *sitn = net_generic(net, sit_net_id); |
135 | 128 | ||
136 | for_each_ip_tunnel_rcu(sitn->tunnels_r_l[h0 ^ h1]) { | 129 | for_each_ip_tunnel_rcu(t, sitn->tunnels_r_l[h0 ^ h1]) { |
137 | if (local == t->parms.iph.saddr && | 130 | if (local == t->parms.iph.saddr && |
138 | remote == t->parms.iph.daddr && | 131 | remote == t->parms.iph.daddr && |
139 | (!dev || !t->parms.link || dev->iflink == t->parms.link) && | 132 | (!dev || !t->parms.link || dev->iflink == t->parms.link) && |
140 | (t->dev->flags & IFF_UP)) | 133 | (t->dev->flags & IFF_UP)) |
141 | return t; | 134 | return t; |
142 | } | 135 | } |
143 | for_each_ip_tunnel_rcu(sitn->tunnels_r[h0]) { | 136 | for_each_ip_tunnel_rcu(t, sitn->tunnels_r[h0]) { |
144 | if (remote == t->parms.iph.daddr && | 137 | if (remote == t->parms.iph.daddr && |
145 | (!dev || !t->parms.link || dev->iflink == t->parms.link) && | 138 | (!dev || !t->parms.link || dev->iflink == t->parms.link) && |
146 | (t->dev->flags & IFF_UP)) | 139 | (t->dev->flags & IFF_UP)) |
147 | return t; | 140 | return t; |
148 | } | 141 | } |
149 | for_each_ip_tunnel_rcu(sitn->tunnels_l[h1]) { | 142 | for_each_ip_tunnel_rcu(t, sitn->tunnels_l[h1]) { |
150 | if (local == t->parms.iph.saddr && | 143 | if (local == t->parms.iph.saddr && |
151 | (!dev || !t->parms.link || dev->iflink == t->parms.link) && | 144 | (!dev || !t->parms.link || dev->iflink == t->parms.link) && |
152 | (t->dev->flags & IFF_UP)) | 145 | (t->dev->flags & IFF_UP)) |