From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none 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=XOUdoQt/; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id CC43B5A026E for ; Tue, 20 Aug 2024 21:56:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724183797; 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=URtf988KqSA1lDhqSx596uMeCARCGNMKJuz63Wmxa1Q=; b=XOUdoQt/5QadYfEV+UeKw/A1j8pUSMQQe7l6fcCplDrf5afXjf0npdDmGsqeuQlu3NR14K LD8Tn61wA6bYByKXvhqoLsURY/2CXS9MB/CtCYDBCFKaRz/Iaa/+fX4/2eWZy7FQ6XcgBJ 9pWSpILziZ8MCQa2w6J0m61CSQGtDwI= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-abVZuU-9PuaixllBvHWCcw-1; Tue, 20 Aug 2024 15:56:36 -0400 X-MC-Unique: abVZuU-9PuaixllBvHWCcw-1 Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-201e318ac63so51725815ad.1 for ; Tue, 20 Aug 2024 12:56:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724183794; x=1724788594; 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=URtf988KqSA1lDhqSx596uMeCARCGNMKJuz63Wmxa1Q=; b=MovGdqiis+0Jn45r3/QqMfBFv6oHoz0+uHXcT3UnZmdGPfyGMuTEzIRIOOcW4kr4Ck HhF99i6X+9OadHib6L48FCG2K1OxAyMbhbSACnUfRIegS2BkLOWsCB3+yipWRx6KaDA1 dpWJIi7tszv5tDkqHJb0XgCaZhRidAXlJj6FQtwV1FCBSnxV8gE7nDOeVGudwKmQZp/z CTkDUyFNdrlfp6tYwEnsQZONltCXi5yh+brgQ+qLVIUdaO1CR0WHMvmDFldeGFOewTR0 BRwpyIRM4jQYEpI/FZv00lpfKf92Pz7Op3tCFj5ebET9lVDnirP44Sa2bNrYZUuPww76 V9Pw== X-Gm-Message-State: AOJu0Yzd/Ih2vTbRaC06BF7nRlXMsViWi2ebDVhKwZ1LHwoKmaY9qgLH ESDi+I7cQGMhEdmcTHlSjupUU8mvzHb1H9O16fx6CLlpiY5+97CRCOzcNHHPjGKyDUkW3J3oKX5 CdKbSUAZO9RkiFDNg08JoHWW5NuHMqQk84WW88RjUAJIRhSRHMNo2OWnQww== X-Received: by 2002:a17:902:e54c:b0:202:4592:ccf7 with SMTP id d9443c01a7336-20367e65bcdmr278945ad.20.1724183794654; Tue, 20 Aug 2024 12:56:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ1sCYkz5VDhHVYbMFA4KrT5wX/0EfXldHSdS1nBmiUPplMuoHRIr55WVhkjg6NLHutttnyA== X-Received: by 2002:a17:902:e54c:b0:202:4592:ccf7 with SMTP id d9443c01a7336-20367e65bcdmr278735ad.20.1724183794200; Tue, 20 Aug 2024 12:56:34 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f03030a3sm81764975ad.18.2024.08.20.12.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 12:56:33 -0700 (PDT) Date: Tue, 20 Aug 2024 21:56:31 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 19/22] conf, fwd: Split notion of gateway/router from guest-visible host address Message-ID: <20240820215631.48f6cc6e@elisabeth> In-Reply-To: <20240816054004.1335006-20-david@gibson.dropbear.id.au> References: <20240816054004.1335006-1-david@gibson.dropbear.id.au> <20240816054004.1335006-20-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; 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: XH2MINXDPEJXHGHK26KY7KHSDK4TCWRL X-Message-ID-Hash: XH2MINXDPEJXHGHK26KY7KHSDK4TCWRL 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, 16 Aug 2024 15:40:00 +1000 David Gibson wrote: > The @gw fields in the ip4_ctx and ip6_ctx give the (host's) default > gateway. We use this for two quite distinct things: advertising the > gateway that the guest should use (via DHCP, NDP and/or --config-net) > and for a limited form of NAT. So that the guest can access services > on the host, we map the gateway address within the guest to the > loopback address on the host. > > Using the gateway address for this isn't necessarily the best choice > for this purpose, certainly not for all circumstances. So, start off > by splitting the notion of these into two different values: @guest_gw > which is the gateway address the guest should use and @nat_host_loopback, > which is the guest visible address to remap to the host's loopback. > > Usually nat_host_loopback will have the same value as guest_gw. However > when --no-map-gw is specified we leave them unspecified instead. This > means when we use nat_host_loopback, we don't need to separately check > c->no_map_gw to see if it's relevant. > > Signed-off-by: David Gibson > --- > conf.c | 60 +++++++++++++++++++++++++++++---------------------------- > dhcp.c | 10 ++++++---- > fwd.c | 4 ++-- > passt.h | 16 +++++++++------ > pasta.c | 6 ++++-- > 5 files changed, 53 insertions(+), 43 deletions(-) > > diff --git a/conf.c b/conf.c > index b1c58d5b..26373584 100644 > --- a/conf.c > +++ b/conf.c > @@ -410,12 +410,12 @@ static void add_dns_resolv(struct ctx *c, const char *nameserver, > * redirect > */ > if (IN4_IS_ADDR_LOOPBACK(&ns4)) { > - if (c->no_map_gw) > + if (IN4_IS_ADDR_UNSPECIFIED(&c->ip4.nat_host_loopback)) If you change the command-line option name to use "map", it would be good to also change these names. -- Stefano