diff options
author | Susant Sahani <ssahani@gmail.com> | 2023-08-24 20:38:48 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-09-04 16:40:40 +0200 |
commit | 6a6d27bc5b08388964118e922f0c1b49b3c6a8ae (patch) | |
tree | 342b4bb608a58936be3fc2b8cdcc1b6c1548f88d /src/network/networkd-radv.c | |
parent | Merge pull request #28896 from pelaufer/dhcp_dbus_notify (diff) | |
download | systemd-6a6d27bc5b08388964118e922f0c1b49b3c6a8ae.tar.xz systemd-6a6d27bc5b08388964118e922f0c1b49b3c6a8ae.zip |
network: sd-radv - Allow to configure Mobile IPv6 Home Agent
Diffstat (limited to 'src/network/networkd-radv.c')
-rw-r--r-- | src/network/networkd-radv.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index 57fd68f5a0..b5ee1c322d 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -600,6 +600,18 @@ static int radv_configure(Link *link) { if (r < 0) return log_link_debug_errno(link, r, "Could not set RA Domains: %m"); + r = sd_radv_set_home_agent_information(link->radv, link->network->router_home_agent_information); + if (r < 0) + return r; + + r = sd_radv_set_home_agent_preference(link->radv, link->network->router_home_agent_preference); + if (r < 0) + return r; + + r = sd_radv_set_home_agent_lifetime(link->radv, DIV_ROUND_UP(link->network->home_agent_lifetime_usec, USEC_PER_SEC)); + if (r < 0) + return r; + return 0; } @@ -1575,3 +1587,47 @@ int config_parse_router_preference( return 0; } + +int config_parse_router_home_agent_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) { + + usec_t usec, *home_agent_lifetime_usec = ASSERT_PTR(data); + int r; + + assert(filename); + assert(section); + assert(lvalue); + assert(rvalue); + + if (isempty(rvalue)) { + *home_agent_lifetime_usec = 0; + return 0; + } + + r = parse_sec(rvalue, &usec); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse %s=, ignoring assignment: %s", lvalue, rvalue); + return 0; + } + + if (usec == USEC_INFINITY || usec == 0 || + DIV_ROUND_UP(usec, USEC_PER_SEC) > RADV_MAX_HOME_AGENT_LIFETIME_USEC) { + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Invalid %s= must be in the range 1...%lu seconds, ignoring: %s", lvalue, + RADV_MAX_HOME_AGENT_LIFETIME_USEC / USEC_PER_SEC, rvalue); + return 0; + } + + *home_agent_lifetime_usec = usec; + return 0; +} |