From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 4FD585A0271 for ; Fri, 8 Mar 2024 08:08:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709881728; 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=HZm1Haqk/FN5SsiYVO+v6SXo6wsyJYDHB0Td8Xy2Z6o=; b=HgeOhdd/tpU/kY6gwlbOSdcmZXYspRwtqhnlsGfCrA8m/CXlbmE/nbEMQhbGLduYsaHdQu V8zyZ9D6lDc6F0qbicZWMHkosXCgBg6SNMYUixrTod673hgafbzN9GHSaZSba1WiK/FBz+ vOls3exida/d82FlUB1BD+aKsdH+xJg= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-489-Yj1ibEaTP-yoPLSFn8iUTA-1; Fri, 08 Mar 2024 02:08:46 -0500 X-MC-Unique: Yj1ibEaTP-yoPLSFn8iUTA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-56753c0faa2so256166a12.2 for ; Thu, 07 Mar 2024 23:08:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709881725; x=1710486525; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HZm1Haqk/FN5SsiYVO+v6SXo6wsyJYDHB0Td8Xy2Z6o=; b=WNtR9fFrmyazM6dmVBnQ/3jIFlRGJ0S3PIrUuCvWwzdr6ur8CcsNsVuoQP7CSW/qMj KJIBxpogXzjUHEv/K3qJknqsLRJJMDNpc2Qkf+Ve+3NhoYYyBeAu69AvYroZBP1L/PuZ wGurjiF34C+IPqr58CdGoX1ewonAxlPLgNZZLRrFkw2a7Ef5qTNQXbkuF1wsCMi4BHv8 yufXqaHcRFHT6e4dcdcr1HEoWvZidijc3sGZNjVU59SbEjd/bsnMBlc5DrKhS5GARPR1 p7e8AjjxFM0LRBNX1SljNsuraYV9CzSU8Q8hphpycNj7HXKw55r0cIcMCS8U4osMfhgp 29zg== X-Gm-Message-State: AOJu0Yy/fFDk/8AvOBX8XpGJipkF8lUjWtCWYC7vITxfBy55qufvhlpN ntnm8itPhTS0w1DK4lFAX4pzfK3QXG+mnNUToIBZs4Skrkipf0sQLbSma2d8rR/spiLu9IGU2zN Ue4FFQmYcecOd/O+j20lTELCXMvTNIwvmMXbHbXrSEG2v9ueExg== X-Received: by 2002:a17:906:b154:b0:a45:da1:9364 with SMTP id bt20-20020a170906b15400b00a450da19364mr10727500ejb.19.1709881725120; Thu, 07 Mar 2024 23:08:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IE35ZQxRPVk+1e1iEvrCDP/ZeyU+D0Oi/4WO1USXKyLqQ/z+fHlxDKSdjDLsiQ+upIplKH7BQ== X-Received: by 2002:a17:906:b154:b0:a45:da1:9364 with SMTP id bt20-20020a170906b15400b00a450da19364mr10727473ejb.19.1709881724420; Thu, 07 Mar 2024 23:08:44 -0800 (PST) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id me25-20020a170906aed900b00a44efa48c24sm6509117ejb.117.2024.03.07.23.08.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2024 23:08:43 -0800 (PST) Date: Fri, 8 Mar 2024 08:07:53 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] conf: Don't warn if nameservers were found, but won't be advertised Message-ID: <20240308080753.3f35c406@elisabeth> In-Reply-To: References: <20240307232551.1828628-1-sbrivio@redhat.com> <20240308070530.6cef401c@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: G6BTPWQ3QMZXV5XICREBS2RFYD4UUJZP X-Message-ID-Hash: G6BTPWQ3QMZXV5XICREBS2RFYD4UUJZP 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-dev@passt.top, Paul Holzinger 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: On Fri, 8 Mar 2024 17:33:00 +1100 David Gibson wrote: > On Fri, Mar 08, 2024 at 07:05:30AM +0100, Stefano Brivio wrote: > > On Fri, 8 Mar 2024 12:17:13 +1100 > > David Gibson wrote: > > > > > On Fri, Mar 08, 2024 at 12:25:51AM +0100, Stefano Brivio wrote: > > > > Starting from commit 3a2afde87dd1 ("conf, udp: Drop mostly duplicated > > > > dns_send arrays, rename related fields"), we won't add to c->ip4.dns > > > > and c->ip6.dns nameservers that can't be used by the guest or > > > > container, and we won't advertise them. > > > > > > > > However, the fact that we don't advertise any nameserver doesn't mean > > > > that we didn't find any, and we should warn only if we couldn't find > > > > any. > > > > > > > > This is particularly relevant in case both --dns-forward and > > > > --no-map-gw are passed, and a single loopback address is listed in > > > > /etc/resolv.conf: we'll forward queries directed to the address > > > > specified by --dns-forward to the loopback address we found, we > > > > won't advertise that address, so we shouldn't warn: this is a > > > > perfectly legitimate usage. > > > > > > > > Reported-by: Paul Holzinger > > > > Link: https://github.com/containers/podman/issues/19213 > > > > Fixes: 3a2afde87dd1 ("conf, udp: Drop mostly duplicated dns_send arrays, rename related fields") > > > > Signed-off-by: Stefano Brivio > > > > > > I don't think this is quite the right fix. It makes sense *when* > > > --dns-forward is specified. However if --dns-forward is *not* > > > specified, then having only localhost resolvers on the host side means > > > we really do have nothing the guest can use. So I think we need to > > > make the behaviour explicitly conditional on the dns_match variable. > > > > I was actually about to do that, then I read the text of the warning > > again: "Couldn't get any nameserver address". > > > > If there are just loopback addresses in resolv.conf, and we don't have > > --dns-forward, is that claim correct? We could get them, we actually > > parse them, we just don't advertise them. At the same time, we show the > > user (at least without --quiet) that we don't advertise any server via > > DHCP/NDP/DHCPv6: that section will be missing. > > > > On the other hand, I guess there might be some value in giving the user > > a hint if they just see name resolution failing. Maybe, if we don't use > > any nameserver from resolv.conf (or from the command line), we could > > say "Couldn't use any nameserver address"? > > Right. I think giving some sort of warning if we're unable to > advertise any useful nameserver to the guest is more important than > the pedantic correctness of what the message says. Though obviously > we want to get the latter right too, ideally. > > > > Possibly by making add_dns[46]() accept localhost addresses if > > > (dns_match && no_map_gw)? > > > > What do you mean by "accept"? It already sets .dns_host, no matter > > what. I don't think we should add loopback addresses to the list we > > advertise if c->no_map_gw, because they can't be reached anyway. > > > > Another alternative would be to automatically advertise the address > > passed by --dns-forward. But the user can already specify that via > > --dns, so we'd be actually losing functionality. > > Ah.. I forgot that. It seems weird to me that these are set > separately. I guess that approach doesn't quite work. > > What about your patch, plus a new explicit check about whether we have > something we can advertise to the guest (whether it comes from > resolv.conf or from --dns)? It makes sense, yes. Actually, right now, to unblock Podman with that issue, I would go ahead with my patch, then think of an appropriate text for the other warning. > > I was rather pondering to set .dns_host from add_dns[46]() iff it's > > used (that is, if !IN6_IS_ADDR_UNSPECIFIED(&c->ip[46].dns_match) and > > return some value there (maybe that's what you meant by "accept")? > > > > Then, if any call to add_dns[46]() used any address (advertised or > > mapped), we wouldn't print any warning. > > Hm, maybe. Basically it seems to me we kind of need two different > checks: one if we have no resolvers on the host side for passt itself > to use, one if we have no resolver address we can advertise to the > guest. Each would be suppressed in certain conditions when it's not > relevant, but those conditions are different for each check. Right. > > I'm a bit undecided, because we'd make it more complicated for the sake > > of a warning that doesn't really need to be printed anyway. But again, > > it might be helpful. > > It's a bit more of an extensive change, but a possibly conceptually > easier to understand approach would be: > - Make dns_host an array, instead of single > - add_dns[46]() adds things to the dns_host array, instead of > the dns array (more or less unconditionally) > - We generate the dns array by filtering and/or translating > the dns_host array, unless overridden by --dns > > The two checks then become whether each of the two arrays is empty. The only inconsistent side of this is that dns_host would be an array, but we'd be using only one (we had this inconsistency in the past and we solved it with commit 3a2afde87dd1). Other than that it makes sense, but I wonder if we shouldn't rather revisit the whole DNS mapping mechanism once we have the (complete) flow table in place. -- Stefano