[PATCH RFC v3 0/9] tun: Introduce virtio-net hashing feature

2024-09-14 Thread Akihiko Odaki
patches will soon be submitted to the upstream as RFC too. This work will be presented at LPC 2024: https://lpc.events/event/18/contributions/1963/ V1 -> V2: Changed to introduce a new BPF program type. Signed-off-by: Akihiko Odaki --- Changes in v3: - Reverted back to add ioctl. - Split patch &

[PATCH RFC v3 1/9] skbuff: Introduce SKB_EXT_TUN_VNET_HASH

2024-09-14 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

[PATCH RFC v3 2/9] virtio_net: Add functions for hashing

2024-09-14 Thread Akihiko Odaki
They are useful to implement VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Signed-off-by: Akihiko Odaki --- include/linux/virtio_net.h | 198 + 1 file changed, 198 insertions(+) diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h

[PATCH RFC v3 3/9] net: flow_dissector: Export flow_keys_dissector_symmetric

2024-09-14 Thread Akihiko Odaki
flow_keys_dissector_symmetric is useful to derive a symmetric hash and to know its source such as IPv4, IPv6, TCP, and UDP. Signed-off-by: Akihiko Odaki --- include/net/flow_dissector.h | 1 + net/core/flow_dissector.c| 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a

[PATCH RFC v3 4/9] tap: Pad virtio header with zero

2024-09-14 Thread Akihiko Odaki
leaving the garbage in the buffer is awkward anyway so fill the buffer in tap. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 77574f7a3bd4..ba044302ccc6 100644 --- a/drivers/net/tap.c

[PATCH RFC v3 5/9] tun: Pad virtio header with zero

2024-09-14 Thread Akihiko Odaki
leaving the garbage in the buffer is awkward anyway so fill the buffer in tun. Signed-off-by: Akihiko Odaki --- drivers/net/tun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 1d06c560c5e6..9d93ab9ee58f 100644 --- a/drivers/net

[PATCH RFC v3 6/9] tun: Introduce virtio-net hash reporting feature

2024-09-14 Thread Akihiko Odaki
Allow the guest to reuse the hash value to make receive steering consistent between the host and guest, and to save hash computation. Signed-off-by: Akihiko Odaki --- Documentation/networking/tuntap.rst | 7 ++ drivers/net/Kconfig | 1 + drivers/net/tun.c

[PATCH RFC v3 7/9] tun: Introduce virtio-net RSS

2024-09-14 Thread Akihiko Odaki
UAPIs. Signed-off-by: Akihiko Odaki --- drivers/net/tun.c | 119 +++- include/uapi/linux/if_tun.h | 27 ++ 2 files changed, 133 insertions(+), 13 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index b8fcd71becac..5a429b3

[PATCH RFC v3 8/9] selftest: tun: Add tests for virtio-net hashing

2024-09-14 Thread Akihiko Odaki
The added tests confirm tun can perform RSS and hash reporting, and reject invalid configurations for them. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tun.c| 666 ++- 2 files changed, 660

[PATCH RFC v3 9/9] vhost/net: Support VIRTIO_NET_F_HASH_REPORT

2024-09-14 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 f16279351db5..ec1167a782ec 100644 --- a/drivers

[PATCH RFC v5 02/10] skbuff: Introduce SKB_EXT_TUN_VNET_HASH

2024-10-08 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 | 3 +++ net/core/skbuff.c | 4 2 files changed, 7 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux

[PATCH RFC v5 00/10] tun: Introduce virtio-net hashing feature

2024-10-08 Thread Akihiko Odaki
-hash-v3-0-79cb08d28...@daynix.com/ This work was presented at LPC 2024: https://lpc.events/event/18/contributions/1963/ V1 -> V2: Changed to introduce a new BPF program type. Signed-off-by: Akihiko Odaki --- Changes in v5: - Fixed a compilation error with CONFIG_TUN_VNET_CROSS_LE. - Optimi

[PATCH RFC v5 01/10] virtio_net: Add functions for hashing

2024-10-08 Thread Akihiko Odaki
They are useful to implement VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Signed-off-by: Akihiko Odaki --- include/linux/virtio_net.h | 188 + 1 file changed, 188 insertions(+) diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h

[PATCH RFC v5 03/10] net: flow_dissector: Export flow_keys_dissector_symmetric

2024-10-08 Thread Akihiko Odaki
flow_keys_dissector_symmetric is useful to derive a symmetric hash and to know its source such as IPv4, IPv6, TCP, and UDP. Signed-off-by: Akihiko Odaki --- include/net/flow_dissector.h | 1 + net/core/flow_dissector.c| 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a

[PATCH RFC v5 04/10] tun: Unify vnet implementation

