Skip to contentSkip to conversation

Import rntlutil from iwd

PATCH In review Daniel Wagner 2 participants 4 messages Feb 14, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Import rntlutil from iwd

This just copies over the code from iwd. No changes there except the prefix of the functions name.

Unfortunatly, the unit test can only test the get/dump function because the setters need root permissions. For this we need some sort of sandbox. Does anyone have any ideas for this?

While writing the test case I noticed some inconsistency in the naming sceme:

The IPv6 functions are consistent in the naming sceme, always append ipv6 after the first name:

rtnl_ifaddr_ipv6_extract
rtnl_ifaddr_ipv6_get
rtnl_ifaddr_ipv6_add
rtnl_ifaddr_ipv6_delete

rtnl_route_ipv6_add_gateway
rtnl_route_ipv6_delete_gateway

For the IPv4 functions it's either a plain 'ifaddr' infix or somewhere ipv4 in the name:

rtnl_ifaddr_extract
rtnl_ifaddr_get
rtnl_ifaddr_add
rtnl_ifaddr_delete

rtnl_route_extract_ipv4
rtnl_route_dump_ipv4

-> drop ipv4?

rtnl_route_ipv4_add_connected
rtnl_route_ipv4_add_gateway

-> drop ipv4?

And there are the setters:

rtnl_set_linkmode_and_operstate
rtnl_set_mac
rtnl_set_powered

Is this the standard naming sceme?

Thanks,
Daniel

Daniel Wagner (2):
rtnl: Add initial rtnl support
unit: Add l_rtnl_* unit tests

 .gitignore       |   1 +
 Makefile.am      |   5 +
 ell/ell.h        |   1 +
 ell/rtnl.c       | 641 +++++++++++++++++++++++++++++++++++++++++++++++
 ell/rtnl.h       | 119 +++++++++
 unit/test-rtnl.c | 236 +++++++++++++++++
 6 files changed, 1003 insertions(+)
 create mode 100644 ell/rtnl.c
 create mode 100644 ell/rtnl.h
 create mode 100644 unit/test-rtnl.c
Signature · 1 line
2.25.0
#1 lore raw

PATCH 1/2 rtnl: Add initial rtnl support

Import from iwd the rtnlutil helper code. There are no changes expect prefix the name of the functions.

---
 Makefile.am |   2 +
 ell/ell.h   |   1 +
 ell/rtnl.c  | 641 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 ell/rtnl.h  | 119 ++++++++++
 4 files changed, 763 insertions(+)
 create mode 100644 ell/rtnl.c
 create mode 100644 ell/rtnl.h
Makefile.am +2 -0
index 3ead678ff194..453f0d1b42d0 100644
@@ -34,6 +34,7 @@ pkginclude_HEADERS = ell/ell.h \
 			ell/checksum.h \
 			ell/netlink.h \
 			ell/genl.h \
+			ell/rtnl.h \
 			ell/dbus.h \
 			ell/dbus-service.h \
 			ell/dbus-client.h \
@@ -85,6 +86,7 @@ ell_libell_la_SOURCES = $(linux_headers) \
 			ell/netlink.c \
 			ell/genl-private.h \
 			ell/genl.c \
+			ell/rtnl.c \
 			ell/dbus-private.h \
 			ell/dbus.c \
 			ell/dbus-message.c \
ell/ell.h +1 -0
index 3bb91851fe94..d16d1b2044be 100644
@@ -52,6 +52,7 @@
 #include <ell/net.h>
 #include <ell/netlink.h>
 #include <ell/genl.h>
+#include <ell/rtnl.h>
 #include <ell/dbus.h>
 #include <ell/dbus-service.h>
 #include <ell/dbus-client.h>
ell/rtnl.c new file +641 -0

641 lines not on this page · raw message

ell/rtnl.h new file +119 -0

119 lines not on this page · raw message

Signature · 1 line
2.25.0
#2 lore raw

PATCH 2/2 unit: Add l_rtnl_* unit tests

In reply to Daniel Wagner

Test the get and dump functions because these don't need special permissions to run.

For testing the other functions we need first setup a test environment so we don't disturb the hosts routing or IP configuration.

---
 .gitignore       |   1 +
 Makefile.am      |   3 +
 unit/test-rtnl.c | 236 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 240 insertions(+)
 create mode 100644 unit/test-rtnl.c
.gitignore +1 -0
index 372f0e7d3885..fca4b423678c 100644
@@ -32,6 +32,7 @@ unit/test-checksum
 unit/test-settings
 unit/test-netlink
 unit/test-genl-msg
+unit/test-rtnl
 unit/test-dbus
 unit/test-dbus-message
 unit/test-dbus-message-fds
Makefile.am +3 -0
index 453f0d1b42d0..22b8f3daf5bb 100644
@@ -167,6 +167,7 @@ unit_tests = unit/test-unit \
 			unit/test-settings \
 			unit/test-netlink \
 			unit/test-genl-msg \
+			unit/test-rtnl \
 			unit/test-siphash \
 			unit/test-cipher \
 			unit/test-random \
@@ -249,6 +250,8 @@ unit_test_netlink_LDADD = ell/libell-private.la
 
 unit_test_genl_msg_LDADD = ell/libell-private.la
 
+unit_test_rtnl_LDADD = ell/libell-private.la
+
 unit_test_dbus_LDADD = ell/libell-private.la
 
 unit_test_dbus_message_LDADD = ell/libell-private.la
unit/test-rtnl.c new file +236 -0

236 lines not on this page · raw message

Signature · 1 line
2.25.0
#3 lore raw
In reply to Daniel Wagner

Hi Daniel,

Quoted 42 lines · Daniel Wagner

This just copies over the code from iwd. No changes there except the prefix of the functions name.

Unfortunatly, the unit test can only test the get/dump function because the setters need root permissions. For this we need some sort of sandbox. Does anyone have any ideas for this?

While writing the test case I noticed some inconsistency in the naming sceme:

The IPv6 functions are consistent in the naming sceme, always append ipv6 after the first name:

rtnl_ifaddr_ipv6_extract
rtnl_ifaddr_ipv6_get
rtnl_ifaddr_ipv6_add
rtnl_ifaddr_ipv6_delete

rtnl_route_ipv6_add_gateway
rtnl_route_ipv6_delete_gateway

For the IPv4 functions it's either a plain 'ifaddr' infix or somewhere ipv4 in the name:

   rtnl_ifaddr_extract
   rtnl_ifaddr_get
   rtnl_ifaddr_add
   rtnl_ifaddr_delete

   rtnl_route_extract_ipv4
   rtnl_route_dump_ipv4

   -> drop ipv4?

   rtnl_route_ipv4_add_connected
   rtnl_route_ipv4_add_gateway

   -> drop ipv4?
Quoted 9 lines

And there are the setters:

rtnl_set_linkmode_and_operstate
rtnl_set_mac
rtnl_set_powered

Is this the standard naming sceme?

Both applied. Now lets fix these up as discussed on IRC.

Regards,
-Denis