]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
ebpf: Fix indirections table setting
authorAkihiko Odaki <akihiko.odaki@daynix.com>
Wed, 27 Mar 2024 02:05:10 +0000 (11:05 +0900)
committerJason Wang <jasowang@redhat.com>
Fri, 29 Mar 2024 06:59:00 +0000 (14:59 +0800)
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>
Acked-by: Andrew Melnychenko <andrew@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
ebpf/ebpf_rss.c

index 2e506f974357dc7093df863df13519e467a54bae..d102f3dd0929ba17452f7ad654a7ae62b0bc65a9 100644 (file)
@@ -185,13 +185,18 @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
                                             uint16_t *indirections_table,
                                             size_t len)
 {
+    char *cursor = ctx->mmap_indirections_table;
+
     if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
        len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
         return false;
     }
 
-    memcpy(ctx->mmap_indirections_table, indirections_table,
-            sizeof(*indirections_table) * len);
+    for (size_t i = 0; i < len; i++) {
+        *(uint16_t *)cursor = indirections_table[i];
+        cursor += 8;
+    }
+
     return true;
 }