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=iMPkfkGY; 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 BE5C15A0269 for ; Tue, 17 Feb 2026 23:18:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771366711; 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=3XsigDCfmNSZ7wUz9kKcCwApStmi0vbUCBKWfLHmRwI=; b=iMPkfkGYos68EkjNQjctF4QlCR65ZHSEVWrYqealsCWbwEHedtZRMKJrgAGRxw+IpWycmd +aU06rpDyNkO73AtmalT1i4iJN/yg/Kv2HCHDVHOIgLitDtYcm58z5kuezIhp4mJB2OTxk R8rMod9c+K6dgqPREXJMzVPl3SGDyK0= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-442-pTiqiGgLN-GsYBWGzPJAlQ-1; Tue, 17 Feb 2026 17:18:28 -0500 X-MC-Unique: pTiqiGgLN-GsYBWGzPJAlQ-1 X-Mimecast-MFC-AGG-ID: pTiqiGgLN-GsYBWGzPJAlQ_1771366707 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F5E418005AD; Tue, 17 Feb 2026 22:18:27 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (unknown [10.22.80.48]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0D2071800349; Tue, 17 Feb 2026 22:18:25 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, dgibson@redhat.com, david@gibson.dropbear.id.au, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH v4 06/12] netlink: Return prefix length for IPv6 addresses in nl_addr_get() Date: Tue, 17 Feb 2026 17:18:08 -0500 Message-ID: <20260217221814.4053583-7-jmaloy@redhat.com> In-Reply-To: <20260217221814.4053583-1-jmaloy@redhat.com> References: <20260217221814.4053583-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: WD8w6zNF3F8-_HoRa3MDIZyKVvvgbEyzhoqvoBCpVNk_1771366707 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: Z6QGSC5KUUATIII6A6QAX74P26PFB76Q X-Message-ID-Hash: Z6QGSC5KUUATIII6A6QAX74P26PFB76Q 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: nl_addr_get() was not setting the prefix_len output parameter for IPv6 addresses, only for IPv4. This meant callers always got 0 for IPv6, forcing them to use a hardcoded default (64). Fix by assigning *prefix_len in the IPv6 case, matching the IPv4 behavior. Signed-off-by: Jon Maloy --- conf.c | 2 +- netlink.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf.c b/conf.c index ee1b4fe..b894ec5 100644 --- a/conf.c +++ b/conf.c @@ -805,7 +805,7 @@ static unsigned int conf_ip6(struct ctx *c, unsigned int ifi) if (!e) { e = &c->addrs[c->addr_count++]; e->addr = addr; - e->prefix_len = prefix_len ? prefix_len : 64; + e->prefix_len = prefix_len; e->flags = CONF_ADDR_HOST; } diff --git a/netlink.c b/netlink.c index 82a2f0c..769cb23 100644 --- a/netlink.c +++ b/netlink.c @@ -752,7 +752,7 @@ int nl_addr_set_ll_nodad(int s, unsigned int ifi) * @ifi: Interface index in outer network namespace * @af: Address family * @addr: Global address to fill - * @prefix_len: Mask or prefix length, to fill (for IPv4) + * @prefix_len: Mask or prefix length, to fill * @addr_l: Link-scoped address to fill (for IPv6) * * Return: 0 on success, negative error code on failure @@ -797,7 +797,7 @@ int nl_addr_get(int s, unsigned int ifi, sa_family_t af, ifa->ifa_prefixlen > prefix_max) { memcpy(addr, RTA_DATA(rta), RTA_PAYLOAD(rta)); - prefix_max = ifa->ifa_prefixlen; + prefix_max = *prefix_len = ifa->ifa_prefixlen; } if (addr_l && -- 2.52.0