netinet/in.h: Add IP_DONTFRAG socket option, and implement for IPv4.

To allow consumers to cause the "don't fragment" bit to be set in
all IPv4 packet headers.

There is no standard way of doing this, and different OSes expose
this option in different ways. Linux has "IP_MTU_DISCOVER", but it
takes an enum, not a boolean. NetBSD and OpenBSD appear to have
no socket option, instead they have "IP_MTUDISC", an option for
the "ip_output()" kernel-level network stack method.

"IP_DONTFRAG" sockopt originates on FreeBSD, and it seems macOS now
also supports it in version 11+. Windows has "IP_DONTFRAGMENT",
which, at a glance, appears to do the same thing. So this looks
like the one that makes the most sense to adopt.

This doesn't add any code to process MTU changes yet, though.

Change-Id: I492d22dbd0ee5f4ab35c600396ad3d3ec9f4f200
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9401
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
Augustin Cavalier
2025-06-28 17:22:47 +00:00
committed by waddlesplash
parent d31febdefa
commit 83aa27ada6
2 changed files with 28 additions and 1 deletions
+2
View File
@@ -164,6 +164,8 @@ struct group_source_req {
#define IPV6_DSTOPTS 36 /* struct ip6_dest */
#define IPV6_RTHDR 37 /* struct ip6_rthdr */
#define IP_DONTFRAG 38 /* bool; don't fragment */
#define INADDR_ANY ((in_addr_t)0x00000000)
#define INADDR_LOOPBACK ((in_addr_t)0x7f000001)