diff mbox series

[v3,5/5] virtio-net: Remove fallback from ebpf-rss-fds

Message ID 20240714-auto-v3-5-e27401aabab3@daynix.com
State New
Headers show
Series virtio-net: Convert feature properties to OnOffAuto | expand

Commit Message

Akihiko Odaki July 14, 2024, 5:11 a.m. UTC
If ebpf-rss-fds is specified but we fail to use, we should not fall
back to loading eBPF programs by ourselves as such makes the situation
complicated.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 hw/net/virtio-net.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index e779ba2df428..2f0a4f2aabf7 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1361,21 +1361,21 @@  static void virtio_net_disable_rss(VirtIONet *n)
     virtio_net_commit_rss_config(n);
 }
 
-static bool virtio_net_load_ebpf_fds(VirtIONet *n)
+static bool virtio_net_load_ebpf_fds(VirtIONet *n, Error **errp)
 {
     int fds[EBPF_RSS_MAX_FDS] = { [0 ... EBPF_RSS_MAX_FDS - 1] = -1};
     int ret = true;
     int i = 0;
 
     if (n->nr_ebpf_rss_fds != EBPF_RSS_MAX_FDS) {
-        warn_report("Expected %d file descriptors but got %d",
-                    EBPF_RSS_MAX_FDS, n->nr_ebpf_rss_fds);
+        error_setg(errp, "Expected %d file descriptors but got %d",
+                   EBPF_RSS_MAX_FDS, n->nr_ebpf_rss_fds);
        return false;
    }
 
     for (i = 0; i < n->nr_ebpf_rss_fds; i++) {
         fds[i] = monitor_fd_param(monitor_cur(), n->ebpf_rss_fds[i],
-                                  &error_warn);
+                                  errp);
         if (fds[i] < 0) {
             ret = false;
             goto exit;
@@ -1394,17 +1394,11 @@  exit:
     return ret;
 }
 
-static bool virtio_net_load_ebpf(VirtIONet *n)
+static bool virtio_net_load_ebpf(VirtIONet *n, Error **errp)
 {
-    bool ret = false;
-
-    if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
-        if (!(n->ebpf_rss_fds && virtio_net_load_ebpf_fds(n))) {
-            ret = ebpf_rss_load(&n->ebpf_rss);
-        }
-    }
-
-    return ret;
+    return virtio_net_attach_ebpf_to_backend(n->nic, -1) &&
+           (n->ebpf_rss_fds ? virtio_net_load_ebpf_fds(n, errp) :
+                              ebpf_rss_load(&n->ebpf_rss));
 }
 
 static void virtio_net_unload_ebpf(VirtIONet *n)
@@ -3805,7 +3799,7 @@  static void virtio_net_device_realize(DeviceState *dev, Error **errp)
     if (virtio_has_feature(n->host_features.on_bits |
                            n->host_features.auto_bits,
                            VIRTIO_NET_F_RSS)) {
-        virtio_net_load_ebpf(n);
+        virtio_net_load_ebpf(n, errp);
     }
 }