[PATCH] device: restart the DHCP transaction when the carrier goes up during the defer period



This makes NetworkManager recover on brief carrier toggle following a DHCP outage.

  NetworkManager[1106]: <info> (eth0): link connected
  NetworkManager[1106]: <info> (eth0): device state change: unavailable -> disconnected (reason 
'carrier-changed') [20 30 40]
  NetworkManager[1106]: <info> Auto-activating connection 'Wired connection 1'.
  NetworkManager[1106]: <info> Activation (eth0) starting connection 'Wired connection 1'
  NetworkManager[1106]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) scheduled...
  NetworkManager[1106]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) started...
  NetworkManager[1106]: <info> (eth0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
  NetworkManager[1106]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) scheduled...
  NetworkManager[1106]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) complete.
  NetworkManager[1106]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) starting...
  NetworkManager[1106]: <info> (eth0): device state change: prepare -> config (reason 'none') [40 50 0]
  NetworkManager[1106]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) successful.
  NetworkManager[1106]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) scheduled.
  NetworkManager[1106]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) complete.
  NetworkManager[1106]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) started...
  NetworkManager[1106]: <info> (eth0): device state change: config -> ip-config (reason 'none') [50 70 0]
  NetworkManager[1106]: <info> Activation (eth0) Beginning DHCPv4 transaction (timeout in 45 seconds)
  NetworkManager[1106]: <info> dhclient started with pid 4044
  NetworkManager[1106]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) complete.
  NetworkManager[1106]: <info> (eth0): DHCPv4 state changed nbi -> preinit
  dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
  dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
  dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
  dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 15
  dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 14
  NetworkManager[1106]: <info> (eth0): link disconnected (deferring action for 4 seconds)
  NetworkManager[1106]: <info> (eth0): link connected
  NetworkManager[1106]: <warn> (eth0): DHCPv4 request timed out.
  NetworkManager[1106]: <info> (eth0): canceled DHCP transaction, DHCP client pid 4044
  NetworkManager[1106]: <info> Activation (eth0) Stage 4 of 5 (IPv4 Configure Timeout) scheduled...
  NetworkManager[1106]: <info> Activation (eth0) Stage 4 of 5 (IPv4 Configure Timeout) started...
  NetworkManager[1106]: <info> Activation (eth0) Stage 4 of 5 (IPv4 Configure Timeout) complete.

Reported-by: Jean-Christian de Rivaz <jc eclis ch>
---
Hi Jean-Christian,

I think something like this could help.

Lubo

 src/devices/nm-device.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 913c488..53ddb66 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1295,6 +1295,10 @@ link_disconnect_action_cancel (NMDevice *self)
                g_source_remove (priv->carrier_defer_id);
                _LOGD (LOGD_DEVICE, "link disconnected (canceling deferred action) (id=%u)", 
priv->carrier_defer_id);
                priv->carrier_defer_id = 0;
+
+               /* Don't let the DHCP requests that were lost while the carrier was down
+                * contribute to the DHCP timeout -- restart the transaction. */
+               update_dynamic_ip_setup (self);
        }
 }
 
-- 
2.4.3



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]