network: always call address ready callback if address is ready

The address ready callback is used for cleaning up old addresses or
routes acquired by e.g. DHCP. However, the callback was called only
when the address was previously not ready. So, maybe, unnecessary
addresses or routes may not be cleared.

Also, this makes the callback is called slightly earlier. As it may
remove several addresses or routes, and possibly changes the link state.
This commit is contained in:
Yu Watanabe
2021-09-11 10:49:11 +09:00
parent 18d8a33a37
commit 981fab5d0a
+6 -11
View File
@@ -437,7 +437,6 @@ static int address_add(Link *link, const Address *in, Address **ret) {
static int address_update(Address *address, const Address *src) {
Link *link;
bool ready;
int r;
assert(address);
@@ -445,7 +444,6 @@ static int address_update(Address *address, const Address *src) {
assert(src);
link = address->link;
ready = address_is_ready(address);
address->flags = src->flags;
address->scope = src->scope;
@@ -470,17 +468,14 @@ static int address_update(Address *address, const Address *src) {
if (r < 0)
return log_link_warning_errno(link, r, "Could not enable IP masquerading: %m");
link_update_operstate(link, true);
link_check_ready(link);
if (!ready && address_is_ready(address)) {
if (address->callback) {
r = address->callback(address);
if (r < 0)
return r;
}
if (address_is_ready(address) && address->callback) {
r = address->callback(address);
if (r < 0)
return r;
}
link_update_operstate(link, true);
link_check_ready(link);
return 0;
}