Skip to contentSkip to conversation

libnetlink.h: Include <endian.h> explicitly for musl

PATCH Superseded Andreas K. Hüttel 3 participants 6 messages Aug 4, 2024

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

PATCH 1/1 libnetlink.h: Include <endian.h> explicitly for musl

The code added in 976dca372 uses h2be64, defined in endian.h. While this is pulled in around some corners for glibc (see below), that's not the case for musl and an explicit include is required.

. /usr/include/libmnl/libmnl.h
.. /usr/include/sys/socket.h
... /usr/include/bits/socket.h
.... /usr/include/sys/types.h
..... /usr/include/endian.h

---
This time also to the netdev list, sorry...

---
 include/libnetlink.h | 1 +
 1 file changed, 1 insertion(+)
include/libnetlink.h +1 -0
index 30f0c2d2..7074e913 100644
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <endian.h>
 #include <asm/types.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
Signature · 1 line
2.44.2
#1 lore raw
Quoted 11 lines · On Sun, 4 Aug 2024 16:57:46 +0200 Andreas K. Hüttel <[email protected]>…

The code added in 976dca372 uses h2be64, defined in endian.h. While this is pulled in around some corners for glibc (see below), that's not the case for musl and an explicit include is required.

. /usr/include/libmnl/libmnl.h
.. /usr/include/sys/socket.h
... /usr/include/bits/socket.h
.... /usr/include/sys/types.h
..... /usr/include/endian.h

Quoted 3 lines

---

The commit message needs to be reworded. Should use fixes tag than a specific commit hash value.

#2 lore raw

PATCH v2 1/1 libnetlink.h: Include <endian.h> explicitly for musl

The code added in "f_flower: implement pfcp opts" uses h2be64, defined in endian.h. While this is pulled in around some corners for glibc (see below), that's not the case for musl and an explicit include is required there.

. /usr/include/libmnl/libmnl.h
.. /usr/include/sys/socket.h
... /usr/include/bits/socket.h
.... /usr/include/sys/types.h
..... /usr/include/endian.h

Fixes 976dca372 ("f_flower: implement pfcp opts")
---
 include/libnetlink.h | 1 +
 1 file changed, 1 insertion(+)
include/libnetlink.h +1 -0
index 30f0c2d2..7074e913 100644
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <endian.h>
 #include <asm/types.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
Signature · 1 line
2.44.2
#3 lore raw
Quoted 11 lines · On Sun, 4 Aug 2024 18:03:23 +0200 Andreas K. Hüttel <[email protected]>…

The code added in "f_flower: implement pfcp opts" uses h2be64, defined in endian.h. While this is pulled in around some corners for glibc (see below), that's not the case for musl and an explicit include is required there.

. /usr/include/libmnl/libmnl.h
.. /usr/include/sys/socket.h
... /usr/include/bits/socket.h
.... /usr/include/sys/types.h
..... /usr/include/endian.h

Quoted 3 lines
Fixes 976dca372 ("f_flower: implement pfcp opts")

Other parts of flower code use htonll().
It would have been better to be consistent and not use h2be64() at all.

#4 lore raw
Quoted 15 lines · Stephen Hemminger
Quoted 11 lines · On Sun, 4 Aug 2024 18:03:23 +0200 Andreas K. Hüttel <[email protected]>…

The code added in "f_flower: implement pfcp opts" uses h2be64, defined in endian.h. While this is pulled in around some corners for glibc (see below), that's not the case for musl and an explicit include is required there.

. /usr/include/libmnl/libmnl.h
.. /usr/include/sys/socket.h
... /usr/include/bits/socket.h
.... /usr/include/sys/types.h
..... /usr/include/endian.h

Quoted 6 lines
Quoted 3 lines
Fixes 976dca372 ("f_flower: implement pfcp opts")

Other parts of flower code use htonll().
It would have been better to be consistent and not use h2be64() at all.

htonl is used for 32-bit numbers. It won't work properly with 64-bit numbers.

#5 lore raw
Quoted 18 lines · Mike Gilbert
Quoted 15 lines · Stephen Hemminger
Quoted 11 lines · On Sun, 4 Aug 2024 18:03:23 +0200 Andreas K. Hüttel <[email protected]>…

The code added in "f_flower: implement pfcp opts" uses h2be64, defined in endian.h. While this is pulled in around some corners for glibc (see below), that's not the case for musl and an explicit include is required there.

. /usr/include/libmnl/libmnl.h
.. /usr/include/sys/socket.h
... /usr/include/bits/socket.h
.... /usr/include/sys/types.h
..... /usr/include/endian.h

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Fixes 976dca372 ("f_flower: implement pfcp opts")

Other parts of flower code use htonll().
It would have been better to be consistent and not use h2be64() at all.

htonl is used for 32-bit numbers. It won't work properly with 64-bit numbers.

Sorry, I missed the second "l".