Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf: Add support for {set|get} socket options from setsockopt BPF

Add logic to call bpf_setsockopt() and bpf_getsockopt() from setsockopt BPF
programs. An example use case is when the user sets the IPV6_TCLASS socket
option, we would also like to change the tcp-cc for that socket.

We don't have any use case for calling bpf_setsockopt() from supposedly read-
only sys_getsockopt(), so it is made available to BPF_CGROUP_SETSOCKOPT only
at this point.

Signed-off-by: Prankur Gupta <prankgup@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20210817224221.3257826-2-prankgup@fb.com

authored by

Prankur Gupta and committed by
Daniel Borkmann
2c531639 44779a4b

+8
+8
kernel/bpf/cgroup.c
··· 1873 1873 return &bpf_sk_storage_get_proto; 1874 1874 case BPF_FUNC_sk_storage_delete: 1875 1875 return &bpf_sk_storage_delete_proto; 1876 + case BPF_FUNC_setsockopt: 1877 + if (prog->expected_attach_type == BPF_CGROUP_SETSOCKOPT) 1878 + return &bpf_sk_setsockopt_proto; 1879 + return NULL; 1880 + case BPF_FUNC_getsockopt: 1881 + if (prog->expected_attach_type == BPF_CGROUP_SETSOCKOPT) 1882 + return &bpf_sk_getsockopt_proto; 1883 + return NULL; 1876 1884 #endif 1877 1885 #ifdef CONFIG_INET 1878 1886 case BPF_FUNC_tcp_sock: