Re: [PATCH v4 bpf 0/3] AF_XDP Socket Creation Fixes

2021-03-31 Thread Björn Töpel
shares the fd with the umem. > > v3->v4: > * Reduced nesting in xsk_put_ctx as suggested by Alexei. > * Use bools instead of a u8 and flags to represent the > ring setup status as suggested by Björn. > Thanks, Ciara! LGTM! Acked-by: Björn Töpel > v2->v3: > * Ins

Re: [PATCH v3 bpf 3/3] libbpf: only create rx and tx XDP rings when necessary

2021-03-30 Thread Björn Töpel
On Tue, 30 Mar 2021 at 14:05, Ciara Loftus wrote: > > Prior to this commit xsk_socket__create(_shared) always attempted to create > the rx and tx rings for the socket. However this causes an issue when the > socket being setup is that which shares the fd with the UMEM. If a > previous call to this

Re: [PATCH v3 bpf 2/3] libbpf: restore umem state after socket create failure

2021-03-30 Thread Björn Töpel
On Tue, 30 Mar 2021 at 17:08, Alexei Starovoitov wrote: > > On Tue, Mar 30, 2021 at 5:06 AM Ciara Loftus wrote: > > [...] > > if (--ctx->refcount == 0) { > > - err = xsk_get_mmap_offsets(umem->fd, &off); > > - if (!err) { > > - munmap(ct

Re: [PATCHv2 bpf-next 2/4] xdp: extend xdp_redirect_map with broadcast support

2021-03-18 Thread Björn Töpel
On Thu, 18 Mar 2021 at 04:52, Hangbin Liu wrote: > > On Wed, Mar 17, 2021 at 01:03:02PM +0100, Toke Høiland-Jørgensen wrote: > > FYI, this no longer applies to bpf-next due to Björn's refactor in > > commit: ee75aef23afe ("bpf, xdp: Restructure redirect actions") > > Thanks Toke, I need to see how

Re: [PATCH bpf-next 2/2] libbpf: xsk: move barriers from libbpf_util.h to xsk.h

2021-03-10 Thread Björn Töpel
On 2021-03-11 01:06, Jonathan Lemon wrote: On Wed, Mar 10, 2021 at 09:09:29AM +0100, Björn Töpel wrote: From: Björn Töpel The only user of libbpf_util.h is xsk.h. Move the barriers to xsk.h, and remove libbpf_util.h. The barriers are used as an implementation detail, and should not be

Re: linux-next: build failure after merge of the bpf-next tree

2021-03-10 Thread Björn Töpel
On 2021-03-11 01:47, Stephen Rothwell wrote: Hi all, After merging the bpf-next tree, today's linux-next build (perf) failed like this: make[3]: *** No rule to make target 'libbpf_util.h', needed by '/home/sfr/next/perf/staticobjs/xsk.o'. Stop. Hi Stephen, It's an incremental build issue,

[PATCH bpf-next 2/2] libbpf: xsk: move barriers from libbpf_util.h to xsk.h

2021-03-10 Thread Björn Töpel
From: Björn Töpel The only user of libbpf_util.h is xsk.h. Move the barriers to xsk.h, and remove libbpf_util.h. The barriers are used as an implementation detail, and should not be considered part of the stable API. Signed-off-by: Björn Töpel --- tools/lib/bpf/Makefile | 1 - tools/lib

[PATCH bpf-next 1/2] libbpf: xsk: remove linux/compiler.h header

2021-03-10 Thread Björn Töpel
From: Björn Töpel In commit 291471dd1559 ("libbpf, xsk: Add libbpf_smp_store_release libbpf_smp_load_acquire") linux/compiler.h was added as a dependency to xsk.h, which is the user-facing API. This makes it harder for userspace application to consume the library. Here the header in

[PATCH bpf-next 0/2] libbpf/xsk cleanups

2021-03-10 Thread Björn Töpel
This series removes a header dependency from xsk.h, and moves libbpf_util.h into xsk.h. More details in each commit! Thank you, Björn Björn Töpel (2): libbpf: xsk: remove linux/compiler.h header libbpf: xsk: move barriers from libbpf_util.h to xsk.h tools/lib/bpf/Makefile | 1

Re: [Intel-wired-lan] [net PATCH] ixgbe: Fix NULL pointer dereference in ethtool loopback test

2021-03-08 Thread Björn Töpel
ropagate napi_id to XDP socket Rx path") > Signed-off-by: Alexander Duyck Thanks Alex! Acked-by: Björn Töpel I'll look into if this applies to the other Intel drivers as well. Björn [...]

[PATCH bpf-next v6 2/2] bpf, xdp: restructure redirect actions

2021-03-08 Thread Björn Töpel
From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect targets for XDP either uses a map, or is based on ifindex. Here, the map type and id

[PATCH bpf-next v6 1/2] bpf, xdp: make bpf_redirect_map() a map operation

2021-03-08 Thread Björn Töpel
From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds bpf_redirect_map() as a map operation. Each map provides its bpf_redirect_map() version, and correct function is

[PATCH bpf-next v6 0/2] Optimize bpf_redirect_map()/xdp_do_redirect()

2021-03-08 Thread Björn Töpel
/bpf/20210226112322.144927-1-bjorn.to...@gmail.com/ v5: https://lore.kernel.org/bpf/20210227122139.183284-1-bjorn.to...@gmail.com/ Björn Töpel (2): bpf, xdp: make bpf_redirect_map() a map operation bpf, xdp: restructure redirect actions include/linux/bpf.h| 26 ++--- include/linux/filter

Re: [PATCH bpf-next v5 2/2] bpf, xdp: restructure redirect actions

2021-03-05 Thread Björn Töpel
On 2021-03-05 16:44, Daniel Borkmann wrote: On 2/27/21 1:21 PM, Björn Töpel wrote: [...] diff --git a/include/linux/filter.h b/include/linux/filter.h index 008691fd3b58..a7752badc2ec 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -646,11 +646,20 @@ struct bpf_redirect_info

Re: [PATCH bpf-next v5 1/2] bpf, xdp: make bpf_redirect_map() a map operation

2021-03-05 Thread Björn Töpel
On 2021-03-05 16:55, Daniel Borkmann wrote: On 2/27/21 1:21 PM, Björn Töpel wrote: [...] Look good. Small nits inline I had originally fixed up locally before glancing at 2/2: diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 4c730863fa77..3d3e89a37e62 100644 --- a/include/linux

[PATCH bpf-next v2 2/2] libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire

2021-03-05 Thread Björn Töpel
From: Björn Töpel Now that the AF_XDP rings have load-acquire/store-release semantics, move libbpf to that as well. The library-internal libbpf_smp_{load_acquire,store_release} are only valid for 32-bit words on ARM64. Also, remove the barriers that are no longer in use. Signed-off-by: Björn

[PATCH bpf-next v2 1/2] xsk: update rings for load-acquire/store-release barriers

2021-03-05 Thread Björn Töpel
From: Björn Töpel Currently, the AF_XDP rings uses general smp_{r,w,}mb() barriers on the kernel-side. On most modern architectures load-acquire/store-release barriers perform better, and results in simpler code for circular ring buffers. This change updates the XDP socket rings to use load

[PATCH bpf-next v2 0/2] load-acquire/store-release barriers for AF_XDP rings

2021-03-05 Thread Björn Töpel
https://lore.kernel.org/bpf/20210301104318.263262-1-bjorn.to...@gmail.com/ Thanks, Björn Björn Töpel (2): xsk: update rings for load-acquire/store-release barriers libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire net/xdp/xsk_queue.h | 30 +++- tool

Re: [PATCH bpf-next 2/2] libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire

2021-03-03 Thread Björn Töpel
On 2021-03-03 16:39, Will Deacon wrote: On Tue, Mar 02, 2021 at 10:13:21AM +0100, Daniel Borkmann wrote: [...] Would also be great to get Will's ACK on that when you have a v2. :) Please stick me on CC for that and I'll take a look as I've forgotten pretty much everything about this since

Re: [PATCH bpf-next 2/2] libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire

2021-03-03 Thread Björn Töpel
On Wed, 3 Mar 2021 at 08:14, Björn Töpel wrote: > > On 2021-03-03 05:38, Andrii Nakryiko wrote: > > On Mon, Mar 1, 2021 at 2:43 AM Björn Töpel wrote: > >> > >> From: Björn Töpel > >> > >> Now that the AF_XDP rings have load-acquire/store-rel

Re: [PATCH bpf-next 2/2] libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire

2021-03-03 Thread Björn Töpel
On Tue, 2 Mar 2021 at 10:25, Daniel Borkmann wrote: > [...] > > I wonder if it's possible to cook a LKMM litmus test for this...? > > That would be amazing! :-) > With the help of Paul and Alan [1] (Thanks!) I've cooked 8 litmus tests for this [2]. The litmus tests is based on a one entry ring

Re: [PATCH bpf-next 2/2] libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire

2021-03-03 Thread Björn Töpel
On 2021-03-03 05:38, Andrii Nakryiko wrote: On Mon, Mar 1, 2021 at 2:43 AM Björn Töpel wrote: From: Björn Töpel Now that the AF_XDP rings have load-acquire/store-release semantics, move libbpf to that as well. The library-internal libbpf_smp_{load_acquire,store_release} are only valid for

Re: [PATCH bpf-next 1/2] xsk: update rings for load-acquire/store-release semantics

2021-03-03 Thread Björn Töpel
On Tue, 2 Mar 2021 at 11:23, Toke Høiland-Jørgensen wrote: > > Björn Töpel writes: > > > On 2021-03-01 17:08, Toke Høiland-Jørgensen wrote: > >> Björn Töpel writes: > >> > >>> From: Björn Töpel > >>> > >>> Currently, the

Re: [PATCH bpf-next v3 0/4] selftests/bpf: xsk improvements and new stats tests

2021-03-02 Thread Björn Töpel
nguish between exiting due to initialisation failure vs test failure > > This series applies on commit d310ec03a34e92a77302edb804f7d68ee4f01ba0 > Ciara, this slipped on my side! Apologies! This is much better, thanks for working on it! For the series: Acked-by: Björn Töpel > > Cia

Re: [PATCH bpf-next 2/2] libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire

2021-03-02 Thread Björn Töpel
On 2021-03-02 10:13, Daniel Borkmann wrote: On 3/2/21 9:05 AM, Björn Töpel wrote: On 2021-03-01 17:10, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Now that the AF_XDP rings have load-acquire/store-release semantics, move libbpf to that as well. The library-internal

Re: [PATCH bpf-next 2/2] libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire

2021-03-02 Thread Björn Töpel
On 2021-03-01 17:10, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Now that the AF_XDP rings have load-acquire/store-release semantics, move libbpf to that as well. The library-internal libbpf_smp_{load_acquire,store_release} are only valid for 32-bit words on ARM64

Re: [PATCH bpf-next 1/2] xsk: update rings for load-acquire/store-release semantics

2021-03-02 Thread Björn Töpel
On 2021-03-01 17:08, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Currently, the AF_XDP rings uses smp_{r,w,}mb() fences on the kernel-side. By updating the rings for load-acquire/store-release semantics, the full barrier on the consumer side can be replaced with

[PATCH bpf-next 2/2] libbpf, xsk: add libbpf_smp_store_release libbpf_smp_load_acquire

2021-03-01 Thread Björn Töpel
From: Björn Töpel Now that the AF_XDP rings have load-acquire/store-release semantics, move libbpf to that as well. The library-internal libbpf_smp_{load_acquire,store_release} are only valid for 32-bit words on ARM64. Also, remove the barriers that are no longer in use. Signed-off-by: Björn

[PATCH bpf-next 1/2] xsk: update rings for load-acquire/store-release semantics

2021-03-01 Thread Björn Töpel
From: Björn Töpel Currently, the AF_XDP rings uses smp_{r,w,}mb() fences on the kernel-side. By updating the rings for load-acquire/store-release semantics, the full barrier on the consumer side can be replaced with improved performance as a nice side-effect. Note that this change does *not

[PATCH bpf-next 0/2] load-acquire/store-release semantics for AF_XDP rings

2021-03-01 Thread Björn Töpel
. This is effectively the change done in commit 6c43c091bdc5 ("documentation: Update circular buffer for load-acquire/store-release"), but for the AF_XDP rings. Both libbpf and the kernel-side are updated. More details in each commit. Thanks, Björn Björn Töpel (2): xsk: update ring

[PATCH bpf-next v5 0/2] Optimize bpf_redirect_map()/xdp_do_redirect()

2021-02-27 Thread Björn Töpel
4125-3-bjorn.to...@gmail.com/ v4: https://lore.kernel.org/bpf/20210226112322.144927-1-bjorn.to...@gmail.com/ Cheers, Björn Björn Töpel (2): bpf, xdp: make bpf_redirect_map() a map operation bpf, xdp: restructure redirect actions include/linux/bpf.h| 26 ++ include/linux/fil

[PATCH bpf-next v5 2/2] bpf, xdp: restructure redirect actions

2021-02-27 Thread Björn Töpel
From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect targets for XDP either uses a map, or is based on ifindex. Here, an explicit

[PATCH bpf-next v5 1/2] bpf, xdp: make bpf_redirect_map() a map operation

2021-02-27 Thread Björn Töpel
From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds bpf_redirect_map() as a map operation. Each map provides its bpf_redirect_map() version, and correct function is

Re: [PATCH bpf-next v4 1/2] bpf, xdp: make bpf_redirect_map() a map operation

2021-02-27 Thread Björn Töpel
On 2021-02-26 22:48, Daniel Borkmann wrote: On 2/26/21 12:23 PM, Björn Töpel wrote: From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds bpf_redirect_map() as a map

Re: [PATCH bpf-next v4 1/2] bpf, xdp: make bpf_redirect_map() a map operation

2021-02-26 Thread Björn Töpel
On 2021-02-26 12:40, Björn Töpel wrote: On 2021-02-26 12:37, Toke Høiland-Jørgensen wrote: [...] (That last paragraph above is why I asked if you updated the performance numbers in the cover letter; removing an additional function call should affect those, right?) Yeah, it should. Let

Re: [PATCH bpf-next v4 1/2] bpf, xdp: make bpf_redirect_map() a map operation

2021-02-26 Thread Björn Töpel
On 2021-02-26 12:37, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds bpf_redirect_map() as a map operation

Re: [PATCH bpf-next v4 0/2] Optimize bpf_redirect_map()/xdp_do_redirect()

2021-02-26 Thread Björn Töpel
On 2021-02-26 12:35, Toke Høiland-Jørgensen wrote: Björn Töpel writes: Hi XDP-folks, This two patch series contain two optimizations for the bpf_redirect_map() helper and the xdp_do_redirect() function. The bpf_redirect_map() optimization is about avoiding the map lookup dispatching

[PATCH bpf-next v4 2/2] bpf, xdp: restructure redirect actions

2021-02-26 Thread Björn Töpel
From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect targets for XDP either uses a map, or is based on ifindex. Here, an explicit

[PATCH bpf-next v4 1/2] bpf, xdp: make bpf_redirect_map() a map operation

2021-02-26 Thread Björn Töpel
From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds bpf_redirect_map() as a map operation. Each map provides its bpf_redirect_map() version, and correct function is

[PATCH bpf-next v4 0/2] Optimize bpf_redirect_map()/xdp_do_redirect()

2021-02-26 Thread Björn Töpel
8-1-bjorn.to...@gmail.com/ v3: https://lore.kernel.org/bpf/20210221200954.164125-3-bjorn.to...@gmail.com/ Cheers, Björn Björn Töpel (2): bpf, xdp: make bpf_redirect_map() a map operation bpf, xdp: restructure redirect actions include/linux/bpf.h| 26 ++ include/linux/filter

Re: [PATCH bpf-next v3 1/2] bpf, xdp: per-map bpf_redirect_map functions for XDP

2021-02-24 Thread Björn Töpel
On 2021-02-25 00:38, Daniel Borkmann wrote: On 2/21/21 9:09 PM, Björn Töpel wrote: From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds one bpf_redirect_map

[PATCH bpf-next v3 2/2] bpf, xdp: restructure redirect actions

2021-02-21 Thread Björn Töpel
From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect targets for XDP either uses a map, or is based on ifindex. Here, an explicit

[PATCH bpf-next v3 1/2] bpf, xdp: per-map bpf_redirect_map functions for XDP

2021-02-21 Thread Björn Töpel
From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds one bpf_redirect_map() implementation per map. Correct function is automatically selected by the BPF verifier. v2

[PATCH bpf-next v3 0/2] Optimize bpf_redirect_map()/xdp_do_redirect()

2021-02-21 Thread Björn Töpel
-drop), and 4% (sample:xdp_redirect_map) on my machine. More details in each commit. Changes since the RFC is outlined in each commit. Cheers, Björn Björn Töpel (2): bpf, xdp: per-map bpf_redirect_map functions for XDP bpf, xdp: restructure redirect actions include/linux/bpf.h| 21

Re: [PATCH bpf-next v2 1/2] bpf, xdp: per-map bpf_redirect_map functions for XDP

2021-02-21 Thread Björn Töpel
On 2021-02-20 18:00, kernel test robot wrote: Hi "Björn, I love your patch! Yet something to improve: [auto build test ERROR on 7b1e385c9a488de9291eaaa412146d3972e9dec5] url: https://github.com/0day-ci/linux/commits/Bj-rn-T-pel/Optimize-bpf_redirect_map-xdp_do_redirect/20210220-233623 base

[PATCH bpf-next v2 2/2] bpf, xdp: restructure redirect actions

2021-02-20 Thread Björn Töpel
From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect targets for XDP either uses a map, or is based on ifindex. Here, an explicit

[PATCH bpf-next v2 1/2] bpf, xdp: per-map bpf_redirect_map functions for XDP

2021-02-20 Thread Björn Töpel
From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds one bpf_redirect_map() implementation per map. Correct function is automatically selected by the BPF verifier. v1

[PATCH bpf-next v2 0/2] Optimize bpf_redirect_map()/xdp_do_redirect()

2021-02-20 Thread Björn Töpel
-drop), and 4% (sample:xdp_redirect_map) on my machine. More details in each commit. Changes since the RFC is outlined in each commit. Cheers, Björn Björn Töpel (2): bpf, xdp: per-map bpf_redirect_map functions for XDP bpf, xdp: restructure redirect actions include/linux/bpf.h| 21

Re: [PATCH bpf-next 2/2] bpf, xdp: restructure redirect actions

2021-02-19 Thread Björn Töpel
On 2021-02-19 18:10, Toke Høiland-Jørgensen wrote: + case XDP_REDIR_DEV_MAP: { struct bpf_dtab_netdev *dst = fwd; I thought the braces around the case body looked a bit odd. I guess that's to get a local scope for the dst var (and xs var below), right? This is basically a c

Re: [PATCH bpf-next 1/2] bpf, xdp: per-map bpf_redirect_map functions for XDP

2021-02-19 Thread Björn Töpel
On 2021-02-19 18:05, Toke Høiland-Jørgensen wrote: Björn Töpel writes: [...] @@ -4110,22 +4094,17 @@ static const struct bpf_func_proto bpf_xdp_redirect_proto = { .arg2_type = ARG_ANYTHING, }; -BPF_CALL_3(bpf_xdp_redirect_map, struct bpf_map *, map, u32, ifindex

[PATCH bpf-next 1/2] bpf, xdp: per-map bpf_redirect_map functions for XDP

2021-02-19 Thread Björn Töpel
From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds one bpf_redirect_map() implementation per map. Correct function is automatically selected by the BPF verifier. rfc

[PATCH bpf-next 2/2] bpf, xdp: restructure redirect actions

2021-02-19 Thread Björn Töpel
From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect targets for XDP either uses a map, or is based on ifindex. Here, an explicit

[PATCH bpf-next 0/2] Optimize bpf_redirect_map()/xdp_do_redirect()

2021-02-19 Thread Björn Töpel
-drop), and 4% (sample:xdp_redirect_map) on my machine. More details in each commit. Changes since the RFC is outlined in each commit. Cheers, Björn Björn Töpel (2): bpf, xdp: per-map bpf_redirect_map functions for XDP bpf, xdp: restructure redirect actions include/linux/bpf.h| 20

Re: [PATCH bpf-next 3/4] selftests/bpf: restructure xsk selftests

2021-02-18 Thread Björn Töpel
On Wed, 17 Feb 2021 at 17:33, Ciara Loftus wrote: > > Prior to this commit individual xsk tests were launched from the > shell script 'test_xsk.sh'. When adding a new test type, two new test > configurations had to be added to this file - one for each of the > supported XDP 'modes' (skb or drv). S

Re: [PATCH bpf-next 1/3] libbpf: xsk: use bpf_link

2021-02-16 Thread Björn Töpel
On 2021-02-16 03:23, Maciej Fijalkowski wrote: On Mon, Feb 15, 2021 at 04:18:28PM -0800, John Fastabend wrote: [...] Once again, is libxdp going to land in th kernel? Still not clear to me. No, libxdp does not live in the kernel tree. Björn [...]

Re: [PATCH bpf-next 3/3] samples: bpf: do not unload prog within xdpsock

2021-02-16 Thread Björn Töpel
On 2021-02-15 21:24, John Fastabend wrote: Maciej Fijalkowski wrote: With the introduction of bpf_link in xsk's libbpf part, there's no further need for explicit unload of prog on xdpsock's termination. When process dies, the bpf_link's refcount will be decremented and resources will be unloaded

Re: [PATCH bpf-next 1/3] libbpf: xsk: use bpf_link

2021-02-16 Thread Björn Töpel
On 2021-02-15 21:49, John Fastabend wrote: Maciej Fijalkowski wrote: Currently, if there are multiple xdpsock instances running on a single interface and in case one of the instances is terminated, the rest of them are left in an inoperable state due to the fact of unloaded XDP prog from interfa

Re: [PATCH bpf-next 1/3] libbpf: xsk: use bpf_link

2021-02-16 Thread Björn Töpel
On 2021-02-16 03:01, Maciej Fijalkowski wrote: On Mon, Feb 15, 2021 at 08:35:29PM +0100, Toke Høiland-Jørgensen wrote: Björn Töpel writes: [...] I'd say it's depending on the libbpf 1.0/libxdp merge timeframe. If we're months ahead, then I'd really like to see this

Re: [PATCH bpf-next 1/3] libbpf: xsk: use bpf_link

2021-02-15 Thread Björn Töpel
On 2021-02-15 18:07, Toke Høiland-Jørgensen wrote: Maciej Fijalkowski writes: Currently, if there are multiple xdpsock instances running on a single interface and in case one of the instances is terminated, the rest of them are left in an inoperable state due to the fact of unloaded XDP prog f

Re: [PATCH bpf-next 0/3] Introduce bpf_link in libbpf's xsk

2021-02-15 Thread Björn Töpel
/netdev/20190603131907.13395-5-maciej.fijalkow...@intel.com/ In the meantime bpf_link was introduced and it seems that it can address the issue of refcounting the XDP prog on interface. More info on commit messages. For the series: Reviewed-by: Björn Töpel Acked-by: Björn Töpel Finally, bpf_link

Re: [PATCH bpf-next] libbpf: use AF_LOCAL instead of AF_INET in xsk.c

2021-02-11 Thread Björn Töpel
-by: Stanislav Fomichev Stanislav, apologies for the delay! Tested-by: Björn Töpel Acked-by: Björn Töpel Björn > --- > tools/lib/bpf/xsk.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c > index 20500fb1f17e..

[PATCH bpf v4] selftests/bpf: convert test_xdp_redirect.sh to bash

2021-02-11 Thread Björn Töpel
From: Björn Töpel The test_xdp_redirect.sh script uses a bash feature, '&>'. On systems, e.g. Debian, where '/bin/sh' is dash, this will not work as expected. Use bash in the shebang to get the expected behavior. Further, using 'set -e' means that the

Re: [PATCH bpf v3] selftests/bpf: convert test_xdp_redirect.sh to bash

2021-02-11 Thread Björn Töpel
On 2021-02-10 21:13, Andrii Nakryiko wrote: On Mon, Feb 8, 2021 at 11:45 PM Björn Töpel wrote: From: Björn Töpel The test_xdp_redirect.sh script uses a bash feature, '&>'. On systems, e.g. Debian, where '/bin/sh' is dash, this will not work as expected. Use bas

[PATCH bpf v3] selftests/bpf: convert test_xdp_redirect.sh to bash

2021-02-08 Thread Björn Töpel
From: Björn Töpel The test_xdp_redirect.sh script uses a bash feature, '&>'. On systems, e.g. Debian, where '/bin/sh' is dash, this will not work as expected. Use bash in the shebang to get the expected behavior. Further, using 'set -e' means that the

Re: [PATCH bpf v2] selftests/bpf: remove bash feature in test_xdp_redirect.sh

2021-02-08 Thread Björn Töpel
On 2021-02-09 06:52, Andrii Nakryiko wrote: On Sat, Feb 6, 2021 at 1:29 AM Björn Töpel wrote: From: Björn Töpel The test_xdp_redirect.sh script uses a bash redirect feature, '&>/dev/null'. Use '>/dev/null 2>&1' instead. We have plenty of explicit b

[PATCH bpf v2] selftests/bpf: remove bash feature in test_xdp_redirect.sh

2021-02-06 Thread Björn Töpel
From: Björn Töpel The test_xdp_redirect.sh script uses a bash redirect feature, '&>/dev/null'. Use '>/dev/null 2>&1' instead. Also remove the 'set -e' since the script actually relies on that the return value can be used to determine pass

Re: [PATCH bpf] selftests/bpf: use bash instead of sh in test_xdp_redirect.sh

2021-02-05 Thread Björn Töpel
On Fri, 5 Feb 2021 at 18:39, Randy Dunlap wrote: > > On 2/5/21 9:30 AM, William Tu wrote: > > On Fri, Feb 5, 2021 at 9:09 AM Björn Töpel wrote: > >> > >> From: Björn Töpel > >> > >> The test_xdp_redirect.sh script uses some bash-features, such

[PATCH bpf] selftests/bpf: use bash instead of sh in test_xdp_redirect.sh

2021-02-05 Thread Björn Töpel
From: Björn Töpel The test_xdp_redirect.sh script uses some bash-features, such as '&>'. On systems that use dash as the sh implementation this will not work as intended. Change the shebang to use bash instead. Also remove the 'set -e' since the script actually reli

Re: [RFC PATCH bpf-next] bpf, xdp: per-map bpf_redirect_map functions for XDP

2021-02-01 Thread Björn Töpel
On 2021-02-01 10:31, Jesper Dangaard Brouer wrote: On Mon, 1 Feb 2021 07:27:57 +0100 Björn Töpel wrote: On 2021-01-29 17:45, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup

Re: [RFC PATCH bpf-next] bpf, xdp: per-map bpf_redirect_map functions for XDP

2021-01-31 Thread Björn Töpel
On 2021-01-29 17:45, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Currently the bpf_redirect_map() implementation dispatches to the correct map-lookup function via a switch-statement. To avoid the dispatching, this change adds one bpf_redirect_map() implementation per

[PATCH bpf-next 12/12] selftests/bpf: avoid useless void *-casts

2021-01-22 Thread Björn Töpel
From: Björn Töpel There is no need to cast to void * when the argument is void *. Avoid cluttering of code. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf

[PATCH bpf-next 08/12] selftests/bpf: change type from void * to struct generic_data *

2021-01-22 Thread Björn Töpel
From: Björn Töpel Instead of casting from void *, let us use the actual type in gen_udp_hdr(). Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools

[PATCH bpf-next 10/12] selftests/bpf: avoid heap allocation

2021-01-22 Thread Björn Töpel
From: Björn Töpel The data variable is only used locally. Instead of using the heap, stick to using the stack. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf

[PATCH bpf-next 09/12] selftests/bpf: define local variables at the beginning of a block

2021-01-22 Thread Björn Töpel
From: Björn Töpel Use C89 rules for variable definition. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf

[PATCH bpf-next 11/12] selftests/bpf: consistent malloc/calloc usage

2021-01-22 Thread Björn Töpel
From: Björn Töpel Use calloc instead of malloc where it makes sense, and avoid C++-style void *-cast. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf

[PATCH bpf-next 07/12] selftests/bpf: change type from void * to struct ifaceconfigobj *

2021-01-22 Thread Björn Töpel
From: Björn Töpel Instead of casting from void *, let us use the actual type in init_iface_config(). Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 28 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests

[PATCH bpf-next 04/12] selftests/bpf: remove memory leak

2021-01-22 Thread Björn Töpel
From: Björn Töpel The allocated entry is immediately overwritten by an assignment. Fix that. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf

[PATCH bpf-next 05/12] selftests/bpf: improve readability of xdpxceiver/worker_pkt_validate()

2021-01-22 Thread Björn Töpel
From: Björn Töpel Introduce a local variable to get rid of lot of casting. Move common code outside the if/else-clause. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 29 ++-- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/tools

[PATCH bpf-next 06/12] selftests/bpf: remove casting by introduce local variable

2021-01-22 Thread Björn Töpel
From: Björn Töpel Let us use a local variable in nsswitchthread(), so we can remove a lot of casting for better readability. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a

[PATCH bpf-next 03/12] selftests/bpf: fix style warnings

2021-01-22 Thread Björn Töpel
From: Björn Töpel Silence three checkpatch style warnings. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf

[PATCH bpf-next 02/12] selftests/bpf: remove unused enums

2021-01-22 Thread Björn Töpel
From: Björn Töpel The enums undef and bidi are not used. Remove them. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/testing/selftests/bpf/xdpxceiver.h b/tools/testing/selftests/bpf/xdpxceiver.h index

[PATCH bpf-next 00/12] Various cleanups/fixes for AF_XDP selftests

2021-01-22 Thread Björn Töpel
This series is a number of fixes/cleanups, mainly to improve the readability of the xdpxceiver selftest application. Details in each commit! Cheers, Björn Björn Töpel (12): selftests/bpf: remove a lot of ifobject casting selftests/bpf: remove unused enums selftests/bpf: fix style

[PATCH bpf-next 01/12] selftests/bpf: remove a lot of ifobject casting

2021-01-22 Thread Björn Töpel
From: Björn Töpel Instead of passing void * all over the place, let us pass the actual type (ifobject) and remove the void-ptr-to-type-ptr casting. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 88 1 file changed, 43 insertions(+), 45

Re: [PATCH bpf-next 0/3] AF_XDP clean up/perf improvements

2021-01-22 Thread Björn Töpel
On 2021-01-22 14:19, Toke Høiland-Jørgensen wrote: Björn Töpel writes: This series has some clean up/performance improvements for XDP sockets. The first two patches are cleanups for the AF_XDP core, and the restructure actually give a little performance boost. The last patch adds support

[PATCH bpf-next 0/3] AF_XDP clean up/perf improvements

2021-01-22 Thread Björn Töpel
tps://lore.kernel.org/bpf/20210119155013.154808-1-bjorn.to...@gmail.com/ Björn Töpel (3): xsk: remove explicit_free parameter from __xsk_rcv() xsk: fold xp_assign_dev and __xp_assign_dev libbpf, xsk: select AF_XDP BPF program based on kernel version net/xdp/xsk.c | 47 +++ net

[PATCH bpf-next 2/3] xsk: fold xp_assign_dev and __xp_assign_dev

2021-01-22 Thread Björn Töpel
From: Björn Töpel Fold xp_assign_dev and __xp_assign_dev. The former directly calls the latter. Reviewed-by: Maciej Fijalkowski Signed-off-by: Björn Töpel --- net/xdp/xsk_buff_pool.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/net/xdp/xsk_buff_pool.c b

[PATCH bpf-next 1/3] xsk: remove explicit_free parameter from __xsk_rcv()

2021-01-22 Thread Björn Töpel
From: Björn Töpel The explicit_free parameter of the __xsk_rcv() function was used to mark whether the call was via the generic XDP or the native XDP path. Instead of clutter the code with if-statements and "true/false" parameters which are hard to understand, simply move the explic

[PATCH bpf-next 3/3] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-22 Thread Björn Töpel
From: Björn Töpel Add detection for kernel version, and adapt the BPF program based on kernel support. This way, users will get the best possible performance from the BPF program. Reviewed-by: Maciej Fijalkowski Acked-by: Maciej Fijalkowski Signed-off-by: Björn Töpel Signed-off-by: Marek

Re: [PATCH bpf-next v2 7/8] selftest/bpf: add XDP socket tests for bpf_redirect_{xsk, map}()

2021-01-21 Thread Björn Töpel
On Thu, 21 Jan 2021 at 08:39, Andrii Nakryiko wrote: > > On Tue, Jan 19, 2021 at 7:55 AM Björn Töpel wrote: > > > > From: Björn Töpel > > > > Add support for externally loaded XDP programs to > > xdpxceiver/test_xsk.sh, so that bpf_redirect_xsk() and >

Re: [PATCH bpf-next v2 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-21 Thread Björn Töpel
On 2021-01-20 22:15, Alexei Starovoitov wrote: On Wed, Jan 20, 2021 at 12:26 PM Toke Høiland-Jørgensen wrote: This argument, however, I buy: bpf_redirect() is the single-purpose helper for redirecting to an ifindex, bpf_redirect_xsk() is the single-purpose helper for redirecting to an XSK, and

Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-20 Thread Björn Töpel
On 2021-01-20 13:52, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Add detection for kernel version, and adapt the BPF program based on kernel support. This way, users will get the best possible performance from the BPF program. Please do explicit feature detection

Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-20 Thread Björn Töpel
On 2021-01-20 19:25, Alexei Starovoitov wrote: On Wed, Jan 20, 2021 at 7:27 AM Björn Töpel wrote: Would it make sense with some kind of BPF-specific "supported features" mechanism? Something else with a bigger scope (whole kernel)? Heh, in my opinion, yeah. Seems like we'll

Re: [PATCH bpf-next v2 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-20 Thread Björn Töpel
On 2021-01-20 18:29, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 15:54, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 13:50, Toke Høiland-Jørgensen wrote: Björn Töpel writes: diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index

Re: [PATCH bpf-next v2 1/8] xdp: restructure redirect actions

2021-01-20 Thread Björn Töpel
On 2021-01-20 17:30, Toke Høiland-Jørgensen wrote: Björn Töpel writes: [...] It can't be free'd but, ri->map can be cleared via bpf_clear_redirect_map(). So, between the helper (setting) and the tracepoint in xdp_do_redirect() it can be cleared (say if the XDP program is swapp

Re: [PATCH bpf-next v2 1/8] xdp: restructure redirect actions

2021-01-20 Thread Björn Töpel
On 2021-01-20 13:44, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths depending on if the target is using a map or not. Today, the redirect

Re: [PATCH bpf-next v2 1/8] xdp: restructure redirect actions

2021-01-20 Thread Björn Töpel
On 2021-01-20 15:52, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 13:44, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel The XDP_REDIRECT implementations for maps and non-maps are fairly similar, but obviously need to take different code paths

Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-20 Thread Björn Töpel
On 2021-01-20 14:25, Björn Töpel wrote: On 2021-01-20 13:52, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Add detection for kernel version, and adapt the BPF program based on kernel support. This way, users will get the best possible performance from the BPF program

Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

2021-01-20 Thread Björn Töpel
On 2021-01-20 16:11, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 14:25, Björn Töpel wrote: On 2021-01-20 13:52, Toke Høiland-Jørgensen wrote: Björn Töpel writes: From: Björn Töpel Add detection for kernel version, and adapt the BPF program based on kernel support

Re: [PATCH bpf-next v2 4/8] xsk: register XDP sockets at bind(), and add new AF_XDP BPF helper

2021-01-20 Thread Björn Töpel
On 2021-01-20 15:54, Toke Høiland-Jørgensen wrote: Björn Töpel writes: On 2021-01-20 13:50, Toke Høiland-Jørgensen wrote: Björn Töpel writes: diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index c001766adcbc..bbc7d9a57262 100644 --- a/include/uapi/linux/bpf.h +++ b

Re: [PATCH bpf-next v2 0/8] Introduce bpf_redirect_xsk() helper

2021-01-20 Thread Björn Töpel
On 2021-01-20 14:15, Maxim Mikityanskiy wrote: On 2021-01-19 17:50, Björn Töpel wrote: This series extends bind() for XDP sockets, so that the bound socket is added to the netdev_rx_queue _rx array in the netdevice. We call this to register the socket. To redirect packets to the registered

  1   2   3   4   5   6   7   8   9   10   >