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 1B1A85A026E for ; Wed, 02 Dec 2026 00:37:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796168247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3qP5GbvsXYm/xg4lywim5bjQDuAnxp3q1BcyPjrZy1k=; b=IRw5Co5ThyWYvTv+UopvbwnF+OtD413yFBhF7h9cqDA00JT7H+ot59nb2q9nGascXA7K8k MZUYq36JTRYU8tQcgEh8N5izcdBRXHhXRQ1IuWa0YnY1bkhPWYua/LeZWkeKKZEkSaoflK c5ghUa9X8MiWWjxXXNrREqL8lDJQQmg= X-MC-Rep: binary re single Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-D1dk2ipcNtGiaSoc9khgSw-1; Tue, 1 Dec 2026 23:37:23 +0000 X-MC-Unique: D1dk2ipcNtGiaSoc9khgSw-1 X-Mimecast-MFC-AGG-ID: D1dk2ipcNtGiaSoc9khgSw_1796168242 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 05A781828AB0; Tue, 1 Dec 2026 23:37:22 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6F49B18011F4; Tue, 1 Dec 2026 23:37:20 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, david@gibson.dropbear.id.au, 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:37:17 -0500 Message-ID: <20261201233719.2470656-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: l9YPPWp5ZyOnZeS0eErlZCSomKCJhr8J1Blk0ra3zAo_1796168242 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: OXM7CXGPKLHAI7QLAZDMPDYTHHCYGJM2 X-Message-ID-Hash: OXM7CXGPKLHAI7QLAZDMPDYTHHCYGJM2 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 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