bpf: Allow to retrieve sol_socket opts from sock_addr progs
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 11 Jan 2021 23:09:39 +0000 (00:09 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 12 Jan 2021 22:44:53 +0000 (14:44 -0800)
commitbcd6f4a8bedabac6949d05e418e73a0a1b309e84
tree1ae4ad9d08bcd512cf0ee24e08890a428c6b80a8
parent28a8add64181059034b7f281491132112cd95bb4
bpf: Allow to retrieve sol_socket opts from sock_addr progs

The _bpf_setsockopt() is able to set some of the SOL_SOCKET level options,
however, _bpf_getsockopt() has little support to actually retrieve them.
This small patch adds few misc options such as SO_MARK, SO_PRIORITY and
SO_BINDTOIFINDEX. For the latter getter and setter are added. The mark and
priority in particular allow to retrieve the options from BPF cgroup hooks
to then implement custom behavior / settings on the syscall hooks compared
to other sockets that stick to the defaults, for example.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/cba44439b801e5ddc1170e5be787f4dc93a2d7f9.1610406333.git.daniel@iogearbox.net
net/core/filter.c