summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorZi Shen Lim <zlim.lnx@gmail.com>2014-07-03 14:56:54 (GMT)
committerDavid S. Miller <davem@davemloft.net>2014-07-08 21:20:00 (GMT)
commit9f12fbe603f7ae346b2b46008e325f0c9a68e55d (patch)
tree440fb57e08880b9a7fe5f9180dd7da9dae50a19c /include
parent3d5baba0ecfdd5de35bb7ce41ef9218f2b17b006 (diff)
downloadlinux-9f12fbe603f7ae346b2b46008e325f0c9a68e55d.tar.xz
net: filter: move load_pointer() into filter.h
load_pointer() is already a static inline function. Let's move it into filter.h so BPF JIT implementations can reuse this function. Since we're exporting this function, let's also rename it to bpf_load_pointer() for clarity. Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com> Reviewed-by: Daniel Borkmann <dborkman@redhat.com> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/filter.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h
index a7e3c48..b885dcb 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -6,6 +6,7 @@
#include <linux/atomic.h>
#include <linux/compat.h>
+#include <linux/skbuff.h>
#include <linux/workqueue.h>
#include <uapi/linux/filter.h>
@@ -406,6 +407,18 @@ static inline u16 bpf_anc_helper(const struct sock_filter *ftest)
}
}
+void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb,
+ int k, unsigned int size);
+
+static inline void *bpf_load_pointer(const struct sk_buff *skb, int k,
+ unsigned int size, void *buffer)
+{
+ if (k >= 0)
+ return skb_header_pointer(skb, k, size, buffer);
+
+ return bpf_internal_load_pointer_neg_helper(skb, k, size);
+}
+
#ifdef CONFIG_BPF_JIT
#include <stdarg.h>
#include <linux/linkage.h>