diff options
| author | Stefano Brivio <sbrivio@redhat.com> | 2025-12-05 01:37:45 +0100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2025-12-07 23:18:11 +0100 |
| commit | 4ddd59bc6085cbb87a3630e746323ac247164976 (patch) | |
| tree | 8c24b2d630d0beb87f18180fa4f303f0dbd386f9 | |
| parent | 834982c0a35145754de38f77de6e41815cb33178 (diff) | |
| download | passt-4ddd59bc6085cbb87a3630e746323ac247164976.tar passt-4ddd59bc6085cbb87a3630e746323ac247164976.tar.gz passt-4ddd59bc6085cbb87a3630e746323ac247164976.tar.bz2 passt-4ddd59bc6085cbb87a3630e746323ac247164976.tar.lz passt-4ddd59bc6085cbb87a3630e746323ac247164976.tar.xz passt-4ddd59bc6085cbb87a3630e746323ac247164976.tar.zst passt-4ddd59bc6085cbb87a3630e746323ac247164976.zip | |
conf: Separate local mode for each IP version, don't enable disabled IP version
This fixes an issue and introduces a feature:
- in local mode, we accidentally ignored the -4 / --ipv4-only and
-6 / --ipv6-only command line options
- if no template interface is available for a given IP version,
instead of disabling that IP version, use local mode, separately,
for it
Link: https://bugs.passt.top/show_bug.cgi?id=129
Link: https://bugs.passt.top/show_bug.cgi?id=128
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Tested-by: Paul Holzinger <pholzing@redhat.com>
| -rw-r--r-- | conf.c | 19 | ||||
| -rw-r--r-- | passt.1 | 15 |
2 files changed, 19 insertions, 15 deletions
@@ -1109,7 +1109,7 @@ static void conf_print(const struct ctx *c) info("Template interface: %s%s%s%s%s", c->ifi4 > 0 ? if_indextoname(c->ifi4, ifn) : "", c->ifi4 > 0 ? " (IPv4)" : "", - (c->ifi4 && c->ifi6) ? ", " : "", + (c->ifi4 > 0 && c->ifi6 > 0) ? ", " : "", c->ifi6 > 0 ? if_indextoname(c->ifi6, ifn) : "", c->ifi6 > 0 ? " (IPv6)" : ""); } @@ -2001,20 +2001,23 @@ void conf(struct ctx *c, int argc, char **argv) (*c->ip6.ifname_out && !c->ifi6)) die("External interface not usable"); + if (!c->ifi4 && !c->ifi6 && !*c->pasta_ifn) { + strncpy(c->pasta_ifn, pasta_default_ifn, + sizeof(c->pasta_ifn) - 1); + } - if (!c->ifi4 && !c->ifi6) { - info("No external interface as template, switch to local mode"); + if (!c->ifi4 && !v6_only) { + info("IPv4: no external interface as template, use local mode"); conf_ip4_local(&c->ip4); c->ifi4 = -1; + } + + if (!c->ifi6 && !v4_only) { + info("IPv6: no external interface as template, use local mode"); conf_ip6_local(&c->ip6); c->ifi6 = -1; - - if (!*c->pasta_ifn) { - strncpy(c->pasta_ifn, pasta_default_ifn, - sizeof(c->pasta_ifn) - 1); - } } if (c->ifi4 && !no_map_gw && @@ -166,8 +166,8 @@ By default, assigned IPv4 and IPv6 addresses are taken from the host interfaces with the first default route, if any, for the corresponding IP version. If no default routes are available and there is any interface with any route for a given IP version, the first of these interfaces will be chosen instead. If no -such interface exists, the link-local address 169.254.2.1 is assigned for IPv4, -and no additional address will be assigned for IPv6. +such interface exists for a given IP version, the link-local address 169.254.2.1 +is assigned for IPv4, and no additional address will be assigned for IPv6. .TP .BR \-n ", " \-\-netmask " " \fImask @@ -194,9 +194,9 @@ first default route, if any, for the corresponding IP version. If the default route is a multipath one, the gateway is the first nexthop router returned by the kernel which has the highest weight in the set of paths. If no default routes are available and there is just one interface with any route, that -interface will be chosen instead. If no such interface exists, the link-local -address 169.254.2.2 is used for IPv4, and the link-local address fe80::1 is used -for IPv6. +interface will be chosen instead. If no such interface exists for a given IP +version, the link-local address 169.254.2.2 is used for IPv4, and the link-local +address fe80::1 is used for IPv6. Note: these addresses are also used as source address for packets directed to the guest or to the target namespace having a loopback or local source address, @@ -1117,8 +1117,9 @@ throughput of TCP connections. .SS Local mode for disconnected setups If \fBpasst\fR and \fBpasta\fR fail to find a host interface with a configured -address, other than loopback addresses, they will, obviously, not attempt to -source addresses or routes from the host. +address for a given IP version, other than loopback addresses, they will, +obviously, not attempt to source addresses or routes from the host, for that +IP version. In this case, unless configured otherwise, they will assign the IPv4 link-local address 169.254.2.1 to the guest or target namespace, and no IPv6 address. The |
