summaryrefslogtreecommitdiff
blob: 98e1c6eb960f23cb815ef71edd6cf859ec6b5180 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
iputils has a lot of ugly goto's that break when using 
large gcc inline-limits.

Fixes by Robert Moss and Dave Stahl
http://bugs.gentoo.org/49241
http://bugs.gentoo.org/80969

--- iputils/tracepath.c
+++ iputils/tracepath.c
@@ -76,7 +76,7 @@
 	int progress = -1;
 	int broken_router;
 	
-restart:
+       while (1) {
 	memset(&rcvbuf, -1, sizeof(rcvbuf));
 	iov.iov_base = &rcvbuf;
 	iov.iov_len = sizeof(rcvbuf);
@@ -93,7 +93,7 @@
 	if (res < 0) {
 		if (errno == EAGAIN)
 			return progress;
-		goto restart;
+		continue;
 	}
 
 	progress = mtu;
@@ -216,7 +216,7 @@
 		perror("NET ERROR");
 		return 0;
 	}
-	goto restart;
+       }
 }
 
 int probe_ttl(int fd, int ttl)
@@ -227,7 +227,6 @@
 
 	memset(sndbuf,0,mtu);
 
-restart:
 	for (i=0; i<10; i++) {
 		int res;
 
@@ -243,7 +242,8 @@
 		if (res==0)
 			return 0;
 		if (res > 0)
-			goto restart;
+			i = 0;
+			continue;
 	}
 	hisptr = (hisptr + 1)&63;
 
--- iputils/tracepath6.c
+++ iputils/tracepath6.c
@@ -66,7 +66,7 @@
 	int progress = -1;
 	int broken_router;
 
-restart:
+       while (1) {
 	memset(&rcvbuf, -1, sizeof(rcvbuf));
 	iov.iov_base = &rcvbuf;
 	iov.iov_len = sizeof(rcvbuf);
@@ -83,7 +83,7 @@
 	if (res < 0) {
 		if (errno == EAGAIN)
 			return progress;
-		goto restart;
+		continue;
 	}
 
 	progress = 2;
@@ -222,34 +222,29 @@
 		perror("NET ERROR");
 		return 0;
 	}
-	goto restart;
+       }
 }
 
 int probe_ttl(int fd, int ttl)
 {
-	int i;
+	int i=0, res;
 	char sndbuf[mtu];
 	struct probehdr *hdr = (struct probehdr*)sndbuf;
 
-restart:
-
-	for (i=0; i<10; i++) {
-		int res;
-
-		hdr->ttl = ttl;
-		gettimeofday(&hdr->tv, NULL);
-		if (send(fd, sndbuf, mtu-overhead, 0) > 0)
-			break;
-		res = recverr(fd, ttl);
-		if (res==0)
-			return 0;
-		if (res > 0)
-			goto restart;
-	}
-
-	if (i<10) {
-		int res;
-
+	while (i<10) {
+		for (i=0; i<10; i++) {
+			hdr->ttl = ttl;
+			gettimeofday(&hdr->tv, NULL);
+			if (send(fd, sndbuf, mtu-overhead, 0) > 0)
+				break;
+			res = recverr(fd, ttl);
+			if (res==0)
+				return 0;
+			if (res > 0) {
+				i = 0;
+				continue;
+			}
+		}
 		data_wait(fd);
 		if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) {
 			printf("%2d?: reply received 8)\n", ttl);
@@ -257,7 +252,7 @@
 		}
 		res = recverr(fd, ttl);
 		if (res == 1)
-			goto restart;
+			continue;
 		return res;
 	}