mirror of
https://passt.top/passt
synced 2025-06-14 03:25:34 +02:00
netlink: Fix selection of template interface
Sincef919dc7a4b
("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:f919dc7a4b
("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>
This commit is contained in:
parent
d35bcbee90
commit
639fdf06ed
2 changed files with 41 additions and 27 deletions
4
conf.c
4
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue