]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: enable IP masquerade when address is assigned
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Sep 2021 06:39:41 +0000 (15:39 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 11 Sep 2021 01:49:11 +0000 (10:49 +0900)
Previously, IP masquerade is enabled when configuring the address. But,
the request of assigning the address may be refused by kernel.

src/network/networkd-address.c

index 714fd8ccc2cb86bb2e7e41ccfa5276e648a46c41..08f0982ff0f12615c550f57e069c82a00e427239 100644 (file)
@@ -454,6 +454,10 @@ static int address_update(Address *address, const Address *src) {
         if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
                 return 0;
 
+        r = address_set_masquerade(address, true);
+        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);
 
@@ -1290,10 +1294,6 @@ int request_process_address(Request *req) {
                         return r;
         }
 
-        r = address_set_masquerade(a, true);
-        if (r < 0)
-                log_link_warning_errno(link, r, "Could not enable IP masquerading, ignoring: %m");
-
         return 1;
 }