From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GTpF9bsY; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id D88A95A0276 for ; Fri, 05 Dec 2025 12:26:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764933971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rTHJicHIj5rYyF3Dpwf2rrQVaxTY1j6Cm3PhqJ/5Xuo=; b=GTpF9bsY6CA4dbuKxDIo55KeJVc4cxH6qGLsgD1aj/Sj2+0bZ80PgIJlW5j408aKYUI8U8 Qu4WdnjmztY8yan8zYnxm5/pGNHlebfvrSBSZuR+GW3698qfjCKDiMzoI5UNJL4Qhcr4gu eUEjYo+JUXKLVzsx8tiuC5m+1YUcu0A= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-qESeeqqvOuOKj3n54K9hfg-1; Fri, 05 Dec 2025 06:26:10 -0500 X-MC-Unique: qESeeqqvOuOKj3n54K9hfg-1 X-Mimecast-MFC-AGG-ID: qESeeqqvOuOKj3n54K9hfg_1764933969 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-42e2e2389aeso1053985f8f.1 for ; Fri, 05 Dec 2025 03:26:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764933969; x=1765538769; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rTHJicHIj5rYyF3Dpwf2rrQVaxTY1j6Cm3PhqJ/5Xuo=; b=GI1I3Tv5vZ/gUPpy9tQ1MXqlM/qmC5yCr06lFU72TzeLe0os5srDmbaR8R+7jbhb/r c2eN8loC3e1scowbhCsQ2XLkt54dUxB11MTV33nYxx7IGHHm4vqeMI1N/rPCgNVkEUmL key03n+/nGR/OJD0jNPGLmR23xrn6PzaPFDHvVU60jhbxDjHTH4QUVU7Bp8Ls461O6ee 727/Gtd9c2kilZ7wiwtBFBzTjhQ00RxkciG6OA9DeIg2IHkJoiitKyjwOf0CvW6I4uI0 +xJrcbb6L/cG9tIHvenCRJX8L8u7iOV/QKiQCnHqUTEb6HknalRp9z+5faF5ai8A3Lwa EVPA== X-Gm-Message-State: AOJu0YyWzTrZDn8DHKCcUgCubAtISvu3Fh1dUNOR2rCMcuJOKj4d7Jgd DDPgh2rj7W5DMIU1r6N/WyuDg9+YrftIc6Y2BmETciVRRMz61/Y45b6Yh5XT2SMHlwFtoORP1cE LkU6sx23BuOZRzsuRVLY/osXAFRp9p1z+dOlWolf1yaHOd4RSpfpw+w== X-Gm-Gg: ASbGncsmVxZQUADVmXTSwXv9lI7wqBiAvKwJAe39r/j+LqzH98aUmqLGb6ar1W4Z8Jg xlAoINdGlIGf5dpwrsFdIWH3y3rh1XsrGYflR8KglBUE9Gf5ce0074cWek2o+Hd3E/ar1XkphOu cEaSjjcuCV1d5MNblPfKUAxxuhOtanGqJHfvcrW/+Nb+xbZSslU0vL/Gp/bHzAniPoHArLJUrvy w6pkNQU6jsVvVDcL03qjhqP5uyZ1XrhEonIEKSiACrAfQkqN9OcyGXLRs/xkITw0Uo3KmGWBWIE rkPbgL5eO1EltLHtFszc9C3X0/fx/a3LHrjsoDdm6X/m9b9Ug32/VY3IKiJWlFCGcs501OvHRU8 5y8GwHdqNfNmn7Zs= X-Received: by 2002:a05:6000:2305:b0:42b:3d7c:c7cf with SMTP id ffacd0b85a97d-42f7317d7f6mr9673095f8f.15.1764933968869; Fri, 05 Dec 2025 03:26:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5Np9nFOYkR1PanWu+Hpd6OHJA8wm3c742P9BpVa+NAdrqdARACQQA1f3cXL39+5byofeQmg== X-Received: by 2002:a05:6000:2305:b0:42b:3d7c:c7cf with SMTP id ffacd0b85a97d-42f7317d7f6mr9673047f8f.15.1764933968256; Fri, 05 Dec 2025 03:26:08 -0800 (PST) Received: from [192.168.188.22] ([80.243.52.135]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42f7d353c9esm7922749f8f.40.2025.12.05.03.26.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Dec 2025 03:26:07 -0800 (PST) Message-ID: Date: Fri, 5 Dec 2025 12:26:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] conf: Separate local mode for each IP version, don't enable disabled IP version To: Stefano Brivio References: <20251205005126.2577347-1-sbrivio@redhat.com> From: Paul Holzinger In-Reply-To: <20251205005126.2577347-1-sbrivio@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: _pYla3FR43-V21bPiwXghZmHARi6P1PwGkANXqbFJfc_1764933969 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: XSQYS2SP47Y46JTFN3BDU6NCQCXZMZ4W X-Message-ID-Hash: XSQYS2SP47Y46JTFN3BDU6NCQCXZMZ4W X-MailFrom: pholzing@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 05/12/2025 01:51, 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 Tested-by: Paul Holzinger > --- > 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 -- Paul Holzinger