diff options
author | Florian Westphal <fw@strlen.de> | 2019-05-31 19:27:04 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-06-03 04:06:26 +0300 |
commit | ef11db3310e272d3d8dbe8739e0770820dd20e52 (patch) | |
tree | 9b03e99d63d2ce8b04a8b489a52aac3d1c47e8f7 /include/linux/inetdevice.h | |
parent | 35ebfc22fe991cf5a01680a43ee238dfc16fe4c1 (diff) | |
download | linux-ef11db3310e272d3d8dbe8739e0770820dd20e52.tar.xz |
net: inetdevice: provide replacement iterators for in_ifaddr walk
The ifa_list is protected either by rcu or rtnl lock, but the
current iterators do not account for this.
This adds two iterators as replacement, a later patch in
the series will update them with the needed rcu/rtnl_dereference calls.
Its not done in this patch yet to avoid sparse warnings -- the fields
lack the proper __rcu annotation.
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.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index 367dc2a0f84a..d5d05503a04b 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h @@ -186,7 +186,7 @@ __be32 inet_confirm_addr(struct net *net, struct in_device *in_dev, __be32 dst, struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, __be32 mask); struct in_ifaddr *inet_lookup_ifaddr_rcu(struct net *net, __be32 addr); -static __inline__ bool inet_ifa_match(__be32 addr, struct in_ifaddr *ifa) +static inline bool inet_ifa_match(__be32 addr, const struct in_ifaddr *ifa) { return !((addr^ifa->ifa_address)&ifa->ifa_mask); } @@ -215,6 +215,14 @@ static __inline__ bool bad_mask(__be32 mask, __be32 addr) #define endfor_ifa(in_dev) } +#define in_dev_for_each_ifa_rtnl(ifa, in_dev) \ + for (ifa = (in_dev)->ifa_list; ifa; \ + ifa = ifa->ifa_next) + +#define in_dev_for_each_ifa_rcu(ifa, in_dev) \ + for (ifa = (in_dev)->ifa_list; ifa; \ + ifa = ifa->ifa_next) + static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev) { return rcu_dereference(dev->ip_ptr); |