qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	Ilya Maximets <i.maximets@ovn.org>,
	Jason Wang <jasowang@redhat.com>,
	Anton Protopopov <aspsk@isovalent.com>
Subject: [PULL V2 15/16] net/af-xdp: Fix up cleanup path upon failure in queue creation
Date: Tue, 15 Jul 2025 12:35:23 +0800	[thread overview]
Message-ID: <20250715043524.21719-16-jasowang@redhat.com> (raw)
In-Reply-To: <20250715043524.21719-1-jasowang@redhat.com>

From: Daniel Borkmann <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;
        }
        ...
    }

The same is true for the attachment probing with bpf_xdp_query_id(). With a
conversion into the above format, the af_xdp_cleanup() handler is called as
expected. Note the error_propagate() handles a NULL err internally.

Fixes: cb039ef3d9e3 ("net: add initial support for AF_XDP network backend")
Reviewed-by: Ilya Maximets <i.maximets@ovn.org>
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>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/af-xdp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/af-xdp.c b/net/af-xdp.c
index 3d3268e18b..cbe1cae700 100644
--- a/net/af-xdp.c
+++ b/net/af-xdp.c
@@ -482,9 +482,8 @@ int net_init_af_xdp(const Netdev *netdev,
         pstrcpy(s->ifname, sizeof(s->ifname), opts->ifname);
         s->ifindex = ifindex;
 
-        if (af_xdp_umem_create(s, sock_fds ? sock_fds[i] : -1, errp)
-            || af_xdp_socket_create(s, opts, errp)) {
-            error_propagate(errp, err);
+        if (af_xdp_umem_create(s, sock_fds ? sock_fds[i] : -1, &err) ||
+            af_xdp_socket_create(s, opts, &err)) {
             goto err;
         }
     }
@@ -492,7 +491,7 @@ int net_init_af_xdp(const Netdev *netdev,
     if (nc0) {
         s = DO_UPCAST(AFXDPState, nc, nc0);
         if (bpf_xdp_query_id(s->ifindex, s->xdp_flags, &prog_id) || !prog_id) {
-            error_setg_errno(errp, errno,
+            error_setg_errno(&err, errno,
                              "no XDP program loaded on '%s', ifindex: %d",
                              s->ifname, s->ifindex);
             goto err;
@@ -506,6 +505,7 @@ int net_init_af_xdp(const Netdev *netdev,
 err:
     if (nc0) {
         qemu_del_net_client(nc0);
+        error_propagate(errp, err);
     }
 
     return -1;
-- 
2.42.0



  parent reply	other threads:[~2025-07-15  4:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-15  4:35 [PULL V2 00/16] Net patches Jason Wang
2025-07-15  4:35 ` [PULL V2 01/16] net: fix buffer overflow in af_xdp_umem_create() Jason Wang
2025-07-15  4:35 ` [PULL V2 02/16] virtio-net: Add queues for RSS during migration Jason Wang
2025-07-15  4:35 ` [PULL V2 03/16] net: Refactor stream logic for reuse in '-net passt' Jason Wang
2025-07-15  4:35 ` [PULL V2 04/16] net: Define net_client_set_link() Jason Wang
2025-07-15  4:35 ` [PULL V2 05/16] vhost_net: Rename vhost_set_vring_enable() for clarity Jason Wang
2025-07-15  4:35 ` [PULL V2 06/16] net: Add get_vhost_net callback to NetClientInfo Jason Wang
2025-07-15  4:35 ` [PULL V2 07/16] net: Consolidate vhost feature bits into vhost_net structure Jason Wang
2025-07-15  4:35 ` [PULL V2 08/16] net: Add get_acked_features callback to VhostNetOptions Jason Wang
2025-07-15  4:35 ` [PULL V2 09/16] net: Add save_acked_features callback to vhost_net Jason Wang
2025-07-15  4:35 ` [PULL V2 10/16] net: Allow network backends to advertise max TX queue size Jason Wang
2025-07-15  4:35 ` [PULL V2 11/16] net: Add is_vhost_user flag to vhost_net struct Jason Wang
2025-07-15  4:35 ` [PULL V2 12/16] net: Add passt network backend Jason Wang
2025-07-17  9:28   ` Peter Maydell
2025-07-17 11:12     ` Laurent Vivier
2025-07-15  4:35 ` [PULL V2 13/16] net/passt: Implement vhost-user backend support Jason Wang
2025-07-17  9:32   ` Peter Maydell
2025-07-15  4:35 ` [PULL V2 14/16] net/af-xdp: Remove XDP program cleanup logic Jason Wang
2025-07-15  4:35 ` Jason Wang [this message]
2025-07-15  4:35 ` [PULL V2 16/16] net/af-xdp: Support pinned map path for AF_XDP sockets Jason Wang
2025-07-16 12:39 ` [PULL V2 00/16] Net patches Stefan Hajnoczi

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