Repository navigation
Add cmsg PKTINFO for IPv4 and IPv6. - #990
Conversation
|
FreeBSD has IP_RECVIF and IP_RECVDSTADDR/IP_SENDSRCADDR to accomplish the same thing as IP_PKTINFO. I haven't added that yet. I will once this is committed. |
|
OpenBSD has IPV6_PKTINFO but cargo test fails before these changes so I did not yet include OpenBSD cfg support. |
|
Not sure if |
| - Added `request_code_write_int!` on FreeBSD/DragonFlyBSD | ||
| ([#833](https://github.com/nix-rust/nix/pull/833)) | ||
| - Added PKTINFO cmsg support on Android/iOS/Linux/MacOS. | ||
| - Added V6PKTINFO cmsg support on Android/FreeBSD/iOS/Linux/MacOS. |
There was a problem hiding this comment.
You'll need to move the changelog entries into the "Unreleased" section, and also add a link to the PR.
| ControlMessage::Ipv4PacketInfo(pktinfo) => { | ||
| mem::size_of_val(pktinfo) | ||
| }, | ||
| #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "ios", target_os = "linux", target_os = "macos"))] |
There was a problem hiding this comment.
Can you please wrap to 80 columns?
|
mips-unknown-linux-gnu looks like an endian problem. Not sure how deep. Index probably should have been 1 and it was 1000000 (hex). |
|
I tested on stable-armv7-unknown-linux-gnueabihf, Debian GNU/Linux 8.11 (jessie) with stable 1.30.0 and it passed. Not sure what's different with the test apparatus other than it using 1.24.1. |
Were you actually running Debian on an arm? The test apparatus uses qemu to emulate the embedded architectures, and qemu's got some bugs. |
Yes. I compiled and tested on real armv7 hardware. It is a solid-run.com Hummingboard. |
|
Looks like you're getting |
Yeah, I probably shouldn't be using unwrap() as much. It's probably when scanning the interfaces for addresses that it's failing. It's too bad that I can't get more info from it. I will try setting up QEMU and seeing if I can narrow it down instead of randomly removing unwrap() until I find it. :) |
|
Cool. All that's left to fix is the big endian problem. |
|
After some trouble, I got Ubuntu 16.04 LTS installed on a PowerMac Dual G5 and ran the pktinfo tests natively and both IPv4 and IPv6 tests passed. Maybe the endian bug is in the qemu emulator? I think the code is ok and don't have any more changes to make. |
|
This leaves us in a bad situation for testing though. I tested with version 1.31.0. I will test with 1.24.1 and verify since that's what the emulator is running. |
|
There definitely are bugs in QEMU. That's why many tests are disabled for the QEMU platforms. It's not necessary for this PR that you fix QEMU; just make sure the tests pass on real platforms and all checkmarks are green. |
|
The powerpc tests passed on 1.24.1 as well. Currently, other tests are disabled for qemu bugs: Should I turn my tests off for powerpc and mips? |
|
That's what I would do. |
|
I'm afraid that you'll need to rebase. You somehow merged several other PRs into this one. |
| ## [Unreleased] | ||
| - Added PKTINFO cmsg support on Android/iOS/Linux/MacOS. | ||
| - Added V6PKTINFO cmsg support on Android/FreeBSD/iOS/Linux/MacOS. | ||
| - ([#990](https://github.com/nix-rust/nix/pull/990)) |
There was a problem hiding this comment.
The PR doesn't get its own bullet. These three lines should either all share a bullet, or the "Added" lines should each get their own and each have the PR link.
| .expect("Mutex got poisoned by another test"); | ||
|
|
||
| let lo_ifaddr = loopback_v4addr(); | ||
| let (lo_name, lo) = match lo_ifaddr { |
There was a problem hiding this comment.
Could you simplify the test by hardcoding this to ("lo0", "127.0.0.1")?
| /// Any test that alters signal handling must grab this mutex. | ||
| pub static ref SIGNAL_MTX: Mutex<()> = Mutex::new(()); | ||
| /// Any test sending packets over the loopback interface | ||
| pub static ref LOOP_MTX: Mutex<()> = Mutex::new(()); |
There was a problem hiding this comment.
Is this really necessary? Why not just bind each test to a different port?
| ); | ||
| }); | ||
|
|
||
| let slice = [1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8]; |
There was a problem hiding this comment.
Pro tip: You can leave out the "u8" on the second and subsequent elements.
There was a problem hiding this comment.
Do you want me to fix the versions above in the other existing tests or just this new one?
|
From the nix gitter from me: @asomers replied: So that's what I did. Also Linux uses "lo" and BSDs and macOS use "lo0". Rather than hard coding it, it's safer to look for the LOOPBACK flag. So now which way do you prefer? |
Well, that answers the question about hardcoding the interface name and address. I guess it's not an issue for most tests, because most tests only need the address, not the name. As for the mutex, I think it's better to use separate port numbers. Using distinct ports is a way to guarantee that the tests won't interfere with each other. |
|
It already has the kernel assign a random unused port number so all I should need to do is remove the mutex, fix the CHANGELOG, and remove the unnecessary u8's? |
|
Sounds good. |
| - Added PKTINFO cmsg support on Android/iOS/Linux/MacOS. | ||
| - Added V6PKTINFO cmsg support on Android/FreeBSD/iOS/Linux/MacOS. | ||
| - ([#990](https://github.com/nix-rust/nix/pull/990)) | ||
| ([#990](https://github.com/nix-rust/nix/pull/990)) |
There was a problem hiding this comment.
This still isn't correct because the link is only associated with the V6PKTINFO bullet. You need to either duplicate the link for both bullets, or collapse everything into a single bullet.
|
Ok, everything is good! Please squash and then I'll merge. |
ignore pktinfo tests on qemu mips,mips64,powerpc64 Original work by @mcginty.
990: Add cmsg PKTINFO for IPv4 and IPv6. r=asomers a=pusateri Replaces #891 and attempts to address all previous concerns. Co-authored-by: Tom Pusateri <[email protected]>
Replaces #891 and attempts to address all previous concerns.