From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D5E8E5A026F for ; Tue, 15 Aug 2023 05:51:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1692071493; bh=kVGxpEcWn2AcISRHhnJSKfD7+C00uu6bgU6R4YTbuas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jGP+MG8v/uWnnOS07gtmDElaVuznftZh8tcoRsco6o0SkN7TuUS6bqRDX5hHtDL40 FsYMzZ9uvt7nJ5wnlTjVDHuKX7HM5fFs/9PbgY4/hdTJ/LlFmp1tqZdQaNosfDUnGv L3RRhTvfMS+0dp/3reAiJ0pL3zTThXP8mIak5HmU= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RPy4P21j0z4wxx; Tue, 15 Aug 2023 13:51:33 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 3/3] netlink: Don't propagate host address expiry to the container Date: Tue, 15 Aug 2023 13:51:29 +1000 Message-ID: <20230815035129.1942905-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815035129.1942905-1-david@gibson.dropbear.id.au> References: <20230815035129.1942905-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: IFOW65MOSTIZNESA572DFJUJ5UXRNCLQ X-Message-ID-Hash: IFOW65MOSTIZNESA572DFJUJ5UXRNCLQ X-MailFrom: dgibson@gandalf.ozlabs.org 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: David Gibson 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: When we copy addresses from the host to the container in nl_addr_dup(), we copy all the address's attributes, including IFA_CACHEINFO, which controls the address's lifetime. If the host address is managed by, for example, DHCP, it will typically have a finite lifetime. When we copy that lifetime to the pasta container, that lifetime will remain, meaning the kernel will eventually remove the address, typically some hours later. The container, however, won't have the DHCP client or whatever was managing and maintaining the address in the host, so it will just lose connectivity. Long term, we may want to monitor host address changes and reflect them to the guest. But for now, we just want to take a snapshot of the host's address and set those in the container permanently. We can accomplish that by stripping off the IFA_CACHEINFO attribute as we copy addresses. Link: https://github.com/containers/podman/issues/19405 Link: https://bugs.passt.top/show_bug.cgi?id=70 Signed-off-by: David Gibson --- netlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/netlink.c b/netlink.c index 69a5304..f55f2c3 100644 --- a/netlink.c +++ b/netlink.c @@ -679,7 +679,9 @@ int nl_addr_dup(int s_src, unsigned int ifi_src, for (rta = IFA_RTA(ifa), na = IFA_PAYLOAD(nh); RTA_OK(rta, na); rta = RTA_NEXT(rta, na)) { - if (rta->rta_type == IFA_LABEL) + /* Strip label and expiry (cacheinfo) information */ + if (rta->rta_type == IFA_LABEL || + rta->rta_type == IFA_CACHEINFO) rta->rta_type = IFA_UNSPEC; } -- 2.41.0