1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-26 03:22:00 +03:00

network: check if interface is initialized after enumeration completed

We enumerate interfaces at first, then enumerate other configurations
like addresses and so on. If we are running on a container, previously
we started to configure the enumerated interfaces before enumerating other
configurations.
Let's configure interfaces after all configurations are enumerated.
This commit is contained in:
Yu Watanabe 2024-11-02 06:31:25 +09:00
parent 30d5d11be0
commit 9c402e3ae2
3 changed files with 22 additions and 1 deletions

View File

@ -1636,7 +1636,7 @@ static int link_initialized(Link *link, sd_device *device) {
return link_call_getlink(link, link_initialized_handler);
}
static int link_check_initialized(Link *link) {
int link_check_initialized(Link *link) {
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
int r;
@ -2836,6 +2836,10 @@ int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Man
return 0;
}
/* Do not enter initialized state if we are enumerating. */
if (manager->enumerating)
return 0;
r = link_check_initialized(link);
if (r < 0) {
log_link_warning_errno(link, r, "Failed to check link is initialized: %m");
@ -2858,6 +2862,10 @@ int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Man
return 0;
}
/* Do not configure interface if we are enumerating. */
if (manager->enumerating)
return 0;
r = link_reconfigure_impl(link, /* force = */ false);
if (r < 0) {
log_link_warning_errno(link, r, "Failed to reconfigure interface: %m");

View File

@ -263,6 +263,8 @@ int link_reconfigure_impl(Link *link, bool force);
int link_reconfigure(Link *link, bool force);
int link_reconfigure_on_bus_method_reload(Link *link, sd_bus_message *message);
int link_check_initialized(Link *link);
int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t action);
int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);

View File

@ -756,6 +756,17 @@ int manager_start(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to initialize speed meter: %m");
HASHMAP_FOREACH(link, m->links_by_index) {
if (link->state != LINK_STATE_PENDING)
continue;
r = link_check_initialized(link);
if (r < 0) {
log_link_warning_errno(link, r, "Failed to check if link is initialized: %m");
link_enter_failed(link);
}
}
/* The dirty handler will deal with future serialization, but the first one
must be done explicitly. */