[Top] [All Lists]

[PATCH] netlink: defer socket destruction a bit

To: "David S. Miller" <davem@xxxxxxxxxxxxx>, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Subject: [PATCH] netlink: defer socket destruction a bit
From: Tommy Christensen <tommy.christensen@xxxxxxxxx>
Date: Thu, 12 May 2005 00:19:02 +0200
Cc: netdev@xxxxxxxxxxx, Ken-ichirou MATSUZAWA <chamas@xxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803
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@xxxxxxxxx>
diff -ru linux-2.6.12-rc4/net/netlink/af_netlink.c 
--- linux-2.6.12-rc4/net/netlink/af_netlink.c   2005-05-11 11:10:20.000000000 
+++ linux-2.6.12-work/net/netlink/af_netlink.c  2005-05-12 00:11:08.990990172 
@@ -785,11 +785,12 @@
        sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
                do_one_broadcast(sk, &info);
+       kfree_skb(skb);
        if (info.skb2)
-       kfree_skb(skb);
        if (info.delivered) {
                if (info.congested && (allocation & __GFP_WAIT))
<Prev in Thread] Current Thread [Next in Thread>