diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-11-01 22:23:55 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-11-04 18:55:15 +0100 |
commit | 30d5d11be0ba7a0c6e7c7d3047cd501e42c24c22 (patch) | |
tree | 83bce08b6815e4c346d6391fc66fb1dc035ccf31 /src | |
parent | network: introduce network_config_source_from_string() (diff) | |
download | systemd-30d5d11be0ba7a0c6e7c7d3047cd501e42c24c22.tar.xz systemd-30d5d11be0ba7a0c6e7c7d3047cd501e42c24c22.zip |
network: check earlier if we are running in test mode
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-link.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 432084038f..bc4374b42c 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1567,12 +1567,6 @@ static int link_initialized_and_synced(Link *link) { assert(link); assert(link->manager); - if (link->manager->test_mode) { - log_link_debug(link, "Running in test mode, refusing to enter initialized state."); - link_set_state(link, LINK_STATE_UNMANAGED); - return 0; - } - if (link->state == LINK_STATE_PENDING) { log_link_debug(link, "Link state is up-to-date"); link_set_state(link, LINK_STATE_INITIALIZED); @@ -2836,6 +2830,12 @@ int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Man return 0; } + if (link->manager->test_mode) { + log_link_debug(link, "Running in test mode, refusing to enter initialized state."); + link_set_state(link, LINK_STATE_UNMANAGED); + return 0; + } + r = link_check_initialized(link); if (r < 0) { log_link_warning_errno(link, r, "Failed to check link is initialized: %m"); @@ -2849,13 +2849,20 @@ int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Man link_enter_failed(link); return 0; } - if (r > 0) { - r = link_reconfigure_impl(link, /* force = */ false); - if (r < 0) { - log_link_warning_errno(link, r, "Failed to reconfigure interface: %m"); - link_enter_failed(link); - return 0; - } + if (r == 0) + return 0; + + if (link->manager->test_mode) { + log_link_debug(link, "Running in test mode, refusing to configure interface."); + link_set_state(link, LINK_STATE_UNMANAGED); + return 0; + } + + r = link_reconfigure_impl(link, /* force = */ false); + if (r < 0) { + log_link_warning_errno(link, r, "Failed to reconfigure interface: %m"); + link_enter_failed(link); + return 0; } } break; |