aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/bpf.h
diff options
context:
space:
mode:
authorAndrey Ignatov <rdna@fb.com>2019-02-27 16:28:48 -0500
committerAlexei Starovoitov <ast@kernel.org>2019-04-12 16:54:58 -0400
commit808649fb787d918a48a360a668ee4ee9023f0c11 (patch)
treea58fb657373b8886c6ddf715476f62484edc233d /include/uapi/linux/bpf.h
parent7b146cebe30cb481b0f70d85779da938da818637 (diff)
bpf: Introduce bpf_sysctl_get_name helper
Add bpf_sysctl_get_name() helper to copy sysctl name (/proc/sys/ entry) into provided by BPF_PROG_TYPE_CGROUP_SYSCTL program buffer. By default full name (w/o /proc/sys/) is copied, e.g. "net/ipv4/tcp_mem". If BPF_F_SYSCTL_BASE_NAME flag is set, only base name will be copied, e.g. "tcp_mem". Documentation for the new helper is provided in bpf.h UAPI. Signed-off-by: Andrey Ignatov <rdna@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/uapi/linux/bpf.h')
-rw-r--r--include/uapi/linux/bpf.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index cc2a2466d5f3..9c8a2f3ccb9b 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -2506,6 +2506,22 @@ union bpf_attr {
2506 * Return 2506 * Return
2507 * 0 if iph and th are a valid SYN cookie ACK, or a negative error 2507 * 0 if iph and th are a valid SYN cookie ACK, or a negative error
2508 * otherwise. 2508 * otherwise.
2509 *
2510 * int bpf_sysctl_get_name(struct bpf_sysctl *ctx, char *buf, size_t buf_len, u64 flags)
2511 * Description
2512 * Get name of sysctl in /proc/sys/ and copy it into provided by
2513 * program buffer *buf* of size *buf_len*.
2514 *
2515 * The buffer is always NUL terminated, unless it's zero-sized.
2516 *
2517 * If *flags* is zero, full name (e.g. "net/ipv4/tcp_mem") is
2518 * copied. Use **BPF_F_SYSCTL_BASE_NAME** flag to copy base name
2519 * only (e.g. "tcp_mem").
2520 * Return
2521 * Number of character copied (not including the trailing NUL).
2522 *
2523 * **-E2BIG** if the buffer wasn't big enough (*buf* will contain
2524 * truncated name in this case).
2509 */ 2525 */
2510#define __BPF_FUNC_MAPPER(FN) \ 2526#define __BPF_FUNC_MAPPER(FN) \
2511 FN(unspec), \ 2527 FN(unspec), \
@@ -2608,7 +2624,8 @@ union bpf_attr {
2608 FN(skb_ecn_set_ce), \ 2624 FN(skb_ecn_set_ce), \
2609 FN(get_listener_sock), \ 2625 FN(get_listener_sock), \
2610 FN(skc_lookup_tcp), \ 2626 FN(skc_lookup_tcp), \
2611 FN(tcp_check_syncookie), 2627 FN(tcp_check_syncookie), \
2628 FN(sysctl_get_name),
2612 2629
2613/* integer value in 'imm' field of BPF_CALL instruction selects which helper 2630/* integer value in 'imm' field of BPF_CALL instruction selects which helper
2614 * function eBPF program intends to call 2631 * function eBPF program intends to call
@@ -2681,6 +2698,9 @@ enum bpf_func_id {
2681 BPF_ADJ_ROOM_ENCAP_L2_MASK) \ 2698 BPF_ADJ_ROOM_ENCAP_L2_MASK) \
2682 << BPF_ADJ_ROOM_ENCAP_L2_SHIFT) 2699 << BPF_ADJ_ROOM_ENCAP_L2_SHIFT)
2683 2700
2701/* BPF_FUNC_sysctl_get_name flags. */
2702#define BPF_F_SYSCTL_BASE_NAME (1ULL << 0)
2703
2684/* Mode for BPF_FUNC_skb_adjust_room helper. */ 2704/* Mode for BPF_FUNC_skb_adjust_room helper. */
2685enum bpf_adj_room_mode { 2705enum bpf_adj_room_mode {
2686 BPF_ADJ_ROOM_NET, 2706 BPF_ADJ_ROOM_NET,