diff mbox series

[2/2] ebpf: Fix indirections table setting

Message ID 20240326-vhost-v1-2-09bd85b1ba2c@daynix.com (mailing list archive)
State New, archived
Headers show
Series virtio-net: Fix RSS | expand

Commit Message

Akihiko Odaki March 26, 2024, 10:06 a.m. UTC
The kernel documentation says:
> The value stored can be of any size, however, all array elements are
> aligned to 8 bytes.
https://www.kernel.org/doc/html/v6.8/bpf/map_array.html

Fixes: 333b3e5fab75 ("ebpf: Added eBPF map update through mmap.")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 ebpf/ebpf_rss.h | 2 +-
 ebpf/ebpf_rss.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/ebpf/ebpf_rss.h b/ebpf/ebpf_rss.h
index 239242b0d26e..7d15b600bf5b 100644
--- a/ebpf/ebpf_rss.h
+++ b/ebpf/ebpf_rss.h
@@ -26,7 +26,7 @@  struct EBPFRSSContext {
     /* mapped eBPF maps for direct access to omit bpf_map_update_elem() */
     void *mmap_configuration;
     void *mmap_toeplitz_key;
-    void *mmap_indirections_table;
+    uint64_t *mmap_indirections_table;
 };
 
 struct EBPFRSSConfig {
diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
index 2e506f974357..e0f300febb77 100644
--- a/ebpf/ebpf_rss.c
+++ b/ebpf/ebpf_rss.c
@@ -190,8 +190,9 @@  static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
         return false;
     }
 
-    memcpy(ctx->mmap_indirections_table, indirections_table,
-            sizeof(*indirections_table) * len);
+    for (size_t i = 0; i < len; i++) {
+        ctx->mmap_indirections_table[i] = indirections_table[i];
+    }
     return true;
 }