diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/inetdevice.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index 7e1e15f934f3..fd7af86151b1 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h | |||
@@ -142,13 +142,21 @@ static __inline__ int bad_mask(u32 mask, u32 addr) | |||
142 | 142 | ||
143 | #define endfor_ifa(in_dev) } | 143 | #define endfor_ifa(in_dev) } |
144 | 144 | ||
145 | static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev) | ||
146 | { | ||
147 | struct in_device *in_dev = dev->ip_ptr; | ||
148 | if (in_dev) | ||
149 | in_dev = rcu_dereference(in_dev); | ||
150 | return in_dev; | ||
151 | } | ||
152 | |||
145 | static __inline__ struct in_device * | 153 | static __inline__ struct in_device * |
146 | in_dev_get(const struct net_device *dev) | 154 | in_dev_get(const struct net_device *dev) |
147 | { | 155 | { |
148 | struct in_device *in_dev; | 156 | struct in_device *in_dev; |
149 | 157 | ||
150 | rcu_read_lock(); | 158 | rcu_read_lock(); |
151 | in_dev = dev->ip_ptr; | 159 | in_dev = __in_dev_get_rcu(dev); |
152 | if (in_dev) | 160 | if (in_dev) |
153 | atomic_inc(&in_dev->refcnt); | 161 | atomic_inc(&in_dev->refcnt); |
154 | rcu_read_unlock(); | 162 | rcu_read_unlock(); |
@@ -156,7 +164,7 @@ in_dev_get(const struct net_device *dev) | |||
156 | } | 164 | } |
157 | 165 | ||
158 | static __inline__ struct in_device * | 166 | static __inline__ struct in_device * |
159 | __in_dev_get(const struct net_device *dev) | 167 | __in_dev_get_rtnl(const struct net_device *dev) |
160 | { | 168 | { |
161 | return (struct in_device*)dev->ip_ptr; | 169 | return (struct in_device*)dev->ip_ptr; |
162 | } | 170 | } |