Skip to contentSkip to conversation

Build fixes for older kernel headers and musl

PATCH In review Florian Fainelli 2 participants 6 messages Jan 14, 2023 – Jan 24, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Build fixes for older kernel headers and musl

Hi Michal,

These 3 patches fix build issues encountered in the 6.1 release with either older kernel headers (pre v4.11) or with musl-libc.

In case you want to add a prebuilt toolchain with your release procedure you can use those binaries:

https://github.com/Broadcom/stbgcc-8.3/releases/tag/stbgcc-8.3-0.4

Changes in v2:

- reworked the first commit to bring in if.h, this is a more invasive change but it allows us to drop the ALTIFNAMSIZ override and it might be easier to maintain moving forward

- reworked the third commit to avoid using non standard integer types

Florian Fainelli (3):
uapi: Bring in if.h
netlink: Fix maybe uninitialized 'meters' variable marvell.c: Fix build with musl-libc

 Makefile.am             |   6 +-
 internal.h              |   7 +-
 marvell.c               |  34 ++---
 netlink/parser.c        |   2 +-
 uapi/linux/hdlc/ioctl.h |  94 +++++++++++++
 uapi/linux/if.h         | 296 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 415 insertions(+), 24 deletions(-)
 create mode 100644 uapi/linux/hdlc/ioctl.h
 create mode 100644 uapi/linux/if.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/3 uapi: Bring in if.h

Bring in if.h from commit eec517cdb481 ("net: Add IF_OPER_TESTING") as well as uapi/linux/hdlc/ioctl.h. Ensure that we define all of the necessary guards to provide updated definitions of ifmap, ifreq and IFNAMSIZ. This resolves build issues with kernel headers < 4.11 which lacked 2618be7dccf8739b89e1906b64bd8d551af351e6 ("uapi: fix linux/if.h userspace compilation errors").

Fixes 1fa60003a8b8 ("misc: header includes cleanup")
---
 Makefile.am             |   6 +-
 internal.h              |   7 +-
 uapi/linux/hdlc/ioctl.h |  94 +++++++++++++
 uapi/linux/if.h         | 296 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 397 insertions(+), 6 deletions(-)
 create mode 100644 uapi/linux/hdlc/ioctl.h
 create mode 100644 uapi/linux/if.h
Makefile.am +4 -2
index 663f40a07b7d..691a20ed49c6 100644
@@ -7,7 +7,8 @@ EXTRA_DIST = LICENSE ethtool.8 ethtool.spec.in aclocal.m4 ChangeLog autogen.sh
 
 sbin_PROGRAMS = ethtool
 ethtool_SOURCES = ethtool.c uapi/linux/ethtool.h internal.h \
-		  uapi/linux/net_tstamp.h rxclass.c common.c common.h \
+		  uapi/linux/net_tstamp.h uapi/linux/if.h uapi/linux/hdlc/ioctl.h \
+		  rxclass.c common.c common.h \
 		  json_writer.c json_writer.h json_print.c json_print.h \
 		  list.h
 if ETHTOOL_ENABLE_PRETTY_DUMP
@@ -43,7 +44,8 @@ ethtool_SOURCES += \
 		  netlink/desc-rtnl.c netlink/cable_test.c netlink/tunnels.c \
 		  uapi/linux/ethtool_netlink.h \
 		  uapi/linux/netlink.h uapi/linux/genetlink.h \
-		  uapi/linux/rtnetlink.h uapi/linux/if_link.h
+		  uapi/linux/rtnetlink.h uapi/linux/if_link.h \
+		  uapi/linux/if.h uapi/linux/hdlc/ioctl.h
 AM_CPPFLAGS += @MNL_CFLAGS@
 LDADD += @MNL_LIBS@
 endif
internal.h +3 -4
index b80f77afa4c0..3923719c39d5 100644
@@ -21,6 +21,9 @@
 #include <unistd.h>
 #include <endian.h>
 #include <sys/ioctl.h>
+#define __UAPI_DEF_IF_IFNAMSIZ	1
+#define __UAPI_DEF_IF_IFMAP	1
+#define __UAPI_DEF_IF_IFREQ	1
 #include <linux/if.h>
 
 #include "json_writer.h"
@@ -52,10 +55,6 @@ typedef int32_t s32;
 #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
 #endif
 
-#ifndef ALTIFNAMSIZ
-#define ALTIFNAMSIZ 128
-#endif
-
 #include <linux/ethtool.h>
 #include <linux/net_tstamp.h>
 
uapi/linux/hdlc/ioctl.h new file +94 -0

