diff options
| author | Alexei Starovoitov <ast@fb.com> | 2017-10-22 13:29:06 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2017-10-22 20:06:31 -0400 |
| commit | e27afb84b4680570b64c958dfcba9e0b3da92fc9 (patch) | |
| tree | 9ca8f99bbd1c4019508481b20844dddea9c47034 /tools/include | |
| parent | f8ddadc4db6c7b7029b6d0e0d9af24f74ad27ca2 (diff) | |
selftests/bpf: fix broken build of test_maps
fix multiple build errors and warnings
1.
test_maps.c: In function ‘test_map_rdonly’:
test_maps.c:1051:30: error: ‘BPF_F_RDONLY’ undeclared (first use in this function)
MAP_SIZE, map_flags | BPF_F_RDONLY);
2.
test_maps.c:1048:6: warning: unused variable ‘i’ [-Wunused-variable]
int i, fd, key = 0, value = 0;
3.
test_maps.c:1087:2: error: called object is not a function or function pointer
assert(bpf_map_lookup_elem(fd, &key, &value) == -1 && errno == EPERM);
4.
./bpf_helpers.h:72:11: error: use of undeclared identifier 'BPF_FUNC_getsockopt'
(void *) BPF_FUNC_getsockopt;
Fixes: e043325b3087 ("bpf: Add tests for eBPF file mode")
Fixes: 6e71b04a8224 ("bpf: Add file mode configuration into bpf maps")
Fixes: cd86d1fd2102 ("bpf: Adding helper function bpf_getsockops")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/include')
| -rw-r--r-- | tools/include/uapi/linux/bpf.h | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 850a5497dcc3..f650346aaa1a 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h | |||
| @@ -218,6 +218,10 @@ enum bpf_attach_type { | |||
| 218 | 218 | ||
| 219 | #define BPF_OBJ_NAME_LEN 16U | 219 | #define BPF_OBJ_NAME_LEN 16U |
| 220 | 220 | ||
| 221 | /* Flags for accessing BPF object */ | ||
| 222 | #define BPF_F_RDONLY (1U << 3) | ||
| 223 | #define BPF_F_WRONLY (1U << 4) | ||
| 224 | |||
| 221 | union bpf_attr { | 225 | union bpf_attr { |
| 222 | struct { /* anonymous struct used by BPF_MAP_CREATE command */ | 226 | struct { /* anonymous struct used by BPF_MAP_CREATE command */ |
| 223 | __u32 map_type; /* one of enum bpf_map_type */ | 227 | __u32 map_type; /* one of enum bpf_map_type */ |
| @@ -260,6 +264,7 @@ union bpf_attr { | |||
| 260 | struct { /* anonymous struct used by BPF_OBJ_* commands */ | 264 | struct { /* anonymous struct used by BPF_OBJ_* commands */ |
| 261 | __aligned_u64 pathname; | 265 | __aligned_u64 pathname; |
| 262 | __u32 bpf_fd; | 266 | __u32 bpf_fd; |
| 267 | __u32 file_flags; | ||
| 263 | }; | 268 | }; |
| 264 | 269 | ||
| 265 | struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */ | 270 | struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */ |
| @@ -287,6 +292,7 @@ union bpf_attr { | |||
| 287 | __u32 map_id; | 292 | __u32 map_id; |
| 288 | }; | 293 | }; |
| 289 | __u32 next_id; | 294 | __u32 next_id; |
| 295 | __u32 open_flags; | ||
| 290 | }; | 296 | }; |
| 291 | 297 | ||
| 292 | struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */ | 298 | struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */ |
| @@ -607,12 +613,22 @@ union bpf_attr { | |||
| 607 | * int bpf_setsockopt(bpf_socket, level, optname, optval, optlen) | 613 | * int bpf_setsockopt(bpf_socket, level, optname, optval, optlen) |
| 608 | * Calls setsockopt. Not all opts are available, only those with | 614 | * Calls setsockopt. Not all opts are available, only those with |
| 609 | * integer optvals plus TCP_CONGESTION. | 615 | * integer optvals plus TCP_CONGESTION. |
| 610 | * Supported levels: SOL_SOCKET and IPROTO_TCP | 616 | * Supported levels: SOL_SOCKET and IPPROTO_TCP |
| 611 | * @bpf_socket: pointer to bpf_socket | 617 | * @bpf_socket: pointer to bpf_socket |
| 612 | * @level: SOL_SOCKET or IPROTO_TCP | 618 | * @level: SOL_SOCKET or IPPROTO_TCP |
| 613 | * @optname: option name | 619 | * @optname: option name |
| 614 | * @optval: pointer to option value | 620 | * @optval: pointer to option value |
| 615 | * @optlen: length of optval in byes | 621 | * @optlen: length of optval in bytes |
| 622 | * Return: 0 or negative error | ||
| 623 | * | ||
| 624 | * int bpf_getsockopt(bpf_socket, level, optname, optval, optlen) | ||
| 625 | * Calls getsockopt. Not all opts are available. | ||
| 626 | * Supported levels: IPPROTO_TCP | ||
| 627 | * @bpf_socket: pointer to bpf_socket | ||
| 628 | * @level: IPPROTO_TCP | ||
| 629 | * @optname: option name | ||
| 630 | * @optval: pointer to option value | ||
| 631 | * @optlen: length of optval in bytes | ||
| 616 | * Return: 0 or negative error | 632 | * Return: 0 or negative error |
| 617 | * | 633 | * |
| 618 | * int bpf_skb_adjust_room(skb, len_diff, mode, flags) | 634 | * int bpf_skb_adjust_room(skb, len_diff, mode, flags) |
| @@ -623,10 +639,9 @@ union bpf_attr { | |||
| 623 | * @flags: reserved for future use | 639 | * @flags: reserved for future use |
| 624 | * Return: 0 on success or negative error code | 640 | * Return: 0 on success or negative error code |
| 625 | * | 641 | * |
| 626 | * int bpf_sk_redirect_map(skb, map, key, flags) | 642 | * int bpf_sk_redirect_map(map, key, flags) |
| 627 | * Redirect skb to a sock in map using key as a lookup key for the | 643 | * Redirect skb to a sock in map using key as a lookup key for the |
| 628 | * sock in map. | 644 | * sock in map. |
| 629 | * @skb: pointer to skb | ||
| 630 | * @map: pointer to sockmap | 645 | * @map: pointer to sockmap |
| 631 | * @key: key to lookup sock in map | 646 | * @key: key to lookup sock in map |
| 632 | * @flags: reserved for future use | 647 | * @flags: reserved for future use |
| @@ -643,6 +658,21 @@ union bpf_attr { | |||
| 643 | * @xdp_md: pointer to xdp_md | 658 | * @xdp_md: pointer to xdp_md |
| 644 | * @delta: An positive/negative integer to be added to xdp_md.data_meta | 659 | * @delta: An positive/negative integer to be added to xdp_md.data_meta |
| 645 | * Return: 0 on success or negative on error | 660 | * Return: 0 on success or negative on error |
| 661 | * | ||
| 662 | * int bpf_perf_event_read_value(map, flags, buf, buf_size) | ||
| 663 | * read perf event counter value and perf event enabled/running time | ||
| 664 | * @map: pointer to perf_event_array map | ||
| 665 | * @flags: index of event in the map or bitmask flags | ||
| 666 | * @buf: buf to fill | ||
| 667 | * @buf_size: size of the buf | ||
| 668 | * Return: 0 on success or negative error code | ||
| 669 | * | ||
| 670 | * int bpf_perf_prog_read_value(ctx, buf, buf_size) | ||
| 671 | * read perf prog attached perf event counter and enabled/running time | ||
| 672 | * @ctx: pointer to ctx | ||
| 673 | * @buf: buf to fill | ||
| 674 | * @buf_size: size of the buf | ||
| 675 | * Return : 0 on success or negative error code | ||
| 646 | */ | 676 | */ |
| 647 | #define __BPF_FUNC_MAPPER(FN) \ | 677 | #define __BPF_FUNC_MAPPER(FN) \ |
| 648 | FN(unspec), \ | 678 | FN(unspec), \ |
| @@ -701,7 +731,8 @@ union bpf_attr { | |||
| 701 | FN(sock_map_update), \ | 731 | FN(sock_map_update), \ |
| 702 | FN(xdp_adjust_meta), \ | 732 | FN(xdp_adjust_meta), \ |
| 703 | FN(perf_event_read_value), \ | 733 | FN(perf_event_read_value), \ |
| 704 | FN(perf_prog_read_value), | 734 | FN(perf_prog_read_value), \ |
| 735 | FN(getsockopt), | ||
| 705 | 736 | ||
| 706 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 737 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 707 | * function eBPF program intends to call | 738 | * function eBPF program intends to call |
| @@ -745,7 +776,9 @@ enum bpf_func_id { | |||
| 745 | #define BPF_F_ZERO_CSUM_TX (1ULL << 1) | 776 | #define BPF_F_ZERO_CSUM_TX (1ULL << 1) |
| 746 | #define BPF_F_DONT_FRAGMENT (1ULL << 2) | 777 | #define BPF_F_DONT_FRAGMENT (1ULL << 2) |
| 747 | 778 | ||
| 748 | /* BPF_FUNC_perf_event_output and BPF_FUNC_perf_event_read flags. */ | 779 | /* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and |
| 780 | * BPF_FUNC_perf_event_read_value flags. | ||
| 781 | */ | ||
| 749 | #define BPF_F_INDEX_MASK 0xffffffffULL | 782 | #define BPF_F_INDEX_MASK 0xffffffffULL |
| 750 | #define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK | 783 | #define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK |
| 751 | /* BPF_FUNC_perf_event_output for sk_buff input context. */ | 784 | /* BPF_FUNC_perf_event_output for sk_buff input context. */ |
| @@ -873,7 +906,7 @@ struct bpf_prog_info { | |||
| 873 | __u32 created_by_uid; | 906 | __u32 created_by_uid; |
| 874 | __u32 nr_map_ids; | 907 | __u32 nr_map_ids; |
| 875 | __aligned_u64 map_ids; | 908 | __aligned_u64 map_ids; |
| 876 | char name[BPF_OBJ_NAME_LEN]; | 909 | char name[BPF_OBJ_NAME_LEN]; |
| 877 | } __attribute__((aligned(8))); | 910 | } __attribute__((aligned(8))); |
| 878 | 911 | ||
| 879 | struct bpf_map_info { | 912 | struct bpf_map_info { |
| @@ -933,9 +966,22 @@ enum { | |||
| 933 | BPF_SOCK_OPS_NEEDS_ECN, /* If connection's congestion control | 966 | BPF_SOCK_OPS_NEEDS_ECN, /* If connection's congestion control |
| 934 | * needs ECN | 967 | * needs ECN |
| 935 | */ | 968 | */ |
| 969 | BPF_SOCK_OPS_BASE_RTT, /* Get base RTT. The correct value is | ||
| 970 | * based on the path and may be | ||
| 971 | * dependent on the congestion control | ||
| 972 | * algorithm. In general it indicates | ||
| 973 | * a congestion threshold. RTTs above | ||
| 974 | * this indicate congestion | ||
| 975 | */ | ||
| 936 | }; | 976 | }; |
| 937 | 977 | ||
| 938 | #define TCP_BPF_IW 1001 /* Set TCP initial congestion window */ | 978 | #define TCP_BPF_IW 1001 /* Set TCP initial congestion window */ |
| 939 | #define TCP_BPF_SNDCWND_CLAMP 1002 /* Set sndcwnd_clamp */ | 979 | #define TCP_BPF_SNDCWND_CLAMP 1002 /* Set sndcwnd_clamp */ |
| 940 | 980 | ||
| 981 | struct bpf_perf_event_value { | ||
| 982 | __u64 counter; | ||
| 983 | __u64 enabled; | ||
| 984 | __u64 running; | ||
| 985 | }; | ||
| 986 | |||
| 941 | #endif /* _UAPI__LINUX_BPF_H__ */ | 987 | #endif /* _UAPI__LINUX_BPF_H__ */ |
