From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=L97MfgRn; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 52DAA5A0623 for ; Fri, 09 Jan 2026 17:54:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767977693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KDcT/Fpqgn+KXIzVELXqb+wcoEdqn8SgbCpXUyRIWkM=; b=L97MfgRnRQh03e6z+VxmKauzojLLBYu+5BuMsqBnmysvuEY5iIvZvjqGNctj43FUJCx/xb zKZZMc9Q2wWt6eZnfVFfflAMPEQaQEvxEJHr94nqoysoYTtQFwry0wVHESfyNUsezpuR3f IfkyxvSJw8AP+7rfOf3h1mJOJ62iaSU= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-xTXwntRYNlyypbelqbyAhA-1; Fri, 09 Jan 2026 11:54:50 -0500 X-MC-Unique: xTXwntRYNlyypbelqbyAhA-1 X-Mimecast-MFC-AGG-ID: xTXwntRYNlyypbelqbyAhA_1767977689 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E82141955E77; Fri, 9 Jan 2026 16:54:48 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.32.149]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B54DB19560BA; Fri, 9 Jan 2026 16:54:47 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v3 4/6] udp_flow: Assign socket to flow inside udp_flow_sock() Date: Fri, 9 Jan 2026 17:54:36 +0100 Message-ID: <20260109165438.2492285-5-lvivier@redhat.com> In-Reply-To: <20260109165438.2492285-1-lvivier@redhat.com> References: <20260109165438.2492285-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QcCIqa_w5JW1NMXQtNGiFpsBKyudVcS1zbOJNQ-hHE0_1767977689 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: WX74MLQM5DNICM3CPVOZULX5NKQBHXSY X-Message-ID-Hash: WX74MLQM5DNICM3CPVOZULX5NKQBHXSY X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Move the assignment of uflow->s[sidei] from the caller (udp_flow_new()) into udp_flow_sock() itself, placing it after the successful connect(). This is a pure refactoring with no functional change. The socket fd is now assigned within udp_flow_sock() where the socket is created, rather than requiring the caller to capture the return value. On error paths, uflow->s[sidei] remains at its initialized value of -1 rather than being set to the negative error code, which is semantically cleaner (though functionally equivalent given the >= 0 check in udp_flow_close()). Signed-off-by: Laurent Vivier Reviewed-by: David Gibson --- udp_flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/udp_flow.c b/udp_flow.c index 0ba788060db7..c4cf35c2c89d 100644 --- a/udp_flow.c +++ b/udp_flow.c @@ -105,6 +105,7 @@ static int udp_flow_sock(const struct ctx *c, flow_dbg_perror(uflow, "Couldn't connect flow socket"); return rc; } + uflow->s[sidei] = s; /* It's possible, if unlikely, that we could receive some packets in * between the bind() and connect() which may or may not be for this @@ -159,7 +160,7 @@ static flow_sidx_t udp_flow_new(const struct ctx *c, union flow *flow, flow_foreach_sidei(sidei) { if (pif_is_socket(uflow->f.pif[sidei])) - if ((uflow->s[sidei] = udp_flow_sock(c, uflow, sidei)) < 0) + if (udp_flow_sock(c, uflow, sidei) < 0) goto cancel; } -- 2.52.0