All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: davem@davemloft.net
Cc: daniel@iogearbox.net, andrii@kernel.org, bpf@vger.kernel.org,
	kernel-team@fb.com
Subject: [PATCH bpf-next 6/7] bpf: Open code obj_get_info_by_fd in bpf preload.
Date: Mon, 31 Jan 2022 14:05:27 -0800	[thread overview]
Message-ID: <20220131220528.98088-7-alexei.starovoitov@gmail.com> (raw)
In-Reply-To: <20220131220528.98088-1-alexei.starovoitov@gmail.com>

From: Alexei Starovoitov <ast@kernel.org>

Open code obj_get_info_by_fd in bpf preload.
It's the last part of libbpf that preload/iterators were using.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
 kernel/bpf/preload/iterators/iterators.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/preload/iterators/iterators.c b/kernel/bpf/preload/iterators/iterators.c
index 23b74916fb84..4dafe0f4f2b2 100644
--- a/kernel/bpf/preload/iterators/iterators.c
+++ b/kernel/bpf/preload/iterators/iterators.c
@@ -16,6 +16,22 @@
 int to_kernel = -1;
 int from_kernel = 0;
 
+static int __bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len)
+{
+	union bpf_attr attr;
+	int err;
+
+	memset(&attr, 0, sizeof(attr));
+	attr.info.bpf_fd = bpf_fd;
+	attr.info.info_len = *info_len;
+	attr.info.info = (long) info;
+
+	err = skel_sys_bpf(BPF_OBJ_GET_INFO_BY_FD, &attr, sizeof(attr));
+	if (!err)
+		*info_len = attr.info.info_len;
+	return err;
+}
+
 static int send_link_to_kernel(int link_fd, const char *link_name)
 {
 	struct bpf_preload_info obj = {};
@@ -23,7 +39,7 @@ static int send_link_to_kernel(int link_fd, const char *link_name)
 	__u32 info_len = sizeof(info);
 	int err;
 
-	err = bpf_obj_get_info_by_fd(link_fd, &info, &info_len);
+	err = __bpf_obj_get_info_by_fd(link_fd, &info, &info_len);
 	if (err)
 		return err;
 	obj.link_id = info.id;
-- 
2.30.2


  parent reply	other threads:[~2022-01-31 22:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-31 22:05 [PATCH bpf-next 0/7] bpf: drop libbpf from bpf preload Alexei Starovoitov
2022-01-31 22:05 ` [PATCH bpf-next 1/7] libbpf: Add support for bpf iter in light skeleton Alexei Starovoitov
2022-02-01 18:40   ` Martin KaFai Lau
2022-01-31 22:05 ` [PATCH bpf-next 2/7] libbpf: Open code low level bpf commands Alexei Starovoitov
2022-02-01 18:52   ` Martin KaFai Lau
2022-01-31 22:05 ` [PATCH bpf-next 3/7] libbpf: Open code raw_tp_open and link_create commands Alexei Starovoitov
2022-02-01 19:07   ` Martin KaFai Lau
2022-01-31 22:05 ` [PATCH bpf-next 4/7] bpf: Remove unnecessary setrlimit from bpf preload Alexei Starovoitov
2022-02-01 19:09   ` Martin KaFai Lau
2022-01-31 22:05 ` [PATCH bpf-next 5/7] bpf: Convert bpf preload to light skeleton Alexei Starovoitov
2022-02-01 19:18   ` Martin KaFai Lau
2022-01-31 22:05 ` Alexei Starovoitov [this message]
2022-02-01 19:26   ` [PATCH bpf-next 6/7] bpf: Open code obj_get_info_by_fd in bpf preload Martin KaFai Lau
2022-01-31 22:05 ` [PATCH bpf-next 7/7] bpf: Drop libbpf, libelf, libz dependency from " Alexei Starovoitov
2022-02-01 19:27   ` Martin KaFai Lau
2022-02-01 23:00 ` [PATCH bpf-next 0/7] bpf: drop libbpf " 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=20220131220528.98088-7-alexei.starovoitov@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.