From 97926373401e4e794fa90f87b42c6cac9c35daf7 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Mon, 22 Oct 2018 21:25:46 +0100 Subject: arping: support -i interval option This option will allow to set time interval to use between packets sent. It may become handy to work around timing issues in the network. For example, Linux kernel as of the time of writing by default ignores all ARP updates that arrive in 1-second interval since previous update for the same table entry *irrespective of whether the previous update was ignored*. It means that calling apring with -c 3 may still not affect Linux network peers because every consequent update is ignored because of the previous ARP update (that was also ignored). In this scenario, we would now be able to call arping -i 2 to work that kernel behaviour around. Linux fix can be found in: https://patchwork.ozlabs.org/patch/760372/ --- arping.c | 9 +++++++-- doc/arping.xml | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/arping.c b/arping.c index 3998d97..80acad0 100644 --- a/arping.c +++ b/arping.c @@ -79,6 +79,7 @@ int dad, unsolicited, advert; int quiet; int count = -1; int timeout; +unsigned int interval = 1; int unicasting; int socketfd; int broadcast_only; @@ -125,6 +126,7 @@ void usage(void) " -V print version and exit\n" " -c how many packets to send\n" " -w how long to wait for a reply\n" + " -i set interval between packets (default: 1 second)\n" " -I which ethernet device to use" #ifdef DEFAULT_DEVICE_STR "(" DEFAULT_DEVICE_STR ")" @@ -382,7 +384,7 @@ void catcher(void) * unsolicited mode */ finish(); } - alarm(1); + alarm(interval); } void print_hex(unsigned char *p, int len) @@ -1004,7 +1006,7 @@ main(int argc, char **argv) disable_capability_raw(); - while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:V")) != EOF) { + while ((ch = getopt(argc, argv, "h?bfDUAqc:w:i:s:I:V")) != EOF) { switch(ch) { case 'b': broadcast_only=1; @@ -1029,6 +1031,9 @@ main(int argc, char **argv) case 'w': timeout = atoi(optarg); break; + case 'i': + interval = (unsigned int)atoi(optarg); + break; case 'I': device.name = optarg; break; diff --git a/doc/arping.xml b/doc/arping.xml index a20e3be..0c7db21 100644 --- a/doc/arping.xml +++ b/doc/arping.xml @@ -23,6 +23,7 @@ -AbDfhqUV -c count -w deadline + -i interval -s source -I interface destination @@ -133,6 +134,11 @@ expire or until probes are answered. + + interval + Specify an interval, in seconds, between packets. + + -- cgit v1.2.1