Re: [PATCH] net: bpf: add bpf_ktime_get_boot_ns()

From: Alexei Starovoitov
Date: Sun Apr 26 2020 - 12:48:23 EST


On Sun, Apr 26, 2020 at 9:31 AM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Mon, Apr 20, 2020 at 01:26:43PM -0700, Maciej Åenczykowski wrote:
> > From: Maciej Åenczykowski <maze@xxxxxxxxxx>
> >
> > On a device like a cellphone which is constantly suspending
> > and resuming CLOCK_MONOTONIC is not particularly useful for
> > keeping track of or reacting to external network events.
> > Instead you want to use CLOCK_BOOTTIME.
> >
> > Hence add bpf_ktime_get_boot_ns() as a mirror of bpf_ktime_get_ns()
> > based around CLOCK_BOOTTIME instead of CLOCK_MONOTONIC.
> >
> > Signed-off-by: Maciej Åenczykowski <maze@xxxxxxxxxx>
> ...
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index 755867867e57..ec567d1e6fb9 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -6009,6 +6009,8 @@ bpf_base_func_proto(enum bpf_func_id func_id)
> > return &bpf_tail_call_proto;
> > case BPF_FUNC_ktime_get_ns:
> > return &bpf_ktime_get_ns_proto;
> > + case BPF_FUNC_ktime_get_boot_ns:
> > + return &bpf_ktime_get_boot_ns_proto;
> > default:
> > break;
> > }
>
> That part got moved into kernel/bpf/helpers.c in the mean time.
> I fixed it up and applied. Thanks
>
> In the future please cc bpf@vger for all bpf related patches.

The order of comments for bpf_ktime_get_boot_ns
was also incorrect.
Most selftests were broken.
I fixed it up as well.