Skip to content

Fix gNMI IPv6 Get Failures Due to Uncompressed Address Storage #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sauumyaaa
Copy link

Fixes #174

Summary
This PR resolves an inconsistency where IPv6 addresses configured via gNMI in uncompressed format were stored as-is in the DB. This behavior broke gnmi_get operations when the same IP was queried in its standard (compressed) form.

Problem Overview
When a user configures an IPv6 address using gNMI, such as:

2001:0db8:abcd:0016::1

…it was stored without compression in the database. This caused:

gnmi_get with compressed IP (2001:db8:abcd:16::1) → fails with “resource not found”

gnmi_get with the exact (uncompressed) configured IP → succeeds

This inconsistency created confusion and prevented retrieval via normalized XPaths.

Root Cause
The IP string from the gNMI request path was used directly in:

Key formation (YangToDb_subintf_ip_addr_key_xfmr)
Configuration merging (YangToDb_intf_ip_addr_xfmr)
No IP normalization was performed.

Fix
We now normalize all IPv6 addresses using:

net.ParseIP(ip).String()
Applied in:

YangToDb_subintf_ip_addr_key_xfmr — for generating consistent keys

YangToDb_intf_ip_addr_xfmr — for normalizing addr.Config.Ip

Testing:

Configured IPv6 address 2001:0db8:abcd:0016::1 via gnmi_set

Verified in Redis that it is stored as 2001:db8:abcd:16::1

Queried via gnmi_get using compressed format → success

Queried via gnmi_get using uncompressed format → fails (as expected)

Copy link

linux-foundation-easycla bot commented Jun 24, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sauumyaaa sauumyaaa force-pushed the uncompressedIPv6FIX branch from c322ff9 to fbf334e Compare June 24, 2025 11:28
@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IPv6 Address Stored in Uncompressed Form in DB When Configured via gNMI
2 participants