Skip to contentSkip to conversation

unit: Test netlink multicast group registration

PATCH Applied Ossama Othman 2 participants 2 messages Apr 28, 2017 – May 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unit: Test netlink multicast group registration

Register for the rtnetlink RTNLGRP_LINK multicast group to test the ELL netlink multicast group registration code. Only registration and deregistration is performed for now. An actual RTNLGRP_LINK multicast notification is not triggered.

---
 unit/test-netlink.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
unit/test-netlink.c +12 -0
index ce522a6..928830a 100644
@@ -27,6 +27,7 @@
 #include <sys/socket.h>
 #include <linux/rtnetlink.h>
 #include <net/if.h>
+#include <assert.h>
 
 #include <ell/ell.h>
 
@@ -72,10 +73,16 @@ done:
 	l_main_quit();
 }
 
+static void link_notification(uint16_t type, void const * data,
+					uint32_t len, void * user_data)
+{
+}
+
 int main(int argc, char *argv[])
 {
 	struct l_netlink *netlink;
 	struct ifinfomsg msg;
+	unsigned int link_id;
 
 	if (!l_main_init())
 		return -1;
@@ -91,8 +98,13 @@ int main(int argc, char *argv[])
 	l_netlink_send(netlink, RTM_GETLINK, NLM_F_DUMP, &msg, sizeof(msg),
 						getlink_callback, NULL, NULL);
 
+	link_id = l_netlink_register(netlink, RTNLGRP_LINK,
+					link_notification, NULL, NULL);
+
 	l_main_run();
 
+	assert(l_netlink_unregister(netlink, link_id));
+
 	l_netlink_destroy(netlink);
 
 	l_main_exit();
Signature · 1 line
2.7.4
#1 lore raw

Hi Ossama,

Quoted 8 lines · Ossama Othman

Register for the rtnetlink RTNLGRP_LINK multicast group to test the ELL netlink multicast group registration code. Only registration and deregistration is performed for now. An actual RTNLGRP_LINK multicast notification is not triggered.

---
 unit/test-netlink.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Applied, thanks.

Regards,
-Denis