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=Mvt5d/rb; 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 3D2455A0265 for ; Sun, 22 Feb 2026 18:45:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771782302; 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=b9nL1pCct56DteAOPWEwOd3zroHCoXe4RWqq2qCLaW0=; b=Mvt5d/rbEpHDDN3GZ0NgDlm1SxBBlfki3sTdbr2z9xumj5omJdHRpvXyWvRG1obusieiae grXbkbiYOPjcX42GAhQSsylsezl2uAmZwbKNrPJ9lgW/E7ipMJluwbhKTBSoI15yTLvxtV 0nVb0HhsvKHPD0M6Lg4E8tLvNn1Eltk= 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-655-nvQ2R1_bPU6cijjUcB1Pbg-1; Sun, 22 Feb 2026 12:44:58 -0500 X-MC-Unique: nvQ2R1_bPU6cijjUcB1Pbg-1 X-Mimecast-MFC-AGG-ID: nvQ2R1_bPU6cijjUcB1Pbg_1771782297 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B07A7195608E; Sun, 22 Feb 2026 17:44:57 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (unknown [10.22.64.49]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B54711800370; Sun, 22 Feb 2026 17:44:55 +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 v5 05/13] netlink: Return prefix length for IPv6 addresses in nl_addr_get() Date: Sun, 22 Feb 2026 12:44:37 -0500 Message-ID: <20260222174445.743845-6-jmaloy@redhat.com> In-Reply-To: <20260222174445.743845-1-jmaloy@redhat.com> References: <20260222174445.743845-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: 5oFNkGmYODZSBQKpOg0JxGv54vYmxfkI9IpMiV7fMiE_1771782297 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 6NAWXD7YQCV6RXZ6BJO3DTGH46TAPFRM X-Message-ID-Hash: 6NAWXD7YQCV6RXZ6BJO3DTGH46TAPFRM 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 f2ff8af..eb967c7 100644 --- a/conf.c +++ b/conf.c @@ -814,7 +814,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