1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

sd-radv: send RA when prefix is updated

This commit is contained in:
Yu Watanabe 2021-12-18 07:52:30 +09:00
parent c0a2e0cc24
commit 059d7b6eae

View File

@ -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;
}