[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/5] ebpf: Fix indirections table setting
From: |
Jason Wang |
Subject: |
[PULL 2/5] ebpf: Fix indirections table setting |
Date: |
Fri, 29 Mar 2024 15:10:57 +0800 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
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 | 9 +++++++--
1 file 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;
}
--
2.42.0
- [PULL 0/5] Net patches, Jason Wang, 2024/03/29
- [PULL 1/5] virtio-net: Fix vhost virtqueue notifiers for RSS, Jason Wang, 2024/03/29
- [PULL 2/5] ebpf: Fix indirections table setting,
Jason Wang <=
- [PULL 4/5] tap-win32: Remove unnecessary stubs, Jason Wang, 2024/03/29
- [PULL 3/5] hw/net/net_tx_pkt: Fix virtio header without checksum offloading, Jason Wang, 2024/03/29
- [PULL 5/5] Revert "tap: setting error appropriately when calling net_init_tap_one()", Jason Wang, 2024/03/29
- Re: [PULL 0/5] Net patches, Peter Maydell, 2024/03/31
- Re: [PULL 0/5] Net patches, Michael Tokarev, 2024/03/31