[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJ+HfNjQkno=iOWherDMuxAVyA=Ku925o25dAYbqQQTrJN_n5g@mail.gmail.com>
Date: Mon, 18 Nov 2019 21:11:32 +0100
From: Björn Töpel <bjorn.topel@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Björn Töpel <bjorn.topel@...el.com>,
bpf <bpf@...r.kernel.org>,
Magnus Karlsson <magnus.karlsson@...il.com>,
Magnus Karlsson <magnus.karlsson@...el.com>,
Jonathan Lemon <jonathan.lemon@...il.com>
Subject: Re: [RFC PATCH bpf-next 2/4] bpf: introduce BPF dispatcher
On Mon, 18 Nov 2019 at 20:36, Andrii Nakryiko <andrii.nakryiko@...il.com> wrote:
>
[...]
> > + sort(&ips[0], num_progs, sizeof(ips[i]), cmp_ips, NULL);
>
> nit: sizeof(ips[i]) looks weird...
>
Ick! Thanks for spotting.
> > + return emit_bpf_dispatcher(&prog, 0, num_progs - 1, &ips[0], fallback);
> > +}
> > +
> > struct x64_jit_data {
> > struct bpf_binary_header *header;
> > int *addrs;
>
> [...]
>
> > +
> > +static int bpf_dispatcher_add_prog(struct bpf_dispatcher *d,
> > + struct bpf_prog *prog)
> > +{
> > + struct bpf_prog **entry = NULL;
> > + int i, err = 0;
> > +
> > + if (d->num_progs == BPF_DISPATCHER_MAX)
> > + return err;
>
> err == 0, not what you want, probably
>
No, the error handling in this RFC is bad. I'll fix that in the patch proper!
[...]
> > +static void bpf_dispatcher_remove_prog(struct bpf_dispatcher *d,
> > + struct bpf_prog *prog)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < BPF_DISPATCHER_MAX; i++) {
> > + if (d->progs[i] == prog) {
> > + bpf_prog_put(prog);
> > + d->progs[i] = NULL;
> > + d->num_progs--;
>
> instead of allowing holes, why not swap removed prog with the last on
> in d->progs?
>
Yeah, holes is a no go. I'll redo that.
[...]
> > +
> > + WARN_ON(bpf_dispatcher_update(d));
>
> shouldn't dispatcher be removed from the list before freed? It seems
> like handling dispatches freeing is better done here explicitly (and
> you won't need to leave a NB remark)
>
I agree. Let's make that explicit. I'll send out a patch proper in a day or two.
Thanks for looking at the code, Andrii!
Björn
Powered by blists - more mailing lists