From: John Fastabend <john.fastabend@gmail.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org
Subject: Re: [PATCH] bpf: bpftool, add support for attaching programs to maps
Date: Wed, 10 Oct 2018 10:53:11 -0700 [thread overview]
Message-ID: <390f3e39-9cd9-e61c-93bd-d5b5908bbb08@gmail.com> (raw)
In-Reply-To: <20181010101146.18e7d3ff@cakuba.netronome.com>
On 10/10/2018 10:11 AM, Jakub Kicinski wrote:
> On Wed, 10 Oct 2018 09:44:26 -0700, John Fastabend wrote:
>> Sock map/hash introduce support for attaching programs to maps. To
>> date I have been doing this with custom tooling but this is less than
>> ideal as we shift to using bpftool as the single CLI for our BPF uses.
>> This patch adds new sub commands 'attach' and 'detach' to the 'prog'
>> command to attach programs to maps and then detach them.
>>
>> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
>> ---
>> tools/bpf/bpftool/main.h | 1 +
>> tools/bpf/bpftool/prog.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 92 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
>> index 40492cd..9ceb2b6 100644
>> --- a/tools/bpf/bpftool/main.h
>> +++ b/tools/bpf/bpftool/main.h
>> @@ -137,6 +137,7 @@ int cmd_select(const struct cmd *cmds, int argc, char **argv,
>> int do_cgroup(int argc, char **arg);
>> int do_perf(int argc, char **arg);
>> int do_net(int argc, char **arg);
>> +int do_attach_cmd(int argc, char **arg);
>
> Looks like a leftover?
>
Yeah original I made attach/detach its own top level command
but it seems better fit under prog.
[..]
>> + if (!REQ_ARGS(4)) {
>
> Hm, 4 or 5? id $prog $type id $map ?
>
Yep thanks.
[...]
>> +
>> + NEXT_ARG();
>
> nit: maybe NEXT_ARG() should be grouped with the code that consumes the
> parameter, i.e. new line after not before?
sure.
>
>> + mapfd = map_parse_fd(&argc, &argv);
>> + if (mapfd < 0)
>> + return mapfd;
>> +
>> + err = bpf_prog_attach(progfd, mapfd, attach_type, 0);
>> + if (err) {
>> + p_err("failed prog attach to map");
>> + return -EINVAL;
>> + }
>
> Could you plunk a
>
> if (json_output)
> jsonw_null(json_wtr);
>
> here to always produce valid JSON even for commands with no output
> today?
>
Makes sense.
> Same comments for detach.
[...]
> Would you mind updating the man page and the bash completions?
>
Will do this. Thanks.
prev parent reply other threads:[~2018-10-11 1:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 16:44 [PATCH] bpf: bpftool, add support for attaching programs to maps John Fastabend
2018-10-10 17:11 ` Jakub Kicinski
2018-10-10 17:53 ` John Fastabend [this message]
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=390f3e39-9cd9-e61c-93bd-d5b5908bbb08@gmail.com \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=jakub.kicinski@netronome.com \
--cc=netdev@vger.kernel.org \
/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.