|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 1/5] Fix IPv6 zero-run compression.
On 10/09/2026 14:54, Owen Smith wrote:
> ZeroIndex was only set when the first zero was found, and ZeroCount is set to
> the longest run of zeros. This would incorrectly compress an address with
> a two runs of zeros, e.g. "1:0:0:2:0:0:0:3" to "1::0:0:0:3".
> ZeroIndex should be recalculated whenever a longer run of zeros is detected,
> so that the above run is correctly compressed to "1:0:2::3"
>
> Simplifies the condition detecting an ending zero run, as Index would always
> be 7 when a trailing ":" is required.
>
> Assisted-by: ClaudeCode:claude-opus-4.8
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
Reviewed-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
> ---
> src/xenvif/frontend.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
> index bece661..56fcc30 100644
> --- a/src/xenvif/frontend.c
> +++ b/src/xenvif/frontend.c
> @@ -774,22 +774,21 @@ FrontendDumpIPv6Address(
> Count = 0;
>
> if (Count > ZeroCount) {
> - if (Count == 1)
> - ZeroIndex = Index;
> + ZeroIndex = 1 + Index - Count;
> ZeroCount = Count;
> }
> }
>
> if (ZeroCount > 1) {
> - CHAR Parts[8][sizeof(":XXXX")];
> + CHAR Parts[8][sizeof(":XXXX")] = { 0 };
>
> 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)) {
> + if (Index == ZeroIndex ||
> + (Index == 7 && ZeroIndex + ZeroCount == 8)) {
> Parts[Index][0] = ':';
> Parts[Index][1] = '\0';
> } else if (Index > ZeroIndex && Index < ZeroIndex + ZeroCount) {
--
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |