diff options
| -rw-r--r-- | net/core/dst.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/net/core/dst.c b/net/core/dst.c index cb1b3488b739..2076d84203d1 100644 --- a/net/core/dst.c +++ b/net/core/dst.c | |||
| @@ -43,7 +43,7 @@ static atomic_t dst_total = ATOMIC_INIT(0); | |||
| 43 | */ | 43 | */ |
| 44 | static struct { | 44 | static struct { |
| 45 | spinlock_t lock; | 45 | spinlock_t lock; |
| 46 | struct dst_entry *list; | 46 | struct dst_entry *list; |
| 47 | unsigned long timer_inc; | 47 | unsigned long timer_inc; |
| 48 | unsigned long timer_expires; | 48 | unsigned long timer_expires; |
| 49 | } dst_garbage = { | 49 | } dst_garbage = { |
| @@ -51,7 +51,7 @@ static struct { | |||
| 51 | .timer_inc = DST_GC_MAX, | 51 | .timer_inc = DST_GC_MAX, |
| 52 | }; | 52 | }; |
| 53 | static void dst_gc_task(struct work_struct *work); | 53 | static void dst_gc_task(struct work_struct *work); |
| 54 | static void ___dst_free(struct dst_entry * dst); | 54 | static void ___dst_free(struct dst_entry *dst); |
| 55 | 55 | ||
| 56 | static DECLARE_DELAYED_WORK(dst_gc_work, dst_gc_task); | 56 | static DECLARE_DELAYED_WORK(dst_gc_work, dst_gc_task); |
| 57 | 57 | ||
| @@ -135,8 +135,8 @@ loop: | |||
| 135 | } | 135 | } |
| 136 | expires = dst_garbage.timer_expires; | 136 | expires = dst_garbage.timer_expires; |
| 137 | /* | 137 | /* |
| 138 | * if the next desired timer is more than 4 seconds in the future | 138 | * if the next desired timer is more than 4 seconds in the |
| 139 | * then round the timer to whole seconds | 139 | * future then round the timer to whole seconds |
| 140 | */ | 140 | */ |
| 141 | if (expires > 4*HZ) | 141 | if (expires > 4*HZ) |
| 142 | expires = round_jiffies_relative(expires); | 142 | expires = round_jiffies_relative(expires); |
| @@ -151,7 +151,8 @@ loop: | |||
| 151 | " expires: %lu elapsed: %lu us\n", | 151 | " expires: %lu elapsed: %lu us\n", |
| 152 | atomic_read(&dst_total), delayed, work_performed, | 152 | atomic_read(&dst_total), delayed, work_performed, |
| 153 | expires, | 153 | expires, |
| 154 | elapsed.tv_sec * USEC_PER_SEC + elapsed.tv_nsec / NSEC_PER_USEC); | 154 | elapsed.tv_sec * USEC_PER_SEC + |
| 155 | elapsed.tv_nsec / NSEC_PER_USEC); | ||
| 155 | #endif | 156 | #endif |
| 156 | } | 157 | } |
| 157 | 158 | ||
| @@ -162,9 +163,9 @@ int dst_discard(struct sk_buff *skb) | |||
| 162 | } | 163 | } |
| 163 | EXPORT_SYMBOL(dst_discard); | 164 | EXPORT_SYMBOL(dst_discard); |
| 164 | 165 | ||
| 165 | void * dst_alloc(struct dst_ops * ops) | 166 | void *dst_alloc(struct dst_ops *ops) |
| 166 | { | 167 | { |
| 167 | struct dst_entry * dst; | 168 | struct dst_entry *dst; |
| 168 | 169 | ||
| 169 | if (ops->gc && atomic_read(&ops->entries) > ops->gc_thresh) { | 170 | if (ops->gc && atomic_read(&ops->entries) > ops->gc_thresh) { |
| 170 | if (ops->gc(ops)) | 171 | if (ops->gc(ops)) |
| @@ -184,19 +185,20 @@ void * dst_alloc(struct dst_ops * ops) | |||
| 184 | atomic_inc(&ops->entries); | 185 | atomic_inc(&ops->entries); |
| 185 | return dst; | 186 | return dst; |
| 186 | } | 187 | } |
| 188 | EXPORT_SYMBOL(dst_alloc); | ||
| 187 | 189 | ||
| 188 | static void ___dst_free(struct dst_entry * dst) | 190 | static void ___dst_free(struct dst_entry *dst) |
| 189 | { | 191 | { |
| 190 | /* The first case (dev==NULL) is required, when | 192 | /* The first case (dev==NULL) is required, when |
| 191 | protocol module is unloaded. | 193 | protocol module is unloaded. |
| 192 | */ | 194 | */ |
| 193 | if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) { | 195 | if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) |
| 194 | dst->input = dst->output = dst_discard; | 196 | dst->input = dst->output = dst_discard; |
| 195 | } | ||
| 196 | dst->obsolete = 2; | 197 | dst->obsolete = 2; |
| 197 | } | 198 | } |
| 199 | EXPORT_SYMBOL(__dst_free); | ||
| 198 | 200 | ||
| 199 | void __dst_free(struct dst_entry * dst) | 201 | void __dst_free(struct dst_entry *dst) |
| 200 | { | 202 | { |
| 201 | spin_lock_bh(&dst_garbage.lock); | 203 | spin_lock_bh(&dst_garbage.lock); |
| 202 | ___dst_free(dst); | 204 | ___dst_free(dst); |
| @@ -261,15 +263,16 @@ again: | |||
| 261 | } | 263 | } |
| 262 | return NULL; | 264 | return NULL; |
| 263 | } | 265 | } |
| 266 | EXPORT_SYMBOL(dst_destroy); | ||
| 264 | 267 | ||
| 265 | void dst_release(struct dst_entry *dst) | 268 | void dst_release(struct dst_entry *dst) |
| 266 | { | 269 | { |
| 267 | if (dst) { | 270 | if (dst) { |
| 268 | int newrefcnt; | 271 | int newrefcnt; |
| 269 | 272 | ||
| 270 | smp_mb__before_atomic_dec(); | 273 | smp_mb__before_atomic_dec(); |
| 271 | newrefcnt = atomic_dec_return(&dst->__refcnt); | 274 | newrefcnt = atomic_dec_return(&dst->__refcnt); |
| 272 | WARN_ON(newrefcnt < 0); | 275 | WARN_ON(newrefcnt < 0); |
| 273 | } | 276 | } |
| 274 | } | 277 | } |
| 275 | EXPORT_SYMBOL(dst_release); | 278 | EXPORT_SYMBOL(dst_release); |
| @@ -305,7 +308,8 @@ static inline void dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
| 305 | } | 308 | } |
| 306 | } | 309 | } |
| 307 | 310 | ||
| 308 | static int dst_dev_event(struct notifier_block *this, unsigned long event, void *ptr) | 311 | static int dst_dev_event(struct notifier_block *this, unsigned long event, |
| 312 | void *ptr) | ||
| 309 | { | 313 | { |
| 310 | struct net_device *dev = ptr; | 314 | struct net_device *dev = ptr; |
| 311 | struct dst_entry *dst, *last = NULL; | 315 | struct dst_entry *dst, *last = NULL; |
| @@ -328,9 +332,8 @@ static int dst_dev_event(struct notifier_block *this, unsigned long event, void | |||
| 328 | last->next = dst; | 332 | last->next = dst; |
| 329 | else | 333 | else |
| 330 | dst_busy_list = dst; | 334 | dst_busy_list = dst; |
| 331 | for (; dst; dst = dst->next) { | 335 | for (; dst; dst = dst->next) |
| 332 | dst_ifdown(dst, dev, event != NETDEV_DOWN); | 336 | dst_ifdown(dst, dev, event != NETDEV_DOWN); |
| 333 | } | ||
| 334 | mutex_unlock(&dst_gc_mutex); | 337 | mutex_unlock(&dst_gc_mutex); |
| 335 | break; | 338 | break; |
| 336 | } | 339 | } |
| @@ -345,7 +348,3 @@ void __init dst_init(void) | |||
| 345 | { | 348 | { |
| 346 | register_netdevice_notifier(&dst_dev_notifier); | 349 | register_netdevice_notifier(&dst_dev_notifier); |
| 347 | } | 350 | } |
| 348 | |||
| 349 | EXPORT_SYMBOL(__dst_free); | ||
| 350 | EXPORT_SYMBOL(dst_alloc); | ||
| 351 | EXPORT_SYMBOL(dst_destroy); | ||