2024-10-08 Thread Akihiko Odaki
Both tun and tap exposes the same set of virtio-net-related features. Unify their implementations to ease future changes. Signed-off-by: Akihiko Odaki --- MAINTAINERS| 1 + drivers/net/tap.c | 172 ++-- drivers/net/tun.c | 208

[PATCH RFC v5 06/10] tun: Introduce virtio-net hash reporting feature

2024-10-08 Thread Akihiko Odaki
Allow the guest to reuse the hash value to make receive steering consistent between the host and guest, and to save hash computation. Signed-off-by: Akihiko Odaki --- Documentation/networking/tuntap.rst | 7 +++ drivers/net/Kconfig | 1 + drivers/net/tap.c

[PATCH RFC v5 05/10] tun: Pad virtio header with zero

2024-10-08 Thread Akihiko Odaki
read() to avoid such a problem, but leaving the garbage in the buffer is awkward anyway so fill the buffer in tun. Signed-off-by: Akihiko Odaki --- drivers/net/tun_vnet.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/tun_vnet.h b/drivers/net/tun_vnet.h index

[PATCH RFC v5 07/10] tun: Introduce virtio-net RSS

2024-10-08 Thread Akihiko Odaki
UAPIs. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 11 +- drivers/net/tun.c | 57 --- drivers/net/tun_vnet.h | 96 + include/linux/if_tap.h | 4 +- include/uapi/linux/if_tun.h

[PATCH RFC v5 08/10] selftest: tun: Test vnet ioctls without device

2024-10-08 Thread Akihiko Odaki
Ensure that vnet ioctls result in EBADFD when the underlying device is deleted. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/net/tun.c | 74 +++ 1 file changed, 74 insertions(+) diff --git a/tools/testing/selftests/net/tun.c b/tools/testing

[PATCH RFC v5 10/10] vhost/net: Support VIRTIO_NET_F_HASH_REPORT

2024-10-08 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 f16279351db5..ec1167a782ec 100644 --- a/drivers

[PATCH RFC v5 09/10] selftest: tun: Add tests for virtio-net hashing

2024-10-08 Thread Akihiko Odaki
The added tests confirm tun can perform RSS and hash reporting, and reject invalid configurations for them. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tun.c| 558 ++- 2 files changed, 551

Re: [PATCH RFC v5 04/10] tun: Unify vnet implementation

2024-10-12 Thread Akihiko Odaki
On 2024/10/09 22:55, Willem de Bruijn wrote: Akihiko Odaki wrote: Both tun and tap exposes the same set of virtio-net-related features. Unify their implementations to ease future changes. Signed-off-by: Akihiko Odaki --- MAINTAINERS| 1 + drivers/net/tap.c | 172

Re: [PATCH RFC v4 0/9] tun: Introduce virtio-net hashing feature

2024-10-01 Thread Akihiko Odaki
On 2024/10/02 1:31, Stephen Hemminger wrote: On Tue, 1 Oct 2024 14:54:29 +0900 Akihiko Odaki wrote: On 2024/09/30 0:33, Stephen Hemminger wrote: On Sun, 29 Sep 2024 16:10:47 +0900 Akihiko Odaki wrote: On 2024/09/29 11:07, Jason Wang wrote: On Fri, Sep 27, 2024 at 3:51 PM Akihiko Odaki

Re: [PATCH RFC v5 06/10] tun: Introduce virtio-net hash reporting feature

2024-10-12 Thread Akihiko Odaki
On 2024/10/09 17:05, Jason Wang wrote: On Tue, Oct 8, 2024 at 2:55 PM Akihiko Odaki wrote: Allow the guest to reuse the hash value to make receive steering consistent between the host and guest, and to save hash computation. Signed-off-by: Akihiko Odaki I wonder if this would cause

Re: [PATCH RFC v5 07/10] tun: Introduce virtio-net RSS

2024-10-12 Thread Akihiko Odaki
On 2024/10/09 17:14, Jason Wang wrote: On Tue, Oct 8, 2024 at 2:55 PM Akihiko Odaki wrote: RSS is a receive steering algorithm that can be negotiated to use with virtio_net. Conventionally the hash calculation was done by the VMM. However, computing the hash after the queue was chosen defeats

Re: [PATCH RFC v5 01/10] virtio_net: Add functions for hashing

2024-10-12 Thread Akihiko Odaki
On 2024/10/09 22:51, Willem de Bruijn wrote: Akihiko Odaki wrote: They are useful to implement VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Signed-off-by: Akihiko Odaki --- include/linux/virtio_net.h | 188 + No need for these to be in header

Re: [PATCH RFC v3 0/9] tun: Introduce virtio-net hashing feature

