diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-07-07 08:53:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 08:53:31 +0200 |
commit | a240147bdc904b91bb6e8f3c6199322fb26e4b68 (patch) | |
tree | 58baf513461970308d2ac27d30f0ea6bcc50356c /src | |
parent | hwdb: Add Google Pixel Slate (nocturne) (#16377) (diff) | |
parent | network: do not restart radv engine when adding prefix (diff) | |
download | systemd-a240147bdc904b91bb6e8f3c6199322fb26e4b68.tar.xz systemd-a240147bdc904b91bb6e8f3c6199322fb26e4b68.zip |
Merge pull request #16383 from yuwata/network-dhcp6-radv-update-prefix
network: do not restart radv engine when adding prefix
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-network/sd-radv.c | 18 | ||||
-rw-r--r-- | src/libsystemd-network/test-ndisc-ra.c | 2 | ||||
-rw-r--r-- | src/network/networkd-dhcp6.c | 31 | ||||
-rw-r--r-- | src/network/networkd-link.c | 2 | ||||
-rw-r--r-- | src/network/networkd-radv.c | 31 | ||||
-rw-r--r-- | src/network/networkd-radv.h | 2 | ||||
-rw-r--r-- | src/systemd/sd-radv.h | 3 |
7 files changed, 47 insertions, 42 deletions
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c index ee7c0ee53f..cc5c0223b5 100644 --- a/src/libsystemd-network/sd-radv.c +++ b/src/libsystemd-network/sd-radv.c @@ -339,12 +339,12 @@ static int radv_timeout(sd_event_source *s, uint64_t usec, void *userdata) { return 0; fail: - sd_radv_stop(ra, true); + sd_radv_stop(ra); return 0; } -_public_ int sd_radv_stop(sd_radv *ra, bool zero_router_lifetime) { +_public_ int sd_radv_stop(sd_radv *ra) { int r; assert_return(ra, -EINVAL); @@ -354,15 +354,11 @@ _public_ int sd_radv_stop(sd_radv *ra, bool zero_router_lifetime) { log_radv("Stopping IPv6 Router Advertisement daemon"); - if (zero_router_lifetime) { - /* RFC 4861, Section 6.2.5, send at least one Router Advertisement - with zero lifetime */ - r = radv_send(ra, NULL, 0); - if (r < 0) - log_radv_errno(r, "Unable to send last Router Advertisement with router lifetime set to zero: %m"); - else - log_radv("Sent last Router Advertisement with router lifetime set to zero"); - } + /* RFC 4861, Section 6.2.5, send at least one Router Advertisement + with zero lifetime */ + r = radv_send(ra, NULL, 0); + if (r < 0) + log_radv_errno(r, "Unable to send last Router Advertisement with router lifetime set to zero: %m"); radv_reset(ra); ra->fd = safe_close(ra->fd); diff --git a/src/libsystemd-network/test-ndisc-ra.c b/src/libsystemd-network/test-ndisc-ra.c index 7c59418ca7..d759ec03a8 100644 --- a/src/libsystemd-network/test-ndisc-ra.c +++ b/src/libsystemd-network/test-ndisc-ra.c @@ -284,7 +284,7 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat return 0; } - assert_se(sd_radv_stop(ra, true) >= 0); + assert_se(sd_radv_stop(ra) >= 0); test_stopped = true; return 0; diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index d9df46a23e..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" @@ -159,8 +159,7 @@ static bool dhcp6_enable_prefix_delegation(Link *dhcp6_link) { return false; } -static int dhcp6_lease_information_acquired(sd_dhcp6_client *client, - Link *link) { +static int dhcp6_lease_information_acquired(sd_dhcp6_client *client, Link *link) { return 0; } @@ -168,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, false); - 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; @@ -206,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-link.c b/src/network/networkd-link.c index dcbf197ff4..053aa3b4ce 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -840,7 +840,7 @@ int link_stop_clients(Link *link, bool may_keep_dhcp) { } if (link->radv) { - k = sd_radv_stop(link->radv, true); + k = sd_radv_stop(link->radv); if (k < 0) r = log_link_warning_errno(link, k, "Could not stop IPv6 Router Advertisement: %m"); } 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_; diff --git a/src/systemd/sd-radv.h b/src/systemd/sd-radv.h index 763d5ddd87..011e40d8a5 100644 --- a/src/systemd/sd-radv.h +++ b/src/systemd/sd-radv.h @@ -22,7 +22,6 @@ #include <inttypes.h> #include <net/ethernet.h> #include <netinet/in.h> -#include <stdbool.h> #include <sys/types.h> #include "_sd-common.h" @@ -50,7 +49,7 @@ int sd_radv_detach_event(sd_radv *nd); sd_event *sd_radv_get_event(sd_radv *ra); int sd_radv_start(sd_radv *ra); -int sd_radv_stop(sd_radv *ra, bool zero_router_lifetime); +int sd_radv_stop(sd_radv *ra); int sd_radv_set_ifindex(sd_radv *ra, int interface_index); int sd_radv_set_mac(sd_radv *ra, const struct ether_addr *mac_addr); |