[lxc-devel] [lxd/master] netns_getifaddrs: adapt to kernel changes

brauner on Github lxc-bot at linuxcontainers.org
Fri Apr 19 13:16:18 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 418 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190419/d386bd06/attachment.bin>
-------------- next part --------------
From 5c2df8b52c54b8c6ee9159dd632bb4f9a1c2e2b9 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 19 Apr 2019 15:15:28 +0200
Subject: [PATCH] netns_getifaddrs: adapt to kernel changes

s/NETLINK_DUMP_STRICT_CHK/NETLINK_GET_STRICT_CHK/g

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/include/macro.h       |  4 ++--
 lxd/main_checkfeature.go  |  6 +++---
 shared/netns_getifaddrs.c |  2 +-
 shared/network.c          | 29 -----------------------------
 4 files changed, 6 insertions(+), 35 deletions(-)

diff --git a/lxd/include/macro.h b/lxd/include/macro.h
index 3384184e9c..7ff60c385d 100644
--- a/lxd/include/macro.h
+++ b/lxd/include/macro.h
@@ -135,8 +135,8 @@ extern int __build_bug_on_failed;
 #define prctl_arg(x) ((unsigned long)x)
 
 /* networking */
-#ifndef NETLINK_DUMP_STRICT_CHK
-#define NETLINK_DUMP_STRICT_CHK 12
+#ifndef NETLINK_GET_STRICT_CHK
+#define NETLINK_GET_STRICT_CHK 12
 #endif
 
 #ifndef SOL_NETLINK
diff --git a/lxd/main_checkfeature.go b/lxd/main_checkfeature.go
index 653aff6e4b..ccd1070dd6 100644
--- a/lxd/main_checkfeature.go
+++ b/lxd/main_checkfeature.go
@@ -107,13 +107,13 @@ void is_netnsid_aware(int *hostnetns_fd, int *newnetns_fd)
 		return;
 	}
 
-	ret = setsockopt(sock_fd, SOL_NETLINK, NETLINK_DUMP_STRICT_CHK, &(int){1}, sizeof(int));
+	ret = setsockopt(sock_fd, SOL_NETLINK, NETLINK_GET_STRICT_CHK, &(int){1}, sizeof(int));
 	if (ret < 0) {
-		// NETLINK_DUMP_STRICT_CHK isn't supported
+		// NETLINK_GET_STRICT_CHK isn't supported
 		return;
 	}
 
-	// NETLINK_DUMP_STRICT_CHK is supported
+	// NETLINK_GET_STRICT_CHK is supported
 	netnsid_aware = true;
 }
 
diff --git a/shared/netns_getifaddrs.c b/shared/netns_getifaddrs.c
index 2e854a44dd..7487b13621 100644
--- a/shared/netns_getifaddrs.c
+++ b/shared/netns_getifaddrs.c
@@ -432,7 +432,7 @@ static int __rtnl_enumerate(int link_af, int addr_af, __s32 netns_id,
 	if (fd < 0)
 		return -1;
 
-	r = setsockopt(fd, SOL_NETLINK, NETLINK_DUMP_STRICT_CHK, &(int){1},
+	r = setsockopt(fd, SOL_NETLINK, NETLINK_GET_STRICT_CHK, &(int){1},
 		       sizeof(int));
 	if (r < 0 && netns_id >= 0) {
 		close(fd);
diff --git a/shared/network.c b/shared/network.c
index 421f99b49f..d0f40b0393 100644
--- a/shared/network.c
+++ b/shared/network.c
@@ -26,35 +26,6 @@
 	((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct rtgenmsg))))
 #endif
 
-#ifndef SOL_NETLINK
-#define SOL_NETLINK 270
-#endif
-
-#ifndef NETLINK_DUMP_STRICT_CHK
-#define NETLINK_DUMP_STRICT_CHK 12
-#endif
-
-#ifndef RTM_GETLINK
-#define RTM_GETLINK 18
-#endif
-
-#ifndef RTM_GETNSID
-#define RTM_GETNSID 90
-#endif
-
-#ifdef IFLA_IF_NETNSID
-#ifndef IFLA_TARGET_NETNSID
-#define IFLA_TARGET_NETNSID = IFLA_IF_NETNSID
-#endif
-#else
-#define IFLA_IF_NETNSID 46
-#define IFLA_TARGET_NETNSID 46
-#endif
-
-#ifndef IFA_TARGET_NETNSID
-#define IFA_TARGET_NETNSID 10
-#endif
-
 #define IFADDRS_HASH_SIZE 64
 
 #define __NETLINK_ALIGN(len) (((len) + 3) & ~3)


More information about the lxc-devel mailing list