diff options
author | Tom Gundersen <teg@jklm.no> | 2015-05-25 17:34:47 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-05-25 17:41:42 +0200 |
commit | 01d28f81a782616b6daa84a42447fd4939783a66 (patch) | |
tree | 6e1804e8a20fb2e60f25f004ab7a8e910742f7e9 /src/network/networkd-link.c | |
parent | bf1d7ba70aceddb5dae0cd2e370b8afaf0c81b05 (diff) |
networkd: fix IFF_UP when ipv6 support is disabled
Passing ipv6 options (even when they should be noops) caused IFF_UP to fail when
ipv6 was supported.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=90103
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r-- | src/network/networkd-link.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 8b0de1f741..f039a2d687 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1010,27 +1010,30 @@ static int link_up(Link *link) { if (r < 0) return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m"); - r = sd_rtnl_message_open_container(req, AF_INET6); - if (r < 0) - return log_link_error_errno(link, r, "Could not open AF_INET6 container: %m"); + if (socket_ipv6_is_supported()) { + /* if the kernel lacks ipv6 support setting IFF_UP fails if any ipv6 options are passed */ + r = sd_rtnl_message_open_container(req, AF_INET6); + if (r < 0) + return log_link_error_errno(link, r, "Could not open AF_INET6 container: %m"); - ipv6ll_mode = link_ipv6ll_enabled(link) ? IN6_ADDR_GEN_MODE_EUI64 : IN6_ADDR_GEN_MODE_NONE; - r = sd_rtnl_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, ipv6ll_mode); - if (r < 0) - return log_link_error_errno(link, r, "Could not append IFLA_INET6_ADDR_GEN_MODE: %m"); + ipv6ll_mode = link_ipv6ll_enabled(link) ? IN6_ADDR_GEN_MODE_EUI64 : IN6_ADDR_GEN_MODE_NONE; + r = sd_rtnl_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, ipv6ll_mode); + if (r < 0) + return log_link_error_errno(link, r, "Could not append IFLA_INET6_ADDR_GEN_MODE: %m"); + + if (!in_addr_is_null(AF_INET6, &link->network->ipv6_token)) { + r = sd_rtnl_message_append_in6_addr(req, IFLA_INET6_TOKEN, &link->network->ipv6_token.in6); + if (r < 0) + return log_link_error_errno(link, r, "Could not append IFLA_INET6_TOKEN: %m"); + } - if (!in_addr_is_null(AF_INET6, &link->network->ipv6_token)) { - r = sd_rtnl_message_append_in6_addr(req, IFLA_INET6_TOKEN, &link->network->ipv6_token.in6); + r = sd_rtnl_message_close_container(req); if (r < 0) - return log_link_error_errno(link, r, "Could not append IFLA_INET6_TOKEN: %m"); + return log_link_error_errno(link, r, "Could not close AF_INET6 container: %m"); } r = sd_rtnl_message_close_container(req); if (r < 0) - return log_link_error_errno(link, r, "Could not close AF_INET6 container: %m"); - - r = sd_rtnl_message_close_container(req); - if (r < 0) return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m"); r = sd_rtnl_call_async(link->manager->rtnl, req, link_up_handler, link, 0, NULL); |