From: Yonghong Song <yhs@fb.com>
Date: Sun, 3 Jun 2018 15:59:42 -0700
Subject: tools/bpf: sync uapi bpf.h for bpf_get_current_cgroup_id() helper
Patch-mainline: v4.18-rc1
Git-commit: c7ddbbaf1e73e2f4e95cfda7b1da1be7fd199a4d
References: bsc#1109837
Sync kernel uapi/linux/bpf.h with tools uapi/linux/bpf.h.
Also add the necessary helper define in bpf_helpers.h.
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
tools/include/uapi/linux/bpf.h | 8 +++++++-
tools/testing/selftests/bpf/bpf_helpers.h | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -1893,6 +1893,11 @@ union bpf_attr {
* **CONFIG_SOCK_CGROUP_DATA** configuration option.
* Return
* The id is returned or 0 in case the id could not be retrieved.
+ *
+ * u64 bpf_get_current_cgroup_id(void)
+ * Return
+ * A 64-bit integer containing the current cgroup id based
+ * on the cgroup within which the current task is running.
*/
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
@@ -1967,7 +1972,8 @@ union bpf_attr {
FN(sock_hash_update), \
FN(msg_redirect_hash), \
FN(sk_redirect_hash), \
- FN(skb_cgroup_id),
+ FN(skb_cgroup_id), \
+ FN(get_current_cgroup_id),
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
* function eBPF program intends to call
--- a/tools/testing/selftests/bpf/bpf_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_helpers.h
@@ -110,6 +110,8 @@ static int (*bpf_skb_get_xfrm_state)(voi
(void *) BPF_FUNC_skb_get_xfrm_state;
static int (*bpf_get_stack)(void *ctx, void *buf, int size, int flags) =
(void *) BPF_FUNC_get_stack;
+static unsigned long long (*bpf_get_current_cgroup_id)(void) =
+ (void *) BPF_FUNC_get_current_cgroup_id;
/* llvm builtin functions that eBPF C program may use to
* emit BPF_LD_ABS and BPF_LD_IND instructions