Debian Codegraph @

upstream/debian-unstable/man2/IP_MTU_DISCOVER.2const

raw
1 '\" t
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH IP_MTU_DISCOVER 2const 2025-11-25 "Linux man-pages 6.18"
7 .SH NAME
8 IP_MTU_DISCOVER
9 \-
10 path maximum transfer unit size discovery
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .BR "#include <netinet/in.h>" " /* Definition of " IP* " constants */"
17 .B #include <sys/socket.h>
18 .P
19 .BI int\~setsockopt(int\~ sockfd ,\~IPPROTO_IP,\~IP_MTU_DISCOVER,
20 .BI " const\~int\~*" val ,\~sizeof(int));
21 .BI int\~getsockopt(int\~ sockfd ,\~IPPROTO_IP,\~IP_MTU_DISCOVER,
22 .BI " int\~*" val ,\~sizeof(int));
23 .fi
24 .SH DESCRIPTION
25 Set or receive the Path MTU Discovery setting for a socket.
26 .P
27 When enabled,
28 Linux will perform Path MTU Discovery
29 as defined in RFC\ 1191 on
30 .B SOCK_STREAM
31 sockets.
32 .P
33 For
34 .RB non- SOCK_STREAM
35 sockets,
36 .B IP_PMTUDISC_DO
37 forces the don't-fragment flag to be set on all outgoing packets.
38 It is the user's responsibility to packetize the data
39 in MTU-sized chunks and to do the retransmits if necessary.
40 The kernel will reject (with
41 .BR EMSGSIZE )
42 datagrams that are bigger than the known path MTU.
43 .B IP_PMTUDISC_WANT
44 will fragment a datagram if needed according to the path MTU,
45 or will set the don't-fragment flag otherwise.
46 .P
47 The system-wide default can be toggled between
48 .B IP_PMTUDISC_WANT
49 and
50 .B IP_PMTUDISC_DONT
51 by writing (respectively, zero and nonzero values) to the
52 .I /proc/sys/net/ipv4/ip_no_pmtu_disc
53 file.
54 .TS
55 tab(:);
56 c l
57 l l.
58 Path MTU discovery value:Meaning
59 IP_PMTUDISC_WANT:Use per-route settings.
60 IP_PMTUDISC_DONT:Never do Path MTU Discovery.
61 IP_PMTUDISC_DO:Always do Path MTU Discovery.
62 IP_PMTUDISC_PROBE:Set DF but ignore Path MTU.
63 .TE
64 .P
65 When PMTU discovery is enabled, the kernel automatically keeps track of
66 the path MTU per destination host.
67 When it is connected to a specific peer with
68 .BR connect (2),
69 the currently known path MTU can be retrieved conveniently using the
70 .BR IP_MTU (2const)
71 socket option (e.g., after an
72 .B EMSGSIZE
73 error occurred).
74 The path MTU may change over time.
75 For connectionless sockets with many destinations,
76 the new MTU for a given destination can also be accessed using the
77 error queue (see
78 .BR IP_RECVERR (2const)).
79 A new error will be queued for every incoming MTU update.
80 .P
81 While MTU discovery is in progress, initial packets from datagram sockets
82 may be dropped.
83 Applications using UDP should be aware of this and not
84 take it into account for their packet retransmit strategy.
85 .P
86 To bootstrap the path MTU discovery process on unconnected sockets, it
87 is possible to start with a big datagram size
88 (headers up to 64 kilobytes long) and let it shrink by updates of the path MTU.
89 .P
90 To get an initial estimate of the
91 path MTU, connect a datagram socket to the destination address using
92 .BR connect (2)
93 and retrieve the MTU by calling
94 .BR getsockopt (2)
95 with the
96 .BR IP_MTU (2const)
97 option.
98 .P
99 It is possible to implement RFC 4821 MTU probing with
100 .B SOCK_DGRAM
101 or
102 .B SOCK_RAW
103 sockets by setting a value of
104 .BR IP_PMTUDISC_PROBE .
105 This is also particularly useful for diagnostic tools such as
106 .BR tracepath (8)
107 that wish to deliberately send probe packets larger than
108 the observed Path MTU.
109 .SH ERRORS
110 See
111 .BR IPPROTO_IP (2const).
112 See
113 .BR setsockopt (2).
114 See
115 .BR ip (7).
116 .SH STANDARDS
117 Linux.
118 .SH HISTORY
119 Linux 2.2.
120 .\" Precisely: since Linux 2.1.124
121 .TP
122 .B IP_PMTUDISC_PROBE
123 Linux 2.6.22.
124 .SH SEE ALSO
125 .BR IPPROTO_IP (2const),
126 .BR setsockopt (2),
127 .BR ip (7)