Skip to contentSkip to conversation

iperf2: Add _GNU_SOURCE in checksums.c

PATCH New Khem Raj 1 participant 1 message Mar 29, 2025

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/1 iperf2: Add _GNU_SOURCE in checksums.c

glibc defines struct udphdr as a union where members have aliased names

uh_sport -> source
uh_dport -> uh_dport
uh_dport -> len
check -> check

But musl only defines the aliases if _GNU_SOURCE is defined, ideally iperf2 should be using uh_* names of the members so it is portable across musl and glibc but thats for upstream to consider.

Fixes

| ../../iperf-2.2.1/src/checksums.c:175:19: error: no member named 'check' in 'struct udphdr'
|   175 |     if (!udp_hdr->check) {
|       |          ~~~~~~~  ^
| 1 error generated.
| make[2]: *** [Makefile:539: checksums.o] Error 1
Cc Randy MacLeod <[email protected]>

---
v2: Use a backport

 ...-buildroot-linux-breakage-ticket-342.patch | 26 +++++++++++++++++++
 .../recipes-benchmark/iperf2/iperf2_2.2.1.bb  |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 meta-oe/recipes-benchmark/iperf2/iperf2/0001-fix-for-buildroot-linux-breakage-ticket-342.patch
meta-oe/recipes-benchmark/iperf2/iperf2/0001-fix-for-buildroot-linux-breakage-ticket-342.patch new file +26 -0
new file mode 100644
index 0000000000..0a6bc7150b
@@ -0,0 +1,26 @@
+From a25566dd66fb0ca951b3b6f6fa5a4bfaac276c71 Mon Sep 17 00:00:00 2001
+From: Robert McMahon <[email protected]>
+Date: Tue, 12 Nov 2024 12:06:54 -0800
+Subject: [PATCH] fix for buildroot linux breakage, ticket 342
+
+Upstream-Status: Backport [https://sourceforge.net/p/iperf2/code/ci/a25566dd66fb0ca951b3b6f6fa5a4bfaac276c71/]
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/checksums.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/checksums.c b/src/checksums.c
+index 852f1952..d7a8109e 100644
+--- a/src/checksums.c
++++ b/src/checksums.c
+@@ -47,6 +47,9 @@
+  * by Robert J. McMahon ([email protected], [email protected])
+  * -------------------------------------------------------------------
+  */
++#ifndef _GNU_SOURCE
++#define _GNU_SOURCE
++#endif
+ #include "headers.h"
+ 
+ /*
meta-oe/recipes-benchmark/iperf2/iperf2_2.2.1.bb +1 -0
index a439616ba4..c353ce02e1 100644
@@ -5,6 +5,7 @@ LICENSE = "BSD-2-Clause"
 LIC_FILES_CHKSUM = "file://COPYING;md5=e136a7b2560d80bcbf0d9b3e1356ecff"
 
 SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/iperf-${PV}.tar.gz \
+           file://0001-fix-for-buildroot-linux-breakage-ticket-342.patch \
 "
 
 SRC_URI[sha256sum] = "754ab0a7e28033dbea81308ef424bc7df4d6e2fe31b60cc536b61b51fefbd8fb"