History

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.

Florian Westphal committed 7 years ago

Commit ef11db31 parent 35ebfc22 files · +25 −16Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/inetdevice.h+9−1
@@ -186,7 +186,7 @@ __be32 inet_confirm_addr(struct net *net, struct in_device *in_dev, __be32 dst, · 185 unmodified lines
186186 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
187187 __be32 mask);
188188 struct in_ifaddr *inet_lookup_ifaddr_rcu(struct net *net, __be32 addr);
189−static __inline__ bool inet_ifa_match(__be32 addr, struct in_ifaddr *ifa)
189+static inline bool inet_ifa_match(__be32 addr, const struct in_ifaddr *ifa)
190190 {
191191 return !((addr^ifa->ifa_address)&ifa->ifa_mask);
192192 }
@@ -215,6 +215,14 @@ static __inline__ bool bad_mask(__be32 mask, __be32 addr) · 22 unmodified lines
215215
216216 #define endfor_ifa(in_dev) }
217217
218+#define in_dev_for_each_ifa_rtnl(ifa, in_dev) \
219+ for (ifa = (in_dev)->ifa_list; ifa; \
220+ ifa = ifa->ifa_next)
221+
222+#define in_dev_for_each_ifa_rcu(ifa, in_dev) \
223+ for (ifa = (in_dev)->ifa_list; ifa; \
224+ ifa = ifa->ifa_next)
225+
218226 static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev)
219227 {
220228 return rcu_dereference(dev->ip_ptr);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t