mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-25 23:21:33 +03:00
network: try to reconfigure when some information is updated
When at least one of the name, MAC address, udev properties, and so on for an interface is updated, try to find a matching .network file, and reconfigure if a new .network file is assigned. Fixes #24975.
This commit is contained in:
parent
6625c39e70
commit
4069545727
@ -1367,21 +1367,18 @@ static int link_initialized_and_synced(Link *link) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This may get called either from the asynchronous netlink callback,
|
||||
* or directly from link_check_initialized() if running in a container. */
|
||||
if (!IN_SET(link->state, LINK_STATE_PENDING, LINK_STATE_INITIALIZED))
|
||||
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);
|
||||
|
||||
log_link_debug(link, "Link state is up-to-date");
|
||||
link_set_state(link, LINK_STATE_INITIALIZED);
|
||||
r = link_new_bound_by_list(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = link_new_bound_by_list(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = link_handle_bound_by_list(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = link_handle_bound_by_list(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return link_reconfigure_impl(link, /* force = */ false);
|
||||
}
|
||||
@ -1414,14 +1411,10 @@ static int link_initialized(Link *link, sd_device *device) {
|
||||
if (r < 0)
|
||||
log_link_warning_errno(link, r, "Failed to manage SR-IOV PF and VF ports, ignoring: %m");
|
||||
|
||||
/* Do not ignore unamanaged state case here. If an interface is renamed after being once
|
||||
* configured, and the corresponding .network file has Name= in [Match] section, then the
|
||||
* interface may be already in unmanaged state. See #20657. */
|
||||
if (!IN_SET(link->state, LINK_STATE_PENDING, LINK_STATE_UNMANAGED))
|
||||
return 0;
|
||||
if (link->state != LINK_STATE_PENDING)
|
||||
return link_reconfigure(link, /* force = */ false);
|
||||
|
||||
log_link_debug(link, "udev initialized link");
|
||||
link_set_state(link, LINK_STATE_INITIALIZED);
|
||||
|
||||
/* udev has initialized the link, but we don't know if we have yet
|
||||
* processed the NEWLINK messages with the latest state. Do a GETLINK,
|
||||
@ -2063,7 +2056,7 @@ static int link_update_driver(Link *link, sd_netlink_message *message) {
|
||||
link->dsa_master_ifindex = (int) dsa_master_ifindex;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1; /* needs reconfigure */
|
||||
}
|
||||
|
||||
static int link_update_permanent_hardware_address_from_ethtool(Link *link, sd_netlink_message *message) {
|
||||
@ -2122,7 +2115,7 @@ static int link_update_permanent_hardware_address(Link *link, sd_netlink_message
|
||||
if (link->permanent_hw_addr.length > 0)
|
||||
log_link_debug(link, "Saved permanent hardware address: %s", HW_ADDR_TO_STR(&link->permanent_hw_addr));
|
||||
|
||||
return 0;
|
||||
return 1; /* needs reconfigure */
|
||||
}
|
||||
|
||||
static int link_update_hardware_address(Link *link, sd_netlink_message *message) {
|
||||
@ -2205,7 +2198,7 @@ static int link_update_hardware_address(Link *link, sd_netlink_message *message)
|
||||
return log_link_debug_errno(link, r, "Could not update MAC address for LLDP Tx: %m");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1; /* needs reconfigure */
|
||||
}
|
||||
|
||||
static int link_update_mtu(Link *link, sd_netlink_message *message) {
|
||||
@ -2297,7 +2290,7 @@ static int link_update_alternative_names(Link *link, sd_netlink_message *message
|
||||
return log_link_debug_errno(link, r, "Failed to manage link by its new alternative names: %m");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1; /* needs reconfigure */
|
||||
}
|
||||
|
||||
static int link_update_name(Link *link, sd_netlink_message *message) {
|
||||
@ -2393,10 +2386,11 @@ static int link_update_name(Link *link, sd_netlink_message *message) {
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r, "Failed to update interface name in IPv4ACD client: %m");
|
||||
|
||||
return 0;
|
||||
return 1; /* needs reconfigure */
|
||||
}
|
||||
|
||||
static int link_update(Link *link, sd_netlink_message *message) {
|
||||
bool needs_reconfigure = false;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
@ -2405,10 +2399,12 @@ static int link_update(Link *link, sd_netlink_message *message) {
|
||||
r = link_update_name(link, message);
|
||||
if (r < 0)
|
||||
return r;
|
||||
needs_reconfigure = needs_reconfigure || r > 0;
|
||||
|
||||
r = link_update_alternative_names(link, message);
|
||||
if (r < 0)
|
||||
return r;
|
||||
needs_reconfigure = needs_reconfigure || r > 0;
|
||||
|
||||
r = link_update_mtu(link, message);
|
||||
if (r < 0)
|
||||
@ -2417,14 +2413,17 @@ static int link_update(Link *link, sd_netlink_message *message) {
|
||||
r = link_update_driver(link, message);
|
||||
if (r < 0)
|
||||
return r;
|
||||
needs_reconfigure = needs_reconfigure || r > 0;
|
||||
|
||||
r = link_update_permanent_hardware_address(link, message);
|
||||
if (r < 0)
|
||||
return r;
|
||||
needs_reconfigure = needs_reconfigure || r > 0;
|
||||
|
||||
r = link_update_hardware_address(link, message);
|
||||
if (r < 0)
|
||||
return r;
|
||||
needs_reconfigure = needs_reconfigure || r > 0;
|
||||
|
||||
r = link_update_master(link, message);
|
||||
if (r < 0)
|
||||
@ -2434,7 +2433,11 @@ static int link_update(Link *link, sd_netlink_message *message) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return link_update_flags(link, message);
|
||||
r = link_update_flags(link, message);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return needs_reconfigure;
|
||||
}
|
||||
|
||||
static Link *link_drop_or_unref(Link *link) {
|
||||
@ -2623,6 +2626,14 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user