[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 14/19] ebpf: Fix RSS error handling
From: |
Akihiko Odaki |
Subject: |
[PATCH v8 14/19] ebpf: Fix RSS error handling |
Date: |
Sun, 10 Dec 2023 14:29:52 +0900 |
calculate_rss_hash() was using hash value 0 to tell if it calculated
a hash, but the hash value may be 0 on a rare occasion. Have a
distinct bool value for correctness.
Fixes: f3fa412de2 ("ebpf: Added eBPF RSS program.")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
tools/ebpf/rss.bpf.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c
index 20f227e2ac..667ea6899e 100644
--- a/tools/ebpf/rss.bpf.c
+++ b/tools/ebpf/rss.bpf.c
@@ -377,18 +377,19 @@ error:
return err;
}
-static inline __u32 calculate_rss_hash(struct __sk_buff *skb,
- struct rss_config_t *config, struct toeplitz_key_data_t *toe)
+static inline bool calculate_rss_hash(struct __sk_buff *skb,
+ struct rss_config_t *config,
+ struct toeplitz_key_data_t *toe,
+ __u32 *result)
{
__u8 rss_input[HASH_CALCULATION_BUFFER_SIZE] = {};
size_t bytes_written = 0;
- __u32 result = 0;
int err = 0;
struct packet_hash_info_t packet_info = {};
err = parse_packet(skb, &packet_info);
if (err) {
- return 0;
+ return false;
}
if (packet_info.is_ipv4) {
@@ -521,11 +522,13 @@ static inline __u32 calculate_rss_hash(struct __sk_buff
*skb,
}
}
- if (bytes_written) {
- net_toeplitz_add(&result, rss_input, bytes_written, toe);
+ if (!bytes_written) {
+ return false;
}
- return result;
+ net_toeplitz_add(result, rss_input, bytes_written, toe);
+
+ return true;
}
SEC("tun_rss_steering")
@@ -546,8 +549,7 @@ int tun_rss_steering_prog(struct __sk_buff *skb)
return config->default_queue;
}
- hash = calculate_rss_hash(skb, config, toe);
- if (hash) {
+ if (calculate_rss_hash(skb, config, toe, &hash)) {
__u32 table_idx = hash % config->indirections_len;
__u16 *queue = 0;
--
2.43.0
- [PATCH v8 03/19] net: Move virtio-net header length assertion, (continued)
- [PATCH v8 03/19] net: Move virtio-net header length assertion, Akihiko Odaki, 2023/12/10
- [PATCH v8 05/19] tap: Call tap_receive_iov() from tap_receive(), Akihiko Odaki, 2023/12/10
- [PATCH v8 04/19] net: Remove receive_raw(), Akihiko Odaki, 2023/12/10
- [PATCH v8 06/19] tap: Shrink zeroed virtio-net header, Akihiko Odaki, 2023/12/10
- [PATCH v8 07/19] virtio-net: Copy header only when necessary, Akihiko Odaki, 2023/12/10
- [PATCH v8 08/19] virtio-net: Disable RSS on reset, Akihiko Odaki, 2023/12/10
- [PATCH v8 09/19] virtio-net: Unify the logic to update NIC state for RSS, Akihiko Odaki, 2023/12/10
- [PATCH v8 10/19] virtio-net: Return an error when vhost cannot enable RSS, Akihiko Odaki, 2023/12/10
- [PATCH v8 12/19] virtio-net: Always set populate_hash, Akihiko Odaki, 2023/12/10
- [PATCH v8 13/19] virtio-net: Do not write hashes to peer buffer, Akihiko Odaki, 2023/12/10
- [PATCH v8 14/19] ebpf: Fix RSS error handling,
Akihiko Odaki <=
- [PATCH v8 11/19] virtio-net: Report RSS warning at device realization, Akihiko Odaki, 2023/12/10
- [PATCH v8 16/19] ebpf: Simplify error handling, Akihiko Odaki, 2023/12/10
- [PATCH v8 15/19] ebpf: Use standard section name, Akihiko Odaki, 2023/12/10
- [PATCH v8 18/19] ebpf: Refactor tun_rss_steering_prog(), Akihiko Odaki, 2023/12/10
- [PATCH v8 19/19] ebpf: Add a separate target for skeleton, Akihiko Odaki, 2023/12/10
- [PATCH v8 17/19] ebpf: Return 0 when configuration fails, Akihiko Odaki, 2023/12/10
- Re: [PATCH v8 00/19] virtio-net RSS/hash report fixes and improvements, Yuri Benditovich, 2023/12/11