diff mbox

[net-next] net: skb_orphan() changes

Message ID 1375225875.10515.36.camel@edumazet-glaptop
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet July 30, 2013, 11:11 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

It is illegal to set skb->sk without corresponding destructor.

Its therefore safe for skb_orphan() to not clear skb->sk if
skb->destructor is not set.

Also avoid clearing skb->destructor if already NULL.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/skbuff.h |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)



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

Comments

David Miller July 31, 2013, 10:24 p.m. UTC | #1
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 30 Jul 2013 16:11:15 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> It is illegal to set skb->sk without corresponding destructor.
> 
> Its therefore safe for skb_orphan() to not clear skb->sk if
> skb->destructor is not set.
> 
> Also avoid clearing skb->destructor if already NULL.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied, but personally I would have considered adding an
else clause checking BUG_ON(skb->sk), or are you not so
confident in your assertion? :-)
--
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
Eric Dumazet July 31, 2013, 10:44 p.m. UTC | #2
On Wed, 2013-07-31 at 15:24 -0700, David Miller wrote:

> Applied, but personally I would have considered adding an
> else clause checking BUG_ON(skb->sk), or are you not so
> confident in your assertion? :-)

I considered this but this was adding a significant overhead, as this
is an inline function.

What about doing that for a limited time, say until 3.12 is released ?


--
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
David Miller July 31, 2013, 11:44 p.m. UTC | #3
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 31 Jul 2013 15:44:51 -0700

> On Wed, 2013-07-31 at 15:24 -0700, David Miller wrote:
> 
>> Applied, but personally I would have considered adding an
>> else clause checking BUG_ON(skb->sk), or are you not so
>> confident in your assertion? :-)
> 
> I considered this but this was adding a significant overhead, as this
> is an inline function.
> 
> What about doing that for a limited time, say until 3.12 is released ?

That sounds like a great idea.
--
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
diff mbox

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 5afefa0..a95547a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1805,10 +1805,11 @@  static inline void pskb_trim_unique(struct sk_buff *skb, unsigned int len)
  */
 static inline void skb_orphan(struct sk_buff *skb)
 {
-	if (skb->destructor)
+	if (skb->destructor) {
 		skb->destructor(skb);
-	skb->destructor = NULL;
-	skb->sk		= NULL;
+		skb->destructor = NULL;
+		skb->sk		= NULL;
+	}
 }
 
 /**