2024-09-23 Thread Akihiko Odaki
On 2024/09/15 21:48, Stephen Hemminger wrote: On Sun, 15 Sep 2024 10:17:39 +0900 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: [PATCH RFC v3 2/9] virtio_net: Add functions for hashing

2024-09-23 Thread Akihiko Odaki
On 2024/09/18 14:50, Willem de Bruijn wrote: Akihiko Odaki wrote: They are useful to implement VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Signed-off-by: Akihiko Odaki --- include/linux/virtio_net.h | 198 + 1 file changed, 198 insertions

Re: [PATCH RFC v3 6/9] tun: Introduce virtio-net hash reporting feature

2024-09-23 Thread Akihiko Odaki
On 2024/09/18 15:17, Willem de Bruijn wrote: Akihiko Odaki wrote: Allow the guest to reuse the hash value to make receive steering consistent between the host and guest, and to save hash computation. Signed-off-by: Akihiko Odaki --- Documentation/networking/tuntap.rst | 7 ++ drivers/net

Re: [PATCH RFC v3 7/9] tun: Introduce virtio-net RSS

2024-09-24 Thread Akihiko Odaki
On 2024/09/24 10:56, Akihiko Odaki wrote: On 2024/09/18 15:28, Willem de Bruijn wrote: Akihiko Odaki wrote: RSS is a receive steering algorithm that can be negotiated to use with virtio_net. Conventionally the hash calculation was done by the VMM. However, computing the hash after the queue

Re: [PATCH RFC v3 7/9] tun: Introduce virtio-net RSS

2024-09-24 Thread Akihiko Odaki
On 2024/09/18 15:28, Willem de Bruijn wrote: Akihiko Odaki wrote: RSS is a receive steering algorithm that can be negotiated to use with virtio_net. Conventionally the hash calculation was done by the VMM. However, computing the hash after the queue was chosen defeats the purpose of RSS

[PATCH RFC v4 0/9] tun: Introduce virtio-net hashing feature

2024-09-24 Thread Akihiko Odaki
-hash-v3-0-79cb08d28...@daynix.com/ This work was presented at LPC 2024: https://lpc.events/event/18/contributions/1963/ V1 -> V2: Changed to introduce a new BPF program type. Signed-off-by: Akihiko Odaki --- Changes in v4: - Moved tun_vnet_hash_ext to if_tun.h. - Renamed virtio_net_toeplitz()

[PATCH RFC v4 2/9] virtio_net: Add functions for hashing

2024-09-24 Thread Akihiko Odaki
They are useful to implement VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Signed-off-by: Akihiko Odaki --- include/linux/virtio_net.h | 174 + 1 file changed, 174 insertions(+) diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h

[PATCH RFC v4 3/9] net: flow_dissector: Export flow_keys_dissector_symmetric

2024-09-24 Thread Akihiko Odaki
flow_keys_dissector_symmetric is useful to derive a symmetric hash and to know its source such as IPv4, IPv6, TCP, and UDP. Signed-off-by: Akihiko Odaki --- include/net/flow_dissector.h | 1 + net/core/flow_dissector.c| 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a

[PATCH RFC v4 1/9] skbuff: Introduce SKB_EXT_TUN_VNET_HASH

2024-09-24 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/if_tun.h | 5 + include/linux/skbuff.h | 3 +++ net/core/skbuff.c | 4 3 files changed, 12 insertions(+) diff --git a

[PATCH RFC v4 6/9] tun: Introduce virtio-net hash reporting feature

2024-09-24 Thread Akihiko Odaki
Allow the guest to reuse the hash value to make receive steering consistent between the host and guest, and to save hash computation. Signed-off-by: Akihiko Odaki --- Documentation/networking/tuntap.rst | 7 +++ drivers/net/Kconfig | 1 + drivers/net/tun.c

[PATCH RFC v4 4/9] tap: Pad virtio header with zero

2024-09-24 Thread Akihiko Odaki
read() to avoid such a problem, but leaving the garbage in the buffer is awkward anyway so fill the buffer in tap. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 77574f7a3bd4

[PATCH RFC v4 5/9] tun: Pad virtio header with zero

2024-09-24 Thread Akihiko Odaki
read() to avoid such a problem, but leaving the garbage in the buffer is awkward anyway so fill the buffer in tun. Signed-off-by: Akihiko Odaki --- drivers/net/tun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 1d06c560c5e6

[PATCH RFC v4 8/9] selftest: tun: Add tests for virtio-net hashing

2024-09-24 Thread Akihiko Odaki
The added tests confirm tun can perform RSS and hash reporting, and reject invalid configurations for them. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tun.c| 666 ++- 2 files changed, 660

[PATCH RFC v4 7/9] tun: Introduce virtio-net RSS

