summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-30 00:52:09 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-31 09:29:42 +0900
commitb732606950f8726c0280080c7d055a714c2888f5 (patch)
tree353657948ee91663e518683004127cb459737bbb /src/network/networkd-link.c
parenta14b9ca2c38ddf55bf22b0103e3bae361bf9b8fc (diff)
downloadsystemd-b732606950f8726c0280080c7d055a714c2888f5.tar.gz
network: automatically determine timeout of waiting for carrier regain
The commit 6706ce2fd2a13df0ae5e469b72d688eaf643dac4 made IgnoreCarrierLoss= setting also take timespan, to make users handle issues like #18738 or #20887. But still users needed to explicitly set a timespan. This makes networkd automatically determine the timeout when the situations #18738 or #19832 is detected. Unfortunately, still users have issue #20887 need to specify a value. Closes #19832.
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c30
1 files changed, 27 insertions, 3 deletions
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,