aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryonghong-song <ys114321@gmail.com>2018-10-10 16:48:15 -0700
committerGitHub <noreply@github.com>2018-10-10 16:48:15 -0700
commitd4b23876e456c1bffda6e8b39875fd271ab35d1b (patch)
tree989894009cc0b8c7d4fd2c2d6bb6a8db3fda3b1c
parent9f3662ee5f6b3d0c570024e1fcd754dd376657c7 (diff)
downloadbcc-d4b23876e456c1bffda6e8b39875fd271ab35d1b.zip
bcc-d4b23876e456c1bffda6e8b39875fd271ab35d1b.tar.gz
bcc-d4b23876e456c1bffda6e8b39875fd271ab35d1b.tar.bz2
sync with latest net-next bpf headers (#2001)
Sync compat bpf.h and virtual_bpf.h with latest net-next versions Also add a barrier for the test_brb bpf program like below meta.prog_id = skb->cb[0]; + asm volatile("" ::: "memory"); meta.rx_port_id = skb->cb[1]; so two cb read does not become a 8 byte load which is not allowed for ubuntu 16.04 kernel (4.4 based). The 8 byte load is allowed for skb->cb's for later kernels. Signed-off-by: Yonghong Song <yhs@fb.com>
-rw-r--r--docs/kernel-versions.md1
-rw-r--r--introspection/bps.c1
-rw-r--r--src/cc/compat/linux/bpf.h26
-rw-r--r--src/cc/compat/linux/virtual_bpf.h26
-rw-r--r--tests/python/test_brb.c1
5 files changed, 55 insertions, 0 deletions
diff --git a/docs/kernel-versions.md b/docs/kernel-versions.md
index 2a0c92b..fc85509 100644
--- a/docs/kernel-versions.md
+++ b/docs/kernel-versions.md
@@ -268,6 +268,7 @@ The list of program types and supported helper functions can be retrieved with:
|`BPF_PROG_TYPE_LWT_SEG6LOCAL`|`BPF_FUNC_lwt_seg6_store_bytes()` <br> `BPF_FUNC_lwt_seg6_action()` <br> `BPF_FUNC_lwt_seg6_adjust_srh()` <br> `LWT functions`|
|`BPF_PROG_TYPE_LIRC_MODE2`|`BPF_FUNC_rc_repeat()` <br> `BPF_FUNC_rc_keydown()` <br> `BPF_FUNC_map_lookup_elem()` <br> `BPF_FUNC_map_update_elem()` <br> `BPF_FUNC_map_delete_elem()` <br> `BPF_FUNC_ktime_get_ns()` <br> `BPF_FUNC_tail_call()` <br> `BPF_FUNC_get_prandom_u32()` <br> `BPF_FUNC_trace_printk()`|
|`BPF_PROG_TYPE_SK_REUSEPORT`|`BPF_FUNC_sk_select_reuseport()` <br> `BPF_FUNC_skb_load_bytes()` <br> `BPF_FUNC_load_bytes_relative()` <br> `Base functions`|
+|`BPF_PROG_TYPE_FLOW_DISSECTOR`|`BPF_FUNC_skb_load_bytes()` <br> `Base functions`|
|Function Group| Functions|
|------------------|-------|
diff --git a/introspection/bps.c b/introspection/bps.c
index 769eb1d..a809395 100644
--- a/introspection/bps.c
+++ b/introspection/bps.c
@@ -38,6 +38,7 @@ static const char * const prog_type_strings[] = {
[BPF_PROG_TYPE_CGROUP_SOCK_ADDR] = "cgroup_sock_addr",
[BPF_PROG_TYPE_LIRC_MODE2] = "lirc_mode2",
[BPF_PROG_TYPE_SK_REUSEPORT] = "sk_reuseport",
+ [BPF_PROG_TYPE_FLOW_DISSECTOR] = "flow_dissector",
};
static const char * const map_type_strings[] = {
diff --git a/src/cc/compat/linux/bpf.h b/src/cc/compat/linux/bpf.h
index 3e1d2c3..05b5460 100644
--- a/src/cc/compat/linux/bpf.h
+++ b/src/cc/compat/linux/bpf.h
@@ -152,6 +152,7 @@ enum bpf_prog_type {
BPF_PROG_TYPE_LWT_SEG6LOCAL,
BPF_PROG_TYPE_LIRC_MODE2,
BPF_PROG_TYPE_SK_REUSEPORT,
+ BPF_PROG_TYPE_FLOW_DISSECTOR,
};
enum bpf_attach_type {
@@ -172,6 +173,7 @@ enum bpf_attach_type {
BPF_CGROUP_UDP4_SENDMSG,
BPF_CGROUP_UDP6_SENDMSG,
BPF_LIRC_MODE2,
+ BPF_FLOW_DISSECTOR,
__MAX_BPF_ATTACH_TYPE
};
@@ -2333,6 +2335,7 @@ struct __sk_buff {
/* ... here. */
__u32 data_meta;
+ struct bpf_flow_keys *flow_keys;
};
struct bpf_tunnel_key {
@@ -2778,4 +2781,27 @@ enum bpf_task_fd_type {
BPF_FD_TYPE_URETPROBE, /* filename + offset */
};
+struct bpf_flow_keys {
+ __u16 nhoff;
+ __u16 thoff;
+ __u16 addr_proto; /* ETH_P_* of valid addrs */
+ __u8 is_frag;
+ __u8 is_first_frag;
+ __u8 is_encap;
+ __u8 ip_proto;
+ __be16 n_proto;
+ __be16 sport;
+ __be16 dport;
+ union {
+ struct {
+ __be32 ipv4_src;
+ __be32 ipv4_dst;
+ };
+ struct {
+ __u32 ipv6_src[4]; /* in6_addr; network order */
+ __u32 ipv6_dst[4]; /* in6_addr; network order */
+ };
+ };
+};
+
#endif /* _UAPI__LINUX_BPF_H__ */
diff --git a/src/cc/compat/linux/virtual_bpf.h b/src/cc/compat/linux/virtual_bpf.h
index 62b3e14..1911ad7 100644
--- a/src/cc/compat/linux/virtual_bpf.h
+++ b/src/cc/compat/linux/virtual_bpf.h
@@ -153,6 +153,7 @@ enum bpf_prog_type {
BPF_PROG_TYPE_LWT_SEG6LOCAL,
BPF_PROG_TYPE_LIRC_MODE2,
BPF_PROG_TYPE_SK_REUSEPORT,
+ BPF_PROG_TYPE_FLOW_DISSECTOR,
};
enum bpf_attach_type {
@@ -173,6 +174,7 @@ enum bpf_attach_type {
BPF_CGROUP_UDP4_SENDMSG,
BPF_CGROUP_UDP6_SENDMSG,
BPF_LIRC_MODE2,
+ BPF_FLOW_DISSECTOR,
__MAX_BPF_ATTACH_TYPE
};
@@ -2334,6 +2336,7 @@ struct __sk_buff {
/* ... here. */
__u32 data_meta;
+ struct bpf_flow_keys *flow_keys;
};
struct bpf_tunnel_key {
@@ -2779,5 +2782,28 @@ enum bpf_task_fd_type {
BPF_FD_TYPE_URETPROBE, /* filename + offset */
};
+struct bpf_flow_keys {
+ __u16 nhoff;
+ __u16 thoff;
+ __u16 addr_proto; /* ETH_P_* of valid addrs */
+ __u8 is_frag;
+ __u8 is_first_frag;
+ __u8 is_encap;
+ __u8 ip_proto;
+ __be16 n_proto;
+ __be16 sport;
+ __be16 dport;
+ union {
+ struct {
+ __be32 ipv4_src;
+ __be32 ipv4_dst;
+ };
+ struct {
+ __u32 ipv6_src[4]; /* in6_addr; network order */
+ __u32 ipv6_dst[4]; /* in6_addr; network order */
+ };
+ };
+};
+
#endif /* _UAPI__LINUX_BPF_H__ */
)********"
diff --git a/tests/python/test_brb.c b/tests/python/test_brb.c
index c2bf5fb..f999a5b 100644
--- a/tests/python/test_brb.c
+++ b/tests/python/test_brb.c
@@ -70,6 +70,7 @@ int pem(struct __sk_buff *skb) {
meta.prog_id = meta.rx_port_id = 0;
} else {
meta.prog_id = skb->cb[0];
+ asm volatile("" ::: "memory");
meta.rx_port_id = skb->cb[1];
}
if (!meta.prog_id) {