aboutgitcodebugslistschat
path: root/conf.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-03-20 16:33:39 +1100
committerStefano Brivio <sbrivio@redhat.com>2024-03-20 09:34:08 +0100
commit639fdf06edecfa0f61eaa55753edb6f3fae9fcef (patch)
treedb8e418609c7b90eb4d9d0ec21b0e06c8e5ace80 /conf.c
parentd35bcbee9009b847fe635a4e298a084ade7b81ca (diff)
downloadpasst-639fdf06edecfa0f61eaa55753edb6f3fae9fcef.tar
passt-639fdf06edecfa0f61eaa55753edb6f3fae9fcef.tar.gz
passt-639fdf06edecfa0f61eaa55753edb6f3fae9fcef.tar.bz2
passt-639fdf06edecfa0f61eaa55753edb6f3fae9fcef.tar.lz
passt-639fdf06edecfa0f61eaa55753edb6f3fae9fcef.tar.xz
passt-639fdf06edecfa0f61eaa55753edb6f3fae9fcef.tar.zst
passt-639fdf06edecfa0f61eaa55753edb6f3fae9fcef.zip
netlink: Fix selection of template interface
Since f919dc7a4b1c ("conf, netlink: Don't require a default route to start"), if there is only one host interface with routes, we will pick that as the template interface, even if there are no default routes for an IP version. Unfortunately this selection had a serious flaw: in some cases it would 'return' in the middle of an nl_foreach() loop, meaning we wouldn't consume all the netlink responses for our query. This could cause later netlink operations to fail as we read leftover responses from the aborted query. Rewrite the interface detection to avoid this problem. While we're there: * Perform detection of both default and non-default routes in a single pass, avoiding an ugly goto * Give more detail on error and working but unusual paths about the situation (no suitable interface, multiple possible candidates, etc.). Fixes: f919dc7a4b1c ("conf, netlink: Don't require a default route to start") Link: https://bugs.passt.top/show_bug.cgi?id=83 Link: https://github.com/containers/podman/issues/22052 Link: https://bugzilla.redhat.com/show_bug.cgi?id=2270257 Signed-off-by: David Gibson <david@gibson.dropbear.id.au> [sbrivio: Use info(), not warn() for somewhat expected cases where one IP version has no default routes, or no routes at all] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/conf.c b/conf.c
index 644752c..9e0318a 100644
--- a/conf.c
+++ b/conf.c
@@ -584,7 +584,7 @@ static unsigned int conf_ip4(unsigned int ifi,
ifi = nl_get_ext_if(nl_sock, AF_INET);
if (!ifi) {
- info("No interface with a route for IPv4: disabling IPv4");
+ info("Couldn't pick external interface: disabling IPv4");
return 0;
}
@@ -656,7 +656,7 @@ static unsigned int conf_ip6(unsigned int ifi,
ifi = nl_get_ext_if(nl_sock, AF_INET6);
if (!ifi) {
- info("No interface with a route for IPv6: disabling IPv6");
+ info("Couldn't pick external interface: disabling IPv6");
return 0;
}