public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Cc: Iyan <iyanmv@gmail.com>
Subject: [PATCH] pasta: Warn, disable matching IP version if not supported, in local mode
Date: Tue, 23 Dec 2025 15:10:58 +0100	[thread overview]
Message-ID: <20251223141058.1068661-1-sbrivio@redhat.com> (raw)

...instead of exiting, but only if local mode is enabled, that is, if
we couldn't find a template interface or if the user didn't specify
one.

With IPv4, we always try to set or copy an address, so check if that
fails.

With IPv6, in local mode, we rely on the link-local address that's
automatically generated inside the target namespace, and only fail
later, as we try to set up routes. Check if that fails, instead.

Otherwise, we'll fail to start if IPv6 support is not built in or
disabled by the kernel ("ipv6.disable=1" on the command line),
because, in that case, we'll try to enable local mode by default, and
then fail to set any address or route.

It would probably be more elegant to check for IP version support in
conf_ip4_local() and conf_ip6_local(), and not even try to enable
connectivity for unsupported versions, but it looks less robust than
trying and failing, as there might be other ways to disable a given
IP version.

Note that there's currently no way to disable IPv4 support on the
kernel command line, that is, there's no such thing as an
ipv4.disable boot parameter. But I guess that's due to be eventually
implemented, one day, so let's cover that case as well, also for
consistency.

Reported-by: Iyan <iyanmv@gmail.com>
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2424192
Fixes: 4ddd59bc6085 ("conf: Separate local mode for each IP version, don't enable disabled IP version")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 pasta.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/pasta.c b/pasta.c
index c307b8a..0ddd6b0 100644
--- a/pasta.c
+++ b/pasta.c
@@ -348,6 +348,12 @@ void pasta_ns_conf(struct ctx *c)
 						 AF_INET);
 			}
 
+			if (c->ifi4 == -1 && rc == -ENOTSUP) {
+				warn("IPv4 not supported, disabling");
+				c->ifi4 = 0;
+				goto ipv4_done;
+			}
+
 			if (rc < 0) {
 				die("Couldn't set IPv4 address(es) in namespace: %s",
 				    strerror_(-rc));
@@ -367,6 +373,7 @@ void pasta_ns_conf(struct ctx *c)
 				    strerror_(-rc));
 			}
 		}
+ipv4_done:
 
 		if (c->ifi6) {
 			rc = nl_addr_get_ll(nl_sock_ns, c->pasta_ifi,
@@ -413,12 +420,19 @@ void pasta_ns_conf(struct ctx *c)
 						  AF_INET6);
 			}
 
+			if (c->ifi6 == -1 && rc == -ENOTSUP) {
+				warn("IPv6 not supported, disabling");
+				c->ifi6 = 0;
+				goto ipv6_done;
+			}
+
 			if (rc < 0) {
 				die("Couldn't set IPv6 route(s) in guest: %s",
 				    strerror_(-rc));
 			}
 		}
 	}
+ipv6_done:
 
 	proto_update_l2_buf(c->guest_mac);
 }
-- 
2.43.0


                 reply	other threads:[~2025-12-23 14:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251223141058.1068661-1-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=iyanmv@gmail.com \
    --cc=passt-dev@passt.top \
    /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).