[PATCH bpf-next v3 3/3] libbpf: add selftests for TC-BPF API

2021-04-20 Thread Kumar Kartikeya Dwivedi
This adds some basic tests for the low level bpf_tc_* API. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi --- .../selftests/bpf/prog_tests/test_tc_bpf.c| 169 ++ .../selftests/bpf/progs/test_tc_bpf_kern.c| 12 ++ 2 files changed, 181

[PATCH bpf-next v3 2/3] libbpf: add low level TC-BPF API

2021-04-20 Thread Kumar Kartikeya Dwivedi
info); if (r < 0) return r; ... where id corresponds to the bpf_tc_attach_id filled in during an attach operation. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi --- tools/lib/bpf/libbpf.h | 44 ++ tools/lib/bpf/libbpf.map | 3 +

[PATCH bpf-next v3 1/3] libbpf: add helpers for preparing netlink attributes

2021-04-20 Thread Kumar Kartikeya Dwivedi
verts the open coded attribute preparation with the helpers. Note that the only failure the internal call to nlattr_add could result in the nested helper would be -EMSGSIZE, hence that is what we return to our caller. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi ---

[PATCH bpf-next v3 0/3] Add TC-BPF API

2021-04-20 Thread Kumar Kartikeya Dwivedi
is already set up, we skip the setup and move on with filter creation. * Other minor changes that came up during the course of discussion and rework. Kumar Kartikeya Dwivedi (3): libbpf: add helpers for preparing netlink attributes libbpf: add low level TC-BPF API libbpf: add selftests fo

Re: [PATCH bpf-next v2 3/4] libbpf: add low level TC-BPF API

2021-04-19 Thread Kumar Kartikeya Dwivedi
On Tue, Apr 20, 2021 at 02:30:44AM IST, Daniel Borkmann wrote: > On 4/19/21 2:18 PM, Kumar Kartikeya Dwivedi wrote: > > This adds functions that wrap the netlink API used for adding, > > manipulating, and removing traffic control filters. These functions > > operate directly

[PATCH bpf-next v2 4/4] libbpf: add selftests for TC-BPF API

2021-04-19 Thread Kumar Kartikeya Dwivedi
This adds some basic tests for the low level bpf_tc_cls_* API. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi --- .../selftests/bpf/prog_tests/test_tc_bpf.c| 112 ++ .../selftests/bpf/progs/test_tc_bpf_kern.c| 12 ++ 2 files changed, 124

[PATCH bpf-next v2 3/4] libbpf: add low level TC-BPF API

2021-04-19 Thread Kumar Kartikeya Dwivedi
if (r < 0) return r; assert(info.class_id == TC_H_MAKE(1UL << 16, 12)); This would be roughly equivalent to doing: # tc filter change dev lo egress prio handle bpf obj foo.o sec \ classifier classid 1:12 ... except a new bpf program will be loaded and

[PATCH bpf-next v2 2/4] libbpf: add helpers for preparing netlink attributes

2021-04-19 Thread Kumar Kartikeya Dwivedi
verts the open coded attribute preparation with the helpers. Note that the only failure the internal call to nlattr_add could result in the nested helper would be -EMSGSIZE, hence that is what we return to our caller. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi ---

[PATCH bpf-next v2 1/4] tools: pkt_cls.h: sync with kernel sources

2021-04-19 Thread Kumar Kartikeya Dwivedi
Update the header file so we can use the new defines in subsequent patches. Also make sure they remain up to date. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi --- tools/include/uapi/linux/pkt_cls.h | 174 - tools/lib/bpf/Makefile

[PATCH bpf-next v2 0/4] Add TC-BPF API