94 lines not on this page · raw message

uapi/linux/if.h new file +296 -0

296 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/3 netlink: Fix maybe uninitialized 'meters' variable

In reply to Florian Fainelli

GCC12 warns that 'meters' may be uninitialized, initialize it accordingly.

Fixes 9561db9b76f4 ("Add cable test TDR support")
---
 netlink/parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
netlink/parser.c +1 -1
index f982f229a040..6f863610a490 100644
@@ -237,7 +237,7 @@ int nl_parse_direct_m2cm(struct nl_context *nlctx, uint16_t type,
 			 struct nl_msg_buff *msgbuff, void *dest)
 {
 	const char *arg = *nlctx->argp;
-	float meters;
+	float meters = 0.0;
 	uint32_t cm;
 	int ret;
 
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/3 marvell.c: Fix build with musl-libc

In reply to Florian Fainelli

After commit 1fa60003a8b8 ("misc: header includes cleanup") we stopped including net/if.h which resolved the proper defines to pull in sys/types.h and provide a definition for u_int32_t. With musl-libc we would need to define _GNU_SOURCE to ensure that sys/types.h does provide a definition for u_int32_t.

Rather, just replace u_uint{16,32}_t with the more standard uint{16,32}_t types from stdint.h

Fixes 1fa60003a8b8 ("misc: header includes cleanup")
---
 marvell.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
marvell.c +17 -17
index d3d570e4d4ad..3f3aed80e404 100644
@@ -31,23 +31,23 @@ static void dump_timer(const char *name, const void *p)
 static void dump_queue(const char *name, const void *a, int rx)
 {
 	struct desc {
-		u_int32_t		ctl;
-		u_int32_t		next;
-		u_int32_t		data_lo;
-		u_int32_t		data_hi;
-		u_int32_t		status;
-		u_int32_t		timestamp;
-		u_int16_t		csum2;
-		u_int16_t		csum1;
-		u_int16_t		csum2_start;
-		u_int16_t		csum1_start;
-		u_int32_t		addr_lo;
-		u_int32_t		addr_hi;
-		u_int32_t		count_lo;
-		u_int32_t		count_hi;
-		u_int32_t               byte_count;
-		u_int32_t               csr;
-		u_int32_t               flag;
+		uint32_t		ctl;
+		uint32_t		next;
+		uint32_t		data_lo;
+		uint32_t		data_hi;
+		uint32_t		status;
+		uint32_t		timestamp;
+		uint16_t		csum2;
+		uint16_t		csum1;
+		uint16_t		csum2_start;
+		uint16_t		csum1_start;
+		uint32_t		addr_lo;
+		uint32_t		addr_hi;
+		uint32_t		count_lo;
+		uint32_t		count_hi;
+		uint32_t		byte_count;
+		uint32_t		csr;
+		uint32_t		flag;
 	};
 	const struct desc *d = a;
 
Signature · 1 line
2.25.1
#4 lore raw
In reply to Florian Fainelli

Hi Michal,

Quoted 10 lines · Florian Fainelli

Hi Michal,

These 3 patches fix build issues encountered in the 6.1 release with either older kernel headers (pre v4.11) or with musl-libc.

In case you want to add a prebuilt toolchain with your release procedure you can use those binaries:

https://github.com/Broadcom/stbgcc-8.3/releases/tag/stbgcc-8.3-0.4

Quoted 7 lines

Changes in v2:

- reworked the first commit to bring in if.h, this is a more invasive change but it allows us to drop the ALTIFNAMSIZ override and it might be easier to maintain moving forward

- reworked the third commit to avoid using non standard integer types

Any feedback on whether you prefer this version versus the v1?

Signature · 1 line
Florian
#5 lore raw
Quoted 15 lines · Florian Fainelli

Hi Michal,

Quoted 12 lines · Florian Fainelli

Hi Michal,

These 3 patches fix build issues encountered in the 6.1 release with either older kernel headers (pre v4.11) or with musl-libc.

In case you want to add a prebuilt toolchain with your release procedure you can use those binaries:

https://github.com/Broadcom/stbgcc-8.3/releases/tag/stbgcc-8.3-0.4

Changes in v2:

Quoted 7 lines
Quoted 5 lines

- reworked the first commit to bring in if.h, this is a more invasive change but it allows us to drop the ALTIFNAMSIZ override and it might be easier to maintain moving forward

- reworked the third commit to avoid using non standard integer types

Any feedback on whether you prefer this version versus the v1?

I like v2 more and unless I run into some trouble with it, I'm going to merge it this week with the rest of the backlog.

Michal