|
|
15862b |
From 922ef94eefd55ca25df7ce7c98ac7c87134aa982 Mon Sep 17 00:00:00 2001
|
|
|
15862b |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
15862b |
Date: Tue, 4 Apr 2017 12:12:35 +0200
|
|
|
15862b |
Subject: [PATCH] send_arp: update usage info
|
|
|
15862b |
|
|
|
15862b |
---
|
|
|
15862b |
heartbeat/IPaddr2 | 2 +-
|
|
|
15862b |
heartbeat/SendArp | 2 +-
|
|
|
15862b |
tools/send_arp.libnet.c | 70 ++++++++++++++++---------------------------------
|
|
|
15862b |
tools/send_arp.linux.c | 60 ++++++++++++++++--------------------------
|
|
|
15862b |
4 files changed, 48 insertions(+), 86 deletions(-)
|
|
|
15862b |
|
|
|
15862b |
diff --git a/heartbeat/IPaddr2 b/heartbeat/IPaddr2
|
|
|
15862b |
index 27b7208..d07c622 100755
|
|
|
15862b |
--- a/heartbeat/IPaddr2
|
|
|
15862b |
+++ b/heartbeat/IPaddr2
|
|
|
15862b |
@@ -708,7 +708,7 @@ run_send_arp() {
|
|
|
15862b |
LOGLEVEL=info
|
|
|
15862b |
fi
|
|
|
15862b |
if [ $ARP_COUNT -ne 0 ] ; then
|
|
|
15862b |
- ARGS="-i $OCF_RESKEY_arp_interval -r $ARP_COUNT -p $SENDARPPIDFILE $NIC $OCF_RESKEY_ip $MY_MAC not_used not_used"
|
|
|
15862b |
+ ARGS="-i $OCF_RESKEY_arp_interval -c $ARP_COUNT -p $SENDARPPIDFILE -I $NIC -m $MY_MAC $OCF_RESKEY_ip"
|
|
|
15862b |
ocf_log $LOGLEVEL "$SENDARP $ARGS"
|
|
|
15862b |
if ocf_is_true $OCF_RESKEY_arp_bg; then
|
|
|
15862b |
($SENDARP $ARGS || ocf_log err "Could not send gratuitous arps")& >&2
|
|
|
15862b |
diff --git a/heartbeat/SendArp b/heartbeat/SendArp
|
|
|
15862b |
index dbcc7dc..033865f 100755
|
|
|
15862b |
--- a/heartbeat/SendArp
|
|
|
15862b |
+++ b/heartbeat/SendArp
|
|
|
15862b |
@@ -156,7 +156,7 @@ sendarp_start() {
|
|
|
15862b |
fi
|
|
|
15862b |
|
|
|
15862b |
|
|
|
15862b |
- ARGS="-i $ARP_INTERVAL_MS -r $ARP_REPEAT -p $SENDARPPIDFILE $INTERFACE $BASEIP auto $BASEIP $ARP_NETMASK"
|
|
|
15862b |
+ ARGS="-i $ARP_INTERVAL_MS -c $ARP_REPEAT -p $SENDARPPIDFILE -I $INTERFACE -m auto $BASEIP"
|
|
|
15862b |
ocf_log debug "$SENDARP $ARGS"
|
|
|
15862b |
|
|
|
15862b |
rc=$OCF_SUCCESS
|
|
|
15862b |
diff --git a/tools/send_arp.libnet.c b/tools/send_arp.libnet.c
|
|
|
15862b |
index 12fe7f1..bd96a49 100644
|
|
|
15862b |
--- a/tools/send_arp.libnet.c
|
|
|
15862b |
+++ b/tools/send_arp.libnet.c
|
|
|
15862b |
@@ -62,35 +62,14 @@
|
|
|
15862b |
#define PIDFILE_BASE PIDDIR "/send_arp-"
|
|
|
15862b |
|
|
|
15862b |
static char print_usage[]={
|
|
|
15862b |
-"send_arp: sends out custom ARP packet.\n"
|
|
|
15862b |
-" usage: send_arp [-i repeatinterval-ms] [-r repeatcount] [-p pidfile] \\\n"
|
|
|
15862b |
-" device src_ip_addr src_hw_addr broadcast_ip_addr netmask\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" where:\n"
|
|
|
15862b |
-" repeatinterval-ms: timing, in milliseconds of sending arp packets\n"
|
|
|
15862b |
-" For each ARP announcement requested, a pair of ARP packets is sent,\n"
|
|
|
15862b |
-" an ARP request, and an ARP reply. This is becuse some systems\n"
|
|
|
15862b |
-" ignore one or the other, and this combination gives the greatest\n"
|
|
|
15862b |
-" chance of success.\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" Each time an ARP is sent, if another ARP will be sent then\n"
|
|
|
15862b |
-" the code sleeps for half of repeatinterval-ms.\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" repeatcount: how many pairs of ARP packets to send.\n"
|
|
|
15862b |
-" See above for why pairs are sent\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" pidfile: pid file to use\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" device: netowrk interace to use\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" src_ip_addr: source ip address\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" src_hw_addr: source hardware address.\n"
|
|
|
15862b |
-" If \"auto\" then the address of device\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" broadcast_ip_addr: ignored\n"
|
|
|
15862b |
-"\n"
|
|
|
15862b |
-" netmask: ignored\n"
|
|
|
15862b |
+"Usage: send_arp [-i repeatinterval-ms] [-c count] [-p pidfile] [-I device] [-m mac] destination\n"
|
|
|
15862b |
+" -i repeatinterval-ms : repeat interval in milliseconds (ignored in Linux version)\n"
|
|
|
15862b |
+" -c count : how many packets to send\n"
|
|
|
15862b |
+" -p pidfile : pid file (ignored in Linux version)\n"
|
|
|
15862b |
+" -I device : which ethernet device to use\n"
|
|
|
15862b |
+" -m mac : source MAC address (ignored in Linux version).\n"
|
|
|
15862b |
+" If \"auto\" device address is used\n"
|
|
|
15862b |
+" destination : ask for what ip address\n"
|
|
|
15862b |
};
|
|
|
15862b |
|
|
|
15862b |
static const char * SENDARPNAME = "send_arp";
|
|
|
15862b |
@@ -158,41 +137,38 @@ main(int argc, char *argv[])
|
|
|
15862b |
cl_log_set_facility(LOG_USER);
|
|
|
15862b |
cl_inherit_logging_environment(0);
|
|
|
15862b |
|
|
|
15862b |
- while ((flag = getopt(argc, argv, "i:r:p:")) != EOF) {
|
|
|
15862b |
+ while ((flag = getopt(argc, argv, "h?c:I:i:p:m:")) != EOF) {
|
|
|
15862b |
switch(flag) {
|
|
|
15862b |
|
|
|
15862b |
case 'i': msinterval= atol(optarg);
|
|
|
15862b |
break;
|
|
|
15862b |
|
|
|
15862b |
- case 'r': repeatcount= atoi(optarg);
|
|
|
15862b |
+ case 'c': repeatcount= atoi(optarg);
|
|
|
15862b |
break;
|
|
|
15862b |
|
|
|
15862b |
case 'p': pidfilename= optarg;
|
|
|
15862b |
break;
|
|
|
15862b |
|
|
|
15862b |
+ case 'I': device= optarg;
|
|
|
15862b |
+ break;
|
|
|
15862b |
+
|
|
|
15862b |
+ case 'm': macaddr= optarg;
|
|
|
15862b |
+ break;
|
|
|
15862b |
+
|
|
|
15862b |
+ case 'h':
|
|
|
15862b |
+ case '?':
|
|
|
15862b |
default: fprintf(stderr, "%s\n\n", print_usage);
|
|
|
15862b |
return 1;
|
|
|
15862b |
break;
|
|
|
15862b |
}
|
|
|
15862b |
}
|
|
|
15862b |
- if (argc-optind != 5) {
|
|
|
15862b |
- fprintf(stderr, "%s\n\n", print_usage);
|
|
|
15862b |
- return 1;
|
|
|
15862b |
- }
|
|
|
15862b |
|
|
|
15862b |
- /*
|
|
|
15862b |
- * argv[optind+1] DEVICE dc0,eth0:0,hme0:0,
|
|
|
15862b |
- * argv[optind+2] IP 192.168.195.186
|
|
|
15862b |
- * argv[optind+3] MAC ADDR 00a0cc34a878
|
|
|
15862b |
- * argv[optind+4] BROADCAST 192.168.195.186
|
|
|
15862b |
- * argv[optind+5] NETMASK ffffffffffff
|
|
|
15862b |
- */
|
|
|
15862b |
+ argc -= optind;
|
|
|
15862b |
+ argv += optind;
|
|
|
15862b |
+ if (argc != 1)
|
|
|
15862b |
+ usage();
|
|
|
15862b |
|
|
|
15862b |
- device = argv[optind];
|
|
|
15862b |
- ipaddr = argv[optind+1];
|
|
|
15862b |
- macaddr = argv[optind+2];
|
|
|
15862b |
- broadcast = argv[optind+3];
|
|
|
15862b |
- netmask = argv[optind+4];
|
|
|
15862b |
+ ipaddr = *argv;
|
|
|
15862b |
|
|
|
15862b |
if (!pidfilename) {
|
|
|
15862b |
if (snprintf(pidfilenamebuf, sizeof(pidfilenamebuf), "%s%s",
|
|
|
15862b |
diff --git a/tools/send_arp.linux.c b/tools/send_arp.linux.c
|
|
|
15862b |
index 477100a..348794c 100644
|
|
|
15862b |
--- a/tools/send_arp.linux.c
|
|
|
15862b |
+++ b/tools/send_arp.linux.c
|
|
|
15862b |
@@ -137,22 +137,25 @@ static socklen_t sll_len(size_t halen)
|
|
|
15862b |
void usage(void)
|
|
|
15862b |
{
|
|
|
15862b |
fprintf(stderr,
|
|
|
15862b |
- "Usage: arping [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination\n"
|
|
|
15862b |
- " -f : quit on first reply\n"
|
|
|
15862b |
- " -q : be quiet\n"
|
|
|
15862b |
- " -b : keep broadcasting, don't go unicast\n"
|
|
|
15862b |
- " -D : duplicate address detection mode\n"
|
|
|
15862b |
- " -U : Unsolicited ARP mode, update your neighbours\n"
|
|
|
15862b |
- " -A : ARP answer mode, update your neighbours\n"
|
|
|
15862b |
- " -V : print version and exit\n"
|
|
|
15862b |
+ "Usage: send_arp [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination\n"
|
|
|
15862b |
+ " -f : quit on first reply (not available in libnet version)\n"
|
|
|
15862b |
+ " -q : be quiet (not available in libnet version)\n"
|
|
|
15862b |
+ " -b : keep broadcasting, don't go unicast (not available in libnet version)\n"
|
|
|
15862b |
+ " -i : repeat interval in milliseconds (ignored)\n"
|
|
|
15862b |
+ " -p : pid file (ignored)\n"
|
|
|
15862b |
+ " -D : duplicate address detection mode (not available in libnet version)\n"
|
|
|
15862b |
+ " -U : Unsolicited ARP mode, update your neighbours (not available in libnet version)\n"
|
|
|
15862b |
+ " -A : ARP answer mode, update your neighbours (not available in libnet version)\n"
|
|
|
15862b |
+ " -V : print version and exit (not available in libnet version)\n"
|
|
|
15862b |
" -c count : how many packets to send\n"
|
|
|
15862b |
- " -w timeout : how long to wait for a reply\n"
|
|
|
15862b |
+ " -w timeout : how long to wait for a reply (not available in libnet version)\n"
|
|
|
15862b |
" -I device : which ethernet device to use"
|
|
|
15862b |
#ifdef DEFAULT_DEVICE_STR
|
|
|
15862b |
" (" DEFAULT_DEVICE_STR ")"
|
|
|
15862b |
#endif
|
|
|
15862b |
"\n"
|
|
|
15862b |
- " -s source : source ip address\n"
|
|
|
15862b |
+ " -s source : source ip address (not available in libnet version)\n"
|
|
|
15862b |
+ " -m mac : source MAC address (ignored).\n"
|
|
|
15862b |
" destination : ask for what ip address\n"
|
|
|
15862b |
);
|
|
|
15862b |
exit(2);
|
|
|
15862b |
@@ -1044,7 +1047,7 @@ main(int argc, char **argv)
|
|
|
15862b |
|
|
|
15862b |
disable_capability_raw();
|
|
|
15862b |
|
|
|
15862b |
- while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:Vr:i:p:")) != EOF) {
|
|
|
15862b |
+ while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:Vi:m:p:")) != EOF) {
|
|
|
15862b |
switch(ch) {
|
|
|
15862b |
case 'b':
|
|
|
15862b |
broadcast_only=1;
|
|
|
15862b |
@@ -1063,9 +1066,6 @@ main(int argc, char **argv)
|
|
|
15862b |
case 'q':
|
|
|
15862b |
quiet++;
|
|
|
15862b |
break;
|
|
|
15862b |
- case 'r': /* send_arp.libnet compatibility option */
|
|
|
15862b |
- hb_mode = 1;
|
|
|
15862b |
- /* fall-through */
|
|
|
15862b |
case 'c':
|
|
|
15862b |
count = atoi(optarg);
|
|
|
15862b |
break;
|
|
|
15862b |
@@ -1086,9 +1086,10 @@ main(int argc, char **argv)
|
|
|
15862b |
exit(0);
|
|
|
15862b |
case 'p':
|
|
|
15862b |
case 'i':
|
|
|
15862b |
- hb_mode = 1;
|
|
|
15862b |
- /* send_arp.libnet compatibility options, ignore */
|
|
|
15862b |
- break;
|
|
|
15862b |
+ case 'm':
|
|
|
15862b |
+ hb_mode = 1;
|
|
|
15862b |
+ /* send_arp.libnet compatibility options, ignore */
|
|
|
15862b |
+ break;
|
|
|
15862b |
case 'h':
|
|
|
15862b |
case '?':
|
|
|
15862b |
default:
|
|
|
15862b |
@@ -1098,30 +1099,15 @@ main(int argc, char **argv)
|
|
|
15862b |
|
|
|
15862b |
if(hb_mode) {
|
|
|
15862b |
/* send_arp.libnet compatibility mode */
|
|
|
15862b |
- if (argc - optind != 5) {
|
|
|
15862b |
- usage();
|
|
|
15862b |
- return 1;
|
|
|
15862b |
- }
|
|
|
15862b |
- /*
|
|
|
15862b |
- * argv[optind+1] DEVICE dc0,eth0:0,hme0:0,
|
|
|
15862b |
- * argv[optind+2] IP 192.168.195.186
|
|
|
15862b |
- * argv[optind+3] MAC ADDR 00a0cc34a878
|
|
|
15862b |
- * argv[optind+4] BROADCAST 192.168.195.186
|
|
|
15862b |
- * argv[optind+5] NETMASK ffffffffffff
|
|
|
15862b |
- */
|
|
|
15862b |
-
|
|
|
15862b |
unsolicited = 1;
|
|
|
15862b |
- device.name = argv[optind];
|
|
|
15862b |
- target = argv[optind+1];
|
|
|
15862b |
+ }
|
|
|
15862b |
|
|
|
15862b |
- } else {
|
|
|
15862b |
- argc -= optind;
|
|
|
15862b |
- argv += optind;
|
|
|
15862b |
- if (argc != 1)
|
|
|
15862b |
+ argc -= optind;
|
|
|
15862b |
+ argv += optind;
|
|
|
15862b |
+ if (argc != 1)
|
|
|
15862b |
usage();
|
|
|
15862b |
|
|
|
15862b |
- target = *argv;
|
|
|
15862b |
- }
|
|
|
15862b |
+ target = *argv;
|
|
|
15862b |
|
|
|
15862b |
if (device.name && !*device.name)
|
|
|
15862b |
device.name = NULL;
|