- update to latest upstream
- enables flowlabel feature (-F option)
This commit is contained in:
parent
f3f6691665
commit
0bbd377017
@ -1,244 +0,0 @@
|
|||||||
diff -up iputils-s20071127/arping.c.infiniband iputils-s20071127/arping.c
|
|
||||||
--- iputils-s20071127/arping.c.infiniband 2007-11-27 01:57:27.000000000 +0100
|
|
||||||
+++ iputils-s20071127/arping.c 2008-08-08 10:05:04.000000000 +0200
|
|
||||||
@@ -50,14 +50,26 @@ int unicasting;
|
|
||||||
int s;
|
|
||||||
int broadcast_only;
|
|
||||||
|
|
||||||
-struct sockaddr_ll me;
|
|
||||||
-struct sockaddr_ll he;
|
|
||||||
+/*
|
|
||||||
+ * Make these two structs have padding at the end so the overly long Infiniband
|
|
||||||
+ * hardware addresses can have the remainder of their address tacked onto
|
|
||||||
+ * the end of the struct without overlapping anything.
|
|
||||||
+ */
|
|
||||||
+struct sockaddr_ll me[2];
|
|
||||||
+struct sockaddr_ll he[2];
|
|
||||||
|
|
||||||
struct timeval start, last;
|
|
||||||
|
|
||||||
int sent, brd_sent;
|
|
||||||
int received, brd_recv, req_recv;
|
|
||||||
|
|
||||||
+#define SYSFS_MNT_PATH "/sys"
|
|
||||||
+#define SYSFS_CLASS "class"
|
|
||||||
+#define SYSFS_NET "net"
|
|
||||||
+#define SYSFS_BROADCAST "broadcast"
|
|
||||||
+#define SYSFS_PATH_ENV "SYSFS_PATH"
|
|
||||||
+#define SYSFS_PATH_LEN 256
|
|
||||||
+
|
|
||||||
#define MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \
|
|
||||||
((tv1).tv_usec-(tv2).tv_usec)/1000 )
|
|
||||||
|
|
||||||
@@ -124,7 +136,8 @@ int send_pack(int s, struct in_addr src,
|
|
||||||
p+=4;
|
|
||||||
|
|
||||||
gettimeofday(&now, NULL);
|
|
||||||
- err = sendto(s, buf, p-buf, 0, (struct sockaddr*)HE, sizeof(*HE));
|
|
||||||
+ err = sendto(s, buf, p-buf, 0, (struct sockaddr*)HE, (ah->ar_hln > 8) ?
|
|
||||||
+ sizeof(*HE) + ah->ar_hln - 8 : sizeof(*HE));
|
|
||||||
if (err == p-buf) {
|
|
||||||
last = now;
|
|
||||||
sent++;
|
|
||||||
@@ -172,7 +185,7 @@ void catcher(void)
|
|
||||||
finish();
|
|
||||||
|
|
||||||
if (last.tv_sec==0 || MS_TDIFF(tv,last) > 500) {
|
|
||||||
- send_pack(s, src, dst, &me, &he);
|
|
||||||
+ send_pack(s, src, dst, &me[0], &he[0]);
|
|
||||||
if (count == 0 && unsolicited)
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
@@ -219,7 +232,7 @@ int recv_pack(unsigned char *buf, int le
|
|
||||||
return 0;
|
|
||||||
if (ah->ar_pln != 4)
|
|
||||||
return 0;
|
|
||||||
- if (ah->ar_hln != me.sll_halen)
|
|
||||||
+ if (ah->ar_hln != me[0].sll_halen)
|
|
||||||
return 0;
|
|
||||||
if (len < sizeof(*ah) + 2*(4 + ah->ar_hln))
|
|
||||||
return 0;
|
|
||||||
@@ -230,7 +243,7 @@ int recv_pack(unsigned char *buf, int le
|
|
||||||
return 0;
|
|
||||||
if (src.s_addr != dst_ip.s_addr)
|
|
||||||
return 0;
|
|
||||||
- if (memcmp(p+ah->ar_hln+4, &me.sll_addr, ah->ar_hln))
|
|
||||||
+ if (memcmp(p+ah->ar_hln+4, &me[0].sll_addr, ah->ar_hln))
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
/* DAD packet was:
|
|
||||||
@@ -248,7 +261,7 @@ int recv_pack(unsigned char *buf, int le
|
|
||||||
*/
|
|
||||||
if (src_ip.s_addr != dst.s_addr)
|
|
||||||
return 0;
|
|
||||||
- if (memcmp(p, &me.sll_addr, me.sll_halen) == 0)
|
|
||||||
+ if (memcmp(p, &me[0].sll_addr, me[0].sll_halen) == 0)
|
|
||||||
return 0;
|
|
||||||
if (src.s_addr && src.s_addr != dst_ip.s_addr)
|
|
||||||
return 0;
|
|
||||||
@@ -264,7 +277,7 @@ int recv_pack(unsigned char *buf, int le
|
|
||||||
printf("for %s ", inet_ntoa(dst_ip));
|
|
||||||
s_printed = 1;
|
|
||||||
}
|
|
||||||
- if (memcmp(p+ah->ar_hln+4, me.sll_addr, ah->ar_hln)) {
|
|
||||||
+ if (memcmp(p+ah->ar_hln+4, me[0].sll_addr, ah->ar_hln)) {
|
|
||||||
if (!s_printed)
|
|
||||||
printf("for ");
|
|
||||||
printf("[");
|
|
||||||
@@ -290,12 +303,69 @@ int recv_pack(unsigned char *buf, int le
|
|
||||||
if (quit_on_reply)
|
|
||||||
finish();
|
|
||||||
if(!broadcast_only) {
|
|
||||||
- memcpy(he.sll_addr, p, me.sll_halen);
|
|
||||||
+ memcpy(he[0].sll_addr, p, me[0].sll_halen);
|
|
||||||
unicasting=1;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
+int get_sysfs_mnt_path(char *mnt_path, size_t len)
|
|
||||||
+{
|
|
||||||
+ const char *sysfs_path_env;
|
|
||||||
+ int pth_len=0;
|
|
||||||
+
|
|
||||||
+ if (len == 0 || mnt_path == NULL)
|
|
||||||
+ return -1;
|
|
||||||
+
|
|
||||||
+ /* possible overrride of real mount path */
|
|
||||||
+ sysfs_path_env = getenv(SYSFS_PATH_ENV);
|
|
||||||
+ memset(mnt_path, 0, len);
|
|
||||||
+ strncpy(mnt_path,
|
|
||||||
+ sysfs_path_env != NULL ? sysfs_path_env : SYSFS_MNT_PATH,
|
|
||||||
+ len-1);
|
|
||||||
+
|
|
||||||
+ if ((pth_len = strlen(mnt_path)) > 0 && mnt_path[pth_len-1] == '/')
|
|
||||||
+ mnt_path[pth_len-1] = '\0';
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int make_sysfs_broadcast_path(char *broadcast_path, size_t len)
|
|
||||||
+{
|
|
||||||
+ char mnt_path[SYSFS_PATH_LEN];
|
|
||||||
+
|
|
||||||
+ if (get_sysfs_mnt_path(mnt_path, len) != 0)
|
|
||||||
+ return -1;
|
|
||||||
+
|
|
||||||
+ snprintf(broadcast_path, len,
|
|
||||||
+ "%s/" SYSFS_CLASS "/" SYSFS_NET "/%s/" SYSFS_BROADCAST,
|
|
||||||
+ mnt_path, device);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+char * read_sysfs_broadcast(char *brdcast_path)
|
|
||||||
+{
|
|
||||||
+ int fd;
|
|
||||||
+ int len_to_read;
|
|
||||||
+ char *brdcast = NULL;
|
|
||||||
+
|
|
||||||
+ if ((fd = open(brdcast_path, O_RDONLY)) > -1) {
|
|
||||||
+ len_to_read = lseek(fd, 0L, SEEK_END);
|
|
||||||
+ if ((brdcast = malloc(len_to_read+1)) != NULL) {
|
|
||||||
+ lseek(fd, 0L, SEEK_SET);
|
|
||||||
+ memset(brdcast, 0, len_to_read+1);
|
|
||||||
+ if (read(fd, brdcast, len_to_read) == -1) {
|
|
||||||
+ free(brdcast);
|
|
||||||
+ brdcast = NULL;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ close(fd);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return brdcast;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
@@ -459,9 +529,9 @@ main(int argc, char **argv)
|
|
||||||
close(probe_fd);
|
|
||||||
};
|
|
||||||
|
|
||||||
- me.sll_family = AF_PACKET;
|
|
||||||
- me.sll_ifindex = ifindex;
|
|
||||||
- me.sll_protocol = htons(ETH_P_ARP);
|
|
||||||
+ me[0].sll_family = AF_PACKET;
|
|
||||||
+ me[0].sll_ifindex = ifindex;
|
|
||||||
+ me[0].sll_protocol = htons(ETH_P_ARP);
|
|
||||||
if (bind(s, (struct sockaddr*)&me, sizeof(me)) == -1) {
|
|
||||||
perror("bind");
|
|
||||||
exit(2);
|
|
||||||
@@ -474,14 +544,33 @@ main(int argc, char **argv)
|
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- if (me.sll_halen == 0) {
|
|
||||||
+ if (me[0].sll_halen == 0) {
|
|
||||||
if (!quiet)
|
|
||||||
printf("Interface \"%s\" is not ARPable (no ll address)\n", device);
|
|
||||||
exit(dad?0:2);
|
|
||||||
}
|
|
||||||
+ he[0] = me[0];
|
|
||||||
+ he[1] = me[1];
|
|
||||||
+ {
|
|
||||||
+ char brdcast_path[SYSFS_PATH_LEN];
|
|
||||||
+ char *brdcast_val;
|
|
||||||
+ char *next_ch;
|
|
||||||
+
|
|
||||||
+ if (make_sysfs_broadcast_path(brdcast_path, sizeof brdcast_path) != 0) {
|
|
||||||
+ perror("sysfs attribute broadcast");
|
|
||||||
+ exit(2);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if ((brdcast_val = read_sysfs_broadcast(brdcast_path)) == NULL) {
|
|
||||||
+ perror("sysfs read broadcast value");
|
|
||||||
+ exit(2);
|
|
||||||
+ }
|
|
||||||
+ for (ch=0; ch<he[0].sll_halen; ch++) {
|
|
||||||
+ he[0].sll_addr[ch] = strtol(brdcast_val + (ch*3), &next_ch, 16);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- he = me;
|
|
||||||
- memset(he.sll_addr, -1, he.sll_halen);
|
|
||||||
+ free(brdcast_val);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
if (!quiet) {
|
|
||||||
printf("ARPING %s ", inet_ntoa(dst));
|
|
||||||
@@ -501,12 +590,12 @@ main(int argc, char **argv)
|
|
||||||
while(1) {
|
|
||||||
sigset_t sset, osset;
|
|
||||||
unsigned char packet[4096];
|
|
||||||
- struct sockaddr_ll from;
|
|
||||||
+ struct sockaddr_ll from[2];
|
|
||||||
socklen_t alen = sizeof(from);
|
|
||||||
int cc;
|
|
||||||
|
|
||||||
if ((cc = recvfrom(s, packet, sizeof(packet), 0,
|
|
||||||
- (struct sockaddr *)&from, &alen)) < 0) {
|
|
||||||
+ (struct sockaddr *)&from[0], &alen)) < 0) {
|
|
||||||
perror("arping: recvfrom");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
@@ -514,7 +603,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]);
|
|
||||||
sigprocmask(SIG_SETMASK, &osset, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff -up iputils-s20071127/Makefile.infiniband iputils-s20071127/Makefile
|
|
||||||
--- iputils-s20071127/Makefile.infiniband 2008-08-08 09:17:35.000000000 +0200
|
|
||||||
+++ iputils-s20071127/Makefile 2008-08-08 10:02:10.000000000 +0200
|
|
||||||
@@ -37,6 +37,8 @@ rdisc_srv: rdisc_srv.o
|
|
||||||
rdisc_srv.o: rdisc.c
|
|
||||||
$(CC) $(CFLAGS) -DRDISC_SERVER -o rdisc_srv.o rdisc.c
|
|
||||||
|
|
||||||
+arping: arping.o
|
|
||||||
+ $(CC) $(LDFLAGS) arping.o $(LOADLIBES) $(LDLIBS) -o arping
|
|
||||||
|
|
||||||
check-kernel:
|
|
||||||
ifeq ($(KERNEL_INCLUDE),)
|
|
@ -1,65 +0,0 @@
|
|||||||
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;
|
|
||||||
-int count=-1;
|
|
||||||
+int count;
|
|
||||||
+int forever = 1;
|
|
||||||
int timeout;
|
|
||||||
int unicasting;
|
|
||||||
int s;
|
|
||||||
@@ -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;
|
|
||||||
@@ -172,13 +173,15 @@ void catcher(void)
|
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
|
|
||||||
- if (start.tv_sec==0)
|
|
||||||
- start = tv;
|
|
||||||
-
|
|
||||||
- if (count-- == 0 || (timeout && MS_TDIFF(tv,start) > timeout*1000 + 500))
|
|
||||||
- finish();
|
|
||||||
+ if (!forever && count == 0) {
|
|
||||||
+ if (timeout && MS_TDIFF(tv, last) > timeout * 1000 + 500)
|
|
||||||
+ finish();
|
|
||||||
+ else if (!timeout)
|
|
||||||
+ finish();
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- 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[0], &he[0]);
|
|
||||||
if (count == 0 && unsolicited)
|
|
||||||
finish();
|
|
||||||
@@ -339,6 +342,10 @@ main(int argc, char **argv)
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
count = atoi(optarg);
|
|
||||||
+ if (count > 0)
|
|
||||||
+ forever = 0;
|
|
||||||
+ else
|
|
||||||
+ forever = 1;
|
|
||||||
break;
|
|
||||||
case 'w':
|
|
||||||
timeout = atoi(optarg);
|
|
||||||
@@ -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[0]);
|
|
||||||
+ if (recv_pack(packet, cc, from) && count == 0 && !forever)
|
|
||||||
+ finish();
|
|
||||||
sigprocmask(SIG_SETMASK, &osset, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
266
iputils-20071127-infiniband.patch
Normal file
266
iputils-20071127-infiniband.patch
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
diff -up iputils-s20100418/arping.c.infiniband iputils-s20100418/arping.c
|
||||||
|
--- iputils-s20100418/arping.c.infiniband 2010-04-23 11:29:24.982567625 +0200
|
||||||
|
+++ iputils-s20100418/arping.c 2010-04-23 14:28:28.328587690 +0200
|
||||||
|
@@ -32,8 +32,6 @@
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
-#include <sysfs/libsysfs.h>
|
||||||
|
-
|
||||||
|
#include "SNAPSHOT.h"
|
||||||
|
|
||||||
|
static void usage(void) __attribute__((noreturn));
|
||||||
|
@@ -52,14 +50,22 @@ int unicasting;
|
||||||
|
int s;
|
||||||
|
int broadcast_only;
|
||||||
|
|
||||||
|
-struct sockaddr_storage me;
|
||||||
|
-struct sockaddr_storage he;
|
||||||
|
+struct sockaddr_ll *me=NULL;
|
||||||
|
+struct sockaddr_ll *he=NULL;
|
||||||
|
|
||||||
|
struct timeval start, last;
|
||||||
|
|
||||||
|
int sent, brd_sent;
|
||||||
|
int received, brd_recv, req_recv;
|
||||||
|
|
||||||
|
+#define SYSFS_MNT_PATH "/sys"
|
||||||
|
+#define SYSFS_CLASS "class"
|
||||||
|
+#define SYSFS_NET "net"
|
||||||
|
+#define SYSFS_BROADCAST "broadcast"
|
||||||
|
+#define SYSFS_PATH_ENV "SYSFS_PATH"
|
||||||
|
+#define SYSFS_PATH_LEN 256
|
||||||
|
+#define SOCKADDR_LEN (2 * sizeof(struct sockaddr_ll))
|
||||||
|
+
|
||||||
|
#define MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \
|
||||||
|
((tv1).tv_usec-(tv2).tv_usec)/1000 )
|
||||||
|
|
||||||
|
@@ -166,6 +172,10 @@ void finish(void)
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ free(me);
|
||||||
|
+ free(he);
|
||||||
|
+
|
||||||
|
if (dad)
|
||||||
|
exit(!!received);
|
||||||
|
if (unsolicited)
|
||||||
|
@@ -186,8 +196,7 @@ void catcher(void)
|
||||||
|
finish();
|
||||||
|
|
||||||
|
if (last.tv_sec==0 || MS_TDIFF(tv,last) > 500) {
|
||||||
|
- send_pack(s, src, dst,
|
||||||
|
- (struct sockaddr_ll *)&me, (struct sockaddr_ll *)&he);
|
||||||
|
+ send_pack(s, src, dst, me, he);
|
||||||
|
if (count == 0 && unsolicited)
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
@@ -234,7 +243,7 @@ int recv_pack(unsigned char *buf, int le
|
||||||
|
return 0;
|
||||||
|
if (ah->ar_pln != 4)
|
||||||
|
return 0;
|
||||||
|
- if (ah->ar_hln != ((struct sockaddr_ll *)&me)->sll_halen)
|
||||||
|
+ if (ah->ar_hln != me->sll_halen)
|
||||||
|
return 0;
|
||||||
|
if (len < sizeof(*ah) + 2*(4 + ah->ar_hln))
|
||||||
|
return 0;
|
||||||
|
@@ -245,7 +254,7 @@ int recv_pack(unsigned char *buf, int le
|
||||||
|
return 0;
|
||||||
|
if (src.s_addr != dst_ip.s_addr)
|
||||||
|
return 0;
|
||||||
|
- if (memcmp(p+ah->ar_hln+4, ((struct sockaddr_ll *)&me)->sll_addr, ah->ar_hln))
|
||||||
|
+ if (memcmp(p+ah->ar_hln+4, me->sll_addr, ah->ar_hln))
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
/* DAD packet was:
|
||||||
|
@@ -263,7 +272,7 @@ int recv_pack(unsigned char *buf, int le
|
||||||
|
*/
|
||||||
|
if (src_ip.s_addr != dst.s_addr)
|
||||||
|
return 0;
|
||||||
|
- if (memcmp(p, ((struct sockaddr_ll *)&me)->sll_addr, ((struct sockaddr_ll *)&me)->sll_halen) == 0)
|
||||||
|
+ if (memcmp(p, me->sll_addr, me->sll_halen) == 0)
|
||||||
|
return 0;
|
||||||
|
if (src.s_addr && src.s_addr != dst_ip.s_addr)
|
||||||
|
return 0;
|
||||||
|
@@ -279,7 +288,7 @@ int recv_pack(unsigned char *buf, int le
|
||||||
|
printf("for %s ", inet_ntoa(dst_ip));
|
||||||
|
s_printed = 1;
|
||||||
|
}
|
||||||
|
- if (memcmp(p+ah->ar_hln+4, ((struct sockaddr_ll *)&me)->sll_addr, ah->ar_hln)) {
|
||||||
|
+ if (memcmp(p+ah->ar_hln+4, me->sll_addr, ah->ar_hln)) {
|
||||||
|
if (!s_printed)
|
||||||
|
printf("for ");
|
||||||
|
printf("[");
|
||||||
|
@@ -305,40 +314,67 @@ int recv_pack(unsigned char *buf, int le
|
||||||
|
if (quit_on_reply)
|
||||||
|
finish();
|
||||||
|
if(!broadcast_only) {
|
||||||
|
- memcpy(((struct sockaddr_ll *)&he)->sll_addr, p, ((struct sockaddr_ll *)&me)->sll_halen);
|
||||||
|
+ memcpy(he->sll_addr, p, me->sll_halen);
|
||||||
|
unicasting=1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-void set_device_broadcast(char *device, unsigned char *ba, size_t balen)
|
||||||
|
+int get_sysfs_mnt_path(char *mnt_path, size_t len)
|
||||||
|
{
|
||||||
|
- struct sysfs_class_device *dev;
|
||||||
|
- struct sysfs_attribute *brdcast;
|
||||||
|
- unsigned char *p;
|
||||||
|
- int ch;
|
||||||
|
+ const char *sysfs_path_env;
|
||||||
|
+ int pth_len=0;
|
||||||
|
|
||||||
|
- dev = sysfs_open_class_device("net", device);
|
||||||
|
- if (!dev) {
|
||||||
|
- perror("sysfs_open_class_device(net)");
|
||||||
|
- exit(2);
|
||||||
|
- }
|
||||||
|
+ if (len == 0 || mnt_path == NULL)
|
||||||
|
+ return -1;
|
||||||
|
|
||||||
|
- brdcast = sysfs_get_classdev_attr(dev, "broadcast");
|
||||||
|
- if (!brdcast) {
|
||||||
|
- perror("sysfs_get_classdev_attr(broadcast)");
|
||||||
|
- exit(2);
|
||||||
|
- }
|
||||||
|
+ /* possible overrride of real mount path */
|
||||||
|
+ sysfs_path_env = getenv(SYSFS_PATH_ENV);
|
||||||
|
+ memset(mnt_path, 0, len);
|
||||||
|
+ strncpy(mnt_path,
|
||||||
|
+ sysfs_path_env != NULL ? sysfs_path_env : SYSFS_MNT_PATH,
|
||||||
|
+ len-1);
|
||||||
|
|
||||||
|
- if (sysfs_read_attribute(brdcast)) {
|
||||||
|
- perror("sysfs_read_attribute");
|
||||||
|
- exit(2);
|
||||||
|
- }
|
||||||
|
+ if ((pth_len = strlen(mnt_path)) > 0 && mnt_path[pth_len-1] == '/')
|
||||||
|
+ mnt_path[pth_len-1] = '\0';
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int make_sysfs_broadcast_path(char *broadcast_path, size_t len)
|
||||||
|
+{
|
||||||
|
+ char mnt_path[SYSFS_PATH_LEN];
|
||||||
|
+
|
||||||
|
+ if (get_sysfs_mnt_path(mnt_path, len) != 0)
|
||||||
|
+ return -1;
|
||||||
|
|
||||||
|
- for (p = ba, ch = 0; p < ba + balen; p++, ch += 3)
|
||||||
|
- *p++ = strtoul(brdcast->value + ch * 3, NULL, 16);
|
||||||
|
+ snprintf(broadcast_path, len,
|
||||||
|
+ "%s/" SYSFS_CLASS "/" SYSFS_NET "/%s/" SYSFS_BROADCAST,
|
||||||
|
+ mnt_path, device);
|
||||||
|
|
||||||
|
- return;
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+char * read_sysfs_broadcast(char *brdcast_path)
|
||||||
|
+{
|
||||||
|
+ int fd;
|
||||||
|
+ int len_to_read;
|
||||||
|
+ char *brdcast = NULL;
|
||||||
|
+
|
||||||
|
+ if ((fd = open(brdcast_path, O_RDONLY)) > -1) {
|
||||||
|
+ len_to_read = lseek(fd, 0L, SEEK_END);
|
||||||
|
+ if ((brdcast = malloc(len_to_read+1)) != NULL) {
|
||||||
|
+ lseek(fd, 0L, SEEK_SET);
|
||||||
|
+ memset(brdcast, 0, len_to_read+1);
|
||||||
|
+ if (read(fd, brdcast, len_to_read) == -1) {
|
||||||
|
+ free(brdcast);
|
||||||
|
+ brdcast = NULL;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ close(fd);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return brdcast;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
@@ -356,6 +392,17 @@ main(int argc, char **argv)
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ me = malloc(SOCKADDR_LEN);
|
||||||
|
+ if (!me) {
|
||||||
|
+ fprintf(stderr, "arping: could not allocate memory\n");
|
||||||
|
+ exit(1);
|
||||||
|
+ }
|
||||||
|
+ he = malloc(SOCKADDR_LEN);
|
||||||
|
+ if (!he) {
|
||||||
|
+ fprintf(stderr, "arping: could not allocate memory\n");
|
||||||
|
+ exit(1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:V")) != EOF) {
|
||||||
|
switch(ch) {
|
||||||
|
case 'b':
|
||||||
|
@@ -504,34 +551,51 @@ main(int argc, char **argv)
|
||||||
|
close(probe_fd);
|
||||||
|
};
|
||||||
|
|
||||||
|
- ((struct sockaddr_ll *)&me)->sll_family = AF_PACKET;
|
||||||
|
- ((struct sockaddr_ll *)&me)->sll_ifindex = ifindex;
|
||||||
|
- ((struct sockaddr_ll *)&me)->sll_protocol = htons(ETH_P_ARP);
|
||||||
|
- if (bind(s, (struct sockaddr*)&me, sizeof(me)) == -1) {
|
||||||
|
+ me->sll_family = AF_PACKET;
|
||||||
|
+ me->sll_ifindex = ifindex;
|
||||||
|
+ me->sll_protocol = htons(ETH_P_ARP);
|
||||||
|
+ if (bind(s, (struct sockaddr*)me, SOCKADDR_LEN) == -1) {
|
||||||
|
perror("bind");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1) {
|
||||||
|
- socklen_t alen = sizeof(me);
|
||||||
|
- if (getsockname(s, (struct sockaddr*)&me, &alen) == -1) {
|
||||||
|
+ socklen_t alen = SOCKADDR_LEN;
|
||||||
|
+ if (getsockname(s, (struct sockaddr*)me, &alen) == -1) {
|
||||||
|
perror("getsockname");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- if (((struct sockaddr_ll *)&me)->sll_halen == 0) {
|
||||||
|
+ if (me->sll_halen == 0) {
|
||||||
|
if (!quiet)
|
||||||
|
printf("Interface \"%s\" is not ARPable (no ll address)\n", device);
|
||||||
|
exit(dad?0:2);
|
||||||
|
}
|
||||||
|
|
||||||
|
- he = me;
|
||||||
|
+ memcpy(he, me, SOCKADDR_LEN);
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
- set_device_broadcast(device, ((struct sockaddr_ll *)&he)->sll_addr,
|
||||||
|
- ((struct sockaddr_ll *)&he)->sll_halen);
|
||||||
|
+ char brdcast_path[SYSFS_PATH_LEN];
|
||||||
|
+ char *brdcast_val=NULL;
|
||||||
|
+ char *next_ch;
|
||||||
|
+
|
||||||
|
+ if (make_sysfs_broadcast_path(brdcast_path, sizeof brdcast_path) != 0) {
|
||||||
|
+ perror("sysfs attribute broadcast");
|
||||||
|
+ exit(2);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if ((brdcast_val = read_sysfs_broadcast(brdcast_path)) == NULL) {
|
||||||
|
+ perror("sysfs read broadcast value");
|
||||||
|
+ exit(2);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (ch=0; ch<he->sll_halen; ch++) {
|
||||||
|
+ he->sll_addr[ch] = strtol(brdcast_val + (ch*3), &next_ch, 16);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ free(brdcast_val);
|
||||||
|
#else
|
||||||
|
- memset(((struct sockaddr_ll *)&he)->sll_addr, -1, ((struct sockaddr_ll *)&he)->sll_halen);
|
||||||
|
+ memset(he->sll_addr, -1, he->sll_halen);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!quiet) {
|
24
iputils-20100418-convtoint.patch
Normal file
24
iputils-20100418-convtoint.patch
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
diff -up iputils-s20100418/tracepath6.c.convtoint iputils-s20100418/tracepath6.c
|
||||||
|
--- iputils-s20100418/tracepath6.c.convtoint 2010-04-23 11:28:15.294593391 +0200
|
||||||
|
+++ iputils-s20100418/tracepath6.c 2010-04-23 11:28:23.544605551 +0200
|
||||||
|
@@ -89,7 +89,7 @@ void print_host(const char *a, const cha
|
||||||
|
}
|
||||||
|
if (plen >= HOST_COLUMN_SIZE)
|
||||||
|
plen = HOST_COLUMN_SIZE - 1;
|
||||||
|
- printf("%*s", HOST_COLUMN_SIZE - plen, "");
|
||||||
|
+ printf("%*s", HOST_COLUMN_SIZE - (int)plen, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
int recverr(int fd, int ttl)
|
||||||
|
diff -up iputils-s20100418/tracepath.c.convtoint iputils-s20100418/tracepath.c
|
||||||
|
--- iputils-s20100418/tracepath.c.convtoint 2010-04-23 11:26:20.273555629 +0200
|
||||||
|
+++ iputils-s20100418/tracepath.c 2010-04-23 11:26:20.281562493 +0200
|
||||||
|
@@ -77,7 +77,7 @@ void print_host(const char *a, const cha
|
||||||
|
}
|
||||||
|
if (plen >= HOST_COLUMN_SIZE)
|
||||||
|
plen = HOST_COLUMN_SIZE - 1;
|
||||||
|
- printf("%*s", HOST_COLUMN_SIZE - plen, "");
|
||||||
|
+ printf("%*s", HOST_COLUMN_SIZE - (int)plen, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
int recverr(int fd, int ttl)
|
67
iputils-20100418-flowlabel.patch
Normal file
67
iputils-20100418-flowlabel.patch
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
diff -up iputils-s20100418/in6_flowlabel.h.flowlabel iputils-s20100418/in6_flowlabel.h
|
||||||
|
--- iputils-s20100418/in6_flowlabel.h.flowlabel 2010-05-17 13:54:03.422586206 +0200
|
||||||
|
+++ iputils-s20100418/in6_flowlabel.h 2010-05-17 13:54:03.422586206 +0200
|
||||||
|
@@ -0,0 +1,40 @@
|
||||||
|
+/*
|
||||||
|
+ It is just a stripped copy of the kernel header "linux/in6.h"
|
||||||
|
+
|
||||||
|
+ "Flow label" things are still not defined in "netinet/in*.h" headers,
|
||||||
|
+ but we cannot use "linux/in6.h" immediately because it currently
|
||||||
|
+ conflicts with "netinet/in.h" .
|
||||||
|
+*/
|
||||||
|
+
|
||||||
|
+struct in6_flowlabel_req
|
||||||
|
+{
|
||||||
|
+ struct in6_addr flr_dst;
|
||||||
|
+ __u32 flr_label;
|
||||||
|
+ __u8 flr_action;
|
||||||
|
+ __u8 flr_share;
|
||||||
|
+ __u16 flr_flags;
|
||||||
|
+ __u16 flr_expires;
|
||||||
|
+ __u16 flr_linger;
|
||||||
|
+ __u32 __flr_pad;
|
||||||
|
+ /* Options in format of IPV6_PKTOPTIONS */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+#define IPV6_FL_A_GET 0
|
||||||
|
+#define IPV6_FL_A_PUT 1
|
||||||
|
+#define IPV6_FL_A_RENEW 2
|
||||||
|
+
|
||||||
|
+#define IPV6_FL_F_CREATE 1
|
||||||
|
+#define IPV6_FL_F_EXCL 2
|
||||||
|
+
|
||||||
|
+#define IPV6_FL_S_NONE 0
|
||||||
|
+#define IPV6_FL_S_EXCL 1
|
||||||
|
+#define IPV6_FL_S_PROCESS 2
|
||||||
|
+#define IPV6_FL_S_USER 3
|
||||||
|
+#define IPV6_FL_S_ANY 255
|
||||||
|
+
|
||||||
|
+#define IPV6_FLOWINFO_FLOWLABEL 0x000fffff
|
||||||
|
+#define IPV6_FLOWINFO_PRIORITY 0x0ff00000
|
||||||
|
+
|
||||||
|
+#define IPV6_FLOWLABEL_MGR 32
|
||||||
|
+#define IPV6_FLOWINFO_SEND 33
|
||||||
|
+
|
||||||
|
diff -up iputils-s20100418/Makefile.flowlabel iputils-s20100418/Makefile
|
||||||
|
--- iputils-s20100418/Makefile.flowlabel 2010-05-17 13:54:03.339556213 +0200
|
||||||
|
+++ iputils-s20100418/Makefile 2010-05-17 13:54:03.423585869 +0200
|
||||||
|
@@ -35,7 +35,7 @@ ping: ping.o ping_common.o
|
||||||
|
ping6: ping6.o ping_common.o
|
||||||
|
$(CC) $(CFLAGS) ping6.o ping_common.o -lresolv -lcrypto -o ping6
|
||||||
|
|
||||||
|
-ping.o ping6.o ping_common.o: ping_common.h
|
||||||
|
+ping.o ping6.o ping_common.o: ping_common.h in6_flowlabel.h
|
||||||
|
tftpd.o tftpsubs.o: tftp.h
|
||||||
|
|
||||||
|
rdisc_srv: rdisc_srv.o
|
||||||
|
diff -up iputils-s20100418/ping6.c.flowlabel iputils-s20100418/ping6.c
|
||||||
|
--- iputils-s20100418/ping6.c.flowlabel 2010-05-17 13:55:34.012839691 +0200
|
||||||
|
+++ iputils-s20100418/ping6.c 2010-05-17 13:55:36.411557280 +0200
|
||||||
|
@@ -74,6 +74,7 @@ char copyright[] =
|
||||||
|
#include <resolv.h>
|
||||||
|
|
||||||
|
#include "ping6_niquery.h"
|
||||||
|
+#include "in6_flowlabel.h"
|
||||||
|
|
||||||
|
#ifndef SOL_IPV6
|
||||||
|
#define SOL_IPV6 IPPROTO_IPV6
|
@ -29,6 +29,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
|||||||
BuildRequires: docbook-utils perl-SGMLSpm
|
BuildRequires: docbook-utils perl-SGMLSpm
|
||||||
BuildRequires: glibc-kernheaders >= 2.4-8.19
|
BuildRequires: glibc-kernheaders >= 2.4-8.19
|
||||||
BuildRequires: libidn-devel
|
BuildRequires: libidn-devel
|
||||||
|
BuildRequires: openssl-devel
|
||||||
Requires(post): /sbin/chkconfig
|
Requires(post): /sbin/chkconfig
|
||||||
Requires(preun): /sbin/chkconfig
|
Requires(preun): /sbin/chkconfig
|
||||||
Requires(preun): /sbin/service
|
Requires(preun): /sbin/service
|
||||||
|
Loading…
Reference in New Issue
Block a user