diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-09-07 19:01:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-07 19:01:57 +0200 |
commit | 9ecf63a457a357fa6c3d7801bbfc7c14800ae87d (patch) | |
tree | 890ce16439c79dfd8b31a9032d07583ff691983c /src/network | |
parent | hwdb: Add Cube i7 Stylus sensor rotation matrix (#6722) (diff) | |
parent | man: Document prefix delegation in systemd.network (diff) | |
download | systemd-9ecf63a457a357fa6c3d7801bbfc7c14800ae87d.tar.xz systemd-9ecf63a457a357fa6c3d7801bbfc7c14800ae87d.zip |
Merge pull request #6616 from pfl/rdnss
networkd: RDNSS option for systemd-networkd prefix delegation
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 2 | ||||
-rw-r--r-- | src/network/networkd-network.c | 53 | ||||
-rw-r--r-- | src/network/networkd-network.h | 4 | ||||
-rw-r--r-- | src/network/networkd-radv.c | 10 |
4 files changed, 69 insertions, 0 deletions
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 7dab421392..112efd2dfb 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -145,6 +145,8 @@ IPv6PrefixDelegation.RouterLifetimeSec, config_parse_sec, IPv6PrefixDelegation.Managed, config_parse_bool, 0, offsetof(Network, router_managed) IPv6PrefixDelegation.OtherInformation, config_parse_bool, 0, offsetof(Network, router_other_information) IPv6PrefixDelegation.RouterPreference, config_parse_router_preference, 0, 0 +IPv6PrefixDelegation.DNS, config_parse_radv_dns, 0, 0 +IPv6PrefixDelegation.DNSLifetimeSec, config_parse_sec, 0, offsetof(Network, router_dns_lifetime_usec) IPv6Prefix.Prefix, config_parse_prefix, 0, 0 IPv6Prefix.OnLink, config_parse_prefix_flags, 0, 0 IPv6Prefix.AddressAutoconfiguration, config_parse_prefix_flags, 0, 0 diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 4a997b76d7..a873e55d4c 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -26,6 +26,7 @@ #include "dns-domain.h" #include "fd-util.h" #include "hostname-util.h" +#include "in-addr-util.h" #include "network-internal.h" #include "networkd-manager.h" #include "networkd-network.h" @@ -1063,6 +1064,58 @@ int config_parse_dhcp_server_dns( return 0; } +int config_parse_radv_dns( + const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + Network *n = data; + const char *p = rvalue; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + + for (;;) { + _cleanup_free_ char *w = NULL; + union in_addr_union a; + + r = extract_first_word(&p, &w, NULL, 0); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract word, ignoring: %s", rvalue); + return 0; + } + if (r == 0) + break; + + if (in_addr_from_string(AF_INET6, w, &a) >= 0) { + struct in6_addr *m; + + m = realloc(n->router_dns, (n->n_router_dns + 1) * sizeof(struct in6_addr)); + if (!m) + return log_oom(); + + m[n->n_router_dns++] = a.in6; + n->router_dns = m; + + } else + log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse DNS server address, ignoring: %s", w); + + } + + return 0; +} + int config_parse_dhcp_server_ntp( const char *unit, const char *filename, diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 4025e0fa2f..035b57d5f2 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -165,6 +165,9 @@ struct Network { uint8_t router_preference; bool router_managed; bool router_other_information; + usec_t router_dns_lifetime_usec; + struct in6_addr *router_dns; + unsigned n_router_dns; /* Bridge Support */ bool use_bpdu; @@ -267,6 +270,7 @@ int config_parse_ipv6_privacy_extensions(const char *unit, const char *filename, int config_parse_hostname(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_timezone(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_dhcp_server_dns(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); +int config_parse_radv_dns(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_dhcp_server_ntp(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_dnssec_negative_trust_anchors(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_dhcp_use_domains(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index af9e116936..d47a2fd3fd 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -75,5 +75,15 @@ int radv_configure(Link *link) { return r; } + if (link->network->router_dns) { + r = sd_radv_set_rdnss(link->radv, + DIV_ROUND_UP(link->network->router_dns_lifetime_usec, + USEC_PER_SEC), + link->network->router_dns, + link->network->n_router_dns); + if (r < 0) + return r; + } + return 0; } |