summaryrefslogtreecommitdiff
path: root/src/network/networkd-address.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2017-05-12 16:48:30 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2017-05-15 14:49:50 +0300
commit7d5cac19b5d04b39405273c6ab6bfc8811bd4f3a (patch)
tree16008fe928bd4a2a95e6f3a2ef77477201e1b9f4 /src/network/networkd-address.c
parent9d5d0090cae80e705c61e3fad49b5ca728e1479b (diff)
downloadsystemd-7d5cac19b5d04b39405273c6ab6bfc8811bd4f3a.tar.gz
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/networkd-address.c')
-rw-r--r--src/network/networkd-address.c30
1 files changed, 30 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;