[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LRH.2.21.2006021730340.17227@localhost>
Date: Tue, 2 Jun 2020 17:41:51 +0100 (BST)
From: Alan Maguire <alan.maguire@...cle.com>
To: Daniel Borkmann <daniel@...earbox.net>
cc: Lorenz Bauer <lmb@...udflare.com>,
Alexei Starovoitov <alexei.starovoitov@...il.com>,
Alan Maguire <alan.maguire@...cle.com>,
bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf 2/3] bpf: Add csum_level helper for fixing up csum
levels
On Tue, 2 Jun 2020, Daniel Borkmann wrote:
> On 6/2/20 5:19 PM, Lorenz Bauer wrote:
> > On Tue, 2 Jun 2020 at 15:58, Daniel Borkmann <daniel@...earbox.net> wrote:
> >>
> >> Add a bpf_csum_level() helper which BPF programs can use in combination
> >> with bpf_skb_adjust_room() when they pass in BPF_F_ADJ_ROOM_NO_CSUM_RESET
> >> flag to the latter to avoid falling back to CHECKSUM_NONE.
> >>
> >> The bpf_csum_level() allows to adjust CHECKSUM_UNNECESSARY skb->csum_levels
> >> via BPF_CSUM_LEVEL_{INC,DEC} which calls
> >> __skb_{incr,decr}_checksum_unnecessary()
> >> on the skb. The helper also allows a BPF_CSUM_LEVEL_RESET which sets the
> >> skb's
> >> csum to CHECKSUM_NONE as well as a BPF_CSUM_LEVEL_QUERY to just return the
> >> current level. Without this helper, there is no way to otherwise adjust the
> >> skb->csum_level. I did not add an extra dummy flags as there is plenty of
> >> free
> >> bitspace in level argument itself iff ever needed in future.
> >>
> >> Signed-off-by: Daniel Borkmann <daniel@...earbox.net>
> >> ---
> >> include/uapi/linux/bpf.h | 43 +++++++++++++++++++++++++++++++++-
> >> net/core/filter.c | 38 ++++++++++++++++++++++++++++++
> >> tools/include/uapi/linux/bpf.h | 43 +++++++++++++++++++++++++++++++++-
> >> 3 files changed, 122 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> >> index 3ba2bbbed80c..46622901cba7 100644
> >> --- a/include/uapi/linux/bpf.h
> >> +++ b/include/uapi/linux/bpf.h
> >> @@ -3220,6 +3220,38 @@ union bpf_attr {
> >> * calculation.
> >> * Return
> >> * Requested value, or 0, if flags are not recognized.
> >> + *
> >> + * int bpf_csum_level(struct sk_buff *skb, u64 level)
> >
> > u64 flags? We can also stuff things into level I guess.
>
> Yeah, I did mention it in the commit log. There is plenty of bit space to
> extend
> with flags in there iff ever needed. Originally, helper was called
> bpf_csum_adjust()
> but then renamed into bpf_csum_level() to be more 'topic specific' (aka do one
> thing
> and do it well...) and avoid future api overloading, so if necessary level can
> be
> used since I don't think the enum will be extended much further from what we
> have
> here anyway.
>
> [...]
> >
> > Acked-by: Lorenz Bauer <lmb@...udflare.com>
>
Looks great! The only thing that gave me pause was
the -EACCES return value for the case where we query
and the skb is not subject to CHECKSUM_UNNECESSESARY ;
-ENOENT ("no such level") feels slightly closer to the
situation to me but either is a reasonable choice I think.
Reviewed-by: Alan Maguire <alan.maguire@...cle.com>
Powered by blists - more mailing lists