2024-09-24 Thread Akihiko Odaki
UAPIs. Signed-off-by: Akihiko Odaki --- drivers/net/tun.c | 158 ++-- include/uapi/linux/if_tun.h | 27 2 files changed, 163 insertions(+), 22 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 986e4a5bf04d..680eb45

[PATCH RFC v4 9/9] vhost/net: Support VIRTIO_NET_F_HASH_REPORT

2024-09-24 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 f16279351db5..ec1167a782ec 100644 --- a/drivers

Re: [PATCH RFC v4 7/9] tun: Introduce virtio-net RSS

2024-09-26 Thread Akihiko Odaki
On 2024/09/24 22:05, Simon Horman wrote: On Tue, Sep 24, 2024 at 11:01:12AM +0200, Akihiko Odaki wrote: RSS is a receive steering algorithm that can be negotiated to use with virtio_net. Conventionally the hash calculation was done by the VMM. However, computing the hash after the queue was

Re: [PATCH RFC v4 0/9] tun: Introduce virtio-net hashing feature

2024-09-26 Thread Akihiko Odaki
On 2024/09/25 12:30, Jason Wang wrote: On Tue, Sep 24, 2024 at 5:01 PM 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 defeats

Re: [PATCH RFC v4 0/9] tun: Introduce virtio-net hashing feature

2024-09-27 Thread Akihiko Odaki
On 2024/09/27 13:31, Jason Wang wrote: On Fri, Sep 27, 2024 at 10:11 AM Akihiko Odaki wrote: On 2024/09/25 12:30, Jason Wang wrote: On Tue, Sep 24, 2024 at 5:01 PM Akihiko Odaki wrote: virtio-net have two usage of hashes: one is RSS and another is hash reporting. Conventionally the hash

Re: [PATCH RFC v4 0/9] tun: Introduce virtio-net hashing feature

2024-09-29 Thread Akihiko Odaki
On 2024/09/29 11:07, Jason Wang wrote: On Fri, Sep 27, 2024 at 3:51 PM Akihiko Odaki wrote: On 2024/09/27 13:31, Jason Wang wrote: On Fri, Sep 27, 2024 at 10:11 AM Akihiko Odaki wrote: On 2024/09/25 12:30, Jason Wang wrote: On Tue, Sep 24, 2024 at 5:01 PM Akihiko Odaki wrote: virtio

Re: [PATCH RFC v4 0/9] tun: Introduce virtio-net hashing feature

2024-09-30 Thread Akihiko Odaki
On 2024/09/30 0:33, Stephen Hemminger wrote: On Sun, 29 Sep 2024 16:10:47 +0900 Akihiko Odaki wrote: On 2024/09/29 11:07, Jason Wang wrote: On Fri, Sep 27, 2024 at 3:51 PM Akihiko Odaki wrote: On 2024/09/27 13:31, Jason Wang wrote: On Fri, Sep 27, 2024 at 10:11 AM Akihiko Odaki wrote

Re: [PATCH RFC v3 2/9] virtio_net: Add functions for hashing

2024-09-19 Thread Akihiko Odaki
f (be32_to_cpu(*input) & bit) state->hash ^= state->key_buffer; state->key_buffer = (state->key_buffer << 1) | (key & 1); } This unfortunately does not work. swab32() works at *byte*-level but we need to reverse the order of *bits*. bitrev32() is what we need, but it cannot eliminate be32_to_cpu(). Regards, Akihiko Odaki

[PATCH net-next v5 0/7] tun: Unify vnet implementation

2025-02-04 Thread Akihiko Odaki
https://lore.kernel.org/r/20241008-rss-v5-0-f3cf68df0...@daynix.com [2]: https://lore.kernel.org/r/20241227084256-mutt-send-email-...@kernel.org/ Signed-off-by: Akihiko Odaki --- Changes in v5: - s/vnet_hdr_len_sz/vnet_hdr_sz/ for patch "tun: Decouple vnet handling" (Willem de Bruijn) - Changed

[PATCH net-next v5 3/7] tun: Decouple vnet from tun_struct

2025-02-04 Thread Akihiko Odaki
Decouple vnet-related functions from tun_struct so that we can reuse them for tap in the future. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 51 ++- 1 file changed, 26 insertions(+), 25 deletions(-) diff

[PATCH net-next v5 2/7] tun: Keep hdr_len in tun_get_user()

2025-02-04 Thread Akihiko Odaki
hdr_len is repeatedly used so keep it in a local variable. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index

[PATCH net-next v5 1/7] tun: Refactor CONFIG_TUN_VNET_CROSS_LE

2025-02-04 Thread Akihiko Odaki
Check IS_ENABLED(CONFIG_TUN_VNET_CROSS_LE) to save some lines and make future changes easier. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 26 -- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/net/tun.c b

