[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 16/21] ebpf: Fix RSS error handling
|
From: |
Akihiko Odaki |
|
Subject: |
[PATCH v6 16/21] ebpf: Fix RSS error handling |
|
Date: |
Mon, 30 Oct 2023 14:12:37 +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.42.0
- [PATCH v6 06/21] net: Remove flag propagation, (continued)
- [PATCH v6 06/21] net: Remove flag propagation, Akihiko Odaki, 2023/10/30
- [PATCH v6 07/21] tap: Shrink zeroed virtio-net header, Akihiko Odaki, 2023/10/30
- [PATCH v6 08/21] virtio-net: Copy header only when necessary, Akihiko Odaki, 2023/10/30
- [PATCH v6 09/21] virtio-net: Disable RSS on reset, Akihiko Odaki, 2023/10/30
- [PATCH v6 10/21] virtio-net: Unify the logic to update NIC state for RSS, Akihiko Odaki, 2023/10/30
- [PATCH v6 11/21] virtio-net: Return an error when vhost cannot enable RSS, Akihiko Odaki, 2023/10/30
- [PATCH v6 12/21] virtio-net: Enable software RSS, Akihiko Odaki, 2023/10/30
- [PATCH v6 13/21] virtio-net: Always set populate_hash, Akihiko Odaki, 2023/10/30
- [PATCH v6 14/21] virtio-net: Do not write hashes to peer buffer, Akihiko Odaki, 2023/10/30
- [PATCH v6 15/21] virtio-net: Do not clear VIRTIO_NET_F_HASH_REPORT, Akihiko Odaki, 2023/10/30
- [PATCH v6 16/21] ebpf: Fix RSS error handling,
Akihiko Odaki <=
- [PATCH v6 18/21] ebpf: Simplify error handling, Akihiko Odaki, 2023/10/30
- [PATCH v6 17/21] ebpf: Use standard section name, Akihiko Odaki, 2023/10/30
- [PATCH v6 20/21] ebpf: Refactor tun_rss_steering_prog(), Akihiko Odaki, 2023/10/30
- [PATCH v6 19/21] ebpf: Return 0 when configuration fails, Akihiko Odaki, 2023/10/30
- [PATCH v6 21/21] ebpf: Add a separate target for skeleton, Akihiko Odaki, 2023/10/30