From: Stanislav Fomichev <sdf@google.com>
To: netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
Stanislav Fomichev <sdf@google.com>,
Quentin Monnet <quentin@isovalent.com>
Subject: [PATCH bpf-next v4 2/3] bpftool: conditionally append / to the progtype
Date: Thu, 21 Oct 2021 09:56:17 -0700 [thread overview]
Message-ID: <20211021165618.178352-3-sdf@google.com> (raw)
In-Reply-To: <20211021165618.178352-1-sdf@google.com>
Otherwise, attaching with bpftool doesn't work with strict section names.
Also, switch to libbpf strict mode to use the latest conventions
(note, I don't think we have any cli api guarantees?).
Cc: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
tools/bpf/bpftool/main.c | 4 ++++
tools/bpf/bpftool/prog.c | 9 +++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 02eaaf065f65..8223bac1e401 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -409,6 +409,10 @@ int main(int argc, char **argv)
block_mount = false;
bin_name = argv[0];
+ ret = libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
+ if (ret)
+ p_err("failed to enable libbpf strict mode: %d", ret);
+
hash_init(prog_table.table);
hash_init(map_table.table);
hash_init(link_table.table);
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 277d51c4c5d9..b04990588ccf 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -1420,8 +1420,13 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
err = get_prog_type_by_name(type, &common_prog_type,
&expected_attach_type);
free(type);
- if (err < 0)
- goto err_free_reuse_maps;
+ if (err < 0) {
+ err = get_prog_type_by_name(*argv, &common_prog_type,
+ &expected_attach_type);
+ if (err < 0)
+
+ goto err_free_reuse_maps;
+ }
NEXT_ARG();
} else if (is_prefix(*argv, "map")) {
--
2.33.0.1079.g6e70778dc9-goog
next prev parent reply other threads:[~2021-10-21 16:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 16:56 [PATCH bpf-next v4 0/3] libbpf: use func name when pinning programs with LIBBPF_STRICT_SEC_NAME Stanislav Fomichev
2021-10-21 16:56 ` [PATCH bpf-next v4 1/3] " Stanislav Fomichev
2021-10-21 16:56 ` Stanislav Fomichev [this message]
2021-10-21 19:55 ` [PATCH bpf-next v4 2/3] bpftool: conditionally append / to the progtype Quentin Monnet
2021-10-21 20:40 ` Stanislav Fomichev
2021-10-21 21:10 ` Quentin Monnet
2021-10-21 16:56 ` [PATCH bpf-next v4 3/3] selftests/bpf: fix flow dissector tests Stanislav Fomichev
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=20211021165618.178352-3-sdf@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=quentin@isovalent.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).