-
Notifications
You must be signed in to change notification settings - Fork 544
libtailscale: fix regression in interface address enumeration #706
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a regression in interface address enumeration that was introduced in commit 9c933a0. The change updates the address parsing logic to use the more modern netip.ParsePrefix
instead of net.ParseCIDR
and converts the parsed prefix to a *net.IPAddr
for proper storage in the AltAddrs
field.
- Replaces
net.ParseCIDR
withnetip.ParsePrefix
for parsing network addresses - Updates the address storage format from
*net.IPNet
to*net.IPAddr
- Preserves zone information when converting parsed addresses
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
be6a0d7
to
6956bb3
Compare
Fix regression introduced in 9c933a0. Fixes tailscale/tailscale#16836 Signed-off-by: James Tucker <james@tailscale.com>
6956bb3
to
1b5e15a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
I have one suggestion to simplify things.
I was also going to ask for a test case to prevent future breakage, but then I realized that there aren’t any Go tests in this repo?!?
var ip net.IP | ||
if pfx.Addr().Is4() { | ||
v4 := pfx.Addr().As4() | ||
ip = net.IP(v4[:]) | ||
} else { | ||
v6 := pfx.Addr().As16() | ||
ip = net.IP(v6[:]) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion (non-blocking): Is this a good place to use netip.Addr.AsSlice?
var ip net.IP | |
if pfx.Addr().Is4() { | |
v4 := pfx.Addr().As4() | |
ip = net.IP(v4[:]) | |
} else { | |
v6 := pfx.Addr().As16() | |
ip = net.IP(v6[:]) | |
} | |
ip := net.IP(pfx.Addr().AsSlice()) |
Fix regression introduced in 9c933a0.
Fixes tailscale/tailscale#16836