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 BDF2D5A0265 for ; Sun, 15 Nov 2026 23:58:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794783506; 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=E82kcVxNtyca8Z6Jjg65ZRX8M++c5Jv3nvDn4eW0TfQ=; b=JUM1R2cvAYAG+Vkm3VvyqDqyQdfUBWkI5weLxRpp0QlWLNsgrR/NTDuMVF1VZOVujNHH1/ IMQ+DkMm5/nDIGaZmaUPO1hYevBdLarqX+TrZYD/D0yyD4t4fEZGZOtGlsY4UL9UGJhn2W o9sGcbT5tOteMetqNCXGPeRc6LpsXSg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-J5zxq5mBPZKc433d5nXP_A-1; Sun, 15 Nov 2026 17:58:25 -0500 X-MC-Unique: J5zxq5mBPZKc433d5nXP_A-1 X-Mimecast-MFC-AGG-ID: J5zxq5mBPZKc433d5nXP_A_1794783504 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-499ca65ae87so543402f8f.1 for ; Sun, 15 Nov 2026 14:58:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794783504; x=1795388304; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh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k3xLGkqN8lK3nq4+v XjqLe9u0jLyokxyO4kqM9X7790DiN3/ykTNa4YIcwr3AQhAJ9FArE2dw4c9hXG0Png48= X-Received: by 2002:a05:600c:8b38:b0:4a1:c27d:e1a8 with SMTP id 5b1f17b1804b1-4bb55a7b45bmr205870405e9.10.1794783503683; Sun, 15 Nov 2026 14:58:23 -0800 (PST) X-Received: by 2002:a05:600c:8b38:b0:4a1:c27d:e1a8 with SMTP id 5b1f17b1804b1-4bb55a7b45bmr205870125e9.10.1794783503127; Sun, 15 Nov 2026 14:58:23 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb4e28c882sm341209205e9.6.2026.11.15.14.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 14:58:22 -0800 (PST) From: Stefano Brivio To: Rahul Subject: Re: UDP drops when source port is in use in the init namespace Message-ID: <20261115235821.270b892d@elisabeth> In-Reply-To: References: <178828896845.2775.7538203367154726506@maja> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Sun, 15 Nov 2026 23:58:22 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gqjLNUwrZEH-8ZiTDcoBc5Pqq7KdSggzzdPulw6PglA_1794783504 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: ISNU6MU6VF2T3NBX7NOJM24NRIYBWIOP X-Message-ID-Hash: ISNU6MU6VF2T3NBX7NOJM24NRIYBWIOP X-MailFrom: sbrivio@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: David Gibson , passt-user@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: "For passt users: support, questions and answers" Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Rahul, On Wed, 2 Sep 2026 19:09:15 +1000 David Gibson wrote: > On Tue, Sep 01, 2026 at 08:56:01PM +0200, Stefano Brivio via user wrote: > > Date: Tue, 01 Sep 2026 20:56:01 +0200 (CEST) > > From: Stefano Brivio > > To: Rahul > > CC: passt-user@passt.top > > Subject: Re: UDP drops when source port is in use in the init namespace > > Organization: Red Hat > > List-Id: "For passt users: support, questions and answers" > > > > > > Rahul, thanks for the report and for the investigation. Remarks and > > some answers inline: > > > > On Sun, 30 Aug 2026 11:12:44 +0100 > > Rahul wrote: > > > > > Hi, > > > > > > I'm seeing DNS requests being dropped when using pasta 20250217. As far as > > > I can tell, UDP > > > flows where the source port chosen in the namespace is already in use in the > > > init namespace get dropped. > > > > > > All three fwd_nat_from_*() preserve the source port for UDP: > > > > > > tgt->oport = 0; > > > if (proto == IPPROTO_UDP) > > > /* But for UDP preserve the source port */ > > > tgt->oport = ini->eport; > > > > This is intended, to offer compatibility with applications or protocols > > that might rely on UDP source ports to be preserved, and, in general, > > to be as transparent as possible. But: > > > > > That forces a bind() to it, and udp_flow_sock() treats bind failure as > > > fatal, so > > > the flow is cancelled and the datagram dropped with no error to the sender. > > > > ...this is not, that is, it would definitely be desirable to have a > > fallback for bind() failures. > > Probably? The danger with a fallback of this sort is that if you're > using a protocol which cares about the source port it will > work.. until suddenly it doesn't for pretty non-obvious reasons. > > Theoretically another option would be to _not_ preserve the source > port by default, but allow forwarding rules to specify source-port > preservation, specifically for cases which do need it. But, that's a > lot more work both to implement and to configure. > > > > I don't think I ever hit this with slirp4netns, it looks like libslirp's > > > udp_attach() never > > > binds a port, so the kernel just gives it a random free port. > > > > Right, yes, slirp4netns doesn't attempt to preserve UDP source ports > > outside the namespace. It's a feature we added in pasta. > > > > > I'm not sure whether this is intended, but if it is, is there any way to > > > work > > > around it? > > > > I see two ways of implementing this fallback mechanism, roughly: > > > > 1. pass all the way to _sock_l4() via udp_flow_sock() an additional > > argument to entirely ignore bind() failures (like we do for ICMP > > ping sockets). It might be a rather mechanical change but not my > > preferred approach as we would need an extra argument in a large > > number of functions just for a corner case > > > > 2. I think preferable: detect the failure on bind() here (it should be > > EADDRINUSE, did you check?) and try again from udp_flow_sock() with > > tgt->oport as 0. > > > > Here, "tgt" means the target namespace of the connection, and > > "oport" means "our port", implying the source port (because it's an > > outbound connection from pasta's side). > > You'll also need to make sure this takes place _before_ calling > getsockname() to fill in the correct final tgt->oport. > > > I think it would be good to try and sketch a solution (maybe starting > > from 1.) to understand what approach would be more elegant and viable. > > > > I don't have much time on my hands right now but I'll definitely > > provide pointers and support if you feel like proposing a patch for > > this. > > > > As a first test / workaround for your usage: did you already check that > > keeping tgt->oport as 0 in the relevant function in fwd.c works? Meanwhile, see: https://archives.passt.top/passt-dev/20261115223823.1401886-1-sbrivio@redhat.com/ https://bugs.passt.top/show_bug.cgi?id=223 ...it would be good if you could double check whether Gerwim's patch fixes your issue as well. -- Stefano