iputils: multiply sndbuf size by sending icmp times
Subsystems (2)
PATCH 1/1 iputils: multiply sndbuf size by sending icmp times
$ ping -i 0.1 198.168.5.200 -W 1 PING 128.224.124.76 (128.224.124.76) 56(84) bytes of data. ping: sendmsg: No buffer space available
Quoted 1 line
From 128.224.124.205 icmp_seq=1 Destination Host Unreachable
when ping a non-exist IP with same subnet, ping will send arp packet, at first.
there is a limitation for arp packet of same ping.
for linux-2.6, the arp packet of number is 3. so, the size of limitation is (3*sizeof(arp packet)).
for linux-3.x, the arp packet of size is 64k.
so, it maybe exceed the sock of sndbuf.
the linux kernel impoves the limitation.
when customer use "-i 0.1 -W 1" option, it will send 20 icmp packets. at the same time, it send 20 arp packets.
it does not exceed the limitation of linux-3.x,
but, it exceeds the sock sndbuf of ping(324):setsockopt(3, SOL_SOCKET, SO_SNDBUF, [324], 4) = 0
so, auto-resize sndbuf according to the arp packet number.
--- ping.c | 1 + ping6.c | 1 + 2 files changed, 2 insertions(+)
ping.c +1 -0
@@ -531,6 +531,7 @@ main(int argc, char **argv)* Actually, for small datalen's it depends on kernel side a lot. */ hold = datalen +8 ; hold += ((hold+511 )/512 )*(optlen +20 +16 +64 +160 ); + hold *= lingertime/SCHINT (interval/2 );sock_setbufs (icmp_sock, hold);if (broadcast_pings) {
ping6.c +1 -0
@@ -1086,6 +1086,7 @@ int main(int argc, char *argv[])* Actually, for small datalen's it depends on kernel side a lot. */ hold = datalen+8 ; hold += ((hold+511 )/512 )*(40 +16 +64 +160 ); + hold *= lingertime/SCHINT (interval/2 );sock_setbufs (icmp_sock, hold);#ifdef __linux__
Signature · 1 line
1.7.9.5