Skip to content
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

Struct packet_mreq requires repr(C) in rustc versions >= 1.67 #600

Closed
jahofmann opened this issue Feb 2, 2023 · 1 comment
Closed

Struct packet_mreq requires repr(C) in rustc versions >= 1.67 #600

jahofmann opened this issue Feb 2, 2023 · 1 comment

Comments

@jahofmann
Copy link

With recent rustc versions the memory layout of packet_mreq pnet_datalink/src/bindings/linux.rs:32 has changed.

Rustc 1.67.0 is the first failing version for me and the problem could be related to rust-lang/rust#102750.

This leads to an error in pnet_datalink/src/linux.rs:124 as setsockopt receives the differently aligned struct and fails with "os error 19". In my case the IOCTL received 0 as the (invalid) device index.

Adding #[repr(C)] fixes the issue.

// man 7 packet
#[repr(C)]
pub struct packet_mreq {
    pub mr_ifindex: libc::c_int,
    pub mr_type: libc::c_ushort,
    pub mr_alen: libc::c_ushort,
    pub mr_address: [libc::c_uchar; 8],
}
@mrmonday
Copy link
Contributor

mrmonday commented Feb 3, 2023

This should be fixed in v0.32.0.

@mrmonday mrmonday closed this as completed Feb 3, 2023
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

No branches or pull requests

2 participants