From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"Björn Töpel" <bjorn@kernel.org>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Jonathan Lemon" <jonathan.lemon@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"KP Singh" <kpsingh@kernel.org>,
bpf@vger.kernel.org, "Hangbin Liu" <liuhangbin@gmail.com>
Subject: [PATCH bpf-next 1/3] samples/bpf/xdpsock_user.c: Get rid of bpf_prog_load_xattr()
Date: Tue, 7 Jun 2022 16:40:01 +0800 [thread overview]
Message-ID: <20220607084003.898387-2-liuhangbin@gmail.com> (raw)
In-Reply-To: <20220607084003.898387-1-liuhangbin@gmail.com>
Commit 1e4edb6d8c4f ("samples/bpf: Get rid of bpf_prog_load_xattr()
use") tried to remove all the deprecated bpf_prog_load_xattr() API..
But xdpsock_user.c was left as it set GCC diagnostic ignored
"-Wdeprecated-declarations".
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
samples/bpf/xdpsock_user.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index be7d2572e3e6..3ea46c300df2 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -1742,17 +1742,22 @@ static void l2fwd_all(void)
static void load_xdp_program(char **argv, struct bpf_object **obj)
{
- struct bpf_prog_load_attr prog_load_attr = {
- .prog_type = BPF_PROG_TYPE_XDP,
- };
+ struct bpf_program *prog;
char xdp_filename[256];
int prog_fd;
snprintf(xdp_filename, sizeof(xdp_filename), "%s_kern.o", argv[0]);
- prog_load_attr.file = xdp_filename;
+ *obj = bpf_object__open_file(xdp_filename, NULL);
+ if (libbpf_get_error(*obj))
+ exit(EXIT_FAILURE);
- if (bpf_prog_load_xattr(&prog_load_attr, obj, &prog_fd))
+ prog = bpf_object__next_program(*obj, NULL);
+ bpf_program__set_type(prog, BPF_PROG_TYPE_XDP);
+
+ if (bpf_object__load(*obj))
exit(EXIT_FAILURE);
+
+ prog_fd = bpf_program__fd(prog);
if (prog_fd < 0) {
fprintf(stderr, "ERROR: no program found: %s\n",
strerror(prog_fd));
@@ -1885,10 +1890,10 @@ int main(int argc, char **argv)
{
struct __user_cap_header_struct hdr = { _LINUX_CAPABILITY_VERSION_3, 0 };
struct __user_cap_data_struct data[2] = { { 0 } };
+ struct bpf_object *obj = NULL;
bool rx = false, tx = false;
struct sched_param schparam;
struct xsk_umem_info *umem;
- struct bpf_object *obj;
int xsks_map_fd = 0;
pthread_t pt;
int i, ret;
--
2.35.1
next prev parent reply other threads:[~2022-06-07 8:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 8:40 [PATCH bpf-next 0/3] move AF_XDP APIs to libxdp Hangbin Liu
2022-06-07 8:40 ` Hangbin Liu [this message]
2022-06-07 8:40 ` [PATCH bpf-next 2/3] samples/bpf: " Hangbin Liu
2022-06-07 8:40 ` [PATCH bpf-next 3/3] selftests/bpf: " Hangbin Liu
2022-06-07 9:31 ` [PATCH bpf-next 0/3] " Toke Høiland-Jørgensen
2022-06-07 23:28 ` Andrii Nakryiko
2022-06-08 2:31 ` Hangbin Liu
2022-06-08 2:29 ` Hangbin Liu
2022-06-08 10:18 ` Magnus Karlsson
2022-06-09 1:26 ` Hangbin Liu
2022-06-09 20:29 ` Andrii Nakryiko
2022-06-09 20:52 ` Daniel Borkmann
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=20220607084003.898387-2-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jonathan.lemon@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=toke@redhat.com \
--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).