summaryrefslogtreecommitdiff
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@nuts.davemloft.net>2004-08-18 03:15:29 -0700
committerDavid S. Miller <davem@nuts.davemloft.net>2004-08-18 03:15:29 -0700
commit274cac6df0970c5504e94b4e17b946cdab945e49 (patch)
tree6c38d0a6ae4c4e0423a7032ce74e007b41faf5fc /include/linux/skbuff.h
parent4638004e22f76ac6e6b086b2575acf4d71340678 (diff)
[NET]: Add skb_header_pointer, and use it where possible.
This greatly improves netfilter performance where the wanted header area is in the linear SKB data area, therefore no copy into the temporary buffer is needed. Signed-off-by: David S. Miller <davem@redhat.com>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 354f1ff564bb..256c05c11298 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1107,6 +1107,20 @@ extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
extern void skb_split(struct sk_buff *skb,
struct sk_buff *skb1, const u32 len);
+static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
+ int len, void *buffer)
+{
+ int hlen = skb_headlen(skb);
+
+ if (offset + len <= hlen)
+ return skb->data + offset;
+
+ if (skb_copy_bits(skb, offset, buffer, len) < 0)
+ return NULL;
+
+ return buffer;
+}
+
extern void skb_init(void);
extern void skb_add_mtu(int mtu);