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.133.124]) by passt.top (Postfix) with ESMTP id 8D7EA5A0265 for ; Thu, 3 Nov 2022 07:40:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667457631; 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=C1VjfdRO0LWXYkPypJM76m1VzZOB4oAWtXoWQgj8yqY=; b=btDmyqZaMoslXJJxQz6mooOwvY1aypIG7rsPVPZibILDPmusmSE8bYW4Py9pAoJkfemVFr 6tlCJzrHLFFKvMeBLu3ItRsdc1rkhaGuIjaFQuh4HcnTO9CRo/rbYYw8B01lkXcEFK0WQh 9dWKBneT/jphMaTwU7lnUITbUTj+dGc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-636-TDNUqxLdN2-Ml-a-Ik4gMw-1; Thu, 03 Nov 2022 02:40:28 -0400 X-MC-Unique: TDNUqxLdN2-Ml-a-Ik4gMw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F02113817A6F; Thu, 3 Nov 2022 06:40:27 +0000 (UTC) Received: from maya.cloud.tilaa.com (ovpn-208-31.brq.redhat.com [10.40.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B50B4140EBF5; Thu, 3 Nov 2022 06:40:27 +0000 (UTC) Date: Thu, 3 Nov 2022 07:39:36 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 1/3] conf: Consistency check between configured IPv4 netmask and gateway Message-ID: <20221103073936.01b9c614@elisabeth> In-Reply-To: References: <20221102230443.377446-1-sbrivio@redhat.com> <20221102230443.377446-2-sbrivio@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: ARRVZR3ZGLFK6ZWY32EEX24YEWKSULPP X-Message-ID-Hash: ARRVZR3ZGLFK6ZWY32EEX24YEWKSULPP 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.3 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 Thu, 3 Nov 2022 14:17:57 +1100 David Gibson wrote: > On Thu, Nov 03, 2022 at 12:04:41AM +0100, Stefano Brivio wrote: > > Seen in a Google Compute Engine environment with a machine configured > > via cloud-init-dhcp, while testing Podman integration for pasta: the > > assigned address has a /32 netmask, and there's a default route, > > which can be added on the host because there's another route, also > > /32, pointing to the default gateway. > > I'm afraid I'm having trouble getting a good picture of the situation > from this description. I think an actual example with addresses would > make it much clearer. Added in v2. > > This is not a valid configuration as far as I can tell: if the > > address is configured as /32, it shouldn't be used to reach a gateway > > outside its derived netmask. However, Linux allows that, and > > everything works. > > > > The problem comes when pasta --config-net sources address and default > > route from the host, and it can't configure the route in the target > > namespace because the gateway is invalid. > > > > Sourcing more routes than just the default is doable, but probably > > undesirable: pasta users want to provide connectivity to a container, > > not reflect exactly whatever trickery is configured on the host. > > > > Add a consistency check: if the configured default gateway is not > > reachable, shrink the given netmask until we can reach it. > > Hmm... this isn't merely a check, it's changing an otherwise > configured value. Well, yes, there's a check, and if that fails, we adjust the netmask, as this paragraph says. Reporting "[c]onsistency check and eventual adjustment" everywhere sounds a bit heavy. > > Signed-off-by: Stefano Brivio > > --- > > conf.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/conf.c b/conf.c > > index 90214f5..5b88547 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -562,6 +562,10 @@ static unsigned int conf_ip4(unsigned int ifi, > > ip4->mask = 0xffffffff; > > } > > > > + /* Mask consistency check: ensure we can reach the default gateway */ > > Since this is to handle a very weird situation, we absolutely need a > more detailed comment here. Added in v2. -- Stefano