From: Cong Wang <xiyou.wangcong@gmail.com>
To: John Fastabend <john.fastabend@gmail.com>
Cc: Lorenz Bauer <lmb@cloudflare.com>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
duanxiongchun@bytedance.com,
Dongdong Wang <wangdongdong.6@bytedance.com>,
Jiang Wang <jiang.wang@bytedance.com>,
Cong Wang <cong.wang@bytedance.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Jakub Sitnicki <jakub@cloudflare.com>
Subject: Re: [Patch bpf-next v2 2/9] sock: introduce sk_prot->update_proto()
Date: Tue, 9 Mar 2021 09:53:31 -0800 [thread overview]
Message-ID: <CAM_iQpV5vJn5ORbhodinEYP7vV9tGbXwDN2Nw+TLqUNnp5ENcg@mail.gmail.com> (raw)
In-Reply-To: <6042e114a1c9e_135da20839@john-XPS-13-9370.notmuch>
On Fri, Mar 5, 2021 at 5:55 PM John Fastabend <john.fastabend@gmail.com> wrote:
>
> Cong Wang wrote:
> > On Fri, Mar 5, 2021 at 4:27 PM John Fastabend <john.fastabend@gmail.com> wrote:
> > >
> > > Cong Wang wrote:
> > > > On Tue, Mar 2, 2021 at 10:23 AM Cong Wang <xiyou.wangcong@gmail.com> wrote:
> > > > >
> > > > > On Tue, Mar 2, 2021 at 8:22 AM Lorenz Bauer <lmb@cloudflare.com> wrote:
> > > > > >
> > > > > > On Tue, 2 Mar 2021 at 02:37, Cong Wang <xiyou.wangcong@gmail.com> wrote:
> > > > > >
> > > > > > ...
> > > > > > > static inline void sk_psock_restore_proto(struct sock *sk,
> > > > > > > struct sk_psock *psock)
> > > > > > > {
> > > > > > > sk->sk_prot->unhash = psock->saved_unhash;
> > > > > >
> > > > > > Not related to your patch set, but why do an extra restore of
> > > > > > sk_prot->unhash here? At this point sk->sk_prot is one of our tcp_bpf
> > > > > > / udp_bpf protos, so overwriting that seems wrong?
> > >
> > > "extra"? restore_proto should only be called when the psock ref count
> > > is zero and we need to transition back to the original socks proto
> > > handlers. To trigger this we can simply delete a sock from the map.
> > > In the case where we are deleting the psock overwriting the tcp_bpf
> > > protos is exactly what we want.?
> >
> > Why do you want to overwrite tcp_bpf_prots->unhash? Overwriting
> > tcp_bpf_prots is correct, but overwriting tcp_bpf_prots->unhash is not.
> > Because once you overwrite it, the next time you use it to replace
> > sk->sk_prot, it would be a different one rather than sock_map_unhash():
> >
> > // tcp_bpf_prots->unhash == sock_map_unhash
> > sk_psock_restore_proto();
> > // Now tcp_bpf_prots->unhash is inet_unhash
> > ...
> > sk_psock_update_proto();
> > // sk->sk_proto is now tcp_bpf_prots again,
> > // so its ->unhash now is inet_unhash
> > // but it should be sock_map_unhash here
>
> Right, we can fix this on the TLS side. I'll push a fix shortly.
Are you still working on this? If kTLS still needs it, then we can
have something like this:
diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h
index 8edbbf5f2f93..5eb617df7f48 100644
--- a/include/linux/skmsg.h
+++ b/include/linux/skmsg.h
@@ -349,8 +349,8 @@ static inline void sk_psock_update_proto(struct sock *sk,
static inline void sk_psock_restore_proto(struct sock *sk,
struct sk_psock *psock)
{
- sk->sk_prot->unhash = psock->saved_unhash;
if (inet_csk_has_ulp(sk)) {
+ sk->sk_prot->unhash = psock->saved_unhash;
tcp_update_ulp(sk, psock->sk_proto, psock->saved_write_space);
} else {
sk->sk_write_space = psock->saved_write_space;
Thanks.
next prev parent reply other threads:[~2021-03-09 17:54 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 2:37 [Patch bpf-next v2 0/9] sockmap: introduce BPF_SK_SKB_VERDICT and support UDP Cong Wang
2021-03-02 2:37 ` [Patch bpf-next v2 1/9] sock_map: introduce BPF_SK_SKB_VERDICT Cong Wang
2021-03-02 2:37 ` [Patch bpf-next v2 2/9] sock: introduce sk_prot->update_proto() Cong Wang
2021-03-02 16:22 ` Lorenz Bauer
2021-03-02 18:23 ` Cong Wang
2021-03-03 9:35 ` Lorenz Bauer
2021-03-03 18:20 ` Cong Wang
2021-03-04 9:30 ` Lorenz Bauer
2021-03-04 23:52 ` Cong Wang
2021-03-06 0:27 ` John Fastabend
2021-03-06 0:57 ` Cong Wang
2021-03-06 1:55 ` John Fastabend
2021-03-09 17:53 ` Cong Wang [this message]
2021-03-10 6:33 ` John Fastabend
2021-03-02 2:37 ` [Patch bpf-next v2 3/9] udp: implement ->sendmsg_locked() Cong Wang
2021-03-02 2:37 ` [Patch bpf-next v2 4/9] udp: implement ->read_sock() for sockmap Cong Wang
2021-03-03 6:26 ` Yonghong Song
2021-03-02 2:37 ` [Patch bpf-next v2 5/9] udp: add ->read_sock() and ->sendmsg_locked() to ipv6 Cong Wang
2021-03-02 16:23 ` Lorenz Bauer
2021-03-02 17:59 ` Cong Wang
2021-03-02 2:37 ` [Patch bpf-next v2 6/9] skmsg: extract __tcp_bpf_recvmsg() and tcp_bpf_wait_data() Cong Wang
2021-03-02 2:37 ` [Patch bpf-next v2 7/9] udp: implement udp_bpf_recvmsg() for sockmap Cong Wang
2021-03-02 2:37 ` [Patch bpf-next v2 8/9] sock_map: update sock type checks for UDP Cong Wang
2021-03-03 6:37 ` Yonghong Song
2021-03-03 18:02 ` Cong Wang
2021-03-03 18:50 ` Yonghong Song
2021-03-02 2:37 ` [Patch bpf-next v2 9/9] selftests/bpf: add a test case for udp sockmap Cong Wang
2021-03-02 16:31 ` Lorenz Bauer
2021-03-02 18:05 ` Cong Wang
2021-03-03 10:20 ` Lorenz Bauer
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=CAM_iQpV5vJn5ORbhodinEYP7vV9tGbXwDN2Nw+TLqUNnp5ENcg@mail.gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=daniel@iogearbox.net \
--cc=duanxiongchun@bytedance.com \
--cc=jakub@cloudflare.com \
--cc=jiang.wang@bytedance.com \
--cc=john.fastabend@gmail.com \
--cc=lmb@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=wangdongdong.6@bytedance.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).