diff options
Diffstat (limited to 'include/net/addrconf.h')
-rw-r--r-- | include/net/addrconf.h | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 4d40c4d0230b..958d2749b7a9 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h | |||
@@ -175,20 +175,32 @@ extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev, | |||
175 | extern int register_inet6addr_notifier(struct notifier_block *nb); | 175 | extern int register_inet6addr_notifier(struct notifier_block *nb); |
176 | extern int unregister_inet6addr_notifier(struct notifier_block *nb); | 176 | extern int unregister_inet6addr_notifier(struct notifier_block *nb); |
177 | 177 | ||
178 | static inline struct inet6_dev * | 178 | /** |
179 | __in6_dev_get(struct net_device *dev) | 179 | * __in6_dev_get - get inet6_dev pointer from netdevice |
180 | * @dev: network device | ||
181 | * | ||
182 | * Caller must hold rcu_read_lock or RTNL, because this function | ||
183 | * does not take a reference on the inet6_dev. | ||
184 | */ | ||
185 | static inline struct inet6_dev *__in6_dev_get(const struct net_device *dev) | ||
180 | { | 186 | { |
181 | return rcu_dereference_check(dev->ip6_ptr, | 187 | return rcu_dereference_rtnl(dev->ip6_ptr); |
182 | rcu_read_lock_held() || | ||
183 | lockdep_rtnl_is_held()); | ||
184 | } | 188 | } |
185 | 189 | ||
186 | static inline struct inet6_dev * | 190 | /** |
187 | in6_dev_get(struct net_device *dev) | 191 | * in6_dev_get - get inet6_dev pointer from netdevice |
192 | * @dev: network device | ||
193 | * | ||
194 | * This version can be used in any context, and takes a reference | ||
195 | * on the inet6_dev. Callers must use in6_dev_put() later to | ||
196 | * release this reference. | ||
197 | */ | ||
198 | static inline struct inet6_dev *in6_dev_get(const struct net_device *dev) | ||
188 | { | 199 | { |
189 | struct inet6_dev *idev = NULL; | 200 | struct inet6_dev *idev; |
201 | |||
190 | rcu_read_lock(); | 202 | rcu_read_lock(); |
191 | idev = __in6_dev_get(dev); | 203 | idev = rcu_dereference(dev->ip6_ptr); |
192 | if (idev) | 204 | if (idev) |
193 | atomic_inc(&idev->refcnt); | 205 | atomic_inc(&idev->refcnt); |
194 | rcu_read_unlock(); | 206 | rcu_read_unlock(); |
@@ -197,16 +209,21 @@ in6_dev_get(struct net_device *dev) | |||
197 | 209 | ||
198 | extern void in6_dev_finish_destroy(struct inet6_dev *idev); | 210 | extern void in6_dev_finish_destroy(struct inet6_dev *idev); |
199 | 211 | ||
200 | static inline void | 212 | static inline void in6_dev_put(struct inet6_dev *idev) |
201 | in6_dev_put(struct inet6_dev *idev) | ||
202 | { | 213 | { |
203 | if (atomic_dec_and_test(&idev->refcnt)) | 214 | if (atomic_dec_and_test(&idev->refcnt)) |
204 | in6_dev_finish_destroy(idev); | 215 | in6_dev_finish_destroy(idev); |
205 | } | 216 | } |
206 | 217 | ||
207 | #define __in6_dev_put(idev) atomic_dec(&(idev)->refcnt) | 218 | static inline void __in6_dev_put(struct inet6_dev *idev) |
208 | #define in6_dev_hold(idev) atomic_inc(&(idev)->refcnt) | 219 | { |
220 | atomic_dec(&idev->refcnt); | ||
221 | } | ||
209 | 222 | ||
223 | static inline void in6_dev_hold(struct inet6_dev *idev) | ||
224 | { | ||
225 | atomic_inc(&idev->refcnt); | ||
226 | } | ||
210 | 227 | ||
211 | extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp); | 228 | extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp); |
212 | 229 | ||
@@ -216,9 +233,15 @@ static inline void in6_ifa_put(struct inet6_ifaddr *ifp) | |||
216 | inet6_ifa_finish_destroy(ifp); | 233 | inet6_ifa_finish_destroy(ifp); |
217 | } | 234 | } |
218 | 235 | ||
219 | #define __in6_ifa_put(ifp) atomic_dec(&(ifp)->refcnt) | 236 | static inline void __in6_ifa_put(struct inet6_ifaddr *ifp) |
220 | #define in6_ifa_hold(ifp) atomic_inc(&(ifp)->refcnt) | 237 | { |
238 | atomic_dec(&ifp->refcnt); | ||
239 | } | ||
221 | 240 | ||
241 | static inline void in6_ifa_hold(struct inet6_ifaddr *ifp) | ||
242 | { | ||
243 | atomic_inc(&ifp->refcnt); | ||
244 | } | ||
222 | 245 | ||
223 | 246 | ||
224 | /* | 247 | /* |
@@ -241,23 +264,23 @@ static inline int ipv6_addr_is_multicast(const struct in6_addr *addr) | |||
241 | 264 | ||
242 | static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) | 265 | static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) |
243 | { | 266 | { |
244 | return (((addr->s6_addr32[0] ^ htonl(0xff020000)) | | 267 | return ((addr->s6_addr32[0] ^ htonl(0xff020000)) | |
245 | addr->s6_addr32[1] | addr->s6_addr32[2] | | 268 | addr->s6_addr32[1] | addr->s6_addr32[2] | |
246 | (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0); | 269 | (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0; |
247 | } | 270 | } |
248 | 271 | ||
249 | static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) | 272 | static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) |
250 | { | 273 | { |
251 | return (((addr->s6_addr32[0] ^ htonl(0xff020000)) | | 274 | return ((addr->s6_addr32[0] ^ htonl(0xff020000)) | |
252 | addr->s6_addr32[1] | addr->s6_addr32[2] | | 275 | addr->s6_addr32[1] | addr->s6_addr32[2] | |
253 | (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0); | 276 | (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0; |
254 | } | 277 | } |
255 | 278 | ||
256 | extern int __ipv6_isatap_ifid(u8 *eui, __be32 addr); | 279 | extern int __ipv6_isatap_ifid(u8 *eui, __be32 addr); |
257 | 280 | ||
258 | static inline int ipv6_addr_is_isatap(const struct in6_addr *addr) | 281 | static inline int ipv6_addr_is_isatap(const struct in6_addr *addr) |
259 | { | 282 | { |
260 | return ((addr->s6_addr32[2] | htonl(0x02000000)) == htonl(0x02005EFE)); | 283 | return (addr->s6_addr32[2] | htonl(0x02000000)) == htonl(0x02005EFE); |
261 | } | 284 | } |
262 | 285 | ||
263 | #ifdef CONFIG_PROC_FS | 286 | #ifdef CONFIG_PROC_FS |