From 00117f8811da627d62c77ad8ec0589c007a72bc6 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 13 May 2022 20:21:21 +0900 Subject: [PATCH] network: split out link_is_ready_to_create_stacked_netdev() Preparation for later commits. --- src/network/netdev/netdev.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index f015168692..7882cbc364 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -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); -- 2.25.1