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=izWV0qFO; 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 C94FE5A065D for ; Fri, 19 Dec 2025 17:45:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766162726; 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=aMv4OBRHNhdfBSbFu2RN91O6JcUocQYH5XpZ/+a1Vgs=; b=izWV0qFOYz7k8LA1FhcyKZgkH6QyOJi0UkQh6hYfyFqsDXtWQzxI/JfWx5u0C/WidceBCd Ub07/jYky3Evb3oZgJmrWe9zK4v/gPpL1eeq90blcm3i4qAVJerGgxCyQCZYx5IxAWE9rg 58CbH1vgYoXRq5u+SDo43dBRHvqqq3M= Received: from mx-prod-mc-01.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-399-ZsIr8_HsPtKudA1EEUWKQQ-1; Fri, 19 Dec 2025 11:45:25 -0500 X-MC-Unique: ZsIr8_HsPtKudA1EEUWKQQ-1 X-Mimecast-MFC-AGG-ID: ZsIr8_HsPtKudA1EEUWKQQ_1766162724 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2717D195DE49 for ; Fri, 19 Dec 2025 16:45:24 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.32.145]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2E817180049F; Fri, 19 Dec 2025 16:45:22 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 2/7] udp_flow: Assign socket to flow inside udp_flow_sock() Date: Fri, 19 Dec 2025 17:45:13 +0100 Message-ID: <20251219164518.930012-3-lvivier@redhat.com> In-Reply-To: <20251219164518.930012-1-lvivier@redhat.com> References: <20251219164518.930012-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: k3YMj7o_Pm8LCuqsVprUwXMnBIhwRLPkECogfpHZPIQ_1766162724 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: PARVRLRBGPPMGTTU4FAAAYMYOFIELCW6 X-Message-ID-Hash: PARVRLRBGPPMGTTU4FAAAYMYOFIELCW6 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 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 --- udp_flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/udp_flow.c b/udp_flow.c index 8907f2f72741..33f29f21e69e 100644 --- a/udp_flow.c +++ b/udp_flow.c @@ -109,6 +109,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 @@ -163,7 +164,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.51.1