public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 0/2] udp: Don't share preserved source ports with foreign sockets
@ 2026-12-01 23:37 Jon Maloy
  2026-12-01 23:37 ` [PATCH 1/2] udp: Don't share a preserved source port with other sockets Jon Maloy
  2026-12-01 23:37 ` [PATCH 2/2] udp: Keep sharing source ports we forward ourselves Jon Maloy
  0 siblings, 2 replies; 4+ messages in thread
From: Jon Maloy @ 2026-12-01 23:37 UTC (permalink / raw)
  To: sbrivio, david, jmaloy, passt-dev

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


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH 0/2] udp: Don't share preserved source ports with foreign sockets
@ 2026-12-01 23:52 Jon Maloy
  2026-12-01 23:52 ` [PATCH 2/2] udp: Keep sharing source ports we forward ourselves Jon Maloy
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Maloy @ 2026-12-01 23:52 UTC (permalink / raw)
  To: sbrivio, jmaloy, passt-dev; +Cc: Gerwim Feiken

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-01 23:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 23:37 [PATCH 0/2] udp: Don't share preserved source ports with foreign sockets Jon Maloy
2026-12-01 23:37 ` [PATCH 1/2] udp: Don't share a preserved source port with other sockets Jon Maloy
2026-12-01 23:37 ` [PATCH 2/2] udp: Keep sharing source ports we forward ourselves Jon Maloy
2026-12-01 23:52 [PATCH 0/2] udp: Don't share preserved source ports with foreign sockets Jon Maloy
2026-12-01 23:52 ` [PATCH 2/2] udp: Keep sharing source ports we forward ourselves Jon Maloy

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).