From 8341e3a7668235ada012c6448e990399c3090665 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 22 Sep 2011 06:08:30 +0200 Subject: [PATCH] ip.7: Improve description of IP_MTU_DISCOVER I noticed what appears to be a discrepancy between the ip(7) man page and the kernel code with regards to the IP DF flag for UDP sockets. The man page says that "The don't-fragment flag is set on all outgoing datagrams" and that the ip_no_pmtu_disc sysctl affects only SOCK_STREAM sockets. This is quickly disproved by doing: echo 1 > /proc/sys/net/ipv4/ip_no_pmtu_disc firing up netcat and looking at a few outgoing UDP packets in wireshark (they don't have the DF flag set). 1) in the words of `man 7 ip`: IP_MTU_DISCOVER (since Linux 2.2) Set or receive the Path MTU Discovery setting for a socket. When enabled, Linux will perform Path MTU Discovery as defined in RFC 1191 on this socket. The don't-fragment flag is set on all outgoing datagrams. The system-wide default is controlled by the /proc/sys/net/ipv4/ip_no_pmtu_disc file for SOCK_STREAM sockets, and disabled on all others. 2) in net/ipv4/af_inet.c:inet_create(): if (ipv4_config.no_pmtu_disc) inet->pmtudisc = IP_PMTUDISC_DONT; else inet->pmtudisc = IP_PMTUDISC_WANT; and pmtudisc is left alone from there on for UDP sockets. Reviewed-by: Neil Horman Signed-off-by: Michael Kerrisk --- man7/ip.7 | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/man7/ip.7 b/man7/ip.7 index d22ac7081..4e50ac2ca 100644 --- a/man7/ip.7 +++ b/man7/ip.7 @@ -9,7 +9,7 @@ .\" .\" FIXME: Document IP_MINTTL, added in Linux 2.6.34 .\" -.TH IP 7 2010-10-24 "Linux" "Linux Programmer's Manual" +.TH IP 7 2011-09-22 "Linux" "Linux Programmer's Manual" .SH NAME ip \- Linux IPv4 protocol implementation .SH SYNOPSIS @@ -310,22 +310,32 @@ Only valid as a .\" Precisely: 2.1.124 Set or receive the Path MTU Discovery setting for a socket. When enabled, Linux will perform Path MTU Discovery -as defined in RFC\ 1191 -on this socket. -The don't-fragment flag is set on all outgoing datagrams. -The system-wide default is controlled by the -.I /proc/sys/net/ipv4/ip_no_pmtu_disc -file for +as defined in RFC\ 1191 on .B SOCK_STREAM -sockets, and disabled on all others. +sockets. For .RB non- SOCK_STREAM -sockets, it is the user's responsibility to packetize the data -in MTU sized chunks and to do the retransmits if necessary. -The kernel will reject packets that are bigger than the known -path MTU if this flag is set (with -.B EMSGSIZE -). +sockets, +.B IP_PMTUDISC_DO +forces the don't-fragment flag to be set on all outgoing packets. +The don't-fragment flag is set on all outgoing datagrams. +It is the user's responsibility to packetize the data +in MTU-sized chunks and to do the retransmits if necessary. +The kernel will reject (with +.BR EMSGSIZE ) +datagrams that are bigger than the known path MTU. +.B IP_PMTUDISC_WANT +will fragment a datagram if needed according to the path MTU, +or will set the don't-fragment flag otherwise. + +The system-wide default can be toggled between +.B IP_PMTUDISC_WANT +and +.B IP_PMTUDISC_DONT +by writing (respectively, zero and nonzero values) to the +.I /proc/sys/net/ipv4/ip_no_pmtu_disc +file. + .TS tab(:); c l