From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Andrew Melnychenko <andrew@daynix.com>,
Yuri Benditovich <yuri.benditovich@daynix.com>
Cc: qemu-devel@nongnu.org, Akihiko Odaki <akihiko.odaki@daynix.com>
Subject: [PATCH v2 2/2] ebpf: Fix indirections table setting
Date: Wed, 27 Mar 2024 11:05:10 +0900 [thread overview]
Message-ID: <20240327-vhost-v2-2-0a89aa21b54b@daynix.com> (raw)
In-Reply-To: <20240327-vhost-v2-0-0a89aa21b54b@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>
---
| 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
index 2e506f974357..d102f3dd0929 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.44.0
next prev parent reply other threads:[~2024-03-27 2:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-27 2:05 [PATCH v2 0/2] virtio-net: Fix RSS Akihiko Odaki
2024-03-27 2:05 ` [PATCH v2 1/2] virtio-net: Fix vhost virtqueue notifiers for RSS Akihiko Odaki
2024-03-27 2:05 ` Akihiko Odaki [this message]
2024-03-28 9:39 ` [PATCH v2 2/2] ebpf: Fix indirections table setting Yuri Benditovich
2024-03-28 11:59 ` Andrew Melnichenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240327-vhost-v2-2-0a89aa21b54b@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=andrew@daynix.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yuri.benditovich@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).