Skip to contentSkip to conversation

lapi: Add missing IFA_FLAGS

PATCH Superseded Petr Vorel 2 participants 3 messages May 14, 2021 Library code

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH v2 1/1 lapi: Add missing IFA_FLAGS

From: Petr Vorel <[email protected]>

and use them in tst_netdevice.c. This fixes on older toolchains (e.g. sourcery-arm from Buildroot):

tst_netdevice.c: In function 'modify_address':
tst_netdevice.c:218:44: error: 'IFA_FLAGS' undeclared (first use in this function)
if (!tst_rtnl_add_attr(file, lineno, ctx, IFA_FLAGS, &addr_flags,

Fixes bc2151a65 ("lib: Add helper functions for managing network interfaces")

---
Changes v1->v2:

* add missing #include "config.h"
* rename: lapi/if_addr.h => lapi/rtnetlink.h (Cyril)
* include <linux/rtnetlink.h> instead of <linux/if_addr.h> (Cyril)

 configure.ac             |  1 +
 include/lapi/rtnetlink.h | 17 +++++++++++++++++
 lib/tst_netdevice.c      |  3 ++-
 3 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 include/lapi/rtnetlink.h
configure.ac +1 -0
index 136d82d09..95c6d2e72 100644
@@ -59,6 +59,7 @@ AC_CHECK_HEADERS_ONCE([ \
     linux/mempolicy.h \
     linux/module.h \
     linux/netlink.h \
+    linux/rtnetlink.h \
     linux/seccomp.h \
     linux/securebits.h \
     linux/tty.h \
include/lapi/rtnetlink.h new file +17 -0
new file mode 100644
index 000000000..d1dc53df8
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Copyright (c) 2021 Petr Vorel <[email protected]> */
+
+#ifndef LAPI_IF_ADDR_H__
+# define LAPI_IF_ADDR_H__
+
+#include "config.h"
+
+#ifdef HAVE_LINUX_RTNETLINK_H
+# include <linux/rtnetlink.h>
+#endif
+
+#ifndef IFA_FLAGS
+# define IFA_FLAGS 8
+#endif
+
+#endif	/* LAPI_IF_ADDR_H__ */
lib/tst_netdevice.c +2 -1
index 5ca523759..d098173d5 100644
@@ -5,10 +5,11 @@
 
 #include <asm/types.h>
 #include <linux/netlink.h>
-#include <linux/rtnetlink.h>
 #include <linux/veth.h>
 #include <sys/socket.h>
 #include <net/if.h>
+#include "lapi/rtnetlink.h"
+
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "tst_rtnetlink.h"
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/1 lapi: Add missing IFA_FLAGS

Hi!

Quoted 11 lines
 configure.ac             |  1 +
 include/lapi/rtnetlink.h | 17 +++++++++++++++++
 lib/tst_netdevice.c      |  3 ++-
 3 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 include/lapi/rtnetlink.h
configure.ac +0 -0
index 136d82d09..95c6d2e72 100644

configure.ac AC_CHECK_HEADERS_ONCE([ \ · line 62

Quoted 4 lines
configure.ac +1 -0
@@ -59,6 +59,7 @@ AC_CHECK_HEADERS_ONCE([ \
     linux/mempolicy.h \
     linux/module.h \
     linux/netlink.h \
+    linux/rtnetlink.h \

I wonder if this is really needed, if that header is not present we will have to add much more stuff to lapi/rtnetlink.h, so I would just avoid configure check here.

Quoted 46 lines
configure.ac +0 -0
     linux/seccomp.h \
     linux/securebits.h \
     linux/tty.h \
include/lapi/rtnetlink.h new file +17 -0
new file mode 100644
index 000000000..d1dc53df8
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Copyright (c) 2021 Petr Vorel <[email protected]> */
+
+#ifndef LAPI_IF_ADDR_H__
+# define LAPI_IF_ADDR_H__
+
+#include "config.h"
+
+#ifdef HAVE_LINUX_RTNETLINK_H
+# include <linux/rtnetlink.h>
+#endif
+
+#ifndef IFA_FLAGS
+# define IFA_FLAGS 8
+#endif
+
+#endif	/* LAPI_IF_ADDR_H__ */
lib/tst_netdevice.c +2 -1
index 5ca523759..d098173d5 100644
@@ -5,10 +5,11 @@
 
 #include <asm/types.h>
 #include <linux/netlink.h>
-#include <linux/rtnetlink.h>
 #include <linux/veth.h>
 #include <sys/socket.h>
 #include <net/if.h>
+#include "lapi/rtnetlink.h"
+
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "tst_rtnetlink.h"
Signature · 1 line
2.31.1
Signature · 2 lines
Cyril Hrubis
[email protected]
author
#2 lore raw

PATCH v2 1/1 lapi: Add missing IFA_FLAGS

Hi Cyril,

Quoted 7 lines

Hi!

Quoted 5 lines
 configure.ac             |  1 +
 include/lapi/rtnetlink.h | 17 +++++++++++++++++
 lib/tst_netdevice.c      |  3 ++-
 3 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 include/lapi/rtnetlink.h
Quoted 13 lines

configure.ac AC_CHECK_HEADERS_ONCE([ \ · line 62

Quoted 9 lines
configure.ac +1 -0
index 136d82d09..95c6d2e72 100644
@@ -59,6 +59,7 @@ AC_CHECK_HEADERS_ONCE([ \
     linux/mempolicy.h \
     linux/module.h \
     linux/netlink.h \
+    linux/rtnetlink.h \

I wonder if this is really needed, if that header is not present we will have to add much more stuff to lapi/rtnetlink.h, so I would just avoid configure check here.

Sure, we save some time during configure.

Sending v3 (being conservative as there is a git freeze).

Kind regards,
Petr