netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [NET] warn when accounting an skb that already has a destructor
@ 2008-05-04 18:32 Johannes Berg
  2008-05-05  7:20 ` David Miller
  0 siblings, 1 reply; 11+ messages in thread
From: Johannes Berg @ 2008-05-04 18:32 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

This makes the networking layer warn when something tries to
charge an skb to a socket that already is charged to another
socket (or has a destructor from somewhere else.)

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
Not sure if the code size increase is prohibitive, haven't really
checked. Might have helped in early mac80211 days (when we didn't
have the skb_orphan call) but for normal skb usage this shouldn't
ever happen.

 include/net/sock.h |    2 ++
 1 file changed, 2 insertions(+)

--- everything.orig/include/net/sock.h	2008-05-03 15:51:36.000000000 +0200
+++ everything/include/net/sock.h	2008-05-03 15:51:56.000000000 +0200
@@ -1167,6 +1167,7 @@ static inline void skb_set_owner_w(struc
 {
 	sock_hold(sk);
 	skb->sk = sk;
+	WARN_ON(skb->destructor);
 	skb->destructor = sock_wfree;
 	atomic_add(skb->truesize, &sk->sk_wmem_alloc);
 }
@@ -1174,6 +1175,7 @@ static inline void skb_set_owner_w(struc
 static inline void skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
 {
 	skb->sk = sk;
+	WARN_ON(skb->destructor);
 	skb->destructor = sock_rfree;
 	atomic_add(skb->truesize, &sk->sk_rmem_alloc);
 	sk_mem_charge(sk, skb->truesize);



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-05-06  8:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-04 18:32 [PATCH] [NET] warn when accounting an skb that already has a destructor Johannes Berg
2008-05-05  7:20 ` David Miller
2008-05-05  7:31   ` Johannes Berg
2008-05-05  7:40     ` David Miller
2008-05-05  9:43       ` Ilpo Järvinen
2008-05-05 11:37         ` Johannes Berg
2008-05-05 11:58           ` Ilpo Järvinen
2008-05-05 12:04             ` Johannes Berg
2008-05-05 19:08         ` David Miller
2008-05-05 21:57           ` Arnaldo Carvalho de Melo
2008-05-06  8:39             ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).