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=etaaoVJS; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id A0D4E5A0619 for ; Fri, 26 Jun 2026 04:45:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782441930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5T6XZcTk2lqbbTdtXQV8ZIPPjIYEtLJflXzz7qkskEk=; b=etaaoVJSl0nG4wf+Wvl8RavPlkCVzeOdBX1p+dGUQysx+tTVBSIK/Iw9L8CkIvWPITrCu8 A30yigQDz1zWdzn2fpzhk96tpbvALicE4nphtzvipN4Xw2tVQCfWjIDQXsvi6PpLIyyV3a 9SD/RFLIunHLcUcvJnGWecPftf+a30A= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-OoM6FYOSMa-AVtGhVG9Erw-1; Thu, 25 Jun 2026 22:45:26 -0400 X-MC-Unique: OoM6FYOSMa-AVtGhVG9Erw-1 X-Mimecast-MFC-AGG-ID: OoM6FYOSMa-AVtGhVG9Erw_1782441925 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5304619774F3; Fri, 26 Jun 2026 02:45:25 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (unknown [10.22.88.44]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 84F33195608F; Fri, 26 Jun 2026 02:45:24 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, david@gibson.dropbear.id.au, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH v8 03/14] tap, conf: Replace addr_fixed with CONF_ADDR_USER flag check Date: Thu, 25 Jun 2026 22:45:08 -0400 Message-ID: <20260626024519.3701556-4-jmaloy@redhat.com> In-Reply-To: <20260626024519.3701556-1-jmaloy@redhat.com> References: <20260626024519.3701556-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: DaswMn2wpD3XSKFIOErPnb0hQIKqRa4CunuO6c6D7mo_1782441925 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: Q447WOE6JOTITFIQT43B245KIGBO7WK3 X-Message-ID-Hash: Q447WOE6JOTITFIQT43B245KIGBO7WK3 X-MailFrom: jmaloy@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 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: The addr_fixed boolean (per address family) was introduced to prevent observed traffic from overwriting addr_seen when the user explicitly set an address with -a/--address. The unified address array already tracks this: fwd_set_addr() marks user-provided addresses with CONF_ADDR_USER. We now replace all addr_fixed checks with fwd_get_addr() lookups for CONF_ADDR_USER and remove the now-redundant field from ip4_ctx and ip6_ctx. Signed-off-by: Jon Maloy --- conf.c | 7 ++----- passt.h | 6 ------ tap.c | 9 ++++----- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/conf.c b/conf.c index ac8facc8..1c0c1786 100644 --- a/conf.c +++ b/conf.c @@ -1598,13 +1598,10 @@ void conf(struct ctx *c, int argc, char **argv) /* Legacy behaviour: replace existing address if any */ fwd_set_addr(c, &addr, CONF_ADDR_USER, prefix_len); - if (inany_v4(&addr)) { + if (inany_v4(&addr)) c->ip4.no_copy_addrs = true; - c->ip4.addr_fixed = true; - } else { + else c->ip6.no_copy_addrs = true; - c->ip6.addr_fixed = true; - } break; } case 'n': { diff --git a/passt.h b/passt.h index cafa35ea..11ccff05 100644 --- a/passt.h +++ b/passt.h @@ -100,8 +100,6 @@ struct guest_addr { * @ifname_out: Optional interface name to bind outbound sockets to * @no_copy_routes: Don't copy all routes when configuring target namespace * @no_copy_addrs: Don't copy all addresses when configuring namespace - * @addr_fixed: Address was given explicitly (-a): don't update - * addr_seen from traffic observed on tap */ struct ip4_ctx { /* PIF_TAP addresses */ @@ -121,7 +119,6 @@ struct ip4_ctx { bool no_copy_routes; bool no_copy_addrs; - bool addr_fixed; }; /** @@ -141,8 +138,6 @@ struct ip4_ctx { * @ifname_out: Optional interface name to bind outbound sockets to * @no_copy_routes: Don't copy all routes when configuring target namespace * @no_copy_addrs: Don't copy all addresses when configuring namespace - * @addr_fixed: Address was given explicitly (-a): don't update - * addr_seen from traffic observed on tap */ struct ip6_ctx { /* PIF_TAP addresses */ @@ -163,7 +158,6 @@ struct ip6_ctx { bool no_copy_routes; bool no_copy_addrs; - bool addr_fixed; }; #include diff --git a/tap.c b/tap.c index 12630f58..573a3f10 100644 --- a/tap.c +++ b/tap.c @@ -756,7 +756,7 @@ resume: continue; } - if (!c->ip4.addr_fixed && + if (!fwd_get_addr(c, AF_INET, CONF_ADDR_USER, 0) && iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr) c->ip4.addr_seen.s_addr = iph->saddr; @@ -1000,18 +1000,17 @@ resume: if (IN6_IS_ADDR_LINKLOCAL(saddr)) { c->ip6.addr_ll_seen = *saddr; - if (!c->ip6.addr_fixed && + if (!fwd_get_addr(c, AF_INET6, CONF_ADDR_USER, 0) && IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_seen)) { c->ip6.addr_seen = *saddr; } - if (!c->ip6.addr_fixed && - !fwd_get_addr(c, AF_INET6, CONF_ADDR_ANY, 0)) { + if (!fwd_get_addr(c, AF_INET6, CONF_ADDR_USER, 0)) { union inany_addr addr = { .a6 = *saddr }; fwd_set_addr(c, &addr, CONF_ADDR_LINKLOCAL, 64); } - } else if (!c->ip6.addr_fixed && + } else if (!fwd_get_addr(c, AF_INET6, CONF_ADDR_USER, 0) && !IN6_IS_ADDR_UNSPECIFIED(saddr)) { c->ip6.addr_seen = *saddr; } -- 2.52.0