]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: address: do not set IFA_F_PERMANENT flag
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 12 Feb 2021 05:44:42 +0000 (14:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 12 Feb 2021 14:09:21 +0000 (23:09 +0900)
The flag is automatically set by kernel when the valid lifetime is
infinite. Note that the flag in netlink message for IPv4 address is
ignored. See set_ifa_lifetime() in kernel's net/ipv4/devinet.c.
But the flag is honored for IPv6 address. And if the flag is set with
finite valid lifetime, the address will not removed automatically by
the kernel.

src/network/networkd-address.c

index c3e92d987193316d9a0e1e00acba49d04f0c32d5..d857b6d8794e3e90116f39c24c7f62faf76e3888 100644 (file)
@@ -518,7 +518,6 @@ static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link
 }
 
 static int address_set_netlink_message(const Address *address, sd_netlink_message *req, Link *link) {
-        uint32_t flags;
         int r;
 
         assert(address);
@@ -532,13 +531,12 @@ static int address_set_netlink_message(const Address *address, sd_netlink_messag
         /* On remove, only IFA_F_MANAGETEMPADDR flag for IPv6 addresses are used. But anyway, set all
          * flags here unconditionally. Without setting the flag, the template addresses generated by
          * kernel will not be removed automatically when the main address is removed. */
-        flags = address->flags | IFA_F_PERMANENT;
-        r = sd_rtnl_message_addr_set_flags(req, flags & 0xff);
+        r = sd_rtnl_message_addr_set_flags(req, address->flags & 0xff);
         if (r < 0)
                 return log_link_error_errno(link, r, "Could not set flags: %m");
 
-        if (flags & ~0xff) {
-                r = sd_netlink_message_append_u32(req, IFA_FLAGS, flags);
+        if ((address->flags & ~0xff) != 0) {
+                r = sd_netlink_message_append_u32(req, IFA_FLAGS, address->flags);
                 if (r < 0)
                         return log_link_error_errno(link, r, "Could not set extended flags: %m");
         }