diff options
Diffstat (limited to 'net/core/dst.c')
| -rw-r--r-- | net/core/dst.c | 31 | 
1 files changed, 20 insertions, 11 deletions
diff --git a/net/core/dst.c b/net/core/dst.c index ca4231ec734..a028409ee43 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -142,12 +142,12 @@ loop:  	mutex_unlock(&dst_gc_mutex);  } -int dst_discard(struct sk_buff *skb) +int dst_discard_sk(struct sock *sk, struct sk_buff *skb)  {  	kfree_skb(skb);  	return 0;  } -EXPORT_SYMBOL(dst_discard); +EXPORT_SYMBOL(dst_discard_sk);  const u32 dst_default_metrics[RTAX_MAX + 1] = {  	/* This initializer is needed to force linker to place this variable @@ -184,7 +184,7 @@ void *dst_alloc(struct dst_ops *ops, struct net_device *dev,  	dst->xfrm = NULL;  #endif  	dst->input = dst_discard; -	dst->output = dst_discard; +	dst->output = dst_discard_sk;  	dst->error = 0;  	dst->obsolete = initial_obsolete;  	dst->header_len = 0; @@ -209,8 +209,10 @@ static void ___dst_free(struct dst_entry *dst)  	/* The first case (dev==NULL) is required, when  	   protocol module is unloaded.  	 */ -	if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) -		dst->input = dst->output = dst_discard; +	if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) { +		dst->input = dst_discard; +		dst->output = dst_discard_sk; +	}  	dst->obsolete = DST_OBSOLETE_DEAD;  } @@ -267,6 +269,15 @@ again:  }  EXPORT_SYMBOL(dst_destroy); +static void dst_destroy_rcu(struct rcu_head *head) +{ +	struct dst_entry *dst = container_of(head, struct dst_entry, rcu_head); + +	dst = dst_destroy(dst); +	if (dst) +		__dst_free(dst); +} +  void dst_release(struct dst_entry *dst)  {  	if (dst) { @@ -274,11 +285,8 @@ void dst_release(struct dst_entry *dst)  		newrefcnt = atomic_dec_return(&dst->__refcnt);  		WARN_ON(newrefcnt < 0); -		if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt) { -			dst = dst_destroy(dst); -			if (dst) -				__dst_free(dst); -		} +		if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt) +			call_rcu(&dst->rcu_head, dst_destroy_rcu);  	}  }  EXPORT_SYMBOL(dst_release); @@ -361,7 +369,8 @@ static void dst_ifdown(struct dst_entry *dst, struct net_device *dev,  		return;  	if (!unregister) { -		dst->input = dst->output = dst_discard; +		dst->input = dst_discard; +		dst->output = dst_discard_sk;  	} else {  		dst->dev = dev_net(dst->dev)->loopback_dev;  		dev_hold(dst->dev);  | 
