[PATCH] [NET] warn when accounting an skb that already has a destructor

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David S. Miller <davem@...>
Cc: netdev <netdev@...>
Date: Sunday, May 4, 2008 - 2:32 pm

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);


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] [NET] warn when accounting an skb that already has a..., Johannes Berg, (Sun May 4, 2:32 pm)
Re: [PATCH] [NET] warn when accounting an skb that already h..., Arnaldo Carvalho de Melo, (Mon May 5, 5:57 pm)