]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/address: slightly optimize link_address_is_dynamic()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 1 Nov 2024 16:01:30 +0000 (01:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 4 Nov 2024 17:55:03 +0000 (02:55 +0900)
src/network/networkd-address.c

index d580840a26ea60696c44a333c48b4c52ee3068d8..452258891cf1dc6ef6df12346ddddbd08886dd14 100644 (file)
@@ -1270,6 +1270,10 @@ bool link_address_is_dynamic(const Link *link, const Address *address) {
         if (address->lifetime_preferred_usec != USEC_INFINITY)
                 return true;
 
+        /* There is no way to drtermine if the IPv6 address is dynamic when the lifetime is infinity. */
+        if (address->family != AF_INET)
+                return false;
+
         /* Even when the address is leased from a DHCP server, networkd assign the address
          * without lifetime when KeepConfiguration=dhcp. So, let's check that we have
          * corresponding routes with RTPROT_DHCP. */
@@ -1277,7 +1281,7 @@ bool link_address_is_dynamic(const Link *link, const Address *address) {
                 if (route->source != NETWORK_CONFIG_SOURCE_FOREIGN)
                         continue;
 
-                /* The route is not assigned yet, or already removed. Ignoring. */
+                /* The route is not assigned yet, or already being removed. Ignoring. */
                 if (!route_exists(route))
                         continue;