summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2014-12-20 23:09:27 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2014-12-21 17:07:49 +0100
commit43cf7675ef4665eaa43fb4ac109ff09c506dabc1 (patch)
tree3ab8f8c6af076b32a1aec84b3dac2814ab5ce1cc
parent781f444908ded793c27cd41a8e2f0d51b9591016 (diff)
header: add skb_put_padto()
skb_put_padto() is used by the igb driver. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--backport/backport-include/linux/skbuff.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/backport/backport-include/linux/skbuff.h b/backport/backport-include/linux/skbuff.h
index 53c1aa4b..687297c3 100644
--- a/backport/backport-include/linux/skbuff.h
+++ b/backport/backport-include/linux/skbuff.h
@@ -269,6 +269,30 @@ static inline int memcpy_from_msg(void *data, struct msghdr *msg, int len)
{
return memcpy_fromiovec(data, msg->msg_iov, len);
}
+
+/**
+ * skb_put_padto - increase size and pad an skbuff up to a minimal size
+ * @skb: buffer to pad
+ * @len: minimal length
+ *
+ * Pads up a buffer to ensure the trailing bytes exist and are
+ * blanked. If the buffer already contains sufficient data it
+ * is untouched. Otherwise it is extended. Returns zero on
+ * success. The skb is freed on error.
+ */
+#define skb_put_padto LINUX_BACKPORT(skb_put_padto)
+static inline int skb_put_padto(struct sk_buff *skb, unsigned int len)
+{
+ unsigned int size = skb->len;
+
+ if (unlikely(size < len)) {
+ len -= size;
+ if (skb_pad(skb, len))
+ return -ENOMEM;
+ __skb_put(skb, len);
+ }
+ return 0;
+}
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) */
#endif /* __BACKPORT_SKBUFF_H */