public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Jon Maloy <jmaloy@redhat.com>
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	[thread overview]
Message-ID: <20261201233719.2470656-1-jmaloy@redhat.com> (raw)

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


             reply	other threads:[~2026-12-01 23:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 23:37 Jon Maloy [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201233719.2470656-1-jmaloy@redhat.com \
    --to=jmaloy@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).