[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6042e114a1c9e_135da20839@john-XPS-13-9370.notmuch>
Date: Fri, 05 Mar 2021 17:55:32 -0800
From: John Fastabend <john.fastabend@...il.com>
To: Cong Wang <xiyou.wangcong@...il.com>,
John Fastabend <john.fastabend@...il.com>
Cc: Lorenz Bauer <lmb@...udflare.com>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
duanxiongchun@...edance.com,
Dongdong Wang <wangdongdong.6@...edance.com>,
Jiang Wang <jiang.wang@...edance.com>,
Cong Wang <cong.wang@...edance.com>,
Daniel Borkmann <daniel@...earbox.net>,
Jakub Sitnicki <jakub@...udflare.com>
Subject: Re: [Patch bpf-next v2 2/9] sock: introduce sk_prot->update_proto()
Cong Wang wrote:
> On Fri, Mar 5, 2021 at 4:27 PM John Fastabend <john.fastabend@...il.com> wrote:
> >
> > Cong Wang wrote:
> > > On Tue, Mar 2, 2021 at 10:23 AM Cong Wang <xiyou.wangcong@...il.com> wrote:
> > > >
> > > > On Tue, Mar 2, 2021 at 8:22 AM Lorenz Bauer <lmb@...udflare.com> wrote:
> > > > >
> > > > > On Tue, 2 Mar 2021 at 02:37, Cong Wang <xiyou.wangcong@...il.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.
>
> Thanks.
Powered by blists - more mailing lists