瀏覽代碼

[NETLINK]: Defer socket destruction a bit

In netlink_broadcast() we're sending shared skb's to netlink listeners
when possible (saves some copying). This is OK, since we hold the only
other reference to the skb.

However, this implies that we must drop our reference on the skb, before
allowing a receiving socket to disappear. Otherwise, the socket buffer
accounting is disrupted.

Signed-off-by: Tommy S. Christensen <tommy.christensen@tpack.net>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Tommy S. Christensen 20 年之前
父節點
當前提交
aa1c6a6f7f
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      net/netlink/af_netlink.c

+ 2 - 1
net/netlink/af_netlink.c

@@ -789,11 +789,12 @@ int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
 	sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
 	sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
 		do_one_broadcast(sk, &info);
 		do_one_broadcast(sk, &info);
 
 
+	kfree_skb(skb);
+
 	netlink_unlock_table();
 	netlink_unlock_table();
 
 
 	if (info.skb2)
 	if (info.skb2)
 		kfree_skb(info.skb2);
 		kfree_skb(info.skb2);
-	kfree_skb(skb);
 
 
 	if (info.delivered) {
 	if (info.delivered) {
 		if (info.congested && (allocation & __GFP_WAIT))
 		if (info.congested && (allocation & __GFP_WAIT))