Skip to content

Conversation

@flocknetworks
Copy link
Contributor

The ip_mreqn struct has an additional interface id parameter. This
allows programming IPv4 multicast groups using the interface id
alongside the src IPv4 address.
Linux has supported the ip_mreqn struct since Linux 2.2
ref: man ip.7

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gnzlbg (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@flocknetworks
Copy link
Contributor Author

rust-lang.libc spar64 + mips64 tests failed but I cant see anything in the logs specific to this diff set ?

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 17, 2019

There are sparc and mips linux targets, and the ABI of the type you added does not match the C ABI on those targets. Why, I don't know. Maybe the struct definition that you have added does not match the struct definition on those targets ?

}

#[cfg(not(any(target_arch = "mips64", target_arch = "sparc64")))]
pub struct ip_mreqn {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work. If you don't want to add this to all linux targets, you need to manually add this to the targets you want. I do however recommend finding the source code for this and checking out what mips and sparc do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i cant find any alternate versions of the struct in glibc, any ideas where else to look ?

@flocknetworks
Copy link
Contributor Author

in glibc I cant find any ip_mreqn struct specific to an architecture. I assume this struct is just not in the sparc64 / mips64 builds ?

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 17, 2019

Which header file does expose it?

@flocknetworks
Copy link
Contributor Author

struct ip_mreq is defined in inet/netinet/in.h
struct ip_mreqn is defined in sysdeps/unix/sysv/linux/bits/in.h

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 17, 2019

So that's in this header: https://elixir.bootlin.com/linux/v5.4-rc2/source/include/uapi/linux/in.h#L173

I assume this struct is just not in the sparc64 / mips64 builds ?

It is available - we know because the C tests for it on sparc64 and mips64 use the type and they compile successfully, so a type definition must be available.

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 17, 2019

So looking at the error, the test that's failing is the following.

This struct has 3 fields, where each field is 4 bytes wide. The first two fields are a struct { u32 }, while the last fields is an i32.

The test initializes the struct bytes in Rust to the following values: [0, 1, 2, 3, ..., 11]. It then passes the struct by value to a C function expecting it. This function then reads the bytes of the struct and verifies that they match the values set on the Rust side. This fails, reporting that the last 4 bytes (the ones of the i32) are read as [0, 0, 0, 0] instead if [8, 9, 10, 11].

That's weird. In particular, this is apparently the only test that fails there. That is, the struct sizes must match, so there can't be any padding between the in_addr and the c_int (that would explain the zeroes in the C side).

Maybe you can just modify the test_linux function in the libc-test/build.rs file to skip the roundtrip test for this type ? (there is a cfg.skip_roundtrip there where you can specify that). It would be interesting to know if all other tests pass.

@flocknetworks
Copy link
Contributor Author

thanks for looking into this, weird indeed. I will try modifying the build.rs

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 17, 2019

If you need these now and don't have time to investigate that's ok, just add these structs to the platforms you need them, e.g., instead of to linux/, maybe only linux/gnu/x86_64 - copy pasting them isn't a problem.

What we try to avoid is adding types that might be subtly broken on some platforms. In this case, it would cost a mips64 user quite a bit of time to figure out why C is crashing when passing it these types without actually writing some code that tries to print their value in C, because on the Rust side, everything looks fine.

@flocknetworks
Copy link
Contributor Author

all the other tests pass (when the roundtrip test is skipped)

The ip_mreqn struct has an additional interface id parameter. This
allows programming IPv4 multicast groups using the interface id
alongside the src IPv4 address.
Linux has supported the ip_mreqn struct since Linux 2.2
ref: man ip.7

[Adding to linux x86_64 only as adding to linux_like/mod.rs caused
failures in the sparc64 and mips64 C regression tests]
@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 17, 2019

all the other tests pass (when the roundtrip test is skipped)

Damn, so I don't know what might be going on. Maybe our ABI implementation on mips64 and sparc64 is borked somehow? cc @nagisa @nikic

I'm going to open an issue to track investigating what's going on here. In the meantime, we can land this for x86_64, thanks @flocknetworks

@bors: r+

@bors
Copy link
Contributor

bors commented Oct 17, 2019

📌 Commit 44b9022 has been approved by gnzlbg

@bors
Copy link
Contributor

bors commented Oct 17, 2019

⌛ Testing commit 44b9022 with merge b728e0f...

bors added a commit that referenced this pull request Oct 17, 2019
Add struct ip_mreqn: ip multicast req with intf id

The ip_mreqn struct has an additional interface id parameter. This
allows programming IPv4 multicast groups using the interface id
alongside the src IPv4 address.
Linux has supported the ip_mreqn struct since Linux 2.2
ref: man ip.7
@bors
Copy link
Contributor

bors commented Oct 17, 2019

💥 Test timed out

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 18, 2019

@bors: retry

@bors
Copy link
Contributor

bors commented Oct 18, 2019

⌛ Testing commit 44b9022 with merge 636b5eb...

bors added a commit that referenced this pull request Oct 18, 2019
Add struct ip_mreqn: ip multicast req with intf id

The ip_mreqn struct has an additional interface id parameter. This
allows programming IPv4 multicast groups using the interface id
alongside the src IPv4 address.
Linux has supported the ip_mreqn struct since Linux 2.2
ref: man ip.7
@bors
Copy link
Contributor

bors commented Oct 18, 2019

💔 Test failed - status-azure

@flocknetworks
Copy link
Contributor Author

I'm assuming these failures are due to something in the CI infra rather than my diffs ?

@bors
Copy link
Contributor

bors commented Nov 18, 2019

⌛ Testing commit 44b9022 with merge a813015...

bors added a commit that referenced this pull request Nov 18, 2019
Add struct ip_mreqn: ip multicast req with intf id

The ip_mreqn struct has an additional interface id parameter. This
allows programming IPv4 multicast groups using the interface id
alongside the src IPv4 address.
Linux has supported the ip_mreqn struct since Linux 2.2
ref: man ip.7
@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 18, 2019

@bors r- retry

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 18, 2019

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 18, 2019

📌 Commit 44b9022 has been approved by gnzlbg

@bors
Copy link
Contributor

bors commented Nov 18, 2019

⌛ Testing commit 44b9022 with merge e9f6339...

bors added a commit that referenced this pull request Nov 18, 2019
Add struct ip_mreqn: ip multicast req with intf id

The ip_mreqn struct has an additional interface id parameter. This
allows programming IPv4 multicast groups using the interface id
alongside the src IPv4 address.
Linux has supported the ip_mreqn struct since Linux 2.2
ref: man ip.7
@bors
Copy link
Contributor

bors commented Nov 18, 2019

☀️ Test successful - checks-cirrus-freebsd-10, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, status-azure
Approved by: gnzlbg
Pushing e9f6339 to master...

@bors bors merged commit 44b9022 into rust-lang:master Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants