From: John Fastabend <john.fastabend@gmail.com> To: ast@kernel.org, daniel@iogearbox.net Cc: lmb@cloudflare.com, bpf@vger.kernel.org, john.fastabend@gmail.com, jakub@cloudflare.com, netdev@vger.kernel.org Subject: [bpf-next PATCH 3/3] bpf: sk_msg add get socket storage helpers Date: Wed, 13 May 2020 12:24:58 -0700 [thread overview] Message-ID: <158939789875.17281.10136938760299538348.stgit@john-Precision-5820-Tower> (raw) In-Reply-To: <158939776371.17281.8506900883049313932.stgit@john-Precision-5820-Tower> Add helpers to use local socket storage. Signed-off-by: John Fastabend <john.fastabend@gmail.com> --- include/uapi/linux/bpf.h | 2 ++ net/core/filter.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index bfb31c1..3ca7cfd 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -3607,6 +3607,8 @@ struct sk_msg_md { __u32 remote_port; /* Stored in network byte order */ __u32 local_port; /* stored in host byte order */ __u32 size; /* Total size of sk_msg */ + + __bpf_md_ptr(struct bpf_sock *, sk); /* current socket */ }; struct sk_reuseport_md { diff --git a/net/core/filter.c b/net/core/filter.c index d1c4739..c42adc8 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -6395,6 +6395,10 @@ sk_msg_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) return &bpf_get_current_uid_gid_proto; case BPF_FUNC_get_current_pid_tgid: return &bpf_get_current_pid_tgid_proto; + case BPF_FUNC_sk_storage_get: + return &bpf_sk_storage_get_proto; + case BPF_FUNC_sk_storage_delete: + return &bpf_sk_storage_delete_proto; #ifdef CONFIG_CGROUPS case BPF_FUNC_get_current_cgroup_id: return &bpf_get_current_cgroup_id_proto; @@ -7243,6 +7247,11 @@ static bool sk_msg_is_valid_access(int off, int size, if (size != sizeof(__u64)) return false; break; + case offsetof(struct sk_msg_md, sk): + if (size != sizeof(__u64)) + return false; + info->reg_type = PTR_TO_SOCKET; + break; case bpf_ctx_range(struct sk_msg_md, family): case bpf_ctx_range(struct sk_msg_md, remote_ip4): case bpf_ctx_range(struct sk_msg_md, local_ip4): @@ -8577,6 +8586,12 @@ static u32 sk_msg_convert_ctx_access(enum bpf_access_type type, si->dst_reg, si->src_reg, offsetof(struct sk_msg_sg, size)); break; + + case offsetof(struct sk_msg_md, sk): + *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_msg, sk), + si->dst_reg, si->src_reg, + offsetof(struct sk_msg, sk)); + break; } return insn - insn_buf;
next prev parent reply other threads:[~2020-05-13 19:25 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-13 19:23 [bpf-next PATCH 0/3] bpf: Add sk_msg helpers John Fastabend 2020-05-13 19:23 ` [bpf-next PATCH 1/3] bpf: sk_msg add some generic helpers that may be useful from sk_msg John Fastabend 2020-05-14 6:58 ` Yonghong Song 2020-05-13 19:24 ` [bpf-next PATCH 2/3] bpf: sk_msg helpers for probe_* and *current_task* John Fastabend 2020-05-14 7:21 ` Yonghong Song 2020-05-14 13:30 ` John Fastabend 2020-05-14 8:02 ` Daniel Borkmann 2020-05-13 19:24 ` John Fastabend [this message] 2020-05-14 7:26 ` [bpf-next PATCH 3/3] bpf: sk_msg add get socket storage helpers Yonghong Song
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=158939789875.17281.10136938760299538348.stgit@john-Precision-5820-Tower \ --to=john.fastabend@gmail.com \ --cc=ast@kernel.org \ --cc=bpf@vger.kernel.org \ --cc=daniel@iogearbox.net \ --cc=jakub@cloudflare.com \ --cc=lmb@cloudflare.com \ --cc=netdev@vger.kernel.org \ --subject='Re: [bpf-next PATCH 3/3] bpf: sk_msg add get socket storage helpers' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.