Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ping: Lower max allowed -s value to 65507 (IPv4) or 65527 (IPv6)
Maximum value for ping -s option cannot be higher than maximum IPv4/v6 packet size, which is 65535. More precisely, the value should respect maximum IPv4/v6 ICMP data length. Therefore limit: * ICMP payload: 65507 = 65535 (IPv4 packet size) - 20 (min IPv4 header size) - 8 (ICMP header size) * ICMPv6 payload: 65527 = 65535 (IPv6 packet size) - 8 (ICMPv6 header size) Use the higher value unless user chose the protocol. Linux kernel limits IPv4/6 packet size size exactly to these values: * ICMP datagram socket net/ipv4/ping.c in ping_common_sendmsg() (used in both ping_v4_sendmsg() and ping_v6_sendmsg()): if (len > 0xFFFF) return -EMSGSIZE; * raw socket IPv4 in raw_sendmsg() in net/ipv4/raw.c: err = -EMSGSIZE; if (len > 0xFFFF) goto out; * raw IPv6 socket is limited similarly in __ip6_append_data() in include/net/ip6_route.h: /* We do not (yet ?) support IPv6 jumbograms (RFC 2675) * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header */ #define IP6_MAX_MTU (0xFFFF + sizeof(struct ipv6hdr)) Because Big TCP support for IPv4/IPv6 does does not support raw socket nor ICMP datagram socket, it would have to be sent as multiple packets (IPv4 fragmentation, IPv6 next_header packet chain). Other ping implementations on Linux also limit it to similar values (Busybox: 65535, fping: 65507, inetutils: IPv4: 65399, IPv6: 65527, likely kernel limitation, FreeBSD limits on IPv4: 65507). Closes: iputils#550 Signed-off-by: Petr Vorel <[email protected]>
- Loading branch information