Re: Should I add BPF kfuncs for userspace apps? And how?

2023-12-19 Thread Akihiko Odaki
On 2023/12/19 4:56, Song Liu wrote: Hi Akihiko, On Tue, Dec 12, 2023 at 12:05 AM Akihiko Odaki wrote: [...] --- I'm working on a new feature that aids virtio-net implementations using tuntap virtual network device. You can see [1] for details, but basically it's

Re: Should I add BPF kfuncs for userspace apps? And how?

2023-12-16 Thread Akihiko Odaki
On 2023/12/16 1:36, Stephen Hemminger wrote: On Fri, 15 Dec 2023 14:49:56 +0900 Akihiko Odaki wrote: It is exactly what BPF_PROG_TYPE_SOCKET_FILTER does, but it lacks a mechanism to report hash values so I need to extend it or invent a new method. Extending BPF_PROG_TYPE_SOCKET_FILTER is not

Re: Should I add BPF kfuncs for userspace apps? And how?

2023-12-14 Thread Akihiko Odaki
On 2023/12/15 2:40, Stephen Hemminger wrote: On Thu, 14 Dec 2023 14:51:12 +0900 Akihiko Odaki wrote: On 2023/12/13 19:22, Benjamin Tissoires wrote: On Tue, Dec 12, 2023 at 1:41 PM Akihiko Odaki wrote: On 2023/12/12 19:39, Benjamin Tissoires wrote: Hi, On Tue, Dec 12, 2023 at 9:11 AM

Re: Should I add BPF kfuncs for userspace apps? And how?

2023-12-13 Thread Akihiko Odaki
On 2023/12/13 19:22, Benjamin Tissoires wrote: On Tue, Dec 12, 2023 at 1:41 PM Akihiko Odaki wrote: On 2023/12/12 19:39, Benjamin Tissoires wrote: Hi, On Tue, Dec 12, 2023 at 9:11 AM Akihiko Odaki wrote: Hi, Hi, Thanks for reply. It is said eBPF is a safe way to extend kernels and

Re: Should I add BPF kfuncs for userspace apps? And how?

2023-12-12 Thread Akihiko Odaki
On 2023/12/12 19:39, Benjamin Tissoires wrote: Hi, On Tue, Dec 12, 2023 at 9:11 AM Akihiko Odaki wrote: Hi, Hi, Thanks for reply. It is said eBPF is a safe way to extend kernels and that is very attarctive, but we need to use kfuncs to add new usage of eBPF and kfuncs are said as

Should I add BPF kfuncs for userspace apps? And how?

2023-12-12 Thread Akihiko Odaki
ication, which we didn't have to care for BPF_PROG_TYPE_SOCKET_FILTER. Isn't there a better way? Or shouldn't I use BPF in my case in the first place? Thanks, Akihiko Odaki [1] https://lore.kernel.org/all/20231015141644.260646-1-akihiko.od...@daynix.com/ [2] https://gi

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-12-10 Thread Akihiko Odaki
On 2023/12/11 10:40, Song Liu wrote: On Sat, Dec 9, 2023 at 11:03 PM Akihiko Odaki wrote: On 2023/11/22 14:36, Akihiko Odaki wrote: On 2023/11/22 14:25, Song Liu wrote: [...] Now the discussion is stale again so let me summarize the discussion: A tuntap device can have an eBPF

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-12-09 Thread Akihiko Odaki
On 2023/11/22 14:36, Akihiko Odaki wrote: On 2023/11/22 14:25, Song Liu wrote: On Mon, Nov 20, 2023 at 12:05 AM Akihiko Odaki wrote: On 2023/11/20 6:02, Song Liu wrote: [...] In contrast, our intended use case is more like a normal application. So, for example, a user may download a

[PATCH bpf-next v5 3/3] selftests/bpf: Use pkg-config for libelf

2023-11-25 Thread Akihiko Odaki
When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/bpf/Makefile | 8 ++-- 1 file changed, 6

[PATCH bpf-next v5 2/3] selftests/bpf: Override PKG_CONFIG for static builds

2023-11-25 Thread Akihiko Odaki
A library may need to depend on additional archive files for static builds so pkg-config should be instructed to list them. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/bpf/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf

[PATCH bpf-next v5 1/3] selftests/bpf: Choose pkg-config for the target

2023-11-25 Thread Akihiko Odaki
pkg-config is used to build sign-file executable. It should use the library for the target instead of the host as it is called during tests. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/bpf/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools

[PATCH bpf-next v5 0/3] selftests/bpf: Use pkg-config to determine ld flags

2023-11-25 Thread Akihiko Odaki
tch "selftests/bpf: Choose pkg-config for the target". V3 -> V4: Added "2> /dev/null". V2 -> V3: Added missing "echo". V1 -> V2: Implemented fallback, referring to HOSTPKG_CONFIG. Akihiko Odaki (3): selftests/bpf: Choose pkg-config for the target selftes

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-11-21 Thread Akihiko Odaki
On 2023/11/22 14:25, Song Liu wrote: On Mon, Nov 20, 2023 at 12:05 AM Akihiko Odaki wrote: On 2023/11/20 6:02, Song Liu wrote: [...] In contrast, our intended use case is more like a normal application. So, for example, a user may download a container and run QEMU (including the BPF program

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-11-20 Thread Akihiko Odaki
On 2023/11/20 6:02, Song Liu wrote: On Sun, Nov 19, 2023 at 12:03 AM Akihiko Odaki wrote: [...] Unfortunately no. The communication with the userspace can be done with two different means: - usual socket read/write - vhost for direct interaction with a KVM guest The BPF map may be a valid

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-11-19 Thread Akihiko Odaki
On 2023/11/19 1:08, Song Liu wrote: Hi, A few rookie questions below. Thanks for questions. On Sat, Nov 18, 2023 at 2:39 AM Akihiko Odaki wrote: On 2023/10/18 4:19, Akihiko Odaki wrote: On 2023/10/18 4:03, Alexei Starovoitov wrote: [...] I would also appreciate if you have some

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-11-18 Thread Akihiko Odaki
On 2023/10/18 4:19, Akihiko Odaki wrote: On 2023/10/18 4:03, Alexei Starovoitov wrote: On Mon, Oct 16, 2023 at 7:38 PM Jason Wang wrote: On Tue, Oct 17, 2023 at 7:53 AM Alexei Starovoitov wrote: On Sun, Oct 15, 2023 at 10:10 AM Akihiko Odaki wrote: On 2023/10/16 1:07, Alexei

Re: [PATCH bpf-next v4] selftests/bpf: Use pkg-config to determine ld flags

2023-10-17 Thread Akihiko Odaki
On 2023/10/17 23:15, Daniel Borkmann wrote: On 10/16/23 3:03 PM, Akihiko Odaki wrote: When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-10-17 Thread Akihiko Odaki
On 2023/10/18 4:03, Alexei Starovoitov wrote: On Mon, Oct 16, 2023 at 7:38 PM Jason Wang wrote: On Tue, Oct 17, 2023 at 7:53 AM Alexei Starovoitov wrote: On Sun, Oct 15, 2023 at 10:10 AM Akihiko Odaki wrote: On 2023/10/16 1:07, Alexei Starovoitov wrote: On Sun, Oct 15, 2023 at 7:17 AM

Re: [PATCH bpf-next v3] selftests/bpf: Use pkg-config to determine ld flags

2023-10-16 Thread Akihiko Odaki
On 2023/10/16 21:52, Daniel Borkmann wrote: On 10/16/23 2:43 PM, Akihiko Odaki wrote: When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko

[PATCH bpf-next v4] selftests/bpf: Use pkg-config to determine ld flags

2023-10-16 Thread Akihiko Odaki
When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko Odaki --- V3 -> V4: Added "2> /dev/null". V2 -> V3: Added missi

Re: [PATCH v2] selftests/bpf: Use pkg-config to determine ld flags

2023-10-16 Thread Akihiko Odaki
On 2023/10/16 21:19, Daniel Borkmann wrote: On 10/16/23 1:54 PM, Akihiko Odaki wrote: When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko

[PATCH bpf-next v3] selftests/bpf: Use pkg-config to determine ld flags

2023-10-16 Thread Akihiko Odaki
When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko Odaki --- V2 -> V3: Added missing "echo". V1 -> V2: Implemented fallba

Re: [PATCH bpf-next] selftests/bpf: Use pkg-config to determine ld flags

2023-10-16 Thread Akihiko Odaki
On 2023/10/16 20:39, Daniel Borkmann wrote: On 10/15/23 3:39 PM, Akihiko Odaki wrote: When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Is this not covered via

[PATCH v2] selftests/bpf: Use pkg-config to determine ld flags

2023-10-16 Thread Akihiko Odaki
When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko Odaki --- V1 -> V2: Implemented fallback, referring to HOSTPKG_CONFIG. tools/test

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-10-15 Thread Akihiko Odaki
On 2023/10/16 1:07, Alexei Starovoitov wrote: On Sun, Oct 15, 2023 at 7:17 AM Akihiko Odaki wrote: diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 0448700890f7..298634556fab 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -988,6 +988,7 @@ enum

[RFC PATCH v2 7/7] vhost_net: Support VIRTIO_NET_F_HASH_REPORT

2023-10-15 Thread Akihiko Odaki
reported. VIRTIO_NET_F_HASH_REPORT requires VIRTIO_F_VERSION_1. Signed-off-by: Akihiko Odaki --- drivers/vhost/net.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index f2ed7167c848..6a31d450fae2 100644 --- a/drivers

[RFC PATCH v2 6/7] selftests/bpf: Test BPF_PROG_TYPE_VNET_HASH

2023-10-15 Thread Akihiko Odaki
The added tests will ensure that the new relevant members of struct __sk_buff are initialized with 0, that the members are properly interpreted by tun, and tun checks the virtio-net header size before reporting hash values and types the BPF program computed. Signed-off-by: Akihiko Odaki

[RFC PATCH v2 5/7] tun: Support BPF_PROG_TYPE_VNET_HASH

2023-10-15 Thread Akihiko Odaki
Support BPF_PROG_TYPE_VNET_HASH with TUNSETSTEERINGEBPF ioctl to make it possible to report hash values and types when steering packets. Signed-off-by: Akihiko Odaki --- drivers/net/tun.c | 158 ++ 1 file changed, 117 insertions(+), 41 deletions

[RFC PATCH v2 4/7] virtio_net: Add virtio_net_hdr_v1_hash_from_skb()

2023-10-15 Thread Akihiko Odaki
It is identical with virtio_net_hdr_from_skb() except that it impelements hash reporting. Signed-off-by: Akihiko Odaki --- include/linux/virtio_net.h | 22 ++ 1 file changed, 22 insertions(+) diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h index

[RFC PATCH v2 3/7] skbuff: Introduce SKB_EXT_TUN_VNET_HASH

2023-10-15 Thread Akihiko Odaki
This new extension will be used by tun to carry the hash values and types to report with virtio-net headers. Signed-off-by: Akihiko Odaki --- include/linux/skbuff.h | 10 ++ net/core/skbuff.c | 3 +++ 2 files changed, 13 insertions(+) diff --git a/include/linux/skbuff.h b/include

[RFC PATCH v2 2/7] bpf: Add vnet_hash members to __sk_buff

2023-10-15 Thread Akihiko Odaki
They will be used only by BPF_PROG_TYPE_VNET_HASH to tell the queues to deliver packets and the hash values and types reported with virtio-net headers. Signed-off-by: Akihiko Odaki --- include/linux/filter.h | 7 net/core/filter.c | 77

[RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-10-15 Thread Akihiko Odaki
This new program type will be used by tun to determine the queues to deliver packets and the hash values and types reported with virtio-net headers. Signed-off-by: Akihiko Odaki --- Documentation/bpf/bpf_prog_run.rst | 1 + Documentation/bpf/libbpf/program_types.rst | 2 ++ include

[RFC PATCH v2 0/7] tun: Introduce virtio-net hashing feature

2023-10-15 Thread Akihiko Odaki
/bpf The QEMU patches will soon be submitted to the upstream as RFC too. V1 -> V2: Changed to introduce a new BPF program type. Akihiko Odaki (7): bpf: Introduce BPF_PROG_TYPE_VNET_HASH bpf: Add vnet_hash members to __sk_buff skbuff: Introduce SKB_EXT_TUN_VNET_HASH virtio_net:

[PATCH bpf-next] selftests/bpf: Use pkg-config to determine ld flags

2023-10-15 Thread Akihiko Odaki
When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/bpf/Makefile | 3 ++- tools/testing/selftests/bpf

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-10 Thread Akihiko Odaki
On 2023/10/11 12:18, Jason Wang wrote: On Tue, Oct 10, 2023 at 2:19 PM Akihiko Odaki wrote: On 2023/10/10 15:00, Jason Wang wrote: On Tue, Oct 10, 2023 at 1:51 PM Akihiko Odaki wrote: On 2023/10/10 14:45, Jason Wang wrote: On Tue, Oct 10, 2023 at 9:52 AM Akihiko Odaki wrote: On 2023

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/10 15:00, Jason Wang wrote: On Tue, Oct 10, 2023 at 1:51 PM Akihiko Odaki wrote: On 2023/10/10 14:45, Jason Wang wrote: On Tue, Oct 10, 2023 at 9:52 AM Akihiko Odaki wrote: On 2023/10/09 19:44, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:12 AM Akihiko Odaki wrote: On

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/10 14:45, Jason Wang wrote: On Tue, Oct 10, 2023 at 9:52 AM Akihiko Odaki wrote: On 2023/10/09 19:44, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:12 AM Akihiko Odaki wrote: On 2023/10/09 19:06, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:02 AM Akihiko Odaki wrote

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 20:50, Michael S. Tsirkin wrote: On Mon, Oct 09, 2023 at 05:44:20PM +0900, Akihiko Odaki wrote: On 2023/10/09 17:13, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 12:22 AM Akihiko Odaki wrote: virtio-net have two usage of hashes: one is RSS and another is hash reporting

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 20:38, Michael S. Tsirkin wrote: Akihiko Odaki sorry about reposts. Having an email with two "@" in the CC list: xuanzhuo@linux.alibaba.comsh...@kernel.org tripped up mutt's reply-all for me and made it send to you only. I am guessing you meant two a

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 19:44, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:12 AM Akihiko Odaki wrote: On 2023/10/09 19:06, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:02 AM Akihiko Odaki wrote: On 2023/10/09 18:57, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:57 AM Akihiko Odaki

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 19:06, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:02 AM Akihiko Odaki wrote: On 2023/10/09 18:57, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:57 AM Akihiko Odaki wrote: On 2023/10/09 17:04, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 3:46 PM Akihiko Odaki

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 19:07, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:05 AM Akihiko Odaki wrote: On 2023/10/09 18:54, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:44 AM Akihiko Odaki wrote: On 2023/10/09 17:13, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 12:22 AM Akihiko Odaki

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 18:54, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:44 AM Akihiko Odaki wrote: On 2023/10/09 17:13, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 12:22 AM Akihiko Odaki wrote: virtio-net have two usage of hashes: one is RSS and another is hash reporting

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 18:57, Willem de Bruijn wrote: On Mon, Oct 9, 2023 at 3:57 AM Akihiko Odaki wrote: On 2023/10/09 17:04, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 3:46 PM Akihiko Odaki wrote: On 2023/10/09 5:08, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 10:04 PM Akihiko Odaki

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 17:04, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 3:46 PM Akihiko Odaki wrote: On 2023/10/09 5:08, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 10:04 PM Akihiko Odaki wrote: On 2023/10/09 4:07, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 7:22 AM Akihiko Odaki

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-09 Thread Akihiko Odaki
On 2023/10/09 17:13, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 12:22 AM Akihiko Odaki wrote: virtio-net have two usage of hashes: one is RSS and another is hash reporting. Conventionally the hash calculation was done by the VMM. However, computing the hash after the queue was chosen

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-08 Thread Akihiko Odaki
On 2023/10/09 5:08, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 10:04 PM Akihiko Odaki wrote: On 2023/10/09 4:07, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 7:22 AM Akihiko Odaki wrote: virtio-net have two usage of hashes: one is RSS and another is hash reporting. Conventionally

Re: [RFC PATCH 5/7] tun: Introduce virtio-net hashing feature

2023-10-08 Thread Akihiko Odaki
On 2023/10/09 4:07, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 7:22 AM Akihiko Odaki wrote: virtio-net have two usage of hashes: one is RSS and another is hash reporting. Conventionally the hash calculation was done by the VMM. However, computing the hash after the queue was chosen

Re: [RFC PATCH 1/7] net: skbuff: Add tun_vnet_hash flag

2023-10-08 Thread Akihiko Odaki
On 2023/10/09 3:39, Willem de Bruijn wrote: On Sun, Oct 8, 2023 at 7:22 AM Akihiko Odaki wrote: tun_vnet_hash can use this flag to indicate it stored virtio-net hash cache to cb. Signed-off-by: Akihiko Odaki --- include/linux/skbuff.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a