iperf3: update to 3.3 and refresh patches
[openwrt/openwrt.git] / package / network / utils / iperf3 / patches / 010-iperf-3.3-fix-build-warnings.patch
1 The following patches are taken directly from:
2
3 https://github.com/esnet/iperf/pull/664
4
5 as an upstream submission.
6
7 commit b63d41b25f49a76d0be66edfb61bd4cb68921d55
8 Author: Philip Prindeville <philipp@redfish-solutions.com>
9 Date: Tue Oct 31 13:41:08 2017 -0600
10
11 Fix warnings about _GNU_SOURCE being redefined.
12
13 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
14
15 diff --git a/src/iperf.h b/src/iperf.h
16 index bb951dc..b656784 100755
17 --- a/src/iperf.h
18 +++ b/src/iperf.h
19 @@ -36,7 +36,9 @@
20 #endif
21 #include <sys/select.h>
22 #include <sys/socket.h>
23 -#define _GNU_SOURCE
24 +#ifndef _GNU_SOURCE
25 +# define _GNU_SOURCE
26 +#endif
27 #include <netinet/tcp.h>
28
29 #if defined(HAVE_CPUSET_SETAFFINITY)
30 diff --git a/src/iperf_api.c b/src/iperf_api.c
31 index ab30b93..9e41238 100755
32 --- a/src/iperf_api.c
33 +++ b/src/iperf_api.c
34 @@ -24,7 +24,9 @@
35 * This code is distributed under a BSD style license, see the LICENSE file
36 * for complete information.
37 */
38 -#define _GNU_SOURCE
39 +#ifndef _GNU_SOURCE
40 +# define _GNU_SOURCE
41 +#endif
42 #define __USE_GNU
43
44 #include "iperf_config.h"
45
46 commit 315254cfc5f5682627f4a46ade3100bc3c64cfcc
47 Author: Philip Prindeville <philipp@redfish-solutions.com>
48 Date: Tue Oct 31 13:42:58 2017 -0600
49
50 Fix warnings of format-specified mismatching type
51
52 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
53
54 diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c
55 index 91cf032..6f86d5d 100644
56 --- a/src/iperf_tcp.c
57 +++ b/src/iperf_tcp.c
58 @@ -24,8 +24,6 @@
59 * This code is distributed under a BSD style license, see the LICENSE
60 * file for complete information.
61 */
62 -#include "iperf_config.h"
63 -
64 #include <stdio.h>
65 #include <stdlib.h>
66 #include <string.h>
67 @@ -44,6 +42,12 @@
68 #include "net.h"
69 #include "cjson.h"
70
71 +#if defined(HAVE_INTTYPES_H)
72 +# include <inttypes.h>
73 +#else
74 +# define PRIu64 "llu"
75 +#endif
76 +
77 #if defined(HAVE_FLOWLABEL)
78 #include "flowlabel.h"
79 #endif /* HAVE_FLOWLABEL */
80 @@ -90,7 +94,7 @@ iperf_tcp_send(struct iperf_stream *sp)
81 sp->result->bytes_sent_this_interval += r;
82
83 if (sp->test->debug)
84 - printf("sent %d bytes of %d, total %llu\n", r, sp->settings->blksize, sp->result->bytes_sent);
85 + printf("sent %d bytes of %d, total %" PRIu64 "\n", r, sp->settings->blksize, sp->result->bytes_sent);
86
87 return r;
88 }
89 diff --git a/src/iperf_udp.c b/src/iperf_udp.c
90 index a2ea6d0..d04ae44 100644
91 --- a/src/iperf_udp.c
92 +++ b/src/iperf_udp.c
93 @@ -48,6 +48,12 @@
94 #include "cjson.h"
95 #include "portable_endian.h"
96
97 +#if defined(HAVE_INTTYPES_H)
98 +# include <inttypes.h>
99 +#else
100 +# define PRIu64 "llu"
101 +#endif
102 +
103 /* iperf_udp_recv
104 *
105 * receives the data for UDP
106 @@ -98,7 +104,7 @@ iperf_udp_recv(struct iperf_stream *sp)
107 }
108
109 if (sp->test->debug)
110 - fprintf(stderr, "pcount %llu packet_count %d\n", pcount, sp->packet_count);
111 + fprintf(stderr, "pcount %" PRIu64 " packet_count %d\n", pcount, sp->packet_count);
112
113 /*
114 * Try to handle out of order packets. The way we do this
115 @@ -141,7 +147,7 @@ iperf_udp_recv(struct iperf_stream *sp)
116
117 /* Log the out-of-order packet */
118 if (sp->test->debug)
119 - fprintf(stderr, "OUT OF ORDER - incoming packet sequence %llu but expected sequence %d on stream %d", pcount, sp->packet_count, sp->socket);
120 + fprintf(stderr, "OUT OF ORDER - incoming packet sequence %" PRIu64 " but expected sequence %d on stream %d", pcount, sp->packet_count, sp->socket);
121 }
122
123 /*
124 @@ -220,7 +226,7 @@ iperf_udp_send(struct iperf_stream *sp)
125 sp->result->bytes_sent_this_interval += r;
126
127 if (sp->test->debug)
128 - printf("sent %d bytes of %d, total %llu\n", r, sp->settings->blksize, sp->result->bytes_sent);
129 + printf("sent %d bytes of %d, total %" PRIu64 "\n", r, sp->settings->blksize, sp->result->bytes_sent);
130
131 return r;
132 }
133
134 commit 9a66b3b0349e0a158bb4940b668a5cbc7c245762
135 Author: Philip Prindeville <philipp@redfish-solutions.com>
136 Date: Tue Oct 31 13:44:34 2017 -0600
137
138 Simplify endianness checks
139
140 Linux can be built with too many types of C run-time library and it's
141 not reasonable to have to enumerate all of them, especially since at
142 least one of them (MUSL) goes out of its way to not be easily
143 detectable.
144
145 Instead, leverage autoconf better for Linux/BSD to detect either
146 <endian.h> or <sys/endian.h> directly.
147
148 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
149
150 diff --git a/configure.ac b/configure.ac
151 index f57e83f..cfb42ac 100644
152 --- a/configure.ac
153 +++ b/configure.ac
154 @@ -101,6 +101,14 @@ AC_CHECK_HEADERS([netinet/sctp.h],
155 #endif
156 ])
157
158 +AC_CHECK_HEADER([endian.h],
159 + AC_DEFINE([HAVE_ENDIAN_H], [1], [Define to 1 if you have the <endian.h> header file.]),
160 + AC_CHECK_HEADER([sys/endian.h],
161 + AC_DEFINE([HAVE_SYS_ENDIAN_H], [1], [Define to 1 if you have the <sys/endian.h> header file.]),
162 + AC_MSG_WARN([Couldn't find endian.h or sys/endian.h files: doing compile-time tests.])
163 + )
164 + )
165 +
166 if test "x$with_openssl" = "xno"; then
167 AC_MSG_WARN( [Building without OpenSSL; disabling iperf_auth functionality.] )
168 else
169 diff --git a/src/iperf_config.h.in b/src/iperf_config.h.in
170 index bd03935..a9e51ec 100644
171 --- a/src/iperf_config.h.in
172 +++ b/src/iperf_config.h.in
173 @@ -9,6 +9,9 @@
174 /* Define to 1 if you have the <dlfcn.h> header file. */
175 #undef HAVE_DLFCN_H
176
177 +/* Define to 1 if you have the <endian.h> header file. */
178 +#undef HAVE_ENDIAN_H
179 +
180 /* Have IPv6 flowlabel support. */
181 #undef HAVE_FLOWLABEL
182
183 @@ -54,6 +57,9 @@
184 /* Define to 1 if the system has the type `struct sctp_assoc_value'. */
185 #undef HAVE_STRUCT_SCTP_ASSOC_VALUE
186
187 +/* Define to 1 if you have the <sys/endian.h> header file. */
188 +#undef HAVE_SYS_ENDIAN_H
189 +
190 /* Define to 1 if you have the <sys/socket.h> header file. */
191 #undef HAVE_SYS_SOCKET_H
192
193 diff --git a/src/portable_endian.h b/src/portable_endian.h
194 index b86d37a..5dbc6e5 100644
195 --- a/src/portable_endian.h
196 +++ b/src/portable_endian.h
197 @@ -10,14 +10,33 @@
198
199 #endif
200
201 -// GLIBC / Linux with endian(3) support, which was added in glibc 2.9.
202 -// Intended to support CentOS 6 and newer.
203 -#if defined(__linux__) && \
204 - ((__GLIBC__ > 3) || \
205 - (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9))
206 -
207 +#if defined(HAVE_ENDIAN_H)
208 # include <endian.h>
209
210 +#elif defined(HAVE_SYS_ENDIAN_H)
211 +# include <sys/endian.h>
212 +
213 +# if defined(__OpenBSD__)
214 +
215 +# define be16toh(x) betoh16(x)
216 +# define le16toh(x) letoh16(x)
217 +
218 +# define be32toh(x) betoh32(x)
219 +# define le32toh(x) letoh32(x)
220 +
221 +# define be64toh(x) betoh64(x)
222 +# define le64toh(x) letoh64(x)
223 +
224 +# elif defined(__sgi)
225 +
226 +# include <netinet/in.h>
227 +# include <inttypes.h>
228 +
229 +# define be64toh(x) (x)
230 +# define htobe64(x) (x)
231 +
232 +# endif
233 +
234 #elif defined(__CYGWIN__)
235
236 # include <endian.h>
237 @@ -46,32 +65,6 @@
238 # define __LITTLE_ENDIAN LITTLE_ENDIAN
239 # define __PDP_ENDIAN PDP_ENDIAN
240
241 -#elif defined(__OpenBSD__)
242 -
243 -# include <sys/endian.h>
244 -
245 -# define be16toh(x) betoh16(x)
246 -# define le16toh(x) letoh16(x)
247 -
248 -# define be32toh(x) betoh32(x)
249 -# define le32toh(x) letoh32(x)
250 -
251 -# define be64toh(x) betoh64(x)
252 -# define le64toh(x) letoh64(x)
253 -
254 -#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
255 -
256 -# include <sys/endian.h>
257 -
258 -#elif defined(__sgi)
259 -
260 -# include <sys/endian.h>
261 -# include <netinet/in.h>
262 -# include <inttypes.h>
263 -
264 -# define be64toh(x) (x)
265 -# define htobe64(x) (x)
266 -
267 #elif defined(__sun) && defined(__SVR4)
268
269 # include <sys/types.h>
270
271 commit 7e7285d0daf92ef7beda8f78a6f63cc647a77f38
272 Author: Philip Prindeville <philipp@redfish-solutions.com>
273 Date: Tue Oct 31 13:48:06 2017 -0600
274
275 Sys headers should not be included directly
276
277 There's usually a top-level header which then includes the sys/
278 descendent.
279
280 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
281
282 diff --git a/src/net.c b/src/net.c
283 index af456cb..afd0022 100644
284 --- a/src/net.c
285 +++ b/src/net.c
286 @@ -31,13 +31,12 @@
287 #include <errno.h>
288 #include <sys/socket.h>
289 #include <sys/types.h>
290 -#include <sys/errno.h>
291 #include <netinet/in.h>
292 #include <netinet/tcp.h>
293 #include <assert.h>
294 #include <netdb.h>
295 #include <string.h>
296 -#include <sys/fcntl.h>
297 +#include <fcntl.h>
298
299 #ifdef HAVE_SENDFILE
300 #ifdef linux