Repository navigation
Conversation
This contribution use setsocketops to configure Dont Fragment (DF) bit and OS behavior related to PMTU. It introduce PathMtuDiscoveringMode enum to manage it rust-way and 4 functions respectively for ipv4/v6 and set/get. Omit and Interface exist but are not widely documented.
| #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] | ||
| #[repr(C)] | ||
| #[derive(Debug)] | ||
| pub enum PathMtuDiscoveringMode { |
There was a problem hiding this comment.
I'm not sure about this enum.
Maybe it's better as a type alias with constants for the options? This way we don't have to do the conversion and we don't have to deal with the case where the kernel returns a value we don't support yet.
There was a problem hiding this comment.
Ok I agree, I may do a patch to the linux man page since some are not explicitly documented outside of the in.h/in6.h
There was a problem hiding this comment.
Maybe it's better as a type alias with constants for the options? This way we don't have to do the conversion and we don't have to deal with the case where the kernel returns a value we don't support yet.
I reused the pattern used for Type and Protocol code tell me if wasn't the best move. :)
|
Hello, thanks for the review, will do the changes today. |
Co-authored-by: Thomas de Zeeuw <thomasdezeeuw@gmail.com>
I reused the pattern used elsewhere to have handful short hands documented, while yet permiting futur constant not exposed in the lib. Also expose MtuDiscovering Mode types..
|
|
||
| #[cfg(all(feature = "all", target_os = "linux"))] | ||
| #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] | ||
| impl PathMtuDiscoveringModeV6 { |
There was a problem hiding this comment.
It involve some code duplication alas but it's code that... never change except for adding new mode since API don't change for Linux.
|
Sorry @darnuria I didn't have time to review this last weekend and I don't think I'll have time the next two weeks either, so it's going to take a little while. |
|
It would be great if this PR would also allow setting |
|
+1 for this, and a request to extend it to Windows (and macOS) so DF can be set and read back portably. Use case: I'm implementing RFC 9946 (UDPSTP), a UDP capacity-measurement protocol. RFC 9946 §5 says the IPv4 DF bit SHOULD be set on test traffic, and operators must be able to clear it when fragmentation is what they're measuring. Today socket2 covers my other per-socket IP options (TTL, hop limit, TOS/Traffic Class, buffers), but not DF.
What would cover it on every platform:
I'd be glad to contribute the Windows and Apple parts myself, either as a follow-up PR or as commits on this branch if @darnuria prefers. Just say which you'd rather have. I can test on Windows and Linux locally, CI covers mac. |
Hello first contribution here! It may need some careful review since MTU management is a bit complicated and not so portable.
Add ways to set Path Discovery MTU for Linux on a Socket. (it may not work on freebsd EDIT: CI confirmed it! but may work on Windows subsystem and winsock: https://learn.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options.
This contribution use
setsocketopsto configure Dont Fragment (DF) bit and OSbehavior related to PMTU.
It introduce
PathMtuDiscoveringModeenum to manage it rust-way and 4 functionsrespectively for ipv4/v6 and set/get.
Omit and Interface exist but are not widely documented.
Initially It started by preparing a PR for the patch purposed here: #487
Context: Why it can be needed in a rust library? Some protocols such as DNS in UDP or traceroute needs to manage the MTU on a socket level.
Exemples: