]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: always call address ready callback if address is ready
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Sep 2021 06:57:55 +0000 (15:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 11 Sep 2021 01:49:11 +0000 (10:49 +0900)
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.

src/network/networkd-address.c

index 5125c60b86cbcff9ef016e2e519cf07122a816d3..1b8f52fcbfd8061d559ed9d24790ecd5cb9e2cd4 100644 (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;
 }