-
Notifications
You must be signed in to change notification settings - Fork 177
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
IPV6 address stringification different between Mac and Linux #82
Comments
Also of note, the RFC says that a single 16-bit zero field should never be compacted. I have no idea why that is, but: |
Some network tests would fail on a Mac because the IPv6 addressed returned wasn't an exact match due to a difference in the `socket.inet_ntop` function that `netaddr` uses. On a Mac 0 parts of the IPv6 are compressed away to '::' whereas on Linux they remain ':0:'. Ultimately, the fix should be in the upstream `netaddr` library which already has an issue logged for it: netaddr/netaddr#82 Until that's fixed, the solution is to skip the offending tests. Co-Authored-By: Johannes Erdfelt <johannes@erdfelt.com> Change-Id: I7a8a49f4105079a686e553b4d002f04a26b93d0f Closes-Bug: 1409135
Project: openstack/nova 713767660ba44421ea5e0406d121ea868ad178ac network: Fix IPv6 tests for Mac Some network tests would fail on a Mac because the IPv6 addressed returned wasn't an exact match due to a difference in the `socket.inet_ntop` function that `netaddr` uses. On a Mac 0 parts of the IPv6 are compressed away to '::' whereas on Linux they remain ':0:'. Ultimately, the fix should be in the upstream `netaddr` library which already has an issue logged for it: netaddr/netaddr#82 Until that's fixed, the solution is to skip the offending tests. Co-Authored-By: Johannes Erdfelt <johannes@erdfelt.com> Change-Id: I7a8a49f4105079a686e553b4d002f04a26b93d0f Closes-Bug: 1409135
Using fbsocket everywhere does not sound like a good idea, because performance would be very poor. However, it might be a good idea to use dialect objects, just as we already do for EUI objects. The default dialect would be native (=use the local inet_ntop) to maintain current behavior and performance. We could also offer an RFC 5952 dialect and maybe a dialect that never compacts anything. |
@snordhausen Sounds like a good idea. I wonder if the |
there's a similar issue with ipv4-compat addresses. Linux: OSX: |
Seems like a big change so I'll have a look at addressing this as part of 0.8.0 if possible. |
Additionally, there are difference between OSX and Linux when it comes to the validity of zoned ipv6 link local addresses. Example: OSX:
Linux:
|
Linux :
OSX:
|
Some more data points: On Mac OS 10.14 On Windows |
The differences may be disappearing now. Tests on macOS 13.4, CPython 3.11.7:
The issue of zoned IPv6 addresses remains. |
The IPv6 stringification on both and Mac and Linux is done by way of ``socket.inet_ntop`. Unfortunately, the implementations aren't exactly the same, so they produce slightly different results:
Linux
>>> import netaddr; print netaddr.IPAddress(42540766411282592891252304891381481473)
2001:db8:0:1:dcad:beff:feef:1
Mac
>>> import netaddr; print netaddr.IPAddress(42540766411282592891252304891381481473)
2001:db8::1:dcad:beff:feef:1
Notice the Mac version compacts out the extra '0'.
The reason this is a problem is that downstream projects like openstack/nova use this as part of a test suite and will encounter different results depending on whether it's run on a Mac or a Linux box. The consequence for us us, is right now our unit-tests fail on a Mac.
Ideally, it'd be great if
netaddr
provided a completely machine agnostic representation of the IPAddress.It looks like these functions are present in the
fbsocket
module, they're just not used when system versions already exists.So the question is, should we use the
fbsocket
version across all OS's for compatibility's sake?Lower-level failing test
The text was updated successfully, but these errors were encountered: