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

Support ancillary data over sendmsg, recvmsg #313

Open
brunowonka opened this issue Jun 13, 2022 · 6 comments · May be fixed by #316
Open

Support ancillary data over sendmsg, recvmsg #313

brunowonka opened this issue Jun 13, 2022 · 6 comments · May be fixed by #316

Comments

@brunowonka
Copy link

Should socket2 support sendmsg/recvmsg including control ancillary data to expose things like IP_TTL and IPV6_PKTINFO.

I took a quick stab at it to figure out how it'd look like. I only did the writing side, I think there's a lot of design work and discussion here and I'm more than half-convinced this should be an enum instead of what I wrote.

I think it'd be interesting to basically provide some safe wrappers around CMSG and the many control data types. Unclear if it's in the interest of the authors of the crate to maintain all of those, however. Also I have 0 experience with Windows here so I didn't even try satisfying it with my prototype, and I'm honestly not even sure where to begin there.

Interested to hear the maintainer's thoughts. I'm willing to iterate on design and implementation here if there is interest.

Note: This is somewhat related to #86 from what I gathered in the discussion over there.

@Thomasdezeeuw
Copy link
Collaborator

@brunowonka I don't really have time to review this at the moment, but if you open a draft pr I can start reviewing the code once I have some time. In general I think that if the API surface isn't too big socket2 should be able to support this.

brunowonka added a commit to brunowonka/socket2 that referenced this issue Jun 23, 2022
@brunowonka brunowonka linked a pull request Jun 23, 2022 that will close this issue
@brunowonka
Copy link
Author

Thanks @Thomasdezeeuw, opened #316 to get the conversation started

@leshow
Copy link

leshow commented Jun 30, 2022

I don't have an opinion on the code per-say, but I did want to link some other resources I stumbled across that may be helpful:

As an argument for supporting sendmsg/recvmsg, if you want to modify the interface or ip used when sending or receiving a message while bound to ipaddr_any, for instance, those methods are necessary. dnsmasq does this in its DHCP impl. If socket2 is meant to support "advanced configuration options" it seems like something it should be able to do.

edit: it looks like quinn uses sendmmsg/recvmmsg on linux but falls back to just send_to/recv_from on windows? see here

brunowonka added a commit to brunowonka/socket2 that referenced this issue Jul 11, 2022
@the8472
Copy link
Member

the8472 commented Mar 28, 2023

@leshow
Copy link

leshow commented Mar 29, 2023

If this is useful for anyone, I extracted some of the code from quinn into a library that has sendmsg/recvmsg for tokio & std https://github.com/leshow/unix-udp-sock

@chrysn
Copy link

chrysn commented Nov 29, 2023

Reading and writing PKTINFO would also be of great help for std_embedded_nal, as having the local address is mandatory for that interface, to allow QUIC and CoAP implementations. (Right now, that crate goes through nix, but this crate could offer it in a sufficiently abstract way that even Windows can be supported).

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 a pull request may close this issue.

5 participants