diff options
author | Tom Gundersen <teg@jklm.no> | 2015-02-08 23:20:56 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-02-09 12:20:10 +0100 |
commit | 7f77697a1744f8df2089848b9d718faf7ba6c665 (patch) | |
tree | 294907c72f1008bfe7189e81ec27e8a4bae0131c /src/network/networkd-link.c | |
parent | d0d6a4cd70477970812bff0a37e70f66208d7c14 (diff) |
networkd: add support for IPv6 tokens
This allows the admin to set the host-specific part of IPv6 addresses, but still
receive the prefix via SLAAC.
.network file snippet:
[Network]
IPv6Token=::12
gives:
$ ip token
token ::12 dev eth0
This closes https://bugs.freedesktop.org/show_bug.cgi?id=81177.
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r-- | src/network/networkd-link.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 3b9881d71e..1f96c634ef 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1097,36 +1097,44 @@ static int link_up(Link *link) { } } - if (!link_ipv6ll_enabled(link)) { - r = sd_rtnl_message_open_container(req, IFLA_AF_SPEC); - if (r < 0) { - log_link_error(link, "Could not open IFLA_AF_SPEC container: %s", strerror(-r)); - return r; - } + r = sd_rtnl_message_open_container(req, IFLA_AF_SPEC); + if (r < 0) { + log_link_error(link, "Could not open IFLA_AF_SPEC container: %s", strerror(-r)); + return r; + } - r = sd_rtnl_message_open_container(req, AF_INET6); - if (r < 0) { - log_link_error(link, "Could not open AF_INET6 container: %s", strerror(-r)); - return r; - } + r = sd_rtnl_message_open_container(req, AF_INET6); + if (r < 0) { + log_link_error(link, "Could not open AF_INET6 container: %s", strerror(-r)); + return r; + } + if (!link_ipv6ll_enabled(link)) { r = sd_rtnl_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, IN6_ADDR_GEN_MODE_NONE); if (r < 0) { log_link_error(link, "Could not append IFLA_INET6_ADDR_GEN_MODE: %s", strerror(-r)); return r; } + } - r = sd_rtnl_message_close_container(req); + 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) { - log_link_error(link, "Could not close AF_INET6 contaire: %s", strerror(-r)); + log_link_error(link, "Could not append IFLA_INET6_TOKEN: %s", strerror(-r)); return r; } + } - r = sd_rtnl_message_close_container(req); - if (r < 0) { - log_link_error(link, "Could not close IFLA_AF_SPEC contaire: %s", strerror(-r)); - return r; - } + r = sd_rtnl_message_close_container(req); + if (r < 0) { + log_link_error(link, "Could not close AF_INET6 container: %s", strerror(-r)); + return r; + } + + r = sd_rtnl_message_close_container(req); + if (r < 0) { + log_link_error(link, "Could not close IFLA_AF_SPEC contaire: %s", strerror(-r)); + return r; } r = sd_rtnl_call_async(link->manager->rtnl, req, link_up_handler, link, |