public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH] tcp: Add error checking for flow_epoll_set() in tcp_flow_migrate_target()
Date: Mon, 26 Jan 2026 13:13:31 +0100	[thread overview]
Message-ID: <2c2f35f3-1cd4-4c1a-a39a-487bd1732679@redhat.com> (raw)
In-Reply-To: <20260122141319.3054301-1-sbrivio@redhat.com>

On 1/22/26 15:13, Stefano Brivio wrote:
> Commit 90287c2a774e ("tcp: Register fds with epoll at flow creation")
> added a call to flow_epoll_set() in tcp_flow_migrate_target() without
> checking for the error code.
> 
> As Laurent explains, that's harmless, as tcp_flow_migrate_target_ext()
> will clean up the flow anyway, and we'll just uselessly call
> flow_hash_insert() before removing it again.
> 
> But Coverity Scan complains about the unchecked return code, so check
> it, skip flow_hash_insert() in that case, and explain in comments why
> we don't have to do anything else.
> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
>   tcp.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/tcp.c b/tcp.c
> index 6a26826..0a6b7ff 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -3684,17 +3684,19 @@ int tcp_flow_migrate_target(struct ctx *c, int fd)
>   
>   	if ((rc = tcp_flow_repair_socket(c, conn))) {
>   		flow_err(flow, "Can't set up socket: %s, drop", strerror_(-rc));
> -		/* Can't leave the flow in an incomplete state */
> -		FLOW_ACTIVATE(conn);
> -		return 0;
> +		goto out;
>   	}
>   
>   	flow_epollid_set(&conn->f, EPOLLFD_ID_DEFAULT);
> -	flow_epoll_set(&conn->f, EPOLL_CTL_ADD, 0, conn->sock, !TAPSIDE(conn));
> +	if (flow_epoll_set(&conn->f, EPOLL_CTL_ADD, 0, conn->sock,
> +			   !TAPSIDE(conn)))
> +		goto out; /* tcp_flow_migrate_target_ext() will clean this up */
>   
>   	flow_hash_insert(c, TAP_SIDX(conn));
> -	FLOW_ACTIVATE(conn);
>   
> +out:
> +	/* Never leave the flow in an incomplete state */
> +	FLOW_ACTIVATE(conn);
>   	return 0;
>   }
>   

Reviewed-by: Laurent Vivier <lvivier@redhat.com>


      reply	other threads:[~2026-01-26 12:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22 14:13 Stefano Brivio
2026-01-26 12:13 ` Laurent Vivier [this message]

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=2c2f35f3-1cd4-4c1a-a39a-487bd1732679@redhat.com \
    --to=lvivier@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).