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

u32 struct fields in place of file descriptors #1001

Open
arctic-alpaca opened this issue Jan 22, 2024 · 2 comments
Open

u32 struct fields in place of file descriptors #1001

arctic-alpaca opened this issue Jan 22, 2024 · 2 comments

Comments

@arctic-alpaca
Copy link
Contributor

Hi,

I noticed that three structs use u32 instead of file descriptors. This fits their definition in the kernel but seems like a break with the crates goal of using OwnedFd/BorrowedFd/AsFd/RawFd.

Affected structs I found:

Is this intentional?

@sunfishcode
Copy link
Member

In the SocketAddrXdp case, it's not intentional. I didn't realize that SocketAddrXdp's file descriptor field means that any function that "dereferences" it would need to be unsafe, like sendto_xdp and sendto_any. That's also the case for io_uring_params and io_uring_setup too. So those are bugs. I'm not yet sure what to do about them.

For PrctlMmMap, the only user is configure_virtual_memory_map, and it's in the category of things where we can't practically describe the lifetime, so we just make it unsafe. We do a similar thing for kevent.

@arctic-alpaca
Copy link
Contributor Author

arctic-alpaca commented Jan 23, 2024

For SocketAddrXdp, the sendmsg and recvmsg implementations in the kernel currently don't make use of the file descriptor or SocketAddrXdp in general. Only the msghdr, in particular the flag(s) (MSG_DONTWAIT) is used.
The AF_XDP docs also show an example for sendto(...) with the sockaddr parameter set to NULL.

As far as I can tell, SocketAddrXdp is only used in the bind method to signal the usage of a shared UMEM.

Could the sendto_xdp, sendto_any (and probably recvmsg too) methods just omit SocketAddrXdp?

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