- correctly fix the -w option and return code of arping (#387881)

This commit is contained in:
Martin Nagy 2008-02-18 16:10:01 +00:00
parent fe66682113
commit 30468abf14
2 changed files with 35 additions and 33 deletions

View File

@ -1,6 +1,7 @@
--- iputils/Makefile.infiniband 2007-02-22 15:53:04.000000000 +0100
+++ iputils/Makefile 2007-02-22 15:55:05.000000000 +0100
@@ -45,6 +45,8 @@
diff -up iputils-s20070202/Makefile.infiniband iputils-s20070202/Makefile
--- iputils-s20070202/Makefile.infiniband 2008-02-18 16:47:39.000000000 +0100
+++ iputils-s20070202/Makefile 2008-02-18 16:47:39.000000000 +0100
@@ -37,6 +37,8 @@ rdisc_srv: rdisc_srv.o
rdisc_srv.o: rdisc.c
$(CC) $(CFLAGS) -DRDISC_SERVER -o rdisc_srv.o rdisc.c
@ -9,9 +10,10 @@
check-kernel:
ifeq ($(KERNEL_INCLUDE),)
--- iputils/arping.c.infiniband 2007-02-22 15:53:04.000000000 +0100
+++ iputils/arping.c 2007-02-22 15:53:05.000000000 +0100
@@ -29,6 +29,7 @@
diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
--- iputils-s20070202/arping.c.infiniband 2008-02-18 16:47:39.000000000 +0100
+++ iputils-s20070202/arping.c 2008-02-18 16:50:44.000000000 +0100
@@ -31,6 +31,7 @@
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ -19,7 +21,7 @@
#include "SNAPSHOT.h"
@@ -48,8 +49,13 @@
@@ -50,8 +51,13 @@ int unicasting;
int s;
int broadcast_only;
@ -35,7 +37,7 @@
struct timeval start, last;
@@ -124,7 +130,8 @@
@@ -124,7 +130,8 @@ int send_pack(int s, struct in_addr src,
p+=4;
gettimeofday(&now, NULL);
@ -45,16 +47,16 @@
if (err == p-buf) {
last = now;
sent++;
@@ -174,7 +181,7 @@
@@ -172,7 +179,7 @@ void catcher(void)
finish();
if (last.tv_sec==0 || MS_TDIFF(tv,last) > 500) {
count--;
- send_pack(s, src, dst, &me, &he);
+ send_pack(s, src, dst, &me[0], &he[0]);
if (count == 0 && unsolicited)
finish();
}
@@ -221,7 +228,7 @@
@@ -219,7 +226,7 @@ int recv_pack(unsigned char *buf, int le
return 0;
if (ah->ar_pln != 4)
return 0;
@ -63,7 +65,7 @@
return 0;
if (len < sizeof(*ah) + 2*(4 + ah->ar_hln))
return 0;
@@ -232,7 +239,7 @@
@@ -230,7 +237,7 @@ int recv_pack(unsigned char *buf, int le
return 0;
if (src.s_addr != dst_ip.s_addr)
return 0;
@ -72,7 +74,7 @@
return 0;
} else {
/* DAD packet was:
@@ -250,7 +257,7 @@
@@ -248,7 +255,7 @@ int recv_pack(unsigned char *buf, int le
*/
if (src_ip.s_addr != dst.s_addr)
return 0;
@ -81,7 +83,7 @@
return 0;
if (src.s_addr && src.s_addr != dst_ip.s_addr)
return 0;
@@ -266,7 +273,7 @@
@@ -264,7 +271,7 @@ int recv_pack(unsigned char *buf, int le
printf("for %s ", inet_ntoa(dst_ip));
s_printed = 1;
}
@ -90,7 +92,7 @@
if (!s_printed)
printf("for ");
printf("[");
@@ -292,7 +299,7 @@
@@ -290,7 +297,7 @@ int recv_pack(unsigned char *buf, int le
if (quit_on_reply)
finish();
if(!broadcast_only) {
@ -99,7 +101,7 @@
unicasting=1;
}
return 1;
@@ -458,9 +465,9 @@
@@ -459,9 +466,9 @@ main(int argc, char **argv)
close(probe_fd);
};
@ -112,7 +114,7 @@
if (bind(s, (struct sockaddr*)&me, sizeof(me)) == -1) {
perror("bind");
exit(2);
@@ -473,14 +480,37 @@
@@ -474,14 +481,37 @@ main(int argc, char **argv)
exit(2);
}
}
@ -154,7 +156,7 @@
if (!quiet) {
printf("ARPING %s ", inet_ntoa(dst));
@@ -500,7 +530,7 @@
@@ -501,7 +531,7 @@ main(int argc, char **argv)
while(1) {
sigset_t sset, osset;
unsigned char packet[4096];
@ -163,12 +165,12 @@
socklen_t alen = sizeof(from);
int cc;
@@ -513,7 +543,7 @@
@@ -514,7 +544,7 @@ main(int argc, char **argv)
sigaddset(&sset, SIGALRM);
sigaddset(&sset, SIGINT);
sigprocmask(SIG_BLOCK, &sset, &osset);
- recv_pack(packet, cc, &from);
+ recv_pack(packet, cc, &from[0]);
if(received == count)
exit(0);
sigprocmask(SIG_SETMASK, &osset, NULL);
}
}

View File

@ -1,7 +1,7 @@
diff -up iputils-s20070202/arping.c.test_patch iputils-s20070202/arping.c
--- iputils-s20070202/arping.c.test_patch 2007-02-02 13:55:46.000000000 +0100
+++ iputils-s20070202/arping.c 2008-02-14 14:57:19.000000000 +0100
@@ -44,7 +44,8 @@ struct in_addr src, dst;
diff -up iputils-s20070202/arping.c.arping_timeout iputils-s20070202/arping.c
--- iputils-s20070202/arping.c.arping_timeout 2008-02-18 16:51:36.000000000 +0100
+++ iputils-s20070202/arping.c 2008-02-18 16:54:03.000000000 +0100
@@ -45,7 +45,8 @@ struct in_addr src, dst;
char *target;
int dad, unsolicited, advert;
int quiet;
@ -11,16 +11,16 @@ diff -up iputils-s20070202/arping.c.test_patch iputils-s20070202/arping.c
int timeout;
int unicasting;
int s;
@@ -53,7 +54,7 @@ int broadcast_only;
struct sockaddr_ll me;
struct sockaddr_ll he;
@@ -59,7 +60,7 @@ int broadcast_only;
struct sockaddr_ll me[2];
struct sockaddr_ll he[2];
-struct timeval start, last;
+struct timeval last;
int sent, brd_sent;
int received, brd_recv, req_recv;
@@ -165,13 +166,15 @@ void catcher(void)
@@ -172,13 +173,15 @@ void catcher(void)
gettimeofday(&tv, NULL);
@ -39,10 +39,10 @@ diff -up iputils-s20070202/arping.c.test_patch iputils-s20070202/arping.c
- if (last.tv_sec==0 || MS_TDIFF(tv,last) > 500) {
+ if ((count > 0 || forever) && (last.tv_sec == 0 || MS_TDIFF(tv, last) > 500)) {
+ count--;
send_pack(s, src, dst, &me, &he);
send_pack(s, src, dst, &me[0], &he[0]);
if (count == 0 && unsolicited)
finish();
@@ -332,6 +335,10 @@ main(int argc, char **argv)
@@ -339,6 +342,10 @@ main(int argc, char **argv)
break;
case 'c':
count = atoi(optarg);
@ -53,11 +53,11 @@ diff -up iputils-s20070202/arping.c.test_patch iputils-s20070202/arping.c
break;
case 'w':
timeout = atoi(optarg);
@@ -514,7 +521,8 @@ main(int argc, char **argv)
@@ -544,7 +551,8 @@ main(int argc, char **argv)
sigaddset(&sset, SIGALRM);
sigaddset(&sset, SIGINT);
sigprocmask(SIG_BLOCK, &sset, &osset);
- recv_pack(packet, cc, &from);
- recv_pack(packet, cc, &from[0]);
+ if (recv_pack(packet, cc, &from) && count == 0 && !forever)
+ finish();
sigprocmask(SIG_SETMASK, &osset, NULL);