summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.co.jp>2022-01-13 01:28:47 +0100
committerAlexei Starovoitov <ast@kernel.org>2022-01-19 00:45:06 +0100
commiteb7d8f1d9ebc7379f09a51bf4faa35e0bfa7437d (patch)
treeb898281eaf1d1e0316597ea6587feb4217afce0c /net
parentbpf: af_unix: Use batching algorithm in bpf unix iter. (diff)
downloadlinux-eb7d8f1d9ebc7379f09a51bf4faa35e0bfa7437d.tar.xz
linux-eb7d8f1d9ebc7379f09a51bf4faa35e0bfa7437d.zip
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>
Diffstat (limited to 'net')
-rw-r--r--net/unix/af_unix.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index d383d5f63b6b..3e0d6281fd1e 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -3633,6 +3633,20 @@ static const struct bpf_iter_seq_info unix_seq_info = {
.seq_priv_size = sizeof(struct bpf_unix_iter_state),
};
+static const struct bpf_func_proto *
+bpf_iter_unix_get_func_proto(enum bpf_func_id func_id,
+ const struct bpf_prog *prog)
+{
+ switch (func_id) {
+ case BPF_FUNC_setsockopt:
+ return &bpf_sk_setsockopt_proto;
+ case BPF_FUNC_getsockopt:
+ return &bpf_sk_getsockopt_proto;
+ default:
+ return NULL;
+ }
+}
+
static struct bpf_iter_reg unix_reg_info = {
.target = "unix",
.ctx_arg_info_size = 1,
@@ -3640,6 +3654,7 @@ static struct bpf_iter_reg unix_reg_info = {
{ offsetof(struct bpf_iter__unix, unix_sk),
PTR_TO_BTF_ID_OR_NULL },
},
+ .get_func_proto = bpf_iter_unix_get_func_proto,
.seq_info = &unix_seq_info,
};