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: 333b3e5fab
("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>
This commit is contained in:
parent
1c188fc8cb
commit
ba6bb2ec95
@ -185,13 +185,18 @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
|
|||||||
uint16_t *indirections_table,
|
uint16_t *indirections_table,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
|
char *cursor = ctx->mmap_indirections_table;
|
||||||
|
|
||||||
if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
|
if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
|
||||||
len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
|
len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(ctx->mmap_indirections_table, indirections_table,
|
for (size_t i = 0; i < len; i++) {
|
||||||
sizeof(*indirections_table) * len);
|
*(uint16_t *)cursor = indirections_table[i];
|
||||||
|
cursor += 8;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user