public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 3/3] netlink: Don't propagate host address expiry to the container
Date: Tue, 15 Aug 2023 13:51:29 +1000	[thread overview]
Message-ID: <20230815035129.1942905-4-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20230815035129.1942905-1-david@gibson.dropbear.id.au>

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 <david@gibson.dropbear.id.au>
---
 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;
 		}
 
-- 
@@ -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


  parent reply	other threads:[~2023-08-15  3:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15  3:51 [PATCH 0/3] pasta: Don't propagate host address lifetimes to the container David Gibson
2023-08-15  3:51 ` [PATCH 1/3] netlink: Remove redundant check on nlmsg_type David Gibson
2023-08-15  3:51 ` [PATCH 2/3] netlink: Correctly calculate attribute length for address messages David Gibson
2023-08-15  3:51 ` David Gibson [this message]
2023-08-16 16:41 ` [PATCH 0/3] pasta: Don't propagate host address lifetimes to the container Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230815035129.1942905-4-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).