bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Song Liu <songliubraving@fb.com>
Cc: "Andrii Nakryiko" <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
	Netdev <netdev@vger.kernel.org>,
	"Alexei Starovoitov" <ast@fb.com>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Kernel Team" <Kernel-team@fb.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>
Subject: Re: [PATCH bpf-next 1/5] bpf: add support for forced LINK_DETACH command
Date: Thu, 30 Jul 2020 12:03:59 -0700	[thread overview]
Message-ID: <CAEf4BzZsYoBZjsSKgQ-+OYRCa=Xn1EVwmdjGM5FG5oZv7_9vkw@mail.gmail.com> (raw)
In-Reply-To: <E5C327CB-962D-46B9-9816-29169F62C4EF@fb.com>

On Thu, Jul 30, 2020 at 10:43 AM Song Liu <songliubraving@fb.com> wrote:
>
>
>
> > On Jul 29, 2020, at 4:05 PM, Andrii Nakryiko <andriin@fb.com> wrote:
> >
> > Add LINK_DETACH command to force-detach bpf_link without destroying it. It has
> > the same behavior as auto-detaching of bpf_link due to cgroup dying for
> > bpf_cgroup_link or net_device being destroyed for bpf_xdp_link. In such case,
> > bpf_link is still a valid kernel object, but is defuncts and doesn't hold BPF
> > program attached to corresponding BPF hook. This functionality allows users
> > with enough access rights to manually force-detach attached bpf_link without
> > killing respective owner process.
> >
> > This patch implements LINK_DETACH for cgroup, xdp, and netns links, mostly
> > re-using existing link release handling code.
> >
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
>
> The code looks good to me. My only question is, do we need both
> bpf_link_ops->detach and bpf_link_ops->release?

I think so. release() is mandatory for final clean up, after the last
FD was closed, so every type of bpf_link has to implement this.
detach() is optional, though, and potentially can do different things
than release(). It just so happens right now that three bpf_linkl
types can re-use release as-is (with minimal change to netns release
specifically for detach use case). So I think having two is better and
more flexible.

>
> Thanks,
> Song
>
> [...]

  reply	other threads:[~2020-07-30 19:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 23:05 [PATCH bpf-next 0/5] BPF link force-detach support Andrii Nakryiko
2020-07-29 23:05 ` [PATCH bpf-next 1/5] bpf: add support for forced LINK_DETACH command Andrii Nakryiko
2020-07-30 17:43   ` Song Liu
2020-07-30 19:03     ` Andrii Nakryiko [this message]
2020-07-30 20:53       ` Song Liu
2020-07-29 23:05 ` [PATCH bpf-next 2/5] libbpf: add bpf_link detach APIs Andrii Nakryiko
2020-07-30 17:51   ` Song Liu
2020-07-29 23:05 ` [PATCH bpf-next 3/5] selftests/bpf: add link detach tests for cgroup, netns, and xdp bpf_links Andrii Nakryiko
2020-07-30 20:56   ` Song Liu
2020-07-29 23:05 ` [PATCH bpf-next 4/5] tools/bpftool: add `link detach` subcommand Andrii Nakryiko
2020-07-30 21:02   ` Song Liu
2020-07-30 21:14     ` Andrii Nakryiko
2020-07-29 23:05 ` [PATCH bpf-next 5/5] tools/bpftool: add documentation and bash-completion for `link detach` Andrii Nakryiko
2020-07-30 21:13   ` Song Liu
2020-07-30 21:16     ` Andrii Nakryiko
2020-07-30 21:50       ` Song Liu
2020-08-10 15:01 ` [PATCH bpf-next 0/5] BPF link force-detach support Toke Høiland-Jørgensen
2020-08-10 18:43   ` Andrii Nakryiko
2020-08-10 19:03     ` Toke Høiland-Jørgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEf4BzZsYoBZjsSKgQ-+OYRCa=Xn1EVwmdjGM5FG5oZv7_9vkw@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=Kernel-team@fb.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=toke@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).