-
Notifications
You must be signed in to change notification settings - Fork 672
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
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 |
CHANGELOG.md
Outdated
@@ -95,6 +95,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
([#857](https://github.com/nix-rust/nix/pull/857)) | |||
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to move the changelog entries into the "Unreleased" section, and also add a link to the PR.
src/sys/socket/mod.rs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
CHANGELOG.md
Outdated
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. | |||
This project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
## [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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you simplify the test by hardcoding this to ("lo0", "127.0.0.1")
?
test/test.rs
Outdated
@@ -77,4 +77,6 @@ lazy_static! { | |||
pub static ref PTSNAME_MTX: Mutex<()> = Mutex::new(()); | |||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary? Why not just bind each test to a different port?
test/sys/test_socket.rs
Outdated
); | ||
}); | ||
|
||
let slice = [1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8]; |
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.
Pro tip: You can leave out the "u8" on the second and subsequent elements.
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.
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. |
@@ -6,7 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
## [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)) | |||
([#990](https://github.com/nix-rust/nix/pull/990)) |
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.
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.
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.
bors r+
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.