From: Joe Stringer <joe@ovn.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>, Wang Nan <wangnan0@huawei.com>,
ast@fb.com, Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH perf/core REBASE 3/5] tools lib bpf: Add bpf_prog_{attach,detach}
Date: Tue, 20 Dec 2016 10:50:22 -0800 [thread overview]
Message-ID: <CAPWQB7HyzaAck1LEX_ec7gRpoKjyaZPZ+dco3Ca=sR4qQ403BQ@mail.gmail.com> (raw)
In-Reply-To: <20161220143217.GC32756@kernel.org>
On 20 December 2016 at 06:32, Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Em Tue, Dec 20, 2016 at 11:18:51AM -0300, Arnaldo Carvalho de Melo escreveu:
>> Em Wed, Dec 14, 2016 at 02:43:40PM -0800, Joe Stringer escreveu:
>> > Commit d8c5b17f2bc0 ("samples: bpf: add userspace example for attaching
>> > eBPF programs to cgroups") added these functions to samples/libbpf, but
>> > during this merge all of the samples libbpf functionality is shifting to
>> > tools/lib/bpf. Shift these functions there.
>> >
>> > Signed-off-by: Joe Stringer <joe@ovn.org>
>> > ---
>> > Arnaldo, this is a new patch you didn't previously review which I've
>> > prepared due to the conflict with net-next. I figured it's better to try
>> > to get samples/bpf properly switched over this window rather than defer the
>> > problem and end up having to deal with another merge problem next time
>> > around. I hope that is fine for you. If not, this patch onwards will need
>> > to be dropped
>> >
>> > It's a simple copy/paste/delete with a minor change for sys_bpf() vs
>> > syscall().
>> > ---
>> > samples/bpf/libbpf.c | 21 ---------------------
>> > samples/bpf/libbpf.h | 3 ---
>> > tools/lib/bpf/bpf.c | 21 +++++++++++++++++++++
>> > tools/lib/bpf/bpf.h | 3 +++
>> > 4 files changed, 24 insertions(+), 24 deletions(-)
>> >
>> > diff --git a/samples/bpf/libbpf.c b/samples/bpf/libbpf.c
>> > index 3391225ad7e9..d9af876b4a2c 100644
>> > --- a/samples/bpf/libbpf.c
>> > +++ b/samples/bpf/libbpf.c
>> > @@ -11,27 +11,6 @@
>> > #include <arpa/inet.h>
>> > #include "libbpf.h"
>> >
>> > -int bpf_prog_attach(int prog_fd, int target_fd, enum bpf_attach_type type)
>> > -{
>> > - union bpf_attr attr = {
>> > - .target_fd = target_fd,
>> > - .attach_bpf_fd = prog_fd,
>> > - .attach_type = type,
>> > - };
>> > -
>> > - return syscall(__NR_bpf, BPF_PROG_ATTACH, &attr, sizeof(attr));
>>
>> This one makes it fail for CentOS 5 and 6, others may fail as well,
>> still building, investigating...
>
> Ok, fixed it by making it follow the model of the other sys_bpf wrappers
> setting up that bpf_attr union wrt initializing unamed struct members:
>
> int bpf_prog_attach(int prog_fd, int target_fd, enum bpf_attach_type type)
> {
> - union bpf_attr attr = {
> - .target_fd = target_fd,
> - .attach_bpf_fd = prog_fd,
> - .attach_type = type,
> - };
> + union bpf_attr attr;
> +
> + bzero(&attr, sizeof(attr));
> + attr.target_fd = target_fd;
> + attr.attach_bpf_fd = prog_fd;
> + attr.attach_type = type;
>
> return sys_bpf(BPF_PROG_ATTACH, &attr, sizeof(attr));
> }
Ah, I just shifted these across originally so the delta would be
minimal but now I know why this code is like this. Thanks.
next prev parent reply other threads:[~2016-12-20 18:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 22:43 [PATCH perf/core REBASE 0/5] Reuse libbpf from samples/bpf Joe Stringer
2016-12-14 22:43 ` [PATCH perf/core REBASE 1/5] samples/bpf: Make samples more libbpf-centric Joe Stringer
2016-12-20 19:28 ` [tip:perf/urgent] " tip-bot for Joe Stringer
2016-12-14 22:43 ` [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf Joe Stringer
2016-12-15 15:50 ` Arnaldo Carvalho de Melo
2016-12-15 18:29 ` Arnaldo Carvalho de Melo
2016-12-15 18:34 ` Arnaldo Carvalho de Melo
2016-12-15 18:36 ` Arnaldo Carvalho de Melo
2016-12-15 22:00 ` Joe Stringer
2016-12-16 1:48 ` Joe Stringer
2016-12-16 14:21 ` Arnaldo Carvalho de Melo
2016-12-16 15:42 ` Arnaldo Carvalho de Melo
2016-12-20 13:41 ` Arnaldo Carvalho de Melo
2016-12-15 18:29 ` Joe Stringer
2016-12-15 19:04 ` Arnaldo Carvalho de Melo
2016-12-14 22:43 ` [PATCH perf/core REBASE 3/5] tools lib bpf: Add bpf_prog_{attach,detach} Joe Stringer
2016-12-20 14:18 ` Arnaldo Carvalho de Melo
2016-12-20 14:32 ` Arnaldo Carvalho de Melo
2016-12-20 18:50 ` Joe Stringer [this message]
2016-12-21 16:06 ` Arnaldo Carvalho de Melo
2016-12-14 22:43 ` [PATCH perf/core REBASE 4/5] samples/bpf: Remove perf_event_open() declaration Joe Stringer
2016-12-14 22:43 ` [PATCH perf/core REBASE 5/5] samples/bpf: Move open_raw_sock to separate header Joe Stringer
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='CAPWQB7HyzaAck1LEX_ec7gRpoKjyaZPZ+dco3Ca=sR4qQ403BQ@mail.gmail.com' \
--to=joe@ovn.org \
--cc=acme@kernel.org \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=wangnan0@huawei.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).