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 D4BEC5A027F for ; Mon, 22 May 2023 11:58:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684749538; 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=dWx2kz+Gu78QzbGPvskzE3EGBIngjMPXTxvtmOhC0Tw=; b=RAs5Ujpbu+6DMOTfAlveMIeycbYldjE+eRDI3A7gisQDRwM/nVTnlqNv/v2ex6ecxgcY8V B4FgjzEM/dVDDKHOHuTD7UO2/+XDBM7r+Lwc6m0TyOryOUOLiOFD6VLlSx8awFfVPH/qyP b/SwXHN4aBF9EPA9gZa7ivydchljXhI= 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-134-gXXcnI-HN-2vtro0fA-l8g-1; Mon, 22 May 2023 05:58:55 -0400 X-MC-Unique: gXXcnI-HN-2vtro0fA-l8g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12FC22A59546; Mon, 22 May 2023 09:58:55 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 61829407DEC3; Mon, 22 May 2023 09:58:53 +0000 (UTC) Date: Mon, 22 May 2023 11:58:51 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 03/10] netlink: Add functionality to copy routes from outer namespace Message-ID: <20230522115851.2c7f7736@elisabeth> In-Reply-To: References: <20230521234224.2770015-1-sbrivio@redhat.com> <20230521234224.2770015-4-sbrivio@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: TQIHJP5JASVFID3XZEXIDUATCEZF5CYF X-Message-ID-Hash: TQIHJP5JASVFID3XZEXIDUATCEZF5CYF 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, Callum Parsey , me@yawnt.com, lemmi@nerd2nerd.org, Andrea Arcangeli 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 Mon, 22 May 2023 18:42:01 +1000 David Gibson wrote: > On Mon, May 22, 2023 at 01:42:17AM +0200, Stefano Brivio wrote: > > Instead of just fetching the default gateway and configuring a single > > equivalent route in the target namespace, on 'pasta --config-net', it > > might be desirable in some cases to copy the whole set of routes > > corresponding to a given output interface. > > > > For instance, in: > > https://github.com/containers/podman/issues/18539 > > IPv4 Default Route Does Not Propagate to Pasta Containers on Hetzner VPSes > > > > configuring the default gateway won't work without a gateway-less > > route (specifying the output interface only), because the default > > gateway is, somewhat dubiously, not on the same subnet as the > > container. > > > > This is a similar case to the one covered by commit 7656a6f88882 > > ("conf: Adjust netmask on mismatch between IPv4 address/netmask and > > gateway"), and I'm not exactly proud of that workaround. > > > > We also have: > > https://bugs.passt.top/show_bug.cgi?id=49 > > pasta does not work with tap-style interface > > > > for which, eventually, we should be able to configure a gateway-less > > route in the target namespace. > > > > Introduce different operation modes for nl_route(), including a new > > NL_DUP one, not exposed yet, which simply parrots back to the kernel > > the route dump for a given interface from the outer namespace, fixing > > up flags and interface indices on the way, and requesting to add the > > same routes in the target namespace, on the interface we manage. > > > > For n routes we want to duplicate, send n identical netlink requests > > including the full dump: routes might depend on each other and the > > kernel processes RTM_NEWROUTE messages sequentially, not atomically, > > and repeating the full dump naturally resolves dependencies without > > the need to actually calculate them. > > > > I'm not kidding, it actually works pretty well. > > If there's a way to detect whether the kernel rejected some of the > routes, it would be nice to cut that loop short as soon as all the > routes are inserted. Obviously that could be a followup improvement, > though. Yes, there's a way, but to keep things asynchronous in a simple way we process errors from nl_req() only at the next request. This part doesn't really need to be asynchronous, though: we could add a flag for nl_req() saying that we want to know about NLMSG_ERROR right away. This looks relatively straightforward, and already an improvement in the sense you mentioned. Actually parsing the error and finding out the offending route is a bit more complicated, though. -- Stefano