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=T5vLKL3S; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 199775A004E for ; Thu, 08 Jan 2026 15:01:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767880892; 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=T5vLKL3SSduz5palG6CeS1zOSdRoVCEjoqk69P1VRzmP5TGeqpTQHPQUseW8VF3nXHMDfK yAD3XASfsN9xzfOA5pEYl8MqzjbiIDLaSooGjwBT2nGNuQTyQl0xSQ5wzykjQyRA12d7CY C1V1Oo1lYd94xFQ5b4nLfg08Zx66xhM= Received: from mx-prod-mc-05.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-301-z6WiVAkIOkiXKBGcOC2eCQ-1; Thu, 08 Jan 2026 09:01:28 -0500 X-MC-Unique: z6WiVAkIOkiXKBGcOC2eCQ-1 X-Mimecast-MFC-AGG-ID: z6WiVAkIOkiXKBGcOC2eCQ_1767880887 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9E9F519560A1; Thu, 8 Jan 2026 14:01:27 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.45.225.173]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E8ADE180066A; Thu, 8 Jan 2026 14:01:25 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v2 3/5] udp_flow: Assign socket to flow inside udp_flow_sock() Date: Thu, 8 Jan 2026 15:01:17 +0100 Message-ID: <20260108140119.1204797-4-lvivier@redhat.com> In-Reply-To: <20260108140119.1204797-1-lvivier@redhat.com> References: <20260108140119.1204797-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: P70LXf5Pk2ugCmIsqx1ygHAIQkwnHOLb_XvDhABSxjQ_1767880887 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: WNKUWZ3RKLBYWIHTVJ7RMTSNBJLJ4DJB X-Message-ID-Hash: WNKUWZ3RKLBYWIHTVJ7RMTSNBJLJ4DJB 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