From patchwork Wed Dec 3 02:58:51 2014
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Li Wang
X-Patchwork-Id: 417236
X-Patchwork-Delegate: davem@davemloft.net
Return-Path:
X-Original-To: patchwork-incoming@ozlabs.org
Delivered-To: patchwork-incoming@ozlabs.org
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
by ozlabs.org (Postfix) with ESMTP id 8E09814018C
for ;
Wed, 3 Dec 2014 13:59:13 +1100 (AEDT)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1751464AbaLCC7I (ORCPT );
Tue, 2 Dec 2014 21:59:08 -0500
Received: from mail1.windriver.com ([147.11.146.13]:34804 "EHLO
mail1.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1750927AbaLCC7H (ORCPT
); Tue, 2 Dec 2014 21:59:07 -0500
Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com
[147.11.189.40])
by mail1.windriver.com (8.14.9/8.14.5) with ESMTP id sB32x3Tg001849
(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL);
Tue, 2 Dec 2014 18:59:04 -0800 (PST)
Received: from localhost.localdomain (128.224.162.86) by
ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server id
14.3.174.1; Tue, 2 Dec 2014 18:59:03 -0800
From: Li Wang
To: ,
Subject: [PATCH] iputils: multiply sndbuf size by sending icmp times
Date: Wed, 3 Dec 2014 10:58:51 +0800
Message-ID: <1417575531-12856-1-git-send-email-li.wang@windriver.com>
X-Mailer: git-send-email 1.7.9.5
MIME-Version: 1.0
Sender: netdev-owner@vger.kernel.org
Precedence: bulk
List-ID:
X-Mailing-List: netdev@vger.kernel.org
$ 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
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.
Signed-off-by: Li Wang
---
ping.c | 1 +
ping6.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/ping.c b/ping.c
index c0366cd..46ca6df 100644
--- a/ping.c
+++ b/ping.c
@@ -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) {
diff --git a/ping6.c b/ping6.c
index 6d83462..58843a9 100644
--- a/ping6.c
+++ b/ping6.c
@@ -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__