[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] frontend: Format IPv6 addresses according to RFC 5952


  • To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Fri, 5 Jun 2026 14:11:11 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hFG2Gl6efqtuwPYQixsg5f5R/dZyq5us+LxnLHABHn4=; b=qRurBaYt4st1Y1UPywaHp0lNeHRrKbC2HtX0MqxU2rSj7sQsiIzAXwtSBWDKTWZpOC2CTiq34z12uY5mjulpxDyncz0q+O/l+sbBcjJKM6Ik5evLUON+6wW0kxjhOCA89nEFHx9rE0z4dFJi5/7h++dtyYeCXfnUHn+85SmnEmAwQECIcVi1xGZ8HJLKOHkDamV4vXpVgaBBOn0HgVlFTBTb3rillEnhbnrLhs0OXN3jB/Ui7zm340syc7B2G6rCEIKaVIL8g0jEeLVOQqyqgfEqLy0XnNMx01g0C8AMBBk1f6qYgkIGqXwgqsRvB8gDHwnQpNvRXjlnhskJycjTwA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zArO52EHkYTqMqijyP+JP1YSOFk+/H4EXf3WHQdjefLjicBPGE2axL+ezuT0VhkIot2KTAmQ1vdbp+T03wgfTE/Zt1Orywfv7ZUGQZrOPfXdG+9l/WxXsL432kiJHLCbjmgRW/GzeSSm3AvTGZdh9/h0bwfWfwjDjgcuSrGcvWAtFNpsgaFxabSMU5GDRAmIi/X8c/Xdcj4BGfWQdVEZx6Ds5yf66ka9WQzgqH/BAKXLKcD5N/+gusqTYgWY3v5efrz2Y2dmg6PH8GrnlYP48UYcH0vEIAcDqfdFzhAbkMjrgHMb4FU0yDd4fertq251Lk8E1p5MvAbxhCi5xRGyVQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Fri, 05 Jun 2026 14:11:17 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHc9Od8bQaIAcYc+0OPhgE0qFbyKrYv5XWAgAAbC/k=
  • Thread-topic: [PATCH 2/2] frontend: Format IPv6 addresses according to RFC 5952

Reviewed-by: Owen Smith <owen.smith@xxxxxxxxxx>

________________________________________
From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> on behalf of Tu 
Dinh <ngoc-tu.dinh@xxxxxxxxxx>
Sent: 05 June 2026 1:34 PM
To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Subject: Re: [PATCH 2/2] frontend: Format IPv6 addresses according to RFC 5952

On 05/06/2026 14:33, Tu Dinh wrote:
> Scan for and collapse sequences of consecutive zeroes.
> Do not zero-pad components of the IP address.
>
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>

Tests: https://gist.github.com/dinhngtu/103ac89b5c8f23ed4a61cd538cb8f0da

> ---
>   src/xenvif/frontend.c | 87 ++++++++++++++++++++++++++++++++++++-------
>   1 file changed, 73 insertions(+), 14 deletions(-)
>
> diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
> index 4afc72a..256b35b 100644
> --- a/src/xenvif/frontend.c
> +++ b/src/xenvif/frontend.c
> @@ -700,22 +700,81 @@ FrontendDumpIPv6Address(
>       _In_ PIPV6_ADDRESS              Address
>       )
>   {
> +    ULONG                           Index;
> +    ULONG                           Count;
> +    ULONG                           ZeroIndex;
> +    ULONG                           ZeroCount;
>       NTSTATUS                        status;
>
> -    status = XENBUS_STORE(Printf,
> -                          &Frontend->StoreInterface,
> -                          Transaction,
> -                          __FrontendGetPrefix(Frontend),
> -                          Node,
> -                          "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
> -                          NTOHS(Address->Word[0]),
> -                          NTOHS(Address->Word[1]),
> -                          NTOHS(Address->Word[2]),
> -                          NTOHS(Address->Word[3]),
> -                          NTOHS(Address->Word[4]),
> -                          NTOHS(Address->Word[5]),
> -                          NTOHS(Address->Word[6]),
> -                          NTOHS(Address->Word[7]));
> +    Count = ZeroIndex = ZeroCount = 0;
> +    for (Index = 0; Index < 8; Index++) {
> +        if (Address->Word[Index] == 0)
> +            Count++;
> +        else
> +            Count = 0;
> +
> +        if (Count > ZeroCount) {
> +            if (Count == 1)
> +                ZeroIndex = Index;
> +            ZeroCount = Count;
> +        }
> +    }
> +
> +    if (ZeroCount > 1) {
> +        CHAR                        Parts[8][sizeof(":XXXX")];
> +
> +        for (Index = 0; Index < 8; Index++) {
> +            // Consecutive 0s are collapsed into a single semicolon, so that
> +            // appending :xxxx segments would work naturally.
> +            // Compensate for the missing appended semicolon if the last word
> +            // was also collapsed.
> +            if (Index == ZeroIndex || (Index == 7 &&
> +                                       Index == ZeroIndex + ZeroCount - 1)) {
> +                Parts[Index][0] = ':';
> +                Parts[Index][1] = '\0';
> +            } else if (Index > ZeroIndex && Index < ZeroIndex + ZeroCount) {
> +                Parts[Index][0] = '\0';
> +            } else {
> +                status = RtlStringCchPrintfA(Parts[Index],
> +                                             sizeof(Parts[Index]),
> +                                             Index == 0 ? "%hx" : ":%hx",
> +                                             NTOHS(Address->Word[Index]));
> +                if (!NT_SUCCESS(status))
> +                    return status;
> +            }
> +        }
> +
> +        status = XENBUS_STORE(Printf,
> +                              &Frontend->StoreInterface,
> +                              Transaction,
> +                              __FrontendGetPrefix(Frontend),
> +                              Node,
> +                              "%s%s%s%s%s%s%s%s",
> +                              Parts[0],
> +                              Parts[1],
> +                              Parts[2],
> +                              Parts[3],
> +                              Parts[4],
> +                              Parts[5],
> +                              Parts[6],
> +                              Parts[7]);
> +    } else {
> +        status = XENBUS_STORE(Printf,
> +                              &Frontend->StoreInterface,
> +                              Transaction,
> +                              __FrontendGetPrefix(Frontend),
> +                              Node,
> +                              "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx",
> +                              NTOHS(Address->Word[0]),
> +                              NTOHS(Address->Word[1]),
> +                              NTOHS(Address->Word[2]),
> +                              NTOHS(Address->Word[3]),
> +                              NTOHS(Address->Word[4]),
> +                              NTOHS(Address->Word[5]),
> +                              NTOHS(Address->Word[6]),
> +                              NTOHS(Address->Word[7]));
> +    }
> +
>       return status;
>   }
>



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.