From 12942bc17ab7a19c58af098cfb4ff900fcd0811d Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 14 Sep 2016 14:35:08 +0200 Subject: [PATCH] networkd: do not create send IFLA_AF_SPEC container if IPv6 is disabled On older kernels, sending an empty IFLA_AF_SPEC netlink message container causes an EINVAL if IPv6 is not available. Only do the container open/close if IPv6 is available. https://launchpad.net/bugs/1623068 --- src/network/networkd-link.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index aab40a0..13c5a09 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1691,11 +1691,11 @@ static int link_up(Link *link) { return log_link_error_errno(link, r, "Could not set MTU: %m"); } - r = sd_netlink_message_open_container(req, IFLA_AF_SPEC); - if (r < 0) - return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m"); - if (link_ipv6_enabled(link)) { + r = sd_netlink_message_open_container(req, IFLA_AF_SPEC); + if (r < 0) + return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m"); + /* if the kernel lacks ipv6 support setting IFF_UP fails if any ipv6 options are passed */ r = sd_netlink_message_open_container(req, AF_INET6); if (r < 0) @@ -1728,11 +1728,11 @@ static int link_up(Link *link) { r = sd_netlink_message_close_container(req); if (r < 0) return log_link_error_errno(link, r, "Could not close AF_INET6 container: %m"); - } - r = sd_netlink_message_close_container(req); - if (r < 0) - return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m"); + r = sd_netlink_message_close_container(req); + if (r < 0) + return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m"); + } r = sd_netlink_call_async(link->manager->rtnl, req, link_up_handler, link, 0, NULL); if (r < 0) -- 2.9.3