public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Hayato Kiwata <dev@haytok.jp>
To: passt-dev@passt.top
Cc: Hayato Kiwata <dev@haytok.jp>
Subject: [PATCH] netlink: Don't warn about multiple interfaces when there's only one
Date: Sat, 22 Aug 2026 08:49:21	[thread overview]
Message-ID: <20260822084856.3981-1-dev@haytok.jp> (raw)

Suppose there is a single network interface on the host, with two
addresses of different prefixes assigned to it.

In this situation, running pasta to create an isolated netns prints
"Multiple interfaces with %s routes, picked first", even though there
is in fact only one candidate interface.

Reproducer:

  sudo ip link add dummy42 type dummy
  sudo ip link set dev dummy42 up
  sudo ip addr add fdaa:aaaa:aaaa::1/64 dev dummy42
  sudo ip addr add fdbb:bbbb:bbbb::1/64 dev dummy42

  pasta --config-net -- true

This message is meant to indicate that there are multiple candidate
interfaces, but in fact there is only one, which can mislead users.

Therefore, avoid printing this message when there are multiple non-default
routes that all belong to the same interface.

Fixes: 450a6131beab ("netlink: With no default route, pick the first interface with a route")
Signed-off-by: Hayato Kiwata <dev@haytok.jp>
---
 netlink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/netlink.c b/netlink.c
index 8d20dbb..225b666 100644
--- a/netlink.c
+++ b/netlink.c
@@ -271,6 +271,7 @@ unsigned int nl_get_ext_if(int s, sa_family_t af)
 	};
 	unsigned defifi = 0, anyifi = 0;
 	unsigned ndef = 0, nany = 0;
+	bool multi_anyif = false;
 	struct nlmsghdr *nh;
 	struct rtattr *rta;
 	char buf[NLBUFSIZ];
@@ -330,6 +331,8 @@ unsigned int nl_get_ext_if(int s, sa_family_t af)
 			nany++;
 			if (!anyifi)
 				anyifi = thisifi;
+			else if (anyifi != thisifi)
+				multi_anyif = true;
 		}
 	}
 
@@ -345,7 +348,7 @@ unsigned int nl_get_ext_if(int s, sa_family_t af)
 	}
 
 	if (anyifi) {
-		if (nany > 1) {
+		if (multi_anyif) {
 			info("Multiple interfaces with %s routes, picked first",
 			     af_name(af));
 		}
-- 
2.39.5 (Apple Git-154)


                 reply	other threads:[~2026-08-22  8:49 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=20260822084856.3981-1-dev@haytok.jp \
    --to=dev@haytok.jp \
    --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).