From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com 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 0C2785A026E for ; Wed, 02 Dec 2026 00:52:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796169130; 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; bh=3qP5GbvsXYm/xg4lywim5bjQDuAnxp3q1BcyPjrZy1k=; b=PZWQZT5IspbLDIrM5KGu0trMp1Ot1PoI+ud6MT+ijrMzGMP0B5ycjWwKl2+UIfsMpSIalR gXB/Iu3veXnRo2KHEVoDjCcvdOWCh373SP8j9IU5uGQufGtBAjuZo/vMiFFIfepDI1vHZv U7W2m/6/LKdvbtt7LoLOo3FPlt3G8wE= X-MC-Rep: binary re single 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-186-uW7KpjRcNWKMInUFk7qfFQ-1; Tue, 1 Dec 2026 23:52:05 +0000 X-MC-Unique: uW7KpjRcNWKMInUFk7qfFQ-1 X-Mimecast-MFC-AGG-ID: uW7KpjRcNWKMInUFk7qfFQ_1796169124 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 2C01619373FD; Tue, 1 Dec 2026 23:52:04 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4FBBE1944EB5; Tue, 1 Dec 2026 23:52:03 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH 0/2] udp: Don't share preserved source ports with foreign sockets Date: Tue, 1 Dec 2026 18:52:00 -0500 Message-ID: <20261201235202.2474521-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3u4galKX_Sv6CrwbZzGurBhY-KtRhNJltVm4oP99sz0_1796169124 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: DGCILFJE5QLJPBE4JMUDYE2VJWISAOHF X-Message-ID-Hash: DGCILFJE5QLJPBE4JMUDYE2VJWISAOHF X-MailFrom: jmaloy@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: Gerwim Feiken 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: For UDP flows initiated by the guest, we preserve the guest's source port on the host. If another socket already holds that port, we either fail to bind the flow socket, dropping the flow (e.g. with Podman's rootlessport publishing the same port, bug 223), or, if that socket also uses SO_REUSEADDR, end up sharing an identical 4-tuple with it, so that replies get delivered to the wrong socket (e.g. several passt instances in the same namespace talking to the same DNS resolver). Patch 1, by Gerwim Feiken, binds those flow sockets exclusively, and falls back to a port picked by the kernel if the bind fails. Patch 2 keeps sharing the port if it's held by one of our own listening sockets, so that we still preserve the source port for ports we forward, which matters e.g. for BitTorrent's DHT. Tested in three ways: * With a foreign socket holding the port (fallback, reply received) * With pasta forwarding the port itself (port preserved) * With two instances run by the same user using the same source port (no stolen replies). Link: https://bugs.passt.top/show_bug.cgi?id=223 Gerwim Feiken (1): udp: Don't share a preserved source port with other sockets Jon Maloy (1): udp: Keep sharing source ports we forward ourselves flow.c | 14 ++++++++--- flow.h | 2 +- icmp.c | 2 +- pif.c | 2 +- udp_flow.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++--- util.c | 15 +++++++---- util.h | 3 ++- 7 files changed, 95 insertions(+), 16 deletions(-) -- 2.56.1