summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2003-01-10 04:13:16 -0800
committerLinus Torvalds <torvalds@home.transmeta.com>2003-01-10 04:13:16 -0800
commitbfe8242260a75be62af1426efb8e0c72cccf4451 (patch)
tree5d295b9db46344e2be7c198bb6ec26ce537ad124 /include/linux
parentc257c8b6abece73573eb913663c24190aed0397e (diff)
[PATCH] add skb_pad/skb_padto functionality
This is the stuff in 2.4 which DaveM has been over so I hope is ok for 2.5. It provides a simple API for driver writers with hardware that doesn't do packet padding to say 'make sure n bytes beyond the data is all clear' for DMA etc.
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/skbuff.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f94999dcfb1c..e364ce6c003c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -287,6 +287,7 @@ extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
int newheadroom, int newtailroom,
int priority);
+extern struct sk_buff * skb_pad(struct sk_buff *skb, int pad);
#define dev_kfree_skb(a) kfree_skb(a)
extern void skb_over_panic(struct sk_buff *skb, int len,
void *here);
@@ -1088,6 +1089,26 @@ static inline int skb_cow(struct sk_buff *skb, unsigned int headroom)
}
/**
+ * skb_padto - 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. Returns the buffer, which may be a replacement
+ * for the original, or NULL for out of memory - in which case
+ * the original buffer is still freed.
+ */
+
+static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len)
+{
+ unsigned int size = skb->len + skb->data_len;
+ if (likely(size >= len))
+ return skb;
+ return skb_pad(skb, len-size);
+}
+
+/**
* skb_linearize - convert paged skb to linear one
* @skb: buffer to linarize
* @gfp: allocation mode