diff options
author | Akihiko Odaki <akihiko.odaki@daynix.com> | 2024-03-27 11:05:10 +0900 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2024-03-29 14:59:00 +0800 |
commit | ba6bb2ec953f10751f174b6f7da8fe7e5f008c08 (patch) | |
tree | b6699df3350257c950383f2c6bfff3b503dca19d /ebpf/ebpf_rss.c | |
parent | 1c188fc8cbffc5f05cc616cab4e1372fb6e6f11f (diff) |
ebpf: Fix indirections table setting
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>
Diffstat (limited to 'ebpf/ebpf_rss.c')
-rw-r--r-- | ebpf/ebpf_rss.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index 2e506f9743..d102f3dd09 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -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; } |