diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-03-31 04:40:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-31 04:40:30 +0200 |
commit | b2e7ded16b16181767822d471d214cd8eba3c2d5 (patch) | |
tree | 5d16a58f5666e046d077e6df231285b6827f2c19 /src/network | |
parent | Merge pull request #22913 from yuwata/sd-device-cleanups (diff) | |
parent | network: shorten code a bit (diff) | |
download | systemd-b2e7ded16b16181767822d471d214cd8eba3c2d5.tar.xz systemd-b2e7ded16b16181767822d471d214cd8eba3c2d5.zip |
Merge pull request #22899 from yuwata/network-ignore-carrier-loss
network: automatically determine timeout of waiting for carrier regain
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-dhcp4.c | 12 | ||||
-rw-r--r-- | src/network/networkd-link.c | 30 |
2 files changed, 28 insertions, 14 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 6bfcf67dd9..d3fd2571e0 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -735,7 +735,6 @@ static int dhcp4_request_routes(Link *link) { } static int dhcp_reset_mtu(Link *link) { - uint16_t mtu; int r; assert(link); @@ -743,18 +742,9 @@ static int dhcp_reset_mtu(Link *link) { if (!link->network->dhcp_use_mtu) return 0; - r = sd_dhcp_lease_get_mtu(link->dhcp_lease, &mtu); - if (r == -ENODATA) - return 0; - if (r < 0) - return log_link_error_errno(link, r, "DHCP error: failed to get MTU from lease: %m"); - - if (link->original_mtu == mtu) - return 0; - r = link_request_to_set_mtu(link, link->original_mtu); if (r < 0) - return log_link_error_errno(link, r, "DHCP error: could not reset MTU: %m"); + return log_link_error_errno(link, r, "DHCP error: Could not queue request to reset MTU: %m"); return 0; } diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index d509855f48..73850cdea5 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1636,6 +1636,8 @@ static int link_carrier_lost_handler(sd_event_source *s, uint64_t usec, void *us } static int link_carrier_lost(Link *link) { + uint16_t dhcp_mtu; + usec_t usec; int r; assert(link); @@ -1651,16 +1653,38 @@ static int link_carrier_lost(Link *link) { if (!link->network) return 0; - if (link->network->ignore_carrier_loss_usec == USEC_INFINITY) + if (link->network->ignore_carrier_loss_set) + /* If IgnoreCarrierLoss= is explicitly specified, then use the specified value. */ + usec = link->network->ignore_carrier_loss_usec; + + else if (link->network->bond && link->wlan_iftype > 0) + /* Enslaving wlan interface to a bond disconnects from the connected AP, and causes its + * carrier to be lost. See #19832. */ + usec = 3 * USEC_PER_SEC; + + else if (link->network->dhcp_use_mtu && + link->dhcp_lease && + sd_dhcp_lease_get_mtu(link->dhcp_lease, &dhcp_mtu) >= 0 && + dhcp_mtu != link->original_mtu) + /* Some drivers reset interfaces when changing MTU. Resetting interfaces by the static + * MTU should not cause any issues, as MTU is changed only once. However, setting MTU + * through DHCP lease causes an infinite loop of resetting the interface. See #18738. */ + usec = 5 * USEC_PER_SEC; + + else + /* Otherwise, use the currently set value. */ + usec = link->network->ignore_carrier_loss_usec; + + if (usec == USEC_INFINITY) return 0; - if (link->network->ignore_carrier_loss_usec == 0) + if (usec == 0) return link_carrier_lost_impl(link); return event_reset_time_relative(link->manager->event, &link->carrier_lost_timer, CLOCK_BOOTTIME, - link->network->ignore_carrier_loss_usec, + usec, 0, link_carrier_lost_handler, link, |