diff mbox series

[v2,iproute2] libnetlink.h: Include <endian.h> explicitly for musl

Message ID 20240804160355.940167-1-dilfridge@gentoo.org (mailing list archive)
State New, archived
Delegated to: Stephen Hemminger
Headers show
Series [v2,iproute2] libnetlink.h: Include <endian.h> explicitly for musl | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Andreas K. Hüttel Aug. 4, 2024, 4:03 p.m. UTC
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")
Bug: https://bugs.gentoo.org/936234
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
---
 include/libnetlink.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Stephen Hemminger Aug. 4, 2024, 4:58 p.m. UTC | #1
On Sun,  4 Aug 2024 18:03:23 +0200
Andreas K. Hüttel <dilfridge@gentoo.org> wrote:

> 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")
> Bug: https://bugs.gentoo.org/936234
> Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>

Other parts of flower code use htonll().
It would have been better to be consistent and not use h2be64() at all.
Mike Gilbert Aug. 4, 2024, 5:07 p.m. UTC | #2
On Sun, Aug 4, 2024 at 12:58 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Sun,  4 Aug 2024 18:03:23 +0200
> Andreas K. Hüttel <dilfridge@gentoo.org> wrote:
>
> > 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")
> > Bug: https://bugs.gentoo.org/936234
> > Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
>
> 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.
Mike Gilbert Aug. 4, 2024, 5:09 p.m. UTC | #3
On Sun, Aug 4, 2024 at 1:07 PM Mike Gilbert <floppym@gentoo.org> wrote:
>
> On Sun, Aug 4, 2024 at 12:58 PM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> >
> > On Sun,  4 Aug 2024 18:03:23 +0200
> > Andreas K. Hüttel <dilfridge@gentoo.org> wrote:
> >
> > > 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")
> > > Bug: https://bugs.gentoo.org/936234
> > > Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
> >
> > 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".
diff mbox series

Patch

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 30f0c2d2..7074e913 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -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>