aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChema Gonzalez <chema@google.com>2014-04-21 12:21:24 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-22 21:27:57 -0400
commit4cd3675ebf74d7f559038ded6aa8088e4099a83d (patch)
tree6988d7dc3352fbcce10c5c510ffa11e6f30217de /include
parent5a4ae5f6e7d4b2b5a9b8981d513345053e40b6ac (diff)
filter: added BPF random opcode
Added a new ancillary load (bpf call in eBPF parlance) that produces a 32-bit random number. We are implementing it as an ancillary load (instead of an ISA opcode) because (a) it is simpler, (b) allows easy JITing, and (c) seems more in line with generic ISAs that do not have "get a random number" as a instruction, but as an OS call. The main use for this ancillary load is to perform random packet sampling. Signed-off-by: Chema Gonzalez <chema@google.com> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Acked-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/filter.h1
-rw-r--r--include/uapi/linux/filter.h3
2 files changed, 3 insertions, 1 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 024fd03e5d18..759abf78dd61 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -223,6 +223,7 @@ enum {
223 BPF_S_ANC_VLAN_TAG, 223 BPF_S_ANC_VLAN_TAG,
224 BPF_S_ANC_VLAN_TAG_PRESENT, 224 BPF_S_ANC_VLAN_TAG_PRESENT,
225 BPF_S_ANC_PAY_OFFSET, 225 BPF_S_ANC_PAY_OFFSET,
226 BPF_S_ANC_RANDOM,
226}; 227};
227 228
228#endif /* __LINUX_FILTER_H__ */ 229#endif /* __LINUX_FILTER_H__ */
diff --git a/include/uapi/linux/filter.h b/include/uapi/linux/filter.h
index 8eb9ccaa5b48..253b4d42cf2b 100644
--- a/include/uapi/linux/filter.h
+++ b/include/uapi/linux/filter.h
@@ -130,7 +130,8 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
130#define SKF_AD_VLAN_TAG 44 130#define SKF_AD_VLAN_TAG 44
131#define SKF_AD_VLAN_TAG_PRESENT 48 131#define SKF_AD_VLAN_TAG_PRESENT 48
132#define SKF_AD_PAY_OFFSET 52 132#define SKF_AD_PAY_OFFSET 52
133#define SKF_AD_MAX 56 133#define SKF_AD_RANDOM 56
134#define SKF_AD_MAX 60
134#define SKF_NET_OFF (-0x100000) 135#define SKF_NET_OFF (-0x100000)
135#define SKF_LL_OFF (-0x200000) 136#define SKF_LL_OFF (-0x200000)
136 137