Introduce new helper that reuses existing xdp perf_event output implementation, but can be called from raw_tracepoint programs that receive 'struct xdp_buff *' as a tracepoint argument.
Showing the changes to include/uapi/linux (1 of 7 files). Show all
Unified · Split
| @@ -2927,6 +2927,29 @@ union bpf_attr { · 2926 unmodified lines | ||
| 2927 | 2927 | * |
| 2928 | 2928 | * **-ENOENT** if pidns does not exists for the current task. |
| 2929 | 2929 | * |
| 2930 | + * int bpf_xdp_output(void *ctx, struct bpf_map *map, u64 flags, void *data, u64 size) | |
| 2931 | + * Description | |
| 2932 | + * Write raw *data* blob into a special BPF perf event held by | |
| 2933 | + * *map* of type **BPF_MAP_TYPE_PERF_EVENT_ARRAY**. This perf | |
| 2934 | + * event must have the following attributes: **PERF_SAMPLE_RAW** | |
| 2935 | + * as **sample_type**, **PERF_TYPE_SOFTWARE** as **type**, and | |
| 2936 | + * **PERF_COUNT_SW_BPF_OUTPUT** as **config**. | |
| 2937 | + * | |
| 2938 | + * The *flags* are used to indicate the index in *map* for which | |
| 2939 | + * the value must be put, masked with **BPF_F_INDEX_MASK**. | |
| 2940 | + * Alternatively, *flags* can be set to **BPF_F_CURRENT_CPU** | |
| 2941 | + * to indicate that the index of the current CPU core should be | |
| 2942 | + * used. | |
| 2943 | + * | |
| 2944 | + * The value to write, of *size*, is passed through eBPF stack and | |
| 2945 | + * pointed by *data*. | |
| 2946 | + * | |
| 2947 | + * *ctx* is a pointer to in-kernel struct xdp_buff. | |
| 2948 | + * | |
| 2949 | + * This helper is similar to **bpf_perf_eventoutput**\ () but | |
| 2950 | + * restricted to raw_tracepoint bpf programs. | |
| 2951 | + * Return | |
| 2952 | + * 0 on success, or a negative error in case of failure. | |
| 2930 | 2953 | */ |
| 2931 | 2954 | #define __BPF_FUNC_MAPPER(FN) \ |
| 2932 | 2955 | FN(unspec), \ |
| @@ -3049,7 +3072,8 @@ union bpf_attr { · 116 unmodified lines | ||
| 3049 | 3072 | FN(send_signal_thread), \ |
| 3050 | 3073 | FN(jiffies64), \ |
| 3051 | 3074 | FN(read_branch_records), \ |
| 3052 | − FN(get_ns_current_pid_tgid), | |
| 3075 | + FN(get_ns_current_pid_tgid), \ | |
| 3076 | + FN(xdp_output), | |
| 3053 | 3077 | |
| 3054 | 3078 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 3055 | 3079 | * function eBPF program intends to call |