2021-04-19 Thread Kumar Kartikeya Dwivedi
isc is already set up, we skip the setup and move on with filter creation. * Other minor changes that came up during the course of discussion and rework. Kumar Kartikeya Dwivedi (4): tools: pkt_cls.h: sync with kernel sources libbpf: add helpers for preparing netlink attributes libbpf: ad

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-06 Thread Kumar Kartikeya Dwivedi
On Mon, Apr 05, 2021 at 10:51:09PM IST, Andrii Nakryiko wrote: > > [...] > > if _block variant is just a special ifindex value, then it should be > fine for users to know such a detail (we can leave a comment > mentioning this specifically), especially given it's not a very > popular thing. Almost

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-02 Thread Kumar Kartikeya Dwivedi
On Sat, Apr 03, 2021 at 12:02:14AM IST, Alexei Starovoitov wrote: > On Fri, Apr 2, 2021 at 8:27 AM Kumar Kartikeya Dwivedi > wrote: > > [...] > > All of these things are messy because of tc legacy. bpf tried to follow tc > style > with cls and act distinction and it did

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-02 Thread Kumar Kartikeya Dwivedi
On Fri, Apr 02, 2021 at 05:49:29AM IST, Daniel Borkmann wrote: > On 3/31/21 11:44 AM, Kumar Kartikeya Dwivedi wrote: > > On Wed, Mar 31, 2021 at 02:55:47AM IST, Daniel Borkmann wrote: > > > Do we even need the _block variant? I would rather prefer to take the > > >

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-03-31 Thread Kumar Kartikeya Dwivedi
On Wed, Mar 31, 2021 at 02:55:47AM IST, Daniel Borkmann wrote: > Do we even need the _block variant? I would rather prefer to take the chance > and make it as simple as possible, and only iff really needed extend with > other APIs, for example: The block variant can be dropped, I'll use the TC_BLO

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-03-31 Thread Kumar Kartikeya Dwivedi
On Wed, Mar 31, 2021 at 02:41:40AM IST, Toke Høiland-Jørgensen wrote: > Andrii Nakryiko writes: > > > On Sun, Mar 28, 2021 at 1:11 AM Kumar Kartikeya Dwivedi > > wrote: > >> > >> On Sun, Mar 28, 2021 at 10:12:40AM IST, Andrii Nakryiko wrote: > >>

Re: [PATCH v2 1/1] net: sched: bump refcount for new action in ACT replace mode

2021-03-31 Thread Kumar Kartikeya Dwivedi
On Wed, Mar 31, 2021 at 10:10:45AM IST, Cong Wang wrote: > On Mon, Mar 29, 2021 at 3:55 PM Kumar Kartikeya Dwivedi > wrote: > > diff --git a/net/sched/act_api.c b/net/sched/act_api.c > > index b919826939e0..43cceb924976 100644 > > --- a/net/sched/act_api.c >

[PATCH net-next v3] net: sched: bump refcount for new action in ACT replace mode

2021-03-31 Thread Kumar Kartikeya Dwivedi
reference counting action init") Signed-off-by: Kumar Kartikeya Dwivedi --- Changelog: v2 -> v3 Cleanup new action on rollback after raising refcount (Cong) v1 -> v2 Remove erroneous tcf_action_put_many call in tcf_exts_validate (Vlad) Isolate refcount bump to ACT API in replace

Re: [PATCH 1/1] net: sched: extend lifetime of new action in replace mode

2021-03-29 Thread Kumar Kartikeya Dwivedi
On Mon, Mar 29, 2021 at 02:35:12PM IST, Vlad Buslov wrote: > it seems that there are two ways actions are overwritten/deleted: > > 1. Directly through action API, which is still serialized by rtnl lock. > > 2. Classifier API, which doesn't use rtnl lock anymore and can execute > concurrently. > > A

[PATCH v2 1/1] net: sched: bump refcount for new action in ACT replace mode

2021-03-29 Thread Kumar Kartikeya Dwivedi
is no existing action, so no tcf_exts_destroy callback happens. This means no code changes for CLS API. Fixes: cae422f379f3 ("net: sched: use reference counting action init") Signed-off-by: Kumar Kartikeya Dwivedi --- Changelog: v1 -> v2 Remove erroneous tcf_action_put_many call in

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-28 Thread Kumar Kartikeya Dwivedi
On Mon, Mar 29, 2021 at 06:56:02AM IST, Alexei Starovoitov wrote: > This is up to you. I'm trying to understand the motivation for *_block() apis. > I'm not taking a stance for/against them. The block APIs simply attach to a different shared filter block, so in that sense they just forward to the

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-03-28 Thread Kumar Kartikeya Dwivedi
On Sun, Mar 28, 2021 at 10:12:40AM IST, Andrii Nakryiko wrote: > Is there some succinct but complete enough documentation/tutorial/etc > that I can reasonably read to understand kernel APIs provided by TC > (w.r.t. BPF, of course). I'm trying to wrap my head around this and > whether API makes sens

[PATCH 1/1] net: sched: extend lifetime of new action in replace mode

2021-03-27 Thread Kumar Kartikeya Dwivedi
ll to release the reference held during insertion. This is only needed in replace mode. We use a relaxed store as insert will ensure its visibility. Fixes: cae422f379f3 ("net: sched: use reference counting action init") Signed-off-by: Kumar Kartikeya Dwivedi --- include/net/act_api.h |

