summaryrefslogtreecommitdiffstats
path: root/include/linux/inetdevice.h
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2019-05-31 12:27:09 -0400
committerDavid S. Miller <davem@davemloft.net>2019-06-02 21:08:36 -0400
commit2638eb8b50cfc16240e0bb080b9afbf541a9b39d (patch)
tree84264a6f50aaedfac6854bef3d5972926d321c10 /include/linux/inetdevice.h
parentcb8f1478cea68bc9c9bca8bded9617d9b0b7beb6 (diff)
net: ipv4: provide __rcu annotation for ifa_list
ifa_list is protected by rcu, yet code doesn't reflect this. Add the __rcu annotations and fix up all places that are now reported by sparse. I've done this in the same commit to not add intermediate patches that result in new warnings. Reported-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/inetdevice.h')
-rw-r--r--include/linux/inetdevice.h21
1 files changed, 6 insertions, 15 deletions
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index d5d05503a04b..3515ca64e638 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -26,7 +26,7 @@ struct in_device {
26 struct net_device *dev; 26 struct net_device *dev;
27 refcount_t refcnt; 27 refcount_t refcnt;
28 int dead; 28 int dead;
29 struct in_ifaddr *ifa_list; /* IP ifaddr chain */ 29 struct in_ifaddr __rcu *ifa_list;/* IP ifaddr chain */
30 30
31 struct ip_mc_list __rcu *mc_list; /* IP multicast filter chain */ 31 struct ip_mc_list __rcu *mc_list; /* IP multicast filter chain */
32 struct ip_mc_list __rcu * __rcu *mc_hash; 32 struct ip_mc_list __rcu * __rcu *mc_hash;
@@ -136,7 +136,7 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev)
136 136
137struct in_ifaddr { 137struct in_ifaddr {
138 struct hlist_node hash; 138 struct hlist_node hash;
139 struct in_ifaddr *ifa_next; 139 struct in_ifaddr __rcu *ifa_next;
140 struct in_device *ifa_dev; 140 struct in_device *ifa_dev;
141 struct rcu_head rcu_head; 141 struct rcu_head rcu_head;
142 __be32 ifa_local; 142 __be32 ifa_local;
@@ -206,22 +206,13 @@ static __inline__ bool bad_mask(__be32 mask, __be32 addr)
206 return false; 206 return false;
207} 207}
208 208
209#define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \
210 for (ifa = (in_dev)->ifa_list; ifa && !(ifa->ifa_flags&IFA_F_SECONDARY); ifa = ifa->ifa_next)
211
212#define for_ifa(in_dev) { struct in_ifaddr *ifa; \
213 for (ifa = (in_dev)->ifa_list; ifa; ifa = ifa->ifa_next)
214
215
216#define endfor_ifa(in_dev) }
217
218#define in_dev_for_each_ifa_rtnl(ifa, in_dev) \ 209#define in_dev_for_each_ifa_rtnl(ifa, in_dev) \
219 for (ifa = (in_dev)->ifa_list; ifa; \ 210 for (ifa = rtnl_dereference((in_dev)->ifa_list); ifa; \
220 ifa = ifa->ifa_next) 211 ifa = rtnl_dereference(ifa->ifa_next))
221 212
222#define in_dev_for_each_ifa_rcu(ifa, in_dev) \ 213#define in_dev_for_each_ifa_rcu(ifa, in_dev) \
223 for (ifa = (in_dev)->ifa_list; ifa; \ 214 for (ifa = rcu_dereference((in_dev)->ifa_list); ifa; \
224 ifa = ifa->ifa_next) 215 ifa = rcu_dereference(ifa->ifa_next))
225 216
226static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev) 217static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev)
227{ 218{