qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann via <qemu-devel@nongnu.org>
To: qemu-devel@nongnu.org
Cc: daniel@iogearbox.net, Ilya Maximets <i.maximets@ovn.org>,
	Jason Wang <jasowang@redhat.com>,
	Anton Protopopov <aspsk@isovalent.com>
Subject: [PATCH v3 2/2] net/af-xdp: Fix up cleanup path upon failure in queue creation
Date: Wed,  4 Jun 2025 13:29:16 +0200	[thread overview]
Message-ID: <20250604112916.1195368-2-daniel@iogearbox.net> (raw)
In-Reply-To: <20250604112916.1195368-1-daniel@iogearbox.net>

While testing, it turned out that upon error in the queue creation loop,
we never trigger the af_xdp_cleanup() handler. This is because we pass
errp instead of a local err pointer into the various AF_XDP setup functions
instead of a scheme like:

    bool fn(..., Error **errp)
    {
        Error *err = NULL;

        foo(arg, &err);
        if (err) {
            handle the error...
            error_propagate(errp, err);
            return false;
        }
        ...
    }

With a conversion into the above format, the af_xdp_cleanup() handler is
called as expected. Also, making sure the XDP program will be removed does
require to set s->n_queues to i + 1 since the test is nc->queue_index ==
s->n_queues - 1, where nc->queue_index was set to i earlier. With both
fixed the cleanup triggers as expected. Note the error_propagate() handles
a NULL err internally.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Ilya Maximets <i.maximets@ovn.org>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Anton Protopopov <aspsk@isovalent.com>
---
 net/af-xdp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/af-xdp.c b/net/af-xdp.c
index b83d9bc47f..5d9857fdd8 100644
--- a/net/af-xdp.c
+++ b/net/af-xdp.c
@@ -559,12 +559,11 @@ int net_init_af_xdp(const Netdev *netdev,
             s->map_start_index = opts->map_start_index;
         }
 
-        if (af_xdp_umem_create(s, sock_fds ? sock_fds[i] : -1, errp) ||
-            af_xdp_socket_create(s, opts, errp) ||
-            af_xdp_update_xsk_map(s, errp)) {
+        if (af_xdp_umem_create(s, sock_fds ? sock_fds[i] : -1, &err) ||
+            af_xdp_socket_create(s, opts, &err) ||
+            af_xdp_update_xsk_map(s, &err)) {
             /* Make sure the XDP program will be removed. */
-            s->n_queues = i;
-            error_propagate(errp, err);
+            s->n_queues = i + 1;
             goto err;
         }
     }
@@ -586,6 +585,7 @@ int net_init_af_xdp(const Netdev *netdev,
 err:
     if (nc0) {
         qemu_del_net_client(nc0);
+        error_propagate(errp, err);
     }
 
     return -1;
-- 
2.43.0



  reply	other threads:[~2025-06-04 11:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-04 11:29 [PATCH v3 1/2] net/af-xdp: Support pinned map path for AF_XDP sockets Daniel Borkmann via
2025-06-04 11:29 ` Daniel Borkmann via [this message]
2025-06-17 11:59   ` [PATCH v3 2/2] net/af-xdp: Fix up cleanup path upon failure in queue creation Ilya Maximets
2025-06-17 13:03     ` Daniel Borkmann via
2025-06-17 21:41       ` Ilya Maximets
2025-06-18  8:00         ` Ilya Maximets
2025-06-17 11:59 ` [PATCH v3 1/2] net/af-xdp: Support pinned map path for AF_XDP sockets Ilya Maximets
2025-06-17 12:43   ` Daniel Borkmann via

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=20250604112916.1195368-2-daniel@iogearbox.net \
    --to=qemu-devel@nongnu.org \
    --cc=aspsk@isovalent.com \
    --cc=daniel@iogearbox.net \
    --cc=i.maximets@ovn.org \
    --cc=jasowang@redhat.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).