rtnl: Fixup rtnetlink includes
PATCH 1/4 rtnl: Fixup rtnetlink includes
man 7 rtnetlink suggests the 4 includes listed should be used. Also, remove rtnetlink.h inclusion from rtnl.h and move it into the individual code files.
--- ell/netconfig.c | 4 ++++ ell/rtnl.c | 5 ++++- ell/rtnl.h | 3 ++- unit/test-rtnl.c | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-)
ell/netconfig.c +4 -0
@@ -9,6 +9,10 @@#include <config.h> #endif +#include <asm/types.h> +#include <linux/netlink.h> +#include <linux/rtnetlink.h> +#include <sys/socket.h> #include <net/if.h> #include <linux/types.h> #include <linux/if_ether.h>
ell/rtnl.c +4 -1
@@ -10,12 +10,15 @@#endif #define _GNU_SOURCE +#include <asm/types.h> +#include <linux/netlink.h> +#include <linux/rtnetlink.h> +#include <sys/socket.h> #include <linux/if.h> #include <linux/icmpv6.h> #include <linux/neighbour.h> #include <linux/if_ether.h> #include <net/if_arp.h> -#include <sys/socket.h> #include <arpa/inet.h> #include <errno.h>
ell/rtnl.h +2 -1
@@ -9,13 +9,14 @@#define __ELL_RTNL_H#include <stdint.h> -#include <linux/rtnetlink.h> #include <ell/cleanup.h> #ifdef __cplusplusextern "C" {#endif +struct rtmsg ; +struct ifaddrmsg ;struct l_rtnl_address ;struct l_rtnl_route ;
unit/test-rtnl.c +4 -0
@@ -16,6 +16,10 @@#include <stdlib.h> #include <signal.h> #include <sys/wait.h> +#include <asm/types.h> +#include <linux/netlink.h> +#include <linux/rtnetlink.h> +#include <sys/socket.h> #include <ell/ell.h> #include "ell/dbus-private.h"
Signature · 1 line
2.42.0
PATCH 2/4 netlink: Fix compilation on really old platforms
Some platforms lack definitions of new netlink features. Fix this by including a local copy of the most up to date netlink.h header.
CC ell/netlink.loell/netlink.c: In function ‘l_netlink_set_debug’:ell/netlink.c:629:56: error: ‘NETLINK_EXT_ACK’ undeclared (first use in this function)
if (setsockopt(l_io_get_fd(netlink->io), SOL_NETLINK, NETLINK_EXT_ACK,
^
ell/netlink.c:629:56: note: each undeclared identifier is reported only once for each function it appears in ell/netlink.c: In function ‘netlink_parse_ext_ack_error’:ell/netlink.c:649:29: error: ‘NLM_F_ACK_TLVS’ undeclared (first use in this function)
if (!(nlmsg->nlmsg_flags & NLM_F_ACK_TLVS))
^
ell/netlink.c:657:29: error: ‘NLM_F_CAPPED’ undeclared (first use in this function)
if (!(nlmsg->nlmsg_flags & NLM_F_CAPPED))
^
ell/netlink.c:677:8: error: ‘NLMSGERR_ATTR_MSG’ undeclared (first use in this function)
case NLMSGERR_ATTR_MSG:
^
ell/netlink.c:681:8: error: ‘NLMSGERR_ATTR_OFFS’ undeclared (first use in this function)
case NLMSGERR_ATTR_OFFS:
^
---
Makefile.am | 2 +-
linux/netlink.h | 383 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 384 insertions(+), 1 deletion(-)
create mode 100644 linux/netlink.hMakefile.am +1 -1
@@ -12,7 +12,7 @@ ELL_CURRENT = 0 ELL_REVISION = 2 ELL_AGE = 0 -linux_headers = linux/gpio.h +linux_headers = linux/gpio.h linux/netlink.h pkginclude_HEADERS = ell/ell.h \ ell/util.h \
linux/netlink.h new file +383 -0
383 lines not on this page · raw message
Signature · 1 line
2.42.0
Re: [PATCH 2/4] netlink: Fix compilation on really old platforms
Hi Denis,
Quoted 36 lines
Some platforms lack definitions of new netlink features. Fix this by including a local copy of the most up to date
netlink.hheader.CC ell/netlink.lo
ell/netlink.c: In function ‘l_netlink_set_debug’:ell/netlink.c:629:56: error: ‘NETLINK_EXT_ACK’ undeclared (first use in this function)
if (setsockopt(l_io_get_fd(netlink->io),SOL_NETLINK,NETLINK_EXT_ACK,^
ell/netlink.c:629:56: note: each undeclared identifier is reported only once for each function it appears inell/netlink.c: In function ‘netlink_parse_ext_ack_error’:ell/netlink.c:649:29: error: ‘NLM_F_ACK_TLVS’ undeclared (first use in this function)
if (!(nlmsg->nlmsg_flags &NLM_F_ACK_TLVS))^ ell/netlink.c:657:29: error: ‘NLM_F_CAPPED’ undeclared (first use in this function) if (!(nlmsg->nlmsg_flags & NLM_F_CAPPED)) ^ ell/netlink.c:677:8: error: ‘NLMSGERR_ATTR_MSG’ undeclared (first use in this function) case NLMSGERR_ATTR_MSG: ^ ell/netlink.c:681:8: error: ‘NLMSGERR_ATTR_OFFS’ undeclared (first use in this function) case NLMSGERR_ATTR_OFFS: ^ --- Makefile.am | 2 +- linux/netlink.h | 383 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 384 insertions(+), 1 deletion(-)create mode 100644
linux/netlink.hMakefile.am +0
-0@@ -12,7 +12,7 @@ ELL_CURRENT = 0
ELL_REVISION= 2ELL_AGE= 0
Makefile.am ELL_CURRENT = 0 · line 15
Quoted 2 lines
Makefile.am +1
-1-linux_headers = linux/gpio.h +linux_headers = linux/gpio.h linux/netlink.h
so while we could do this, I really don’t like it. Running after upstream netlink.h changes is something I rather not keep doing. For the nl80211.h header this is semi-ok, but I rather not keep doing that for all netlink headers.
Can we just add some of these into missing.h and #ifdef fallbacks. We do that for AF_ALG for example and I would prefer that than chasing upstream.
Regards
Marcel
Re: [PATCH 2/4] netlink: Fix compilation on really old platforms
Hi Marcel,
Quoted 4 lines
Makefile.am ELL_CURRENT = 0 · line 15
Quoted 2 lines
Makefile.am +1
-1-linux_headers = linux/gpio.h +linux_headers = linux/gpio.h linux/netlink.hso while we could do this, I really don’t like it. Running after upstream
netlink.hchanges is something I rather not keep doing. For thenl80211.hheader this is semi-ok, but I rather not keep doing that for all netlink headers.
We don't really need to run after them, the EXT_ACK support has been in there fr some time. The problem is that EXT_ACK uses a ton of other attributes missing from linux-headers circa 2016. The missing #defines are easy enough to add to missing.h, but the problem is this one:
+enum nlmsgerr_attrs {
+ NLMSGERR_ATTR_UNUSED, + NLMSGERR_ATTR_MSG, + NLMSGERR_ATTR_OFFS, + NLMSGERR_ATTR_COOKIE, + NLMSGERR_ATTR_POLICY, + NLMSGERR_ATTR_MISS_TYPE, + NLMSGERR_ATTR_MISS_NEST,
+
+ __NLMSGERR_ATTR_MAX,
+ NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1
+};
That is an enumeration. Maybe we could write a configure-time test for this, but that's a pain...
Same situation with rtnetlink.h, RTA_EXPIRES is an enum, so a configure-time test is required.
Regards,
-Denis
PATCH 3/4 rtnl: Fix compilation on really old platforms
In reply to Denis KenziorSome old platforms lack definitions of rtnl features we depend on. Fix this by including a local copy of the most up to date rtnetlink.h header.
CC ell/rtnl.loell/rtnl.c: In function ‘_rtnl_route_change’:ell/rtnl.c:1408:35: error: ‘RTA_EXPIRES’ undeclared (first use in this function)
rta_buf += rta_add_u32(rta_buf, RTA_EXPIRES,
^ ell/rtnl.c:1408:35: note: each undeclared identifier is reported only once for each function it appears in --- Makefile.am | 2 +- linux/rtnetlink.h | 832 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 833 insertions(+), 1 deletion(-) create mode 100644 linux/rtnetlink.h
Makefile.am +1 -1
@@ -12,7 +12,7 @@ ELL_CURRENT = 0 ELL_REVISION = 2 ELL_AGE = 0 -linux_headers = linux/gpio.h linux/netlink.h +linux_headers = linux/gpio.h linux/netlink.h linux/rtnetlink.h pkginclude_HEADERS = ell/ell.h \ ell/util.h \
linux/rtnetlink.h new file +832 -0
832 lines not on this page · raw message
Signature · 1 line
2.42.0
PATCH 4/4 examples: Fix compilation on old systems
In reply to Denis Kenzior--- examples/dhcp6-client.c | 1 + 1 file changed, 1 insertion(+)
examples/dhcp6-client.c +1 -0
@@ -12,6 +12,7 @@#define _GNU_SOURCE#include <stdio.h> #include <signal.h> +#include <sys/socket.h> #include <linux/if_arp.h> #include <arpa/inet.h>
Signature · 1 line
2.42.0
Hi Denis,
Quoted 9 lines
man 7 rtnetlink suggests the 4 includes listed should be used. Also, remove
rtnetlink.hinclusion fromrtnl.hand move it into the individual code files.
---ell/netconfig.c | 4 ++++ ell/rtnl.c | 5 ++++- ell/rtnl.h | 3 ++- unit/test-rtnl.c | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-)
I applied patch 1 and patch 4 since they are simple fixes.
Regards
Marcel