From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=evUR+iOn; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id A663C5A026D for ; Tue, 01 Sep 2026 20:56:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788288965; 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=GQC08HaR8ZLjO0JqgR+l+Eo25Qbp+ba0OI1Icb7yQ8c=; b=evUR+iOn+qZny17sKG3+jXUSQF6r9nSchFgj7kY6wz2Ymb/8QgQNSOOP8JdPE0e7892K37 s0c5apYN/Rbeo09nOH+A0HmYxTyOMLzIroAC1vi/o2amlNWdXwEj0UuXgDG8mJuWgPbthP V3uyXRAmsS5HtlaGWaC0e1fVbgej8PE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655-V_Qt0JhxPkWqQRIHaVMgnA-1; Tue, 01 Sept 2026 14:56:04 -0400 X-MC-Unique: V_Qt0JhxPkWqQRIHaVMgnA-1 X-Mimecast-MFC-AGG-ID: V_Qt0JhxPkWqQRIHaVMgnA_1788288963 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-4843e59c32dso126769f8f.3 for ; Tue, 01 Sep 2026 11:56:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788288963; x=1788893763; 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=GQC08HaR8ZLjO0JqgR+l+Eo25Qbp+ba0OI1Icb7yQ8c=; b=RquvCu6U5B+HADbcZaq+c7QnkvieH+et6Fnp3QP1Lk070vpDoKDzL70iKckwS2JvBO UIhHpIEo19F19nb9PLQi3NG0vjRt+t7W5mB2JbVB2ifsDFVcqZWSokss086kybJxGKCg xkNdch46JwQdE0ScoI0ejK010ARGN+6+sxmxWH/K+jo2h3UlNF0PsUMJtUDuzw5/sK05 dQGJnpuq0oFVsdLI6jCWB2/+QX6xU2/EP4qGfsVjFYmF/pgB77UPICljtKIAdoORMdZt r/uTJbtogiR9EiqXYboHBi9N8rzzjicS1MLTndKLpcKafvNbKMAqKV8/1G904Uz65DtU WYtg== X-Gm-Message-State: AFuF++mMxsisnSanFMlQsxXSreBZGPLk0QBX0+WCjJknqwLNbncLzfBK /IwJZLtbzDzTJv1TdEYd0Q8X3NaWH305AuBcnNTIgCi0X1HQLUerhniuSKP7DpM8L8iIQuvaKkV USehdJ7d2urBQDtvbR5GCfIRYmv13mPheYoOTL3/6KsAlf1zhkAI7RXF9ZbNSRw4= X-Gm-Gg: AYBFou3fKz1u91LSq0gzqc4A7cjo6WFenJ17dSuTzQUt8y7iooj+G5vAak0zHe/ulM7 lw8CLAAshPWXobLg4xGI8yq1R89TLfWNYL5Iphabv4KTqN/+Co/PVqIn98Fgtg+FeySNsYxKIcV Dq5fyfy5MXoff8srD0X1NVOc4NLF35mB9jx0ObICN+nESdBxjs8vB4TPfKplKRNV0cRGZtsyx8N 0uGRdnN++uJygYoH3bxV7IEaTEe/QB4vc3spvMW6c6wUU3vQt09wSNMQJ9e1F5OazwRvhv86NYU YOYrfGUfVetaDcdIYbE/oJKaF4e5tnxWjwFfIMqJmrxiQmwPGuJ5vqKNVZEGc+fWKyMCAdKoRzy aCnlNkztusltsZZ61WINl08xIVdXz X-Received: by 2002:a05:6000:1864:b0:481:503b:b663 with SMTP id ffacd0b85a97d-482f79c8523mr70582744f8f.18.1788288962479; Tue, 01 Sep 2026 11:56:02 -0700 (PDT) X-Received: by 2002:a05:6000:1864:b0:481:503b:b663 with SMTP id ffacd0b85a97d-482f79c8523mr70582633f8f.18.1788288961916; Tue, 01 Sep 2026 11:56:01 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-484492cdc37sm911543f8f.34.2026.09.01.11.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 11:56:01 -0700 (PDT) From: Stefano Brivio To: Rahul Subject: Re: UDP drops when source port is in use in the init namespace Message-ID: <20260901205559.6691b499@elisabeth> In-Reply-To: References: Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Tue, 01 Sep 2026 20:56:01 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sujOy-w27wbhffLEmW_97RJ85wDoUqObIWy5zx8VAOo_1788288963 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: W23UGYHAZOSTLIYTI7SDJ5TR77U4IKE3 X-Message-ID-Hash: W23UGYHAZOSTLIYTI7SDJ5TR77U4IKE3 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: 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, 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. > 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). 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? -- Stefano