Fix gNMI IPv6 Get Failures Due to Uncompressed Address Storage #175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 → succeedsThis 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 → successQueried via
gnmi_get
using uncompressed format → fails (as expected)