From: Yafang Shao <laoar.shao@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
andrii@kernel.org, martin.lau@linux.dev, song@kernel.org,
yhs@fb.com, kpsingh@kernel.org, sdf@google.com,
haoluo@google.com, jolsa@kernel.org, quentin@isovalent.com
Cc: bpf@vger.kernel.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [RFC PATCH bpf-next 1/4] bpf: Add __bpf_iter_attach_cgroup()
Date: Sun, 16 Jul 2023 12:10:43 +0000 [thread overview]
Message-ID: <20230716121046.17110-2-laoar.shao@gmail.com> (raw)
In-Reply-To: <20230716121046.17110-1-laoar.shao@gmail.com>
This is a preparation for the followup patch. No functional change.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
kernel/bpf/cgroup_iter.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/kernel/bpf/cgroup_iter.c b/kernel/bpf/cgroup_iter.c
index 810378f04fbc..619c13c30e87 100644
--- a/kernel/bpf/cgroup_iter.c
+++ b/kernel/bpf/cgroup_iter.c
@@ -191,21 +191,14 @@ static const struct bpf_iter_seq_info cgroup_iter_seq_info = {
.seq_priv_size = sizeof(struct cgroup_iter_priv),
};
-static int bpf_iter_attach_cgroup(struct bpf_prog *prog,
- union bpf_iter_link_info *linfo,
- struct bpf_iter_aux_info *aux)
+static int __bpf_iter_attach_cgroup(struct bpf_prog *prog,
+ union bpf_iter_link_info *linfo,
+ struct bpf_iter_aux_info *aux)
{
int fd = linfo->cgroup.cgroup_fd;
u64 id = linfo->cgroup.cgroup_id;
- int order = linfo->cgroup.order;
struct cgroup *cgrp;
- if (order != BPF_CGROUP_ITER_DESCENDANTS_PRE &&
- order != BPF_CGROUP_ITER_DESCENDANTS_POST &&
- order != BPF_CGROUP_ITER_ANCESTORS_UP &&
- order != BPF_CGROUP_ITER_SELF_ONLY)
- return -EINVAL;
-
if (fd && id)
return -EINVAL;
@@ -220,10 +213,25 @@ static int bpf_iter_attach_cgroup(struct bpf_prog *prog,
return PTR_ERR(cgrp);
aux->cgroup.start = cgrp;
- aux->cgroup.order = order;
return 0;
}
+static int bpf_iter_attach_cgroup(struct bpf_prog *prog,
+ union bpf_iter_link_info *linfo,
+ struct bpf_iter_aux_info *aux)
+{
+ int order = linfo->cgroup.order;
+
+ if (order != BPF_CGROUP_ITER_DESCENDANTS_PRE &&
+ order != BPF_CGROUP_ITER_DESCENDANTS_POST &&
+ order != BPF_CGROUP_ITER_ANCESTORS_UP &&
+ order != BPF_CGROUP_ITER_SELF_ONLY)
+ return -EINVAL;
+
+ aux->cgroup.order = order;
+ return __bpf_iter_attach_cgroup(prog, linfo, aux);
+}
+
static void bpf_iter_detach_cgroup(struct bpf_iter_aux_info *aux)
{
cgroup_put(aux->cgroup.start);
--
2.39.3
next prev parent reply other threads:[~2023-07-16 12:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-16 12:10 [RFC PATCH bpf-next 0/4] bpf: Introduce cgroup_task iter Yafang Shao
2023-07-16 12:10 ` Yafang Shao [this message]
2023-07-16 12:10 ` [RFC PATCH bpf-next 2/4] bpf: Add " Yafang Shao
2023-07-16 12:10 ` [RFC PATCH bpf-next 3/4] bpftool: Add support for cgroup_task Yafang Shao
2023-07-16 12:10 ` [RFC PATCH bpf-next 4/4] selftests/bpf: Add selftest for cgroup_task iter Yafang Shao
2023-07-27 14:29 ` [RFC PATCH bpf-next 0/4] bpf: Introduce " Yafang Shao
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=20230716121046.17110-2-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=quentin@isovalent.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yhs@fb.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).