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

bpf: Support bpf_(get|set)sockopt() in bpf unix iter.

This patch makes bpf_(get|set)sockopt() available when iterating AF_UNIX
sockets.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Link: https://lore.kernel.org/r/20220113002849.4384-4-kuniyu@amazon.co.jp
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Alexei Starovoitov
eb7d8f1d 855d8e77

+15
+15
net/unix/af_unix.c
··· 3633 3633 .seq_priv_size = sizeof(struct bpf_unix_iter_state), 3634 3634 }; 3635 3635 3636 + static const struct bpf_func_proto * 3637 + bpf_iter_unix_get_func_proto(enum bpf_func_id func_id, 3638 + const struct bpf_prog *prog) 3639 + { 3640 + switch (func_id) { 3641 + case BPF_FUNC_setsockopt: 3642 + return &bpf_sk_setsockopt_proto; 3643 + case BPF_FUNC_getsockopt: 3644 + return &bpf_sk_getsockopt_proto; 3645 + default: 3646 + return NULL; 3647 + } 3648 + } 3649 + 3636 3650 static struct bpf_iter_reg unix_reg_info = { 3637 3651 .target = "unix", 3638 3652 .ctx_arg_info_size = 1, ··· 3654 3640 { offsetof(struct bpf_iter__unix, unix_sk), 3655 3641 PTR_TO_BTF_ID_OR_NULL }, 3656 3642 }, 3643 + .get_func_proto = bpf_iter_unix_get_func_proto, 3657 3644 .seq_info = &unix_seq_info, 3658 3645 }; 3659 3646