diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-12-17 23:52:30 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-12-18 02:09:07 +0100 |
commit | 059d7b6eae827e73c73633bcc40fe74f3696f3f6 (patch) | |
tree | 1e96463bacf3dabb8180983ded09f07d5dbccf22 /src/libsystemd-network/sd-radv.c | |
parent | network: a couple of tweaks suggested by Coccinelle (diff) | |
download | systemd-059d7b6eae827e73c73633bcc40fe74f3696f3f6.tar.xz systemd-059d7b6eae827e73c73633bcc40fe74f3696f3f6.zip |
sd-radv: send RA when prefix is updated
Diffstat (limited to 'src/libsystemd-network/sd-radv.c')
-rw-r--r-- | src/libsystemd-network/sd-radv.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c index f8ffb6358f..a305171902 100644 --- a/src/libsystemd-network/sd-radv.c +++ b/src/libsystemd-network/sd-radv.c @@ -617,7 +617,8 @@ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) { strna(addr_p), FORMAT_TIMESPAN(p->lifetime_preferred_usec, USEC_PER_SEC), FORMAT_TIMESPAN(p->lifetime_valid_usec, USEC_PER_SEC)); - return 0; + + goto announce; } _cleanup_free_ char *addr_cur = NULL; @@ -631,19 +632,21 @@ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) { LIST_APPEND(prefix, ra->prefixes, p); ra->n_prefixes++; - if (ra->state == RADV_STATE_IDLE) { - log_radv(ra, "Added prefix %s", strna(addr_p)); + log_radv(ra, "Added prefix %s", strna(addr_p)); + + if (ra->state == RADV_STATE_IDLE) + return 0; + +announce: + if (ra->ra_sent == 0) return 0; - } /* If RAs have already been sent, send an RA immediately to announce the newly-added prefix */ - if (ra->ra_sent > 0) { - r = radv_send(ra, NULL, ra->lifetime_usec); - if (r < 0) - log_radv_errno(ra, r, "Unable to send Router Advertisement for added prefix: %m"); - else - log_radv(ra, "Sent Router Advertisement for added prefix"); - } + r = radv_send(ra, NULL, ra->lifetime_usec); + if (r < 0) + log_radv_errno(ra, r, "Unable to send Router Advertisement for added prefix: %m"); + else + log_radv(ra, "Sent Router Advertisement for added/updated prefix"); return 0; } @@ -709,7 +712,8 @@ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) { log_radv(ra, "Updated/replaced IPv6 route prefix %s (lifetime: %s)", strna(addr_p), FORMAT_TIMESPAN(p->lifetime_usec, USEC_PER_SEC)); - return 0; + + goto announce; } _cleanup_free_ char *addr_cur = NULL; @@ -723,19 +727,21 @@ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) { LIST_APPEND(prefix, ra->route_prefixes, p); ra->n_route_prefixes++; - if (ra->state == RADV_STATE_IDLE) { - log_radv(ra, "Added route prefix %s", strna(addr_p)); + log_radv(ra, "Added route prefix %s", strna(addr_p)); + + if (ra->state == RADV_STATE_IDLE) + return 0; + +announce: + if (ra->ra_sent == 0) return 0; - } /* If RAs have already been sent, send an RA immediately to announce the newly-added route prefix */ - if (ra->ra_sent > 0) { - r = radv_send(ra, NULL, ra->lifetime_usec); - if (r < 0) - log_radv_errno(ra, r, "Unable to send Router Advertisement for added route prefix: %m"); - else - log_radv(ra, "Sent Router Advertisement for added route prefix"); - } + r = radv_send(ra, NULL, ra->lifetime_usec); + if (r < 0) + log_radv_errno(ra, r, "Unable to send Router Advertisement for added route prefix: %m"); + else + log_radv(ra, "Sent Router Advertisement for added route prefix"); return 0; } |