RFC 2292 struct and constant definitions#4954
RFC 2292 struct and constant definitions#4954Skyb0rg007 wants to merge 1 commit intorust-lang:mainfrom
Conversation
b8f20e4 to
16f3cea
Compare
|
Alright, I need help. On *BSD platforms (FreeBSD, macOS, etc), But the Linux doesn't mark these structs as |
742cf17 to
6d97ed6
Compare
This comment has been minimized.
This comment has been minimized.
|
I am most interested in the addition of the ICMP6_FILTER constant to libc. If it would help with review and acceptance, I can create a separate PR with just that single change, and leave the other RFC constants and structures for later PRs. |
853d828 to
ae0b478
Compare
This comment has been minimized.
This comment has been minimized.
ae0b478 to
2423c2d
Compare
This comment has been minimized.
This comment has been minimized.
2423c2d to
a475f7d
Compare
This comment has been minimized.
This comment has been minimized.
a475f7d to
4f730e5
Compare
This comment has been minimized.
This comment has been minimized.
8700997 to
7f5c749
Compare
|
I see that some C macros such as the |
7f5c749 to
966742a
Compare
This comment has been minimized.
This comment has been minimized.
966742a to
fa47e5e
Compare
This comment has been minimized.
This comment has been minimized.
fa47e5e to
23f6846
Compare
This comment has been minimized.
This comment has been minimized.
23f6846 to
92f0a65
Compare
This comment has been minimized.
This comment has been minimized.
92f0a65 to
247c116
Compare
This comment has been minimized.
This comment has been minimized.
This PR adds the icmp6_filter struct and constants as defined by RFC 2292 - Advanced Sockets API for IPv6. These constants are available for use in get/setsockopt on supported Unix platforms. The operations defined on the icmp6_filter struct are defined as C macros, so the implementations are not included here. See the RFC for definitions and use.
247c116 to
a96955a
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| #[cfg(not(any(target_os = "linux", target_os = "emscripten")))] | ||
| pub ip6r0_reserved: u32, | ||
| #[cfg(any(target_os = "linux", target_os = "emscripten"))] | ||
| pub ip6r0_reserved: u8, |
There was a problem hiding this comment.
For any reserved/padding fields, please make them private and wrap them in Padding
| #[cfg(not(target_os = "solaris"))] | ||
| pub icmp6_filt: [u32; 8], | ||
| #[cfg(target_os = "solaris")] | ||
| pub __icmp6_filt: [u32; 8], |
There was a problem hiding this comment.
This struct should be opaque, can you make the fields private?
There was a problem hiding this comment.
I think enabling these in the unix module is too high level; do we know anything about AIX, fuchsia, redox, etc?
Instead, could you put these into the linux_like and bsd modules? That will mean some duplication, but that's probably fine because it will simplify some of the repetitive padding config.
There was a problem hiding this comment.
What would be ideal here is to instead put these in src/new/common/bsd/{icmp6.rs,ip6.rs} and src/new/common/linux_like/{icmp6.rs,ip6.rs}, to match the header structure. The reexport them in src/new/{bionic_libc,musl,glibc,openbsd,freebsd,...}/{icmp6.rs,ip6.rs}, similar to what is done with unistd, and update src/new/mod.rs.
I won't require that because this has already been waiting a while, but eventually everything will move to that new structure so anything to help that is appreciated.
| #[cfg_attr( | ||
| any( | ||
| target_os = "android", | ||
| target_os = "freebsd", | ||
| target_os = "openbsd", | ||
| target_os = "dragonfly", | ||
| target_os = "macos" | ||
| ), | ||
| repr(packed) | ||
| )] | ||
| #[cfg_attr(any(target_os = "linux", target_os = "emscripten"), repr(align(4)))] |
There was a problem hiding this comment.
Could you add links to the PR description to the headers for these other platforms that have the specific alignment requirements? (Looks like only glibc/musl/freebsd are there)
|
Reminder, once the PR becomes ready for a review, use |
Description
This PR adds the structs and constants as defined by RFC 2292 - Advanced Sockets API for IPv6.
These constants are available for use in get/setsockopt on supported Unix platforms.
The operations defined on the icmp6_filter struct are defined as C macros, so the implementations are not included here.
Sources
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/inet/netinet/icmp6.h
https://github.com/kraj/musl/blob/kraj/master/include/netinet/icmp6.h
https://github.com/freebsd/freebsd-src/blob/9ae367d11de8abbdf53884836c9ba30908c5c8db/sys/netinet/icmp6.h
Also in the RFC: https://datatracker.ietf.org/doc/html/rfc2292#section-3.2
Checklist
Unfortunately I could not get the libc-tests working locally, so this PR is marked as draft.
libc-test/semverhave been updated*LASTor*MAXareincluded (see #3131)
cd libc-test && cargo test --target mytarget);especially relevant for platforms that may not be checked in CI
@rustbot label +stable-nominated