[PATCH 02/12] backport: add skb_ensure_writable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Emmanuel Grumbach <emmanuel.grumbach@xxxxxxxxx>

This was added to skbuff.c in 3.19. Backport it for older
kernels.
iwlwifi will need this soon.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@xxxxxxxxx>
[move skb_ensure_writable out of CONFIG_DEBUG_FS, use EXPORT_SYMBOL_GPL(), include linux/skbuff.h]
Signed-off-by: Hauke Mehrtens <hauke@xxxxxxxxxx>
---
 backport/backport-include/linux/skbuff.h |  4 ++++
 backport/compat/backport-3.19.c          | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/backport/backport-include/linux/skbuff.h b/backport/backport-include/linux/skbuff.h
index a21e6cc..888d2a0 100644
--- a/backport/backport-include/linux/skbuff.h
+++ b/backport/backport-include/linux/skbuff.h
@@ -294,6 +294,10 @@ static inline int skb_put_padto(struct sk_buff *skb, unsigned int len)
 	}
 	return 0;
 }
+
+#define skb_ensure_writable LINUX_BACKPORT(skb_ensure_writable)
+int skb_ensure_writable(struct sk_buff *skb, int write_len);
+
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) */
 
 #endif /* __BACKPORT_SKBUFF_H */
diff --git a/backport/compat/backport-3.19.c b/backport/compat/backport-3.19.c
index 8a241b7..3ad25bb 100644
--- a/backport/compat/backport-3.19.c
+++ b/backport/compat/backport-3.19.c
@@ -13,6 +13,7 @@
 #include <linux/export.h>
 #include <linux/net.h>
 #include <linux/netdevice.h>
+#include <linux/skbuff.h>
 #include <linux/debugfs.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,12)
@@ -148,3 +149,15 @@ struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
 EXPORT_SYMBOL_GPL(debugfs_create_devm_seqfile);
 
 #endif /* CONFIG_DEBUG_FS */
+
+int skb_ensure_writable(struct sk_buff *skb, int write_len)
+{
+	if (!pskb_may_pull(skb, write_len))
+		return -ENOMEM;
+
+	if (!skb_cloned(skb) || skb_clone_writable(skb, write_len))
+		return 0;
+
+	return pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
+}
+EXPORT_SYMBOL_GPL(skb_ensure_writable);
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe backports" in



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux