From 46390d8e7dd2127b50fab99fee4467aca46ab28c Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Mon, 6 Nov 2023 10:06:03 +0100 Subject: sys/linux: describe BPF tail call map This commit updates the BPF description to be able to prepare a tail call map referencing one BPF program. Tail call maps are called to jump from one program (caller) to another (called, referenced in the map). To that end, we must first create a map of the specific type and then update it with a BPF program fd. We follow the same approach as 93789af44b9a ("sys/linux: describe map holding constant string") to specialize the resource outputed by the map update and therefore ensure we can refer specifically to an updated tail call map. This new map will be used in a subsequent commit to perform a tail call. Signed-off-by: Paul Chaignon --- sys/linux/bpf.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sys/linux') diff --git a/sys/linux/bpf.txt b/sys/linux/bpf.txt index 64c69b9ff..539b00e3b 100644 --- a/sys/linux/bpf.txt +++ b/sys/linux/bpf.txt @@ -22,6 +22,8 @@ resource bpf_revision[int64] resource fd_bpf_const_str_map[fd_bpf_map] resource fd_bpf_const_str[fd_bpf_const_str_map] resource bpf_frozen_const_str[fd_bpf_const_str] +resource tail_call_map_fd[fd_bpf_map] +resource tail_call_map[tail_call_map_fd] # NEED: this is a random index in btf_header:types. We can't express this, so we just use a small index. type btf_type_id int32[1:5] @@ -37,9 +39,11 @@ type map_fd_id int32[0:16] bpf$MAP_CREATE(cmd const[BPF_MAP_CREATE], arg ptr[in, bpf_map_create_arg], size len[arg]) fd_bpf_map bpf$MAP_CREATE_CONST_STR(cmd const[BPF_MAP_CREATE], arg ptr[in, bpf_map_create_arg_const_str], size len[arg]) fd_bpf_const_str_map +bpf$MAP_CREATE_TAIL_CALL(cmd const[BPF_MAP_CREATE], arg ptr[in, bpf_map_create_arg_tail_call], size len[arg]) tail_call_map_fd bpf$MAP_LOOKUP_ELEM(cmd const[BPF_MAP_LOOKUP_ELEM], arg ptr[in, bpf_map_lookup_arg], size len[arg]) bpf$MAP_UPDATE_ELEM(cmd const[BPF_MAP_UPDATE_ELEM], arg ptr[in, bpf_map_update_arg], size len[arg]) bpf$MAP_UPDATE_CONST_STR(cmd const[BPF_MAP_UPDATE_ELEM], arg ptr[inout, bpf_map_update_const_str_arg], size len[arg]) +bpf$MAP_UPDATE_ELEM_TAIL_CALL(cmd const[BPF_MAP_UPDATE_ELEM], arg ptr[inout, bpf_map_update_tail_call_arg], size len[arg]) bpf$MAP_DELETE_ELEM(cmd const[BPF_MAP_DELETE_ELEM], arg ptr[in, bpf_map_delete_arg], size len[arg]) bpf$MAP_GET_NEXT_KEY(cmd const[BPF_MAP_GET_NEXT_KEY], arg ptr[in, bpf_map_get_next_arg], size len[arg]) bpf$PROG_LOAD(cmd const[BPF_PROG_LOAD], arg ptr[in, bpf_prog], size len[arg]) fd_bpf_prog @@ -116,6 +120,7 @@ type bpf_map_create_arg_t[TYPE, KSIZE, VSIZE, MAX, FLAGS, MAP_EXTRA] { type bpf_map_create_arg_base bpf_map_create_arg_t[flags[bpf_map_type, int32], int32, int32, int32, flags[map_flags, int32], const[0, int64]] type bpf_map_create_arg_bf bpf_map_create_arg_t[const[BPF_MAP_TYPE_BLOOM_FILTER, int32], int32, int32, int32, flags[map_flags, int32], int64[0:15]] type bpf_map_create_arg_const_str bpf_map_create_arg_t[const[BPF_MAP_TYPE_ARRAY, int32], const[4, int32], const[8, int32], const[1, int32], const[BPF_F_RDONLY_PROG, int32], const[0, int64]] +type bpf_map_create_arg_tail_call bpf_map_create_arg_t[const[BPF_MAP_TYPE_PROG_ARRAY, int32], const[4, int32], const[4, int32], const[10, int32], const[0, int32], const[0, int64]] bpf_map_get_fd_by_id_arg { map_id bpf_map_id @@ -159,6 +164,18 @@ bpf_map_update_const_str_arg { flags const[0, int64] } +tail_call_map_update { + in tail_call_map_fd + out tail_call_map (out_overlay) +} + +bpf_map_update_tail_call_arg { + map tail_call_map_update + key ptr64[in, const[0, int32]] + val ptr64[in, fd_bpf_prog] + flags const[0, int64] +} + bpf_map_delete_arg { map fd_bpf_map key ptr64[in, array[int8]] -- cgit mrf-deployment