Re: [PATCH bpf-next 1/5] tools pkt_cls.h: sync with kernel sources

2021-03-26 Thread Kumar Kartikeya Dwivedi
On Sat, Mar 27, 2021 at 04:55:51AM IST, Andrii Nakryiko wrote: > On Thu, Mar 25, 2021 at 5:01 AM Kumar Kartikeya Dwivedi > wrote: > > > > Update the header file so we can use the new defines in subsequent > > patches. > > > > Reviewed-by: Toke Høiland-Jørgensen

[PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-25 Thread Kumar Kartikeya Dwivedi
This adds some basic tests for the low level bpf_tc_* API and its bpf_program__attach_tc_* wrapper on top. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi --- .../selftests/bpf/prog_tests/test_tc_bpf.c| 261 ++ .../selftests/bpf/progs

[PATCH bpf-next 4/5] libbpf: add high level TC-BPF API

2021-03-25 Thread Kumar Kartikeya Dwivedi
LL(link)) return PTR_ERR(link); bpf_link__destroy(link); Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi --- tools/lib/bpf/libbpf.c | 110 ++- tools/lib/bpf/libbpf.h | 15 ++ tools/lib/bpf/libbpf.map |

[PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-03-25 Thread Kumar Kartikeya Dwivedi
on tc action del action bpf index Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi --- tools/lib/bpf/libbpf.h | 118 +++ tools/lib/bpf/libbpf.map | 14 + tools/lib/bpf/netlink.c | 715 ++- 3 files changed, 841 insertion

[PATCH bpf-next 2/5] libbpf: add helpers for preparing netlink attributes

2021-03-25 Thread Kumar Kartikeya Dwivedi
verts the open coded attribute preparation with the helpers. Note that the only failure the internal call to add_nlattr could result in the nested helper would be -EMSGSIZE, hence that is what we return to our caller. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi ---

[PATCH bpf-next 1/5] tools pkt_cls.h: sync with kernel sources

2021-03-25 Thread Kumar Kartikeya Dwivedi
Update the header file so we can use the new defines in subsequent patches. Reviewed-by: Toke Høiland-Jørgensen Signed-off-by: Kumar Kartikeya Dwivedi --- tools/include/uapi/linux/pkt_cls.h | 174 - 1 file changed, 170 insertions(+), 4 deletions(-) diff --git a

[PATCH bpf-next 0/5] libbpf: Add TC-BPF API

2021-03-25 Thread Kumar Kartikeya Dwivedi
k__destroy, which will also cause the filter/action to be detached if not disconnected. The individual commits contain a general API summary and examples. Kumar Kartikeya Dwivedi (5): tools pkt_cls.h: sync with kernel sources libbpf: add helpers for preparing netlink attributes libbpf: add lo

[PATCH bpf-next v2] libbpf: use SOCK_CLOEXEC when opening the netlink socket

2021-03-17 Thread Kumar Kartikeya Dwivedi
Otherwise, there exists a small window between the opening and closing of the socket fd where it may leak into processes launched by some other thread. Fixes: 949abbe88436 ("libbpf: add function to setup XDP") Signed-off-by: Kumar Kartikeya Dwivedi --- Changelog: v1 -> v2 Tag the

[PATCH] libbpf: use SOCK_CLOEXEC when opening the netlink socket

2021-03-17 Thread Kumar Kartikeya Dwivedi
Otherwise, there exists a small window between the opening and closing of the socket fd where it may leak into processes launched by some other thread. Signed-off-by: Kumar Kartikeya Dwivedi --- tools/lib/bpf/netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools

[PATCH v2] staging: qlge/qlge_ethtool.c: Switch from strlcpy to strscpy

2021-01-30 Thread Kumar Kartikeya Dwivedi
checkpatch warnings from: 5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy") Signed-off-by: Kumar Kartikeya Dwivedi --- drivers/staging/qlge/qlge_ethtool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/qlge/qlge_ethtool.c b/drivers/st

[PATCH] staging: qlge/qlge_ethtool.c: strlcpy -> strscpy

2021-01-28 Thread Kumar Kartikeya Dwivedi
Fixes checkpatch warnings for usage of strlcpy. Signed-off-by: Kumar Kartikeya Dwivedi --- drivers/staging/qlge/qlge_ethtool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/qlge/qlge_ethtool.c b/drivers/staging/qlge/qlge_ethtool.c index a28f0254c