[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKH8qBsntN_T1DFsCzg6ZRaae-AwTxgvUW5diY-cwZ4qGNcWCw@mail.gmail.com>
Date: Fri, 20 May 2022 17:03:25 -0700
From: Stanislav Fomichev <sdf@...gle.com>
To: Yonghong Song <yhs@...com>
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org, ast@...nel.org,
daniel@...earbox.net, andrii@...nel.org
Subject: Re: [PATCH bpf-next v7 01/11] bpf: add bpf_func_t and trampoline helpers
On Thu, May 19, 2022 at 5:45 PM Yonghong Song <yhs@...com> wrote:
>
>
>
> On 5/18/22 3:55 PM, Stanislav Fomichev wrote:
> > I'll be adding lsm cgroup specific helpers that grab
> > trampoline mutex.
> >
> > No functional changes.
> >
> > Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
> > ---
> > include/linux/bpf.h | 11 ++++----
> > kernel/bpf/trampoline.c | 62 ++++++++++++++++++++++-------------------
> > 2 files changed, 38 insertions(+), 35 deletions(-)
> >
> [...]
> > +
> > +int bpf_trampoline_link_prog(struct bpf_tramp_link *link, struct bpf_trampoline *tr)
> > +{
> > + int err;
> > +
> > + mutex_lock(&tr->mutex);
> > + err = __bpf_trampoline_link_prog(link, tr);
> > mutex_unlock(&tr->mutex);
> > return err;
> > }
> >
> > /* bpf_trampoline_unlink_prog() should never fail. */
>
> The comment here can be removed.
Will do, thank you!
> > -int bpf_trampoline_unlink_prog(struct bpf_tramp_link *link, struct bpf_trampoline *tr)
> > +static int __bpf_trampoline_unlink_prog(struct bpf_tramp_link *link, struct bpf_trampoline *tr)
> > {
> > enum bpf_tramp_prog_type kind;
> > int err;
> >
> > kind = bpf_attach_type_to_tramp(link->link.prog);
> > - mutex_lock(&tr->mutex);
> > if (kind == BPF_TRAMP_REPLACE) {
> > WARN_ON_ONCE(!tr->extension_prog);
> > err = bpf_arch_text_poke(tr->func.addr, BPF_MOD_JUMP,
> > tr->extension_prog->bpf_func, NULL);
> > tr->extension_prog = NULL;
> > - goto out;
> > + return err;
> > }
> > hlist_del_init(&link->tramp_hlist);
> > tr->progs_cnt[kind]--;
> > - err = bpf_trampoline_update(tr);
> > -out:
> > + return bpf_trampoline_update(tr);
> > +}
> > +
> > +/* bpf_trampoline_unlink_prog() should never fail. */
> > +int bpf_trampoline_unlink_prog(struct bpf_tramp_link *link, struct bpf_trampoline *tr)
> > +{
> > + int err;
> > +
> > + mutex_lock(&tr->mutex);
> > + err = __bpf_trampoline_unlink_prog(link, tr);
> > mutex_unlock(&tr->mutex);
> > return err;
> > }
Powered by blists - more mailing lists