Thread (288 messages) 288 messages, 13 authors, 2014-04-01
STALE4454d

[PATCH 1/3] net: Add a test to see if a skb is freeable in irq context

From: Eric W. Biederman <hidden>
Date: 2014-03-28 01:15:58
Subsystem: networking [general], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Currently netpoll and skb_release_head_state assume that a skb is
freeable in hard irq context except when skb->destructor is set.

The reality is far from this.  So add a function skb_irq_freeable to
compute the full test and in the process be the living documentation of
what the requirements are of actually freeing a skb in hard irq context.

Signed-off-by: "Eric W. Biederman" <redacted>
---
 include/linux/skbuff.h |   13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index aa2c22cb8158..50a909ca7b3b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2833,6 +2833,19 @@ static inline void skb_init_secmark(struct sk_buff *skb)
 { }
 #endif
 
+static inline bool skb_irq_freeable(struct sk_buff *skb)
+{
+	return !skb->destructor &&
+#if IS_ENABLED(CONFIG_XFRM)
+		!skb->sp &&
+#endif
+#if IS_ENABLED(CONFIG_NF_CONNTRACK)
+		!skb->nfct &&
+#endif
+		!skb->_skb_refdst &&
+		!skb_has_frag_list(skb);
+}
+
 static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
 {
 	skb->queue_mapping = queue_mapping;
-- 
1.7.10.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help