this fixes the net.IP from /proc/net/udp* being broken because they a… #336
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.
…re in network byte order, not host byte order
While testing and working on #332 I discovered a more serious problem with the implementation of the NetUDP reader code. It has a byte order problem.
/proc/net/udp{,6} have the IP addresses in network byte order. The current code does not correctly transform from network byte order to host byte order, so the LocalAddr and RemAddr are stored improperly.
I wrote this patch to fix that, but with a big caveat: it assumes little endian order like intel/amd architectures. I could write generic code to handle both big and little endian, but I would have no way to test it. If someone with a big-endian environment wanted to take that on, I could help.
For ipv4, I simply reverse the bytes. For ipv6 it's more complicated because the address is four words consisting of four bytes each. In each of those four words, the four bytes are written in reverse order.
The reason that the tests were passing was because the tests were incorrect. For ipv4, I updated the fixture for /proc/net/udp to match what the test 10.0.0.5 address would really generate. For ipv6, I kept the existing fixture but fixed the test comparison address to fe80::56e1:adff:fe7c:6609.
If someone could take a look and validate all of this that'd be good.
I will also fix #332 that I was originally working on to add in a similar patch, once someone validates this.