diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2017-05-12 16:48:30 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2017-05-15 14:49:50 +0300 |
commit | 7d5cac19b5d04b39405273c6ab6bfc8811bd4f3a (patch) | |
tree | 16008fe928bd4a2a95e6f3a2ef77477201e1b9f4 /src/network | |
parent | 9d5d0090cae80e705c61e3fad49b5ca728e1479b (diff) | |
download | systemd-7d5cac19b5d04b39405273c6ab6bfc8811bd4f3a.tar.gz systemd-7d5cac19b5d04b39405273c6ab6bfc8811bd4f3a.tar.bz2 systemd-7d5cac19b5d04b39405273c6ab6bfc8811bd4f3a.zip |
networkd: Add Router Advertisement variables
Add variables for enabling Router Advertisements, router lifetime as
well as managed and other information flags indicating use of DHCPv6.
Add configuration of default router preferences as defined in RFC 4191.
IPv6PrefixDelegation in the [Network] section has to be set in order
to enable prefix delegation. The rest of the prefix delegation values
are stored in the [IPv6PrefixDelegation] section. The host will act as
a default router if it is given a non-zero lifetime with
RouterLifetimeSec. Managed and OtherInformation booleans set the level
of DHCPv6 support, and the RouterPreference configures the router's
preference between low, medium and high. Words 'normal' and 'default'
are added as synonyms for 'medium' just to make configuration simpler.
This adds a section like the following to .network configuration files:
[Network]
IPv6PrefixDelegation=true
[IPv6PrefixDelegation]
RouterLifetimeSec=2000
Managed=false
OtherInformation=true
RouterPreference=medium
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-address.c | 30 | ||||
-rw-r--r-- | src/network/networkd-address.h | 1 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 5 | ||||
-rw-r--r-- | src/network/networkd-network.c | 1 | ||||
-rw-r--r-- | src/network/networkd-network.h | 7 |
5 files changed, 44 insertions, 0 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 700ae2adda..de918c3c29 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -933,6 +933,36 @@ bool address_is_ready(const Address *a) { return !(a->flags & (IFA_F_TENTATIVE | IFA_F_DEPRECATED)); } +int config_parse_router_preference(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 *network = userdata; + + assert(filename); + assert(section); + assert(lvalue); + assert(rvalue); + assert(data); + + if (streq(rvalue, "high")) + network->router_preference = SD_NDISC_PREFERENCE_HIGH; + else if (STR_IN_SET(rvalue, "medium", "normal", "default")) + network->router_preference = SD_NDISC_PREFERENCE_MEDIUM; + else if (streq(rvalue, "low")) + network->router_preference = SD_NDISC_PREFERENCE_LOW; + else + log_syntax(unit, LOG_ERR, filename, line, -EINVAL, "Router preference '%s' is invalid, ignoring assignment: %m", rvalue); + + return 0; +} + void prefix_free(Prefix *prefix) { if (!prefix) return; diff --git a/src/network/networkd-address.h b/src/network/networkd-address.h index d9be045302..065328482e 100644 --- a/src/network/networkd-address.h +++ b/src/network/networkd-address.h @@ -102,6 +102,7 @@ int config_parse_broadcast(const char *unit, const char *filename, unsigned line int config_parse_label(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_lifetime(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_address_flags(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_router_preference(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_prefix(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_prefix_flags(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_prefix_lifetime(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-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index eb54a68629..a2d38501a5 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -137,6 +137,11 @@ BridgeFDB.VLANId, config_parse_fdb_vlan_id, BridgeVLAN.PVID, config_parse_brvlan_pvid, 0, 0 BridgeVLAN.VLAN, config_parse_brvlan_vlan, 0, 0 BridgeVLAN.EgressUntagged, config_parse_brvlan_untagged, 0, 0 +Network.IPv6PrefixDelegation, config_parse_bool, 0, offsetof(Network, router_prefix_delegation) +IPv6PrefixDelegation.RouterLifetimeSec, config_parse_sec, 0, offsetof(Network, router_lifetime_usec) +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 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 f5d11d6b99..6f2ae66d40 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -213,6 +213,7 @@ static int network_load_one(Manager *manager, const char *filename) { "Bridge\0" "BridgeFDB\0" "BridgeVLAN\0" + "IPv6PrefixDelegation\0" "IPv6Prefix\0", config_item_perf_lookup, network_network_gperf_lookup, false, network); diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index a9d547b046..b31921947d 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -158,6 +158,13 @@ struct Network { AddressFamilyBoolean link_local; bool ipv4ll_route; + /* IPv6 prefix delegation support */ + bool router_prefix_delegation; + usec_t router_lifetime_usec; + uint8_t router_preference; + bool router_managed; + bool router_other_information; + /* Bridge Support */ bool use_bpdu; bool hairpin; |