[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM_iQpXtKisVu-QJA3=51oDJqEwEiuQu=np83RN0=r2A3wG0HA@mail.gmail.com>
Date: Mon, 8 Feb 2021 10:56:54 -0800
From: Cong Wang <xiyou.wangcong@...il.com>
To: Jakub Sitnicki <jakub@...udflare.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>, duanxiongchun@...edance.com,
Dongdong Wang <wangdongdong.6@...edance.com>,
jiang.wang@...edance.com, Cong Wang <cong.wang@...edance.com>,
John Fastabend <john.fastabend@...il.com>,
Daniel Borkmann <daniel@...earbox.net>,
Lorenz Bauer <lmb@...udflare.com>
Subject: Re: [Patch bpf-next 03/19] skmsg: use skb ext instead of TCP_SKB_CB
On Fri, Feb 5, 2021 at 2:09 PM Jakub Sitnicki <jakub@...udflare.com> wrote:
>
> On Wed, Feb 03, 2021 at 05:16 AM CET, Cong Wang wrote:
> > From: Cong Wang <cong.wang@...edance.com>
> >
> > Currently TCP_SKB_CB() is hard-coded in skmsg code, it certainly
> > won't work for any other non-TCP protocols. We can move them to
> > skb ext instead of playing with skb cb, which is harder to make
> > correct.
> >
> > Of course, except ->data_end, which is used by
> > sk_skb_convert_ctx_access() to adjust compile-time constant offset.
> > Fortunately, we can reuse the anonymous union where the field
> > 'tcp_tsorted_anchor' is and save/restore the overwritten part
> > before/after a brief use.
> >
> > Cc: John Fastabend <john.fastabend@...il.com>
> > Cc: Daniel Borkmann <daniel@...earbox.net>
> > Cc: Jakub Sitnicki <jakub@...udflare.com>
> > Cc: Lorenz Bauer <lmb@...udflare.com>
> > Signed-off-by: Cong Wang <cong.wang@...edance.com>
> > ---
> > include/linux/skbuff.h | 4 ++++
> > include/linux/skmsg.h | 45 ++++++++++++++++++++++++++++++++++++++++++
> > include/net/tcp.h | 25 -----------------------
> > net/Kconfig | 1 +
> > net/core/filter.c | 3 +--
> > net/core/skbuff.c | 7 +++++++
> > net/core/skmsg.c | 44 ++++++++++++++++++++++++++++-------------
> > net/core/sock_map.c | 12 +++++------
> > 8 files changed, 94 insertions(+), 47 deletions(-)
> >
> > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> > index 46f901adf1a8..12a28268233a 100644
> > --- a/include/linux/skbuff.h
> > +++ b/include/linux/skbuff.h
> > @@ -755,6 +755,7 @@ struct sk_buff {
> > void (*destructor)(struct sk_buff *skb);
> > };
> > struct list_head tcp_tsorted_anchor;
> > + void *data_end;
> > };
>
> I think we can avoid `data_end` by computing it in BPF with the help of
> a scratch register. Similar to how we compute skb_shinfo(skb) in
> bpf_convert_shinfo_access(). Something like:
Sounds like an excellent idea! It is certainly much better if we can just
compute it at run-time. I will give this a try.
Thanks!
Powered by blists - more mailing lists