Rebase to 0.86

This commit is contained in:
Michal Sekletar 2016-05-13 23:35:24 +02:00
parent b4b29cdfb8
commit 5dcbf9f493
11 changed files with 7 additions and 548 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ mtr-0.79.tar.gz
/org.fedoraproject.mtr.policy /org.fedoraproject.mtr.policy
/net-xmtr.desktop /net-xmtr.desktop
/generate-tarball.sh /generate-tarball.sh
/mtr-0.86.tar.gz

View File

@ -1,25 +0,0 @@
From 9b5df3b69d2ded1a81627a1619e4ce03ca906367 Mon Sep 17 00:00:00 2001
From: Jan Gorig <jgorig@redhat.com>
Date: Mon, 25 Oct 2010 12:53:16 +0200
Subject: [PATCH 1/3] Crash in XML mode
---
report.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/report.c b/report.c
index 34ea114..49dfcfb 100644
--- a/report.c
+++ b/report.c
@@ -220,7 +220,7 @@ void xml_close(void)
printf(" <HUB COUNT=%d HOST=%s>\n", at+1, name);
for( i=0; i<MAXFLD; i++ ) {
j = fld_index[fld_active[i]];
- if (j < 0) continue;
+ if (j <= 0) continue;
strcpy(name, " <%s>");
strcat(name, data_fields[j].format);
--
1.7.3.1

View File

@ -1,45 +0,0 @@
From a646775da81a6a80c25b8bc5b26c465786ddfa38 Mon Sep 17 00:00:00 2001
From: Roger Wolff <R.E.Wolff@BitWizard.nl>
Date: Wed, 3 Jul 2013 12:00:28 +0200
Subject: [PATCH 1/4] fixed default hostname
---
mtr.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/mtr.c b/mtr.c
index 75a3b06..fd4705d 100644
--- a/mtr.c
+++ b/mtr.c
@@ -141,7 +141,8 @@ append_to_names(const char* progname, const char* item) {
fprintf(stderr, "%s: memory allocation failure\n", progname);
exit(EXIT_FAILURE);
}
- name->name = strdup(item);
+ // prepared for adding NULL name, but decided against that in the end.
+ name->name = item?strdup(item):item;
name->next = names;
names = name;
}
@@ -581,13 +582,16 @@ int main(int argc, char **argv)
}
time_t now = time(NULL);
+
+ if (!names) append_to_names (argv[0], "localhost"); // default: localhost.
+
names_t* head = names;
while (names != NULL) {
Hostname = names->name;
- if (Hostname == NULL) Hostname = "localhost";
+ // if (Hostname == NULL) Hostname = "localhost"; // no longer necessary.
if (gethostname(LocalHostname, sizeof(LocalHostname))) {
- strcpy(LocalHostname, "UNKNOWNHOST");
+ strcpy(LocalHostname, "UNKNOWNHOST");
}
if (net_preopen_result != 0) {
--
1.8.3.1

View File

@ -1,74 +0,0 @@
From 6ce1601b27fdd95b44ed65d7fd83604860276d63 Mon Sep 17 00:00:00 2001
From: Michal Sekletar <sekletar.m@gmail.com>
Date: Tue, 17 Sep 2013 16:11:20 +0200
Subject: [PATCH] core: introduce grace period
In report mode we break out from select loop immediately after we reach
maximum count of iterations. But we should wait for packets which are still on
the way.
In order to fix the issue we introduce grace period during which we don't send
out more packets but we just wait for responses which might be still on the way.
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1009051
---
select.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/select.c b/select.c
index 29088fd..31bfd5f 100644
--- a/select.c
+++ b/select.c
@@ -45,6 +45,8 @@ static struct timeval intervaltime;
int display_offset = 0;
+#define GRACETIME (5 * 1000*1000)
+
void select_loop(void) {
fd_set readfd;
fd_set writefd;
@@ -57,8 +59,12 @@ void select_loop(void) {
int NumPing = 0;
int paused = 0;
struct timeval lasttime, thistime, selecttime;
+ struct timeval startgrace;
int dt;
int rv;
+ int graceperiod = 0;
+
+ memset(&startgrace, 0, sizeof(startgrace));
gettimeofday(&lasttime, NULL);
@@ -124,10 +130,24 @@ void select_loop(void) {
(thistime.tv_sec == lasttime.tv_sec + intervaltime.tv_sec &&
thistime.tv_usec >= lasttime.tv_usec + intervaltime.tv_usec)) {
lasttime = thistime;
- if(NumPing >= MaxPing && (!Interactive || ForceMaxPing))
+
+ if (!graceperiod) {
+ if (NumPing >= MaxPing && (!Interactive || ForceMaxPing)) {
+ graceperiod = 1;
+ startgrace = thistime;
+ }
+
+ /* do not send out batch when we've already initiated grace period */
+ if (!graceperiod && net_send_batch())
+ NumPing++;
+ }
+ }
+
+ if (graceperiod) {
+ dt = (thistime.tv_usec - startgrace.tv_usec) +
+ 1000000 * (thistime.tv_sec - startgrace.tv_sec);
+ if (dt > GRACETIME)
return;
- if (net_send_batch())
- NumPing++;
}
selecttime.tv_usec = (thistime.tv_usec - lasttime.tv_usec);
--
1.8.3.1

View File

@ -1,118 +0,0 @@
From 12c53f98e44598b87d3f2308e0d892f49d7af8e4 Mon Sep 17 00:00:00 2001
From: Roger Wolff <R.E.Wolff@BitWizard.nl>
Date: Tue, 16 Jul 2013 13:59:52 +0200
Subject: [PATCH] Fix bombout with ipv6 enabled binary on ipv4 only system.
---
dns.c | 33 +++++++++++++++++++++------------
gtk.c | 6 ++++--
select.c | 8 ++++++--
3 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/dns.c b/dns.c
index 371934f..221665d 100644
--- a/dns.c
+++ b/dns.c
@@ -529,10 +529,12 @@ void dns_open(void)
#ifdef ENABLE_IPV6
resfd6 = socket(AF_INET6, SOCK_DGRAM, 0);
if (resfd6 == -1) {
+ // consider making removing this warning. For now leave it in to see
+ // new code activated. -- REW
fprintf(stderr,
"Unable to allocate IPv6 socket for nameserver communication: %s\n",
strerror(errno));
- exit(-1);
+ // exit(-1);
}
#endif
option = 1;
@@ -543,11 +545,13 @@ void dns_open(void)
exit(-1);
}
#ifdef ENABLE_IPV6
- if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) {
- fprintf(stderr,
- "Unable to setsockopt() on IPv6 nameserver communication socket: %s\n",
- strerror(errno));
- exit(-1);
+ if (resfd6 > 0) {
+ if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) {
+ fprintf(stderr,
+ "Unable to setsockopt() on IPv6 nameserver communication socket: %s\n",
+ strerror(errno));
+ exit(-1);
+ }
}
#endif
longipstr( "127.0.0.1", &localhost, AF_INET );
@@ -933,12 +937,14 @@ void dorequest(char *s,int type,word id)
hp = (packetheader *)buf;
hp->id = id; /* htons() deliberately left out (redundant) */
#ifdef ENABLE_IPV6
- for (i = 0;i < NSCOUNT6;i++) {
- if (!NSSOCKADDR6(i))
- continue;
- if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
- (void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i),
- sizeof(struct sockaddr_in6));
+ if (resfd6 > 0) {
+ for (i = 0;i < NSCOUNT6;i++) {
+ if (!NSSOCKADDR6(i))
+ continue;
+ if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
+ (void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i),
+ sizeof(struct sockaddr_in6));
+ }
}
#endif
for (i = 0;i < myres.nscount;i++)
@@ -1327,6 +1333,9 @@ void dns_ack6(void)
int r,i;
static char addrstr[INET6_ADDRSTRLEN];
+ // Probably not necessary. -- REW
+ if (resfd6 < 0) return;
+
r = recvfrom(resfd6,(byte *)resrecvbuf,MaxPacketsize,0,
from, &fromlen);
if (r > 0) {
diff --git a/gtk.c b/gtk.c
index d00f769..38ed507 100644
--- a/gtk.c
+++ b/gtk.c
@@ -615,8 +615,10 @@ void gtk_loop(void)
net_iochannel = g_io_channel_unix_new(net_waitfd());
g_io_add_watch(net_iochannel, G_IO_IN, gtk_net_data, NULL);
#ifdef ENABLE_IPV6
- dns_iochannel = g_io_channel_unix_new(dns_waitfd6());
- g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data6, NULL);
+ if (dns_waitfd6() > 0) {
+ dns_iochannel = g_io_channel_unix_new(dns_waitfd6());
+ g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data6, NULL);
+ }
#endif
dns_iochannel = g_io_channel_unix_new(dns_waitfd());
g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data, NULL);
diff --git a/select.c b/select.c
index 0545d9f..e7c397e 100644
--- a/select.c
+++ b/select.c
@@ -80,8 +80,12 @@ void select_loop(void) {
#ifdef ENABLE_IPV6
if (dns) {
dnsfd6 = dns_waitfd6();
- FD_SET(dnsfd6, &readfd);
- if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;
+ if (dnsfd6 >= 0) {
+ FD_SET(dnsfd6, &readfd);
+ if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;
+ } else {
+ dnsfd6 = 0;
+ }
} else
dnsfd6 = 0;
#endif
--
1.8.3.1

View File

@ -1,141 +0,0 @@
diff -up mtr-0.85/mtr.8.docs mtr-0.85/mtr.8
--- mtr-0.85/mtr.8.docs 2013-04-29 20:22:05.000000000 +0200
+++ mtr-0.85/mtr.8 2013-10-04 15:26:58.852865628 +0200
@@ -8,7 +8,7 @@ mtr \- a network diagnostic tool
.SH SYNOPSIS
.B mtr
[\c
-.B \-hvrctglspeniuTP46\c
+.B \-BfhvrctglxspQemniuTP46\c
]
[\c
.B \-\-help\c
@@ -34,6 +34,9 @@ mtr \- a network diagnostic tool
[\c
.B \-\-raw\c
]
+[
+.B \-\-xml\c
+]
[\c
.B \-\-mpls\c
]
@@ -53,12 +56,27 @@ mtr \- a network diagnostic tool
.B \-\-interval\ SECONDS\c
]
[\c
+.B \-\-max-ttl\ NUM\c
+]
+[\c
+.B \-\-first-ttl\ NUM\c
+]
+[\c
+.B \-\-bitpattern\ NUM\c
+]
+[\c
+.B \-\-tos\ NUM\c
+]
+[\c
.B \-\-psize\ BYTES | -s BYTES\c
]
[\c
.B \-\-tcp\c
]
[\c
+.B \-\-udp\c
+]
+[\c
.B \-\-port\ PORT\c
]
[\c
@@ -270,13 +288,23 @@ to spit out a format that is suitable fo
.TP
.B \-\-raw
.br
-Use this option to tell
-.B mtr
+Use this option to tell
+.B mtr
to use the raw output format. This format is better suited for
archival of the measurement results. It could be parsed to
be presented into any of the other display methods.
.TP
+.B \-x
+.TP
+.B \-\-xml
+.br
+Use this option to tell
+.B mtr
+to use the xml output format. This format is better suited for
+automated processing of the measurement results.
+
+.TP
.B \-a\ IP.ADD.RE.SS
.TP
.B \-\-address\ IP.ADD.RE.SS
@@ -295,7 +323,39 @@ Use this option to specify the positive
ECHO requests. The default value for this parameter is one second.
.TP
+.B \-m\ NUM
+.TP
+.B \-\-max-ttl\ NUM
+.br
+Specifies the maximum number of hops (max time-to-live value) traceroute will
+probe. Default is 30.
+
+.TP
+.B \-f\ NUM
+.TP
+.B \-\-first-ttl\ NUM
+.br
+Specifies with what TTL to start. Defaults to 1.
+
+.TP
+.B \-B\ NUM
+.TP
+.B \-\-bitpattern\ NUM
+.br
+Specifies bit pattern to use in payload. Should be within range 0 - 255.
+
+.TP
+.B \-Q\ NUM
+.TP
+.B \-\-tos\ NUM
+.br
+Specifies value for type of service field in IP header. Should be within range 0
+- 255.
+
+.TP
.B \-u
+.TP
+.B \-\-udp
.br
Use UDP datagrams instead of ICMP ECHO.
diff -up mtr-0.85/mtr.c.docs mtr-0.85/mtr.c
--- mtr-0.85/mtr.c.docs 2013-10-04 15:26:58.852865628 +0200
+++ mtr-0.85/mtr.c 2013-10-04 15:30:42.934859098 +0200
@@ -567,16 +567,17 @@ int main(int argc, char **argv)
}
if (PrintHelp) {
- printf("usage: %s [-hvrwctglspniuT46] [--help] [--version] [--report]\n"
+ printf("usage: %s [-BfhvrwctglxspQomniuT46] [--help] [--version] [--report]\n"
"\t\t[--report-wide] [--report-cycles=COUNT] [--curses] [--gtk]\n"
- "\t\t[--csv|-C] [--raw] [--split] [--mpls] [--no-dns] [--show-ips]\n"
+ "\t\t[--csv|-C] [--raw] [--xml] [--split] [--mpls] [--no-dns] [--show-ips]\n"
"\t\t[--address interface] [--filename=FILE|-F]\n" /* BL */
#ifndef NO_IPINFO
"\t\t[--ipinfo=item_no|-y item_no]\n"
"\t\t[--aslookup|-z]\n"
#endif
- "\t\t[--psize=bytes/-s bytes]\n" /* ok */
- "\t\t[--report-wide|-w] [-u|-T] [--port=PORT] [--timeout=SECONDS]\n" /* rew */
+ "\t\t[--psize=bytes/-s bytes] [--order fields]\n" /* ok */
+ "\t\t[--report-wide|-w] [--inet] [--inet6] [--max-ttl=NUM] [--first-ttl=NUM]\n"
+ "\t\t[--bitpattern=NUM] [--tos=NUM] [--udp] [--tcp] [--port=PORT] [--timeout=SECONDS]\n" /* rew */
"\t\t[--interval=SECONDS] HOSTNAME\n", argv[0]);
exit(0);
}

View File

@ -1,30 +0,0 @@
diff -up mtr-0.84/dns.c.mixed mtr-0.84/dns.c
--- mtr-0.84/dns.c.mixed 2013-06-06 18:56:19.360247890 +0200
+++ mtr-0.84/dns.c 2013-06-06 18:58:09.804233105 +0200
@@ -938,6 +938,8 @@ void dorequest(char *s,int type,word id)
hp->id = id; /* htons() deliberately left out (redundant) */
#ifdef ENABLE_IPV6
for (i = 0;i < NSCOUNT6;i++) {
+ if (!NSSOCKADDR6(i))
+ continue;
if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
(void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i),
sizeof(struct sockaddr_in6));
@@ -1336,6 +1338,8 @@ void dns_ack6(void)
if ( addrcmp( (void *) &(from6->sin6_addr), (void *) &localhost6,
(int) AF_INET6 ) == 0 ) {
for (i = 0;i < NSCOUNT6;i++) {
+ if (!NSSOCKADDR6(i))
+ continue;
if ( addrcmp( (void *) &(NSSOCKADDR6(i)->sin6_addr),
(void *) &(from6->sin6_addr), (int) AF_INET6 ) == 0 ||
addrcmp( (void *) &(NSSOCKADDR6(i)->sin6_addr),
@@ -1344,6 +1348,8 @@ void dns_ack6(void)
}
} else
for (i = 0;i < NSCOUNT6;i++) {
+ if (!NSSOCKADDR6(i))
+ continue;
if ( addrcmp( (void *) &(NSSOCKADDR6(i)->sin6_addr),
(void *) &(from6->sin6_addr), AF_INET6 ) == 0 )
break;

View File

@ -1,57 +0,0 @@
From eae1b58c5a9f074f79a0edfaeb1cf7a4e77a34cb Mon Sep 17 00:00:00 2001
From: Michal Sekletar <sekletar.m@gmail.com>
Date: Tue, 24 Sep 2013 12:56:11 +0200
Subject: [PATCH] dns: iterate over all configured nameservers
Previously if there were three nameservers configured and third one was
reachable via IPv6 we didn't sent query to it, since NSCOUNT6 was equal to
one. Clearly it was the original intention to sent query to all IPv6
nameservers.
Reported-by: Benedikt Gollatz <benedikt@gollatz.net>
---
dns.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dns.c b/dns.c
index 221665d..e89fd4b 100644
--- a/dns.c
+++ b/dns.c
@@ -938,7 +938,7 @@ void dorequest(char *s,int type,word id)
hp->id = id; /* htons() deliberately left out (redundant) */
#ifdef ENABLE_IPV6
if (resfd6 > 0) {
- for (i = 0;i < NSCOUNT6;i++) {
+ for (i = 0;i < myres.nscount;i++) {
if (!NSSOCKADDR6(i))
continue;
if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
@@ -1342,7 +1342,7 @@ void dns_ack6(void)
/* Check to see if this server is actually one we sent to */
if ( addrcmp( (void *) &(from6->sin6_addr), (void *) &localhost6,
(int) AF_INET6 ) == 0 ) {
- for (i = 0;i < NSCOUNT6;i++) {
+ for (i = 0;i < myres.nscount;i++) {
if (!NSSOCKADDR6(i))
continue;
@@ -1353,14 +1353,14 @@ void dns_ack6(void)
break;
}
} else
- for (i = 0;i < NSCOUNT6;i++) {
+ for (i = 0;i < myres.nscount;i++) {
if (!NSSOCKADDR6(i))
continue;
if ( addrcmp( (void *) &(NSSOCKADDR6(i)->sin6_addr),
(void *) &(from6->sin6_addr), AF_INET6 ) == 0 )
break;
}
- if (i == NSCOUNT6) {
+ if (i == myres.nscount) {
snprintf(tempstring, sizeof(tempstring),
"Resolver error: Received reply from unknown source: %s",
inet_ntop( AF_INET6, &(from6->sin6_addr), addrstr,
--
1.8.3.1

View File

@ -1,39 +0,0 @@
diff -up mtr-0.83/report.c.orig mtr-0.83/report.c
--- mtr-0.83/report.c.orig 2013-02-18 15:46:33.000000000 +0100
+++ mtr-0.83/report.c 2013-02-18 15:51:38.263294586 +0100
@@ -212,19 +212,19 @@ void xml_close(void)
ip_t *addr;
char name[81];
- printf("<MTR SRC=%s DST=%s", LocalHostname, Hostname);
- printf(" TOS=0x%X", tos);
+ printf("<MTR SRC=\"%s\" DST=\"%s\"", LocalHostname, Hostname);
+ printf(" TOS=\"0x%X\"", tos);
if(cpacketsize >= 0) {
- printf(" PSIZE=%d", cpacketsize);
+ printf(" PSIZE=\"%d\"", cpacketsize);
} else {
- printf(" PSIZE=rand(%d-%d)",MINPACKET, -cpacketsize);
+ printf(" PSIZE=\"rand(%d-%d)\"",MINPACKET, -cpacketsize);
}
if( bitpattern>=0 ) {
- printf(" BITPATTERN=0x%02X", (unsigned char)(bitpattern));
+ printf(" BITPATTERN=\"0x%02X\"", (unsigned char)(bitpattern));
} else {
- printf(" BITPATTERN=rand(0x00-FF)");
+ printf(" BITPATTERN=\"rand(0x00-FF)\"");
}
- printf(" TESTS=%d>\n", MaxPing);
+ printf(" TESTS=\"%d\">\n", MaxPing);
max = net_max();
at = net_min();
@@ -232,7 +232,7 @@ void xml_close(void)
addr = net_addr(at);
snprint_addr(name, sizeof(name), addr);
- printf(" <HUB COUNT=%d HOST=%s>\n", at+1, name);
+ printf(" <HUB COUNT=\"%d\" HOST=\"%s\">\n", at+1, name);
for( i=0; i<MAXFLD; i++ ) {
j = fld_index[fld_active[i]];
if (j <= 0) continue;

View File

@ -2,8 +2,8 @@
Summary: A network diagnostic tool Summary: A network diagnostic tool
Name: mtr Name: mtr
Version: 0.85 Version: 0.86
Release: 8%{?dist} Release: 1%{?dist}
Epoch: 2 Epoch: 2
Group: Applications/Internet Group: Applications/Internet
License: GPLv2+ License: GPLv2+
@ -13,14 +13,6 @@ Source1: net-x%{name}.desktop
Source2: mtr-gtk-pkexec-wrapper.sh Source2: mtr-gtk-pkexec-wrapper.sh
Source3: org.fedoraproject.mtr.policy Source3: org.fedoraproject.mtr.policy
Patch1: mtr-crash-in-xml-mode.patch
Patch2: mtr-xml-format-fixes.patch
Patch3: mtr-default-hostname.patch
Patch4: mtr-ipv6-on-ipv4-only.patch
Patch5: mtr-introduce-grace-period.patch
Patch6: mtr-query-all-ipv6-nameservers.patch
Patch7: mtr-missing-documentation.patch
BuildRequires: ncurses-devel gtk2-devel desktop-file-utils BuildRequires: ncurses-devel gtk2-devel desktop-file-utils
BuildRequires: autoconf automake libtool BuildRequires: autoconf automake libtool
@ -42,14 +34,6 @@ diagnostic tool.
%prep %prep
%setup -q %setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build %build
export CFLAGS="%{optflags} -fPIE" export CFLAGS="%{optflags} -fPIE"
export LDFLAGS="-z now -pie" export LDFLAGS="-z now -pie"
@ -93,6 +77,9 @@ desktop-file-install \
%endif %endif
%changelog %changelog
* Fri May 13 2016 Michal Sekletar <msekleta@redhat.com> - 2:0.86-1
- rebase to 0.86
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2:0.85-8 * Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2:0.85-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

View File

@ -1,4 +1,4 @@
cf6e427e5ce1d342057aec1a1544e089 net-xmtr.desktop cf6e427e5ce1d342057aec1a1544e089 net-xmtr.desktop
c4fb53f4fdb3bbccdace06d34be87dd0 org.fedoraproject.mtr.policy c4fb53f4fdb3bbccdace06d34be87dd0 org.fedoraproject.mtr.policy
8a65f6aec5e2d5f1a665aa76ae649bc9 mtr-gtk-pkexec-wrapper.sh 8a65f6aec5e2d5f1a665aa76ae649bc9 mtr-gtk-pkexec-wrapper.sh
5e665c617e5659b6ec3e201ee7488eb1 mtr-0.85.tar.gz 8d63592c9d4579ef20cf491b41843eb2 mtr-0.86.tar.gz