diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-07-07 11:19:49 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-07-07 11:20:35 +0900 |
commit | 1d596fdec2fe01fba2ac1976c6e60a13554a31fe (patch) | |
tree | e4c095fa94feade426e886492bf642886c2a85a4 /src/network | |
parent | 8fc2a5dff43affd73bfc6ffd0e7366091a400867 (diff) | |
download | systemd-1d596fdec2fe01fba2ac1976c6e60a13554a31fe.tar.gz |
network: do not restart radv engine when adding prefix
Replaces d469cea3bde53bc39317c8b433c825bb4790cbe5.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-dhcp6.c | 28 | ||||
-rw-r--r-- | src/network/networkd-radv.c | 31 | ||||
-rw-r--r-- | src/network/networkd-radv.h | 2 |
3 files changed, 36 insertions, 25 deletions
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 4e49a3c5fc..ad90c0badc 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -6,7 +6,6 @@ #include <netinet/in.h> #include <linux/if.h> #include <linux/if_arp.h> -#include "sd-radv.h" #include "sd-dhcp6-client.h" @@ -18,6 +17,7 @@ #include "networkd-dhcp6.h" #include "networkd-link.h" #include "networkd-manager.h" +#include "networkd-radv.h" #include "siphash24.h" #include "string-table.h" #include "string-util.h" @@ -167,34 +167,12 @@ static int dhcp6_pd_prefix_assign(Link *link, struct in6_addr *prefix, uint8_t prefix_len, uint32_t lifetime_preferred, uint32_t lifetime_valid) { - sd_radv *radv = link->radv; int r; - _cleanup_(sd_radv_prefix_unrefp) sd_radv_prefix *p = NULL; - r = sd_radv_prefix_new(&p); + r = radv_add_prefix(link, prefix, prefix_len, lifetime_preferred, lifetime_valid); if (r < 0) return r; - r = sd_radv_prefix_set_prefix(p, prefix, prefix_len); - if (r < 0) - return r; - - r = sd_radv_prefix_set_preferred_lifetime(p, lifetime_preferred); - if (r < 0) - return r; - - r = sd_radv_prefix_set_valid_lifetime(p, lifetime_valid); - if (r < 0) - return r; - - r = sd_radv_stop(radv); - if (r < 0) - return r; - - r = sd_radv_add_prefix(radv, p, true); - if (r < 0 && r != -EEXIST) - return r; - r = dhcp6_prefix_add(link->manager, prefix, link); if (r < 0) return r; @@ -205,7 +183,7 @@ static int dhcp6_pd_prefix_assign(Link *link, struct in6_addr *prefix, return r; } - return sd_radv_start(radv); + return 0; } static int dhcp6_route_remove_handler(sd_netlink *nl, sd_netlink_message *m, Link *link) { diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index f5f8ec65ed..d52aadecfa 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -672,6 +672,37 @@ int radv_configure(Link *link) { return 0; } +int radv_add_prefix(Link *link, struct in6_addr *prefix, uint8_t prefix_len, + uint32_t lifetime_preferred, uint32_t lifetime_valid) { + _cleanup_(sd_radv_prefix_unrefp) sd_radv_prefix *p = NULL; + int r; + + assert(link); + assert(link->radv); + + r = sd_radv_prefix_new(&p); + if (r < 0) + return r; + + r = sd_radv_prefix_set_prefix(p, prefix, prefix_len); + if (r < 0) + return r; + + r = sd_radv_prefix_set_preferred_lifetime(p, lifetime_preferred); + if (r < 0) + return r; + + r = sd_radv_prefix_set_valid_lifetime(p, lifetime_valid); + if (r < 0) + return r; + + r = sd_radv_add_prefix(link->radv, p, true); + if (r < 0 && r != -EEXIST) + return r; + + return 0; +} + int config_parse_radv_dns( const char *unit, const char *filename, diff --git a/src/network/networkd-radv.h b/src/network/networkd-radv.h index b115243ef5..741aa8692f 100644 --- a/src/network/networkd-radv.h +++ b/src/network/networkd-radv.h @@ -52,6 +52,8 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(RoutePrefix, route_prefix_free); int radv_emit_dns(Link *link); int radv_configure(Link *link); +int radv_add_prefix(Link *link, struct in6_addr *prefix, uint8_t prefix_len, + uint32_t lifetime_preferred, uint32_t lifetime_valid); const char* radv_prefix_delegation_to_string(RADVPrefixDelegation i) _const_; RADVPrefixDelegation radv_prefix_delegation_from_string(const char *s) _pure_; |