aboutgitcodebugslistschat
path: root/conf.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-07-22 15:31:13 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-07-30 21:57:50 +0200
commit06abfcf6d95762976d37aa5721c16802c649efd4 (patch)
tree38b2b7936c0a107015706dd3feadc2021edab13a /conf.c
parent3eaf9f532021326a47f70046b05854d8b1819825 (diff)
downloadpasst-06abfcf6d95762976d37aa5721c16802c649efd4.tar
passt-06abfcf6d95762976d37aa5721c16802c649efd4.tar.gz
passt-06abfcf6d95762976d37aa5721c16802c649efd4.tar.bz2
passt-06abfcf6d95762976d37aa5721c16802c649efd4.tar.lz
passt-06abfcf6d95762976d37aa5721c16802c649efd4.tar.xz
passt-06abfcf6d95762976d37aa5721c16802c649efd4.tar.zst
passt-06abfcf6d95762976d37aa5721c16802c649efd4.zip
Separately locate external interfaces for IPv4 and IPv6
Now that the back end allows passt/pasta to use different external interfaces for IPv4 and IPv6, use that to do the right thing in the case that the host has IPv4 and IPv6 connectivity via different interfaces. If the user hasn't explicitly chosen an interface, separately search for a suitable external interface for each protocol. As a bonus, this substantially simplifies the external interface probe. It also eliminates a subtle confusing case where in some circumstances we would pick the first interface in interface index order, and sometimes in order of routes returned from netlink. On some network configurations that could cause tests to fail, because the logic in the tests was subtly different (it always used route order). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/conf.c b/conf.c
index 943526d..cc08de3 100644
--- a/conf.c
+++ b/conf.c
@@ -630,8 +630,23 @@ static void conf_ip(struct ctx *c)
v4 = v6 = IP_VERSION_PROBE;
}
- if (!c->ifi4 && !c->ifi6)
- c->ifi4 = c->ifi6 = nl_get_ext_if(&v4, &v6);
+ if (v4 != IP_VERSION_DISABLED) {
+ if (!c->ifi4)
+ c->ifi4 = nl_get_ext_if(AF_INET);
+ if (!c->ifi4) {
+ warn("No external routable interface for IPv4");
+ v4 = IP_VERSION_DISABLED;
+ }
+ }
+
+ if (v6 != IP_VERSION_DISABLED) {
+ if (!c->ifi6)
+ c->ifi6 = nl_get_ext_if(AF_INET6);
+ if (!c->ifi6) {
+ warn("No external routable interface for IPv6");
+ v6 = IP_VERSION_DISABLED;
+ }
+ }
if (v4 != IP_VERSION_DISABLED) {
if (!c->gw4)