[PATCH net-next v5 5/7] tun: Extract the vnet handling code

2025-02-04 Thread Akihiko Odaki
The vnet handling code will be reused by tap. Signed-off-by: Akihiko Odaki --- MAINTAINERS| 2 +- drivers/net/tun.c | 179 +-- drivers/net/tun_vnet.h | 184 + 3 files changed, 187

[PATCH net-next v5 4/7] tun: Decouple vnet handling

2025-02-04 Thread Akihiko Odaki
Decouple the vnet handling code so that we can reuse it for tap. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 237 -- 1 file changed, 139 insertions(+), 98 deletions(-) diff --git a/drivers/net/tun.c b

[PATCH net-next v5 7/7] tap: Use tun's vnet-related code

2025-02-04 Thread Akihiko Odaki
tun and tap implements the same vnet-related features so reuse the code. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 152 ++ 1 file changed, 16 insertions(+), 136 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index

[PATCH net-next v5 6/7] tap: Keep hdr_len in tap_get_user()

2025-02-04 Thread Akihiko Odaki
hdr_len is repeatedly used so keep it in a local variable. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 30 +- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index

Re: [PATCH net-next v5 1/7] tun: Refactor CONFIG_TUN_VNET_CROSS_LE

2025-02-05 Thread Akihiko Odaki
On 2025/02/06 6:06, Willem de Bruijn wrote: Akihiko Odaki wrote: Check IS_ENABLED(CONFIG_TUN_VNET_CROSS_LE) to save some lines and make future changes easier. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 26 -- 1 file changed

Re: [PATCH net-next v5 6/7] tap: Keep hdr_len in tap_get_user()

2025-02-05 Thread Akihiko Odaki
On 2025/02/06 6:21, Willem de Bruijn wrote: Akihiko Odaki wrote: hdr_len is repeatedly used so keep it in a local variable. Signed-off-by: Akihiko Odaki @@ -682,11 +683,8 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control, if (msg_control && sock_fla

Re: [PATCH net-next v5 5/7] tun: Extract the vnet handling code

2025-02-05 Thread Akihiko Odaki
On 2025/02/06 6:12, Willem de Bruijn wrote: Akihiko Odaki wrote: The vnet handling code will be reused by tap. Signed-off-by: Akihiko Odaki --- MAINTAINERS| 2 +- drivers/net/tun.c | 179 +-- drivers/net/tun_vnet.h | 184

[PATCH net-next v6 2/7] tun: Keep hdr_len in tun_get_user()

2025-02-06 Thread Akihiko Odaki
hdr_len is repeatedly used so keep it in a local variable. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index

[PATCH net-next v6 0/7] tun: Unify vnet implementation

2025-02-06 Thread Akihiko Odaki
https://lore.kernel.org/r/20241008-rss-v5-0-f3cf68df0...@daynix.com [2]: https://lore.kernel.org/r/20241227084256-mutt-send-email-...@kernel.org/ Signed-off-by: Akihiko Odaki --- Changes in v6: - Added an intermediate variable in tun_vnet_legacy_is_little_endian() to reduce a complexity of an expre

[PATCH net-next v6 1/7] tun: Refactor CONFIG_TUN_VNET_CROSS_LE

2025-02-06 Thread Akihiko Odaki
Check IS_ENABLED(CONFIG_TUN_VNET_CROSS_LE) to save some lines and make future changes easier. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 29 ++--- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/net/tun.c b

[PATCH net-next v6 5/7] tun: Extract the vnet handling code

2025-02-06 Thread Akihiko Odaki
The vnet handling code will be reused by tap. Functions are renamed to ensure that their names contain "vnet" to clarify that they are part of the decoupled vnet handling code. Signed-off-by: Akihiko Odaki --- MAINTAINERS| 2 +- drivers/net/tun.c

[PATCH net-next v6 4/7] tun: Decouple vnet handling

2025-02-06 Thread Akihiko Odaki
Decouple the vnet handling code so that we can reuse it for tap. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 237 -- 1 file changed, 139 insertions(+), 98 deletions(-) diff --git a/drivers/net/tun.c b

[PATCH net-next v6 7/7] tap: Use tun's vnet-related code

2025-02-06 Thread Akihiko Odaki
tun and tap implements the same vnet-related features so reuse the code. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tap.c | 152 ++ 1 file changed, 16 insertions(+), 136 deletions(-) diff --git a/drivers/net

[PATCH net-next v6 3/7] tun: Decouple vnet from tun_struct

2025-02-06 Thread Akihiko Odaki
Decouple vnet-related functions from tun_struct so that we can reuse them for tap in the future. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 51 ++- 1 file changed, 26 insertions(+), 25 deletions(-) diff

[PATCH net-next v6 6/7] tap: Keep hdr_len in tap_get_user()

2025-02-06 Thread Akihiko Odaki
hdr_len is repeatedly used so keep it in a local variable. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 28 ++-- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 5aa41d5f7765a6dcf185bccd3cba2299bad89398

[PATCH v6 0/6] tun: Introduce virtio-net hashing feature

2025-01-08 Thread Akihiko Odaki
V1 -> V2: Changed to introduce a new BPF program type. Signed-off-by: Akihiko Odaki --- Changes in v6: - Extracted changes to fill vnet header holes into another series. - Squashed patches "skbuff: Introduce SKB_EXT_TUN_VNET_HASH", "tun: Introduce virtio-net hash reporting f

[PATCH v6 1/6] virtio_net: Add functions for hashing

2025-01-08 Thread Akihiko Odaki
They are useful to implement VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Signed-off-by: Akihiko Odaki --- include/linux/virtio_net.h | 188 + 1 file changed, 188 insertions(+) diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h

[PATCH v6 2/6] net: flow_dissector: Export flow_keys_dissector_symmetric

2025-01-08 Thread Akihiko Odaki
flow_keys_dissector_symmetric is useful to derive a symmetric hash and to know its source such as IPv4, IPv6, TCP, and UDP. Signed-off-by: Akihiko Odaki --- include/net/flow_dissector.h | 1 + net/core/flow_dissector.c| 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a

[PATCH v6 3/6] tun: Introduce virtio-net hash feature

2025-01-08 Thread Akihiko Odaki
es on legacy context rewriting, and introducing kfunc-based eBPF will result in non-UAPI dependency while the other relevant virtualization APIs such as KVM and vhost_net are UAPIs. Signed-off-by: Akihiko Odaki --- Documentation/networking/tuntap.rst | 7 ++ drivers/net/Kconfig

[PATCH v6 4/6] selftest: tun: Test vnet ioctls without device

2025-01-08 Thread Akihiko Odaki
Ensure that vnet ioctls result in EBADFD when the underlying device is deleted. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/net/tun.c | 74 +++ 1 file changed, 74 insertions(+) diff --git a/tools/testing/selftests/net/tun.c b/tools/testing

[PATCH v6 6/6] vhost/net: Support VIRTIO_NET_F_HASH_REPORT

2025-01-08 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 9ad37c012189..ed1bf01a7fcf 100644 --- a/drivers

[PATCH v6 5/6] selftest: tun: Add tests for virtio-net hashing

2025-01-08 Thread Akihiko Odaki
The added tests confirm tun can perform RSS and hash reporting, and reject invalid configurations for them. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tun.c| 558 ++- 2 files changed, 551

Re: [PATCH v2 2/3] tun: Pad virtio header with zero

2025-01-08 Thread Akihiko Odaki
On 2025/01/09 16:31, Michael S. Tsirkin wrote: On Thu, Jan 09, 2025 at 03:58:44PM +0900, Akihiko Odaki wrote: tun used to simply advance iov_iter when it needs to pad virtio header, which leaves the garbage in the buffer as is. This is especially problematic when tun starts to allow enabling

[PATCH v2 1/3] tun: Unify vnet implementation

2025-01-08 Thread Akihiko Odaki
Both tun and tap exposes the same set of virtio-net-related features. Unify their implementations to ease future changes. Signed-off-by: Akihiko Odaki --- MAINTAINERS| 1 + drivers/net/Kconfig| 5 ++ drivers/net/Makefile | 1 + drivers/net/tap.c | 172

[PATCH v2 0/3] tun: Unify vnet implementation and fill full vnet header

2025-01-08 Thread Akihiko Odaki
https://lore.kernel.org/r/20241008-rss-v5-0-f3cf68df0...@daynix.com [2]: https://lore.kernel.org/r/20241227084256-mutt-send-email-...@kernel.org/ Signed-off-by: Akihiko Odaki --- Changes in v2: - Fixed num_buffers endian. - Link to v1: https://lore.kernel.org/r/20250108-tun-v1-0-67d784b34...@dayni

[PATCH v2 2/3] tun: Pad virtio header with zero

2025-01-08 Thread Akihiko Odaki
read() to avoid such a problem, but leaving the garbage in the buffer is awkward anyway so fill the buffer in tun. Signed-off-by: Akihiko Odaki --- drivers/net/tun_vnet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/tun_vnet.c b/drivers/net/tun_vnet.c index

[PATCH v2 3/3] tun: Set num_buffers for virtio 1.0

2025-01-08 Thread Akihiko Odaki
The specification says the device MUST set num_buffers to 1 if VIRTIO_NET_F_MRG_RXBUF has not been negotiated. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 2 +- drivers/net/tun.c | 6 -- drivers/net/tun_vnet.c | 14 +- drivers/net/tun_vnet.h | 4 ++-- 4

Re: [PATCH v2 3/3] tun: Set num_buffers for virtio 1.0

2025-01-10 Thread Akihiko Odaki
On 2025/01/10 12:27, Jason Wang wrote: On Thu, Jan 9, 2025 at 2:59 PM Akihiko Odaki wrote: The specification says the device MUST set num_buffers to 1 if VIRTIO_NET_F_MRG_RXBUF has not been negotiated. Have we agreed on how to fix the spec or not? As I replied in the spec patch, if we just

Re: [PATCH v2 2/3] tun: Pad virtio header with zero

2025-01-10 Thread Akihiko Odaki
On 2025/01/10 12:27, Jason Wang wrote: On Thu, Jan 9, 2025 at 2:59 PM Akihiko Odaki wrote: tun used to simply advance iov_iter when it needs to pad virtio header, which leaves the garbage in the buffer as is. This is especially problematic when tun starts to allow enabling the hash reporting

Re: [PATCH v2 1/3] tun: Unify vnet implementation

2025-01-10 Thread Akihiko Odaki
On 2025/01/09 23:06, Willem de Bruijn wrote: Akihiko Odaki wrote: Both tun and tap exposes the same set of virtio-net-related features. Unify their implementations to ease future changes. Signed-off-by: Akihiko Odaki --- MAINTAINERS| 1 + drivers/net/Kconfig| 5

Re: [PATCH v6 5/6] selftest: tun: Add tests for virtio-net hashing

2025-01-10 Thread Akihiko Odaki
On 2025/01/09 23:36, Willem de Bruijn wrote: Akihiko Odaki wrote: The added tests confirm tun can perform RSS and hash reporting, and reject invalid configurations for them. Signed-off-by: Akihiko Odaki --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tun.c

Re: [PATCH v6 1/6] virtio_net: Add functions for hashing

2025-01-10 Thread Akihiko Odaki
On 2025/01/09 23:13, Willem de Bruijn wrote: Akihiko Odaki wrote: They are useful to implement VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Toeplitz potentially has users beyond virtio. I wonder if we should from the start implement this as net/core/rss.c. Or in lib/toeplitz.c just as

Re: [PATCH v6 3/6] tun: Introduce virtio-net hash feature

2025-01-10 Thread Akihiko Odaki
On 2025/01/09 23:28, Willem de Bruijn wrote: Akihiko Odaki wrote: Hash reporting -- Allow the guest to reuse the hash value to make receive steering consistent between the host and guest, and to save hash computation. RSS --- RSS is a receive steering algorithm that can be

Re: [PATCH v2 3/3] tun: Set num_buffers for virtio 1.0

2025-01-10 Thread Akihiko Odaki
On 2025/01/10 19:23, Michael S. Tsirkin wrote: On Fri, Jan 10, 2025 at 11:27:13AM +0800, Jason Wang wrote: On Thu, Jan 9, 2025 at 2:59 PM Akihiko Odaki wrote: The specification says the device MUST set num_buffers to 1 if VIRTIO_NET_F_MRG_RXBUF has not been negotiated. Have we agreed on

Re: [PATCH v2 2/3] tun: Pad virtio header with zero

2025-01-09 Thread Akihiko Odaki
On 2025/01/09 21:46, Willem de Bruijn wrote: Akihiko Odaki wrote: On 2025/01/09 16:31, Michael S. Tsirkin wrote: On Thu, Jan 09, 2025 at 03:58:44PM +0900, Akihiko Odaki wrote: tun used to simply advance iov_iter when it needs to pad virtio header, which leaves the garbage in the buffer as is

Re: [PATCH net v3 9/9] tap: Use tun's vnet-related code

2025-01-20 Thread Akihiko Odaki
On 2025/01/20 20:19, Willem de Bruijn wrote: On Mon, Jan 20, 2025 at 1:37 AM Jason Wang wrote: On Fri, Jan 17, 2025 at 6:35 PM Akihiko Odaki wrote: On 2025/01/17 18:23, Willem de Bruijn wrote: Akihiko Odaki wrote: tun and tap implements the same vnet-related features so reuse the code

Re: [PATCH net-next v4 8/9] tap: Keep hdr_len in tap_get_user()

2025-01-20 Thread Akihiko Odaki
On 2025/01/20 20:24, Willem de Bruijn wrote: Akihiko Odaki wrote: hdr_len is repeatedly used so keep it in a local variable. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/tap.c b/drivers

Re: [PATCH v2 3/3] tun: Set num_buffers for virtio 1.0

2025-01-19 Thread Akihiko Odaki
On 2025/01/20 9:40, Jason Wang wrote: On Thu, Jan 16, 2025 at 1:30 PM Akihiko Odaki wrote: On 2025/01/16 10:06, Jason Wang wrote: On Wed, Jan 15, 2025 at 1:07 PM Akihiko Odaki wrote: On 2025/01/13 12:04, Jason Wang wrote: On Fri, Jan 10, 2025 at 7:12 PM Akihiko Odaki wrote: On 2025/01

[PATCH net-next v4 0/9] tun: Unify vnet implementation

2025-01-20 Thread Akihiko Odaki
https://lore.kernel.org/r/20241008-rss-v5-0-f3cf68df0...@daynix.com [2]: https://lore.kernel.org/r/20241227084256-mutt-send-email-...@kernel.org/ Signed-off-by: Akihiko Odaki --- Changes in v4: - s/sz/vnet_hdr_len_sz/ for patch "tun: Decouple vnet handling" (Willem de Bruijn) - Reverted to add

[PATCH net-next v4 5/9] tun: Decouple vnet handling

2025-01-20 Thread Akihiko Odaki
Decouple the vnet handling code so that we can reuse it for tap. Signed-off-by: Akihiko Odaki --- drivers/net/tun.c | 229 +++--- 1 file changed, 133 insertions(+), 96 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index

[PATCH net-next v4 9/9] tap: Use tun's vnet-related code

2025-01-20 Thread Akihiko Odaki
tun and tap implements the same vnet-related features so reuse the code. Signed-off-by: Akihiko Odaki --- drivers/net/Kconfig | 1 + drivers/net/tap.c | 152 ++-- 2 files changed, 16 insertions(+), 137 deletions(-) diff --git a/drivers/net

[PATCH net-next v4 2/9] tun: Avoid double-tracking iov_iter length changes

2025-01-20 Thread Akihiko Odaki
tun_get_user() used to track the length of iov_iter with another variable. We can use iov_iter_count() to determine the current length to avoid such chores. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 12 ++-- 1 file changed, 6 insertions(+), 6

[PATCH net-next v4 1/9] tun: Refactor CONFIG_TUN_VNET_CROSS_LE

2025-01-20 Thread Akihiko Odaki
Check IS_ENABLED(CONFIG_TUN_VNET_CROSS_LE) to save some lines and make future changes easier. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 26 -- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/net/tun.c b

[PATCH net-next v4 4/9] tun: Decouple vnet from tun_struct

2025-01-20 Thread Akihiko Odaki
Decouple vnet-related functions from tun_struct so that we can reuse them for tap in the future. Signed-off-by: Akihiko Odaki --- drivers/net/tun.c | 53 +++-- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/net/tun.c b

[PATCH net-next v4 3/9] tun: Keep hdr_len in tun_get_user()

2025-01-20 Thread Akihiko Odaki
hdr_len is repeatedly used so keep it in a local variable. Signed-off-by: Akihiko Odaki Reviewed-by: Willem de Bruijn --- drivers/net/tun.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index

[PATCH net-next v4 6/9] tun: Extract the vnet handling code

2025-01-20 Thread Akihiko Odaki
The vnet handling code will be reused by tap. Signed-off-by: Akihiko Odaki --- MAINTAINERS| 2 +- drivers/net/Kconfig| 4 ++ drivers/net/Makefile | 1 + drivers/net/tun.c | 174 +- drivers/net/tun_vnet.c | 184

[PATCH net-next v4 8/9] tap: Keep hdr_len in tap_get_user()

2025-01-20 Thread Akihiko Odaki
hdr_len is repeatedly used so keep it in a local variable. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 061c2f27dfc83f5e6d0bea4da0e845cc429b1fd8

[PATCH net-next v4 7/9] tap: Avoid double-tracking iov_iter length changes

2025-01-20 Thread Akihiko Odaki
tap_get_user() used to track the length of iov_iter with another variable. We can use iov_iter_count() to determine the current length to avoid such chores. Signed-off-by: Akihiko Odaki --- drivers/net/tap.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers

Re: [PATCH v2 3/3] tun: Set num_buffers for virtio 1.0

2025-01-14 Thread Akihiko Odaki
On 2025/01/13 12:04, Jason Wang wrote: On Fri, Jan 10, 2025 at 7:12 PM Akihiko Odaki wrote: On 2025/01/10 19:23, Michael S. Tsirkin wrote: On Fri, Jan 10, 2025 at 11:27:13AM +0800, Jason Wang wrote: On Thu, Jan 9, 2025 at 2:59 PM Akihiko Odaki wrote: The specification says the device

  1   2   >