BPF List
 help / color / mirror / Atom feed
From: <thinker.li@gmail.com>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <martin.lau@linux.dev>,
	<kernel-team@meta.com>, <andrii@kernel.org>,
	<sinquersw@gmail.com>, <kuifeng@meta.com>, <thinker.li@gmail.com>
Cc: Quentin Monnet <qmo@kernel.org>
Subject: [PATCH bpf-next v7 8/8] bpftool: Change pid_iter.bpf.c to comply with the change of bpf_link_fops.
Date: Wed, 29 May 2024 23:59:46 -0700	[thread overview]
Message-ID: <20240530065946.979330-9-thinker.li@gmail.com> (raw)
In-Reply-To: <20240530065946.979330-1-thinker.li@gmail.com>

From: Kui-Feng Lee <thinker.li@gmail.com>

To support epoll, a new instance of file_operations, bpf_link_fops_poll,
has been added for links that support epoll. The pid_iter.bpf.c checks
f_ops for links and other BPF objects. The check should fail for struct_ops
links without this patch.

Acked-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
---
 tools/bpf/bpftool/skeleton/pid_iter.bpf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/skeleton/pid_iter.bpf.c b/tools/bpf/bpftool/skeleton/pid_iter.bpf.c
index 7bdbcac3cf62..948dde25034e 100644
--- a/tools/bpf/bpftool/skeleton/pid_iter.bpf.c
+++ b/tools/bpf/bpftool/skeleton/pid_iter.bpf.c
@@ -29,6 +29,7 @@ enum bpf_link_type___local {
 };
 
 extern const void bpf_link_fops __ksym;
+extern const void bpf_link_fops_poll __ksym __weak;
 extern const void bpf_map_fops __ksym;
 extern const void bpf_prog_fops __ksym;
 extern const void btf_fops __ksym;
@@ -84,7 +85,11 @@ int iter(struct bpf_iter__task_file *ctx)
 		fops = &btf_fops;
 		break;
 	case BPF_OBJ_LINK:
-		fops = &bpf_link_fops;
+		if (&bpf_link_fops_poll &&
+		    file->f_op == &bpf_link_fops_poll)
+			fops = &bpf_link_fops_poll;
+		else
+			fops = &bpf_link_fops;
 		break;
 	default:
 		return 0;
-- 
2.43.0


  parent reply	other threads:[~2024-05-30  7:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-30  6:59 [PATCH bpf-next v7 0/8] Notify user space when a struct_ops object is detached/unregistered thinker.li
2024-05-30  6:59 ` [PATCH bpf-next v7 1/8] bpf: pass bpf_struct_ops_link to callbacks in bpf_struct_ops thinker.li
2024-05-30  6:59 ` [PATCH bpf-next v7 2/8] bpf: enable detaching links of struct_ops objects thinker.li
2024-05-30  6:59 ` [PATCH bpf-next v7 3/8] bpf: support epoll from bpf struct_ops links thinker.li
2024-05-30  6:59 ` [PATCH bpf-next v7 4/8] bpf: export bpf_link_inc_not_zero thinker.li
2024-05-30  6:59 ` [PATCH bpf-next v7 5/8] selftests/bpf: test struct_ops with epoll thinker.li
2024-05-30  6:59 ` [PATCH bpf-next v7 6/8] selftests/bpf: detach a struct_ops link from the subsystem managing it thinker.li
2024-05-30 23:02   ` Martin KaFai Lau
2024-05-30  6:59 ` [PATCH bpf-next v7 7/8] selftests/bpf: make sure bpf_testmod handling racing link destroying well thinker.li
2024-05-30  6:59 ` thinker.li [this message]
2024-05-30 22:40 ` [PATCH bpf-next v7 0/8] Notify user space when a struct_ops object is detached/unregistered patchwork-bot+netdevbpf

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=20240530065946.979330-9-thinker.li@gmail.com \
    --to=thinker.li@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuifeng@meta.com \
    --cc=martin.lau@linux.dev \
    --cc=qmo@kernel.org \
    --cc=sinquersw@gmail.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