@@ -1000,11 +1000,13 @@ pub(crate) fn set_xdp_rx_ring_size(fd: BorrowedFd<'_>, value: u32) -> io::Result
10001000#[ cfg( target_os = "linux" ) ]
10011001#[ inline]
10021002pub ( crate ) fn get_xdp_mmap_offsets ( fd : BorrowedFd < ' _ > ) -> io:: Result < XdpMmapOffsets > {
1003- // The kernel will write `xdp_mmap_offsets` or `xdp_mmap_offsets_v1` to the supplied pointer,
1004- // depending on the kernel version. Both structs only contain u64 values.
1005- // By using the larger of both as the parameter, we can shuffle the values to the non-v1 version
1006- // returned by `get_xdp_mmap_offsets` while keeping the return type unaffected by the kernel
1007- // version. This works because C will layout all struct members one after the other.
1003+ // The kernel will write `xdp_mmap_offsets` or `xdp_mmap_offsets_v1` to the
1004+ // supplied pointer, depending on the kernel version. Both structs only
1005+ // contain u64 values. By using the larger of both as the parameter, we can
1006+ // shuffle the values to the non-v1 version returned by
1007+ // `get_xdp_mmap_offsets` while keeping the return type unaffected by the
1008+ // kernel version. This works because C will layout all struct members one
1009+ // after the other.
10081010
10091011 let mut optlen = core:: mem:: size_of :: < xdp_mmap_offsets > ( ) . try_into ( ) . unwrap ( ) ;
10101012 debug_assert ! (
@@ -1015,8 +1017,8 @@ pub(crate) fn get_xdp_mmap_offsets(fd: BorrowedFd<'_>) -> io::Result<XdpMmapOffs
10151017 getsockopt_raw ( fd, c:: SOL_XDP , c:: XDP_MMAP_OFFSETS , & mut value, & mut optlen) ?;
10161018
10171019 if optlen as usize == core:: mem:: size_of :: < c:: xdp_mmap_offsets_v1 > ( ) {
1018- // Safety: All members of xdp_mmap_offsets are u64 and thus are correctly initialized
1019- // by `MaybeUninit::<xdp_statistics>::zeroed()`
1020+ // Safety: All members of xdp_mmap_offsets are u64 and thus are correctly
1021+ // initialized by `MaybeUninit::<xdp_statistics>::zeroed()`
10201022 let xpd_mmap_offsets = unsafe { value. assume_init ( ) } ;
10211023 Ok ( XdpMmapOffsets {
10221024 rx : XdpRingOffset {
@@ -1050,8 +1052,8 @@ pub(crate) fn get_xdp_mmap_offsets(fd: BorrowedFd<'_>) -> io::Result<XdpMmapOffs
10501052 core:: mem:: size_of:: <xdp_mmap_offsets>( ) ,
10511053 "unexpected getsockopt size"
10521054 ) ;
1053- // Safety: All members of xdp_mmap_offsets are u64 and thus are correctly initialized
1054- // by `MaybeUninit::<xdp_statistics>::zeroed()`
1055+ // Safety: All members of xdp_mmap_offsets are u64 and thus are correctly
1056+ // initialized by `MaybeUninit::<xdp_statistics>::zeroed()`
10551057 let xpd_mmap_offsets = unsafe { value. assume_init ( ) } ;
10561058 Ok ( XdpMmapOffsets {
10571059 rx : XdpRingOffset {
@@ -1094,8 +1096,8 @@ pub(crate) fn get_xdp_statistics(fd: BorrowedFd<'_>) -> io::Result<XdpStatistics
10941096 getsockopt_raw ( fd, c:: SOL_XDP , c:: XDP_STATISTICS , & mut value, & mut optlen) ?;
10951097
10961098 if optlen as usize == core:: mem:: size_of :: < xdp_statistics_v1 > ( ) {
1097- // Safety: All members of xdp_statistics are u64 and thus are correctly initialized
1098- // by `MaybeUninit::<xdp_statistics>::zeroed()`
1099+ // Safety: All members of xdp_statistics are u64 and thus are correctly
1100+ // initialized by `MaybeUninit::<xdp_statistics>::zeroed()`
10991101 let xdp_statistics = unsafe { value. assume_init ( ) } ;
11001102 Ok ( XdpStatistics {
11011103 rx_dropped : xdp_statistics. rx_dropped ,
@@ -1111,8 +1113,8 @@ pub(crate) fn get_xdp_statistics(fd: BorrowedFd<'_>) -> io::Result<XdpStatistics
11111113 core:: mem:: size_of:: <xdp_statistics>( ) ,
11121114 "unexpected getsockopt size"
11131115 ) ;
1114- // Safety: All members of xdp_statistics are u64 and thus are correctly initialized
1115- // by `MaybeUninit::<xdp_statistics>::zeroed()`
1116+ // Safety: All members of xdp_statistics are u64 and thus are correctly
1117+ // initialized by `MaybeUninit::<xdp_statistics>::zeroed()`
11161118 let xdp_statistics = unsafe { value. assume_init ( ) } ;
11171119 Ok ( XdpStatistics {
11181120 rx_dropped : xdp_statistics. rx_dropped ,
0 commit comments