On Fri, Dec 05, 2025 at 01:51:26AM +0100, Stefano Brivio wrote: > 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 Reviewed-by: David Gibson > --- > conf.c | 19 +++++++++++-------- > passt.1 | 15 ++++++++------- > 2 files changed, 19 insertions(+), 15 deletions(-) > > diff --git a/conf.c b/conf.c > index 02a4b65..fdc19e8 100644 > --- a/conf.c > +++ b/conf.c > @@ -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 && > diff --git a/passt.1 b/passt.1 > index 0c17454..db0d662 100644 > --- a/passt.1 > +++ b/passt.1 > @@ -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 > -- > 2.43.0 > -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson