]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: split out link_is_ready_to_create_stacked_netdev()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 13 May 2022 11:21:21 +0000 (20:21 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 5 Aug 2022 12:49:27 +0000 (21:49 +0900)
Preparation for later commits.

src/network/netdev/netdev.c

index f015168692b318a826f83da4e61b269ab176cf0f..7882cbc3645539dd9172d51b08147e14b8d2aa67 100644 (file)
@@ -604,24 +604,31 @@ static int stacked_netdev_create(NetDev *netdev, Link *link, Request *req) {
         return 0;
 }
 
+static bool link_is_ready_to_create_stacked_netdev(Link *link) {
+        assert(link);
+
+        if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
+                return false;
+
+        if (link->set_link_messages > 0)
+                return false;
+
+        /* If stacked netdevs are created before the underlying interface being activated, then
+         * the activation policy for the netdevs are ignored. See issue #22593. */
+        if (!link->activated)
+                return false;
+
+        return true;
+}
+
 static int netdev_is_ready_to_create(NetDev *netdev, Link *link) {
         assert(netdev);
 
         if (netdev->state != NETDEV_STATE_LOADING)
                 return false;
 
-        if (link) {
-                if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
-                        return false;
-
-                if (link->set_link_messages > 0)
-                        return false;
-
-                /* If stacked netdevs are created before the underlying interface being activated, then
-                 * the activation policy for the netdevs are ignored. See issue #22593. */
-                if (!link->activated)
-                        return false;
-        }
+        if (link && !link_is_ready_to_create_stacked_netdev(link))
+                return false;
 
         if (NETDEV_VTABLE(netdev)->is_ready_to_create)
                 return NETDEV_VTABLE(netdev)->is_ready_to_create(netdev, link);