On Fri, Feb 5, 2021 at 2:09 PM Jakub Sitnicki <jakub@xxxxxxxxxxxxxx> wrote: > > On Wed, Feb 03, 2021 at 05:16 AM CET, Cong Wang wrote: > > From: Cong Wang <cong.wang@xxxxxxxxxxxxx> > > > > 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@xxxxxxxxx> > > Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx> > > Cc: Jakub Sitnicki <jakub@xxxxxxxxxxxxxx> > > Cc: Lorenz Bauer <lmb@xxxxxxxxxxxxxx> > > Signed-off-by: Cong Wang <cong.wang@xxxxxxxxxxxxx> > > --- > > 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!