X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=net%2Fcore%2Fdst.c;h=c6a05879d58cd3c87fb854541bb3c3440d858de9;hb=40b77c943468236c6dfad3e7b94348fe70c70331;hp=836ec66069254752c7ca2b9db0a597419dd758a2;hpb=1c1afa3c053d4ccdf44e5a4e159005cdfd48bfc6;p=linux-2.6 diff --git a/net/core/dst.c b/net/core/dst.c index 836ec66069..c6a05879d5 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -29,7 +28,7 @@ * 4) All operations modify state, so a spinlock is used. */ static struct dst_entry *dst_garbage_list; -#if RT_CACHE_DEBUG >= 2 +#if RT_CACHE_DEBUG >= 2 static atomic_t dst_total = ATOMIC_INIT(0); #endif static DEFINE_SPINLOCK(dst_lock); @@ -99,19 +98,20 @@ static void dst_run_gc(unsigned long dummy) printk("dst_total: %d/%d %ld\n", atomic_read(&dst_total), delayed, dst_gc_timer_expires); #endif - mod_timer(&dst_gc_timer, jiffies + dst_gc_timer_expires); + /* if the next desired timer is more than 4 seconds in the future + * then round the timer to whole seconds + */ + if (dst_gc_timer_expires > 4*HZ) + mod_timer(&dst_gc_timer, + round_jiffies(jiffies + dst_gc_timer_expires)); + else + mod_timer(&dst_gc_timer, jiffies + dst_gc_timer_expires); out: spin_unlock(&dst_lock); } -static int dst_discard_in(struct sk_buff *skb) -{ - kfree_skb(skb); - return 0; -} - -static int dst_discard_out(struct sk_buff *skb) +static int dst_discard(struct sk_buff *skb) { kfree_skb(skb); return 0; @@ -125,17 +125,15 @@ void * dst_alloc(struct dst_ops * ops) if (ops->gc()) return NULL; } - dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC); + dst = kmem_cache_zalloc(ops->kmem_cachep, GFP_ATOMIC); if (!dst) return NULL; - memset(dst, 0, ops->entry_size); atomic_set(&dst->__refcnt, 0); dst->ops = ops; dst->lastuse = jiffies; dst->path = dst; - dst->input = dst_discard_in; - dst->output = dst_discard_out; -#if RT_CACHE_DEBUG >= 2 + dst->input = dst->output = dst_discard; +#if RT_CACHE_DEBUG >= 2 atomic_inc(&dst_total); #endif atomic_inc(&ops->entries); @@ -148,8 +146,7 @@ static void ___dst_free(struct dst_entry * dst) protocol module is unloaded. */ if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) { - dst->input = dst_discard_in; - dst->output = dst_discard_out; + dst->input = dst->output = dst_discard; } dst->obsolete = 2; } @@ -196,7 +193,7 @@ again: dst->ops->destroy(dst); if (dst->dev) dev_put(dst->dev); -#if RT_CACHE_DEBUG >= 2 +#if RT_CACHE_DEBUG >= 2 atomic_dec(&dst_total); #endif kmem_cache_free(dst->ops->kmem_cachep, dst); @@ -237,8 +234,7 @@ static inline void dst_ifdown(struct dst_entry *dst, struct net_device *dev, return; if (!unregister) { - dst->input = dst_discard_in; - dst->output = dst_discard_out; + dst->input = dst->output = dst_discard; } else { dst->dev = &loopback_dev; dev_hold(&loopback_dev);