[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzaTXtC6RsC9cJQLZB08RV+h-SL0JZAFPgb-M8b+ruro5g@mail.gmail.com>
Date: Wed, 5 Oct 2022 20:19:33 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Daniel Borkmann <daniel@...earbox.net>
Cc: bpf@...r.kernel.org, razor@...ckwall.org, ast@...nel.org,
andrii@...nel.org, martin.lau@...ux.dev, john.fastabend@...il.com,
joannelkoong@...il.com, memxor@...il.com, toke@...hat.com,
joe@...ium.io, netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next 05/10] bpf: Implement link detach for tc BPF link programs
On Tue, Oct 4, 2022 at 4:12 PM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> Add support for forced detach operation of tc BPF link. This detaches the link
> but without destroying it. It has the same semantics as auto-detaching of BPF
> link due to e.g. net device being destroyed for tc or XDP BPF link. Meaning,
> in this case the BPF link is still a valid kernel object, but is defunct given
> it is not attached anywhere anymore. It still holds a reference to the BPF
> program, though. This functionality allows users with enough access rights to
> manually force-detach attached tc BPF link without killing respective owner
> process and to then introspect/debug the BPF assets. Similar LINK_DETACH exists
> also for other BPF link types.
>
> Co-developed-by: Nikolay Aleksandrov <razor@...ckwall.org>
> Signed-off-by: Nikolay Aleksandrov <razor@...ckwall.org>
> Signed-off-by: Daniel Borkmann <daniel@...earbox.net>
> ---
Acked-by: Andrii Nakryiko <andrii@...nel.org>
> kernel/bpf/net.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/kernel/bpf/net.c b/kernel/bpf/net.c
> index a74b86bb60a9..5650f62c1315 100644
> --- a/kernel/bpf/net.c
> +++ b/kernel/bpf/net.c
> @@ -350,6 +350,12 @@ static void xtc_link_release(struct bpf_link *l)
> rtnl_unlock();
> }
>
> +static int xtc_link_detach(struct bpf_link *l)
> +{
> + xtc_link_release(l);
> + return 0;
> +}
> +
> static void xtc_link_dealloc(struct bpf_link *l)
> {
> struct bpf_tc_link *link = container_of(l, struct bpf_tc_link, link);
> @@ -393,6 +399,7 @@ static int xtc_link_fill_info(const struct bpf_link *l,
>
> static const struct bpf_link_ops bpf_tc_link_lops = {
> .release = xtc_link_release,
> + .detach = xtc_link_detach,
> .dealloc = xtc_link_dealloc,
> .update_prog = xtc_link_update,
> .show_fdinfo = xtc_link_fdinfo,
> --
> 2.34.1
>
Powered by blists - more mailing lists