[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEKGpzi8suN-ftSiERx4WT2y1vtq+=L=0aBYva8NgYmhkWbNeA@mail.gmail.com>
Date: Wed, 18 Nov 2020 12:21:23 +0900
From: "Daniel T. Lee" <danieltimlee@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Daniel Borkmann <daniel@...earbox.net>,
Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>, brakmo <brakmo@...com>,
Jesper Dangaard Brouer <brouer@...hat.com>,
Lorenzo Bianconi <lorenzo@...nel.org>,
David Ahern <dsa@...ulusnetworks.com>,
Yonghong Song <yhs@...com>,
Toke Høiland-Jørgensen <toke@...hat.com>,
Ira Weiny <ira.weiny@...el.com>, Thomas Graf <tgraf@...g.ch>,
Jakub Kicinski <kuba@...nel.org>,
Martin KaFai Lau <kafai@...com>,
John Fastabend <john.fastabend@...il.com>,
bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
Xdp <xdp-newbies@...r.kernel.org>
Subject: Re: [PATCH bpf-next 3/9] samples: bpf: refactor test_cgrp2_sock2
program with libbpf
On Wed, Nov 18, 2020 at 12:02 PM Andrii Nakryiko
<andrii.nakryiko@...il.com> wrote:
>
> On Tue, Nov 17, 2020 at 6:57 AM Daniel T. Lee <danieltimlee@...il.com> wrote:
> >
> > This commit refactors the existing cgroup program with libbpf bpf
> > loader. The original test_cgrp2_sock2 has keeped the bpf program
> > attached to the cgroup hierarchy even after the exit of user program.
> > To implement the same functionality with libbpf, this commit uses the
> > BPF_LINK_PINNING to pin the link attachment even after it is closed.
> >
> > Since this uses LINK instead of ATTACH, detach of bpf program from
> > cgroup with 'test_cgrp2_sock' is not used anymore.
> >
> > The code to mount the bpf was added to the .sh file in case the bpff
> > was not mounted on /sys/fs/bpf. Additionally, to fix the problem that
> > shell script cannot find the binary object from the current path,
> > relative path './' has been added in front of binary.
> >
> > Signed-off-by: Daniel T. Lee <danieltimlee@...il.com>
> > ---
> > samples/bpf/Makefile | 2 +-
> > samples/bpf/test_cgrp2_sock2.c | 63 ++++++++++++++++++++++++---------
> > samples/bpf/test_cgrp2_sock2.sh | 21 ++++++++---
> > 3 files changed, 64 insertions(+), 22 deletions(-)
> >
>
> [...]
>
> >
> > - return EXIT_SUCCESS;
> > + err = bpf_link__pin(link, link_pin_path);
> > + if (err < 0) {
> > + printf("err : %d\n", err);
>
> more meaningful error message would be helpful
>
Thanks for pointing out, I will fix it directly!
> > + goto cleanup;
> > + }
> > +
> > + ret = EXIT_SUCCESS;
> > +
> > +cleanup:
> > + if (ret != EXIT_SUCCESS)
> > + bpf_link__destroy(link);
> > +
> > + bpf_object__close(obj);
> > + return ret;
> > }
>
> [...]
>
> >
> > function attach_bpf {
> > - test_cgrp2_sock2 /tmp/cgroupv2/foo sock_flags_kern.o $1
> > + ./test_cgrp2_sock2 /tmp/cgroupv2/foo sock_flags_kern.o $1
>
> Can you please add Fixes: tag for this?
>
Will add it in the next version of patch :)
Thanks for your time and effort for the review.
--
Best,
Daniel T. Lee
Powered by blists - more mailing lists