From f28a0df4a66e8f6c98327691c9c90df0604bbd28 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 9 Sep 2009 07:44:21 -0700 Subject: [PATCH] ppp: ignore certain pppd status changes We don't actually care when pppd goes into the 'network' phase or the 'authenticate' phase, because we're looking for the IP4 configuration to come back, and the device is already in the IP_CONFIG state. Handling those phases would cause the device's state to jump around between NEED_AUTH and IP_CONFIG when we were already past that phase. Specifically, when the PPP link went down, the device would jump from FAILED to IP_CONFIG because pppd entered the 'network' phase when cleaning up the link. The device would also jump from IP_CONFIG to NEED_AUTH during the connection process when we already had secrets. --- src/modem-manager/nm-modem.c | 10 ++++------ src/nm-device-bt.c | 10 ++++------ src/nm-device-ethernet.c | 10 ++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/modem-manager/nm-modem.c b/src/modem-manager/nm-modem.c index 52b35bfc26..bb94c35b83 100644 --- a/src/modem-manager/nm-modem.c +++ b/src/modem-manager/nm-modem.c @@ -105,18 +105,12 @@ ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_ NMDevice *device = NM_DEVICE (user_data); switch (status) { - case NM_PPP_STATUS_NETWORK: - nm_device_state_changed (device, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); - break; case NM_PPP_STATUS_DISCONNECT: nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_DISCONNECT); break; case NM_PPP_STATUS_DEAD: nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED); break; - case NM_PPP_STATUS_AUTHENTICATE: - nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); - break; default: break; } @@ -135,6 +129,10 @@ ppp_ip4_config (NMPPPManager *ppp_manager, guint32 bad_dns2 = htonl (0x0A0B0C0E); guint32 good_dns2 = htonl (0x04020202); /* GTE nameserver */ + /* Ignore PPP IP4 events that come in after initial configuration */ + if (nm_device_get_state (device) != NM_DEVICE_STATE_IP_CONFIG) + return; + /* Work around a PPP bug (#1732) which causes many mobile broadband * providers to return 10.11.12.13 and 10.11.12.14 for the DNS servers. * Apparently fixed in ppp-2.4.5 but we've had some reports that this is diff --git a/src/nm-device-bt.c b/src/nm-device-bt.c index 43e3a44eb3..d50f4c3a70 100644 --- a/src/nm-device-bt.c +++ b/src/nm-device-bt.c @@ -287,18 +287,12 @@ ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_ NMDevice *device = NM_DEVICE (user_data); switch (status) { - case NM_PPP_STATUS_NETWORK: - nm_device_state_changed (device, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); - break; case NM_PPP_STATUS_DISCONNECT: nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_DISCONNECT); break; case NM_PPP_STATUS_DEAD: nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED); break; - case NM_PPP_STATUS_AUTHENTICATE: - nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); - break; default: break; } @@ -312,6 +306,10 @@ ppp_ip4_config (NMPPPManager *ppp_manager, { NMDevice *device = NM_DEVICE (user_data); + /* Ignore PPP IP4 events that come in after initial configuration */ + if (nm_device_get_state (device) != NM_DEVICE_STATE_IP_CONFIG) + return; + nm_device_set_ip_iface (device, iface); NM_DEVICE_BT_GET_PRIVATE (device)->pending_ip4_config = g_object_ref (config); nm_device_activate_schedule_stage4_ip4_config_get (device); diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c index ef4d58e15e..acd033cf8d 100644 --- a/src/nm-device-ethernet.c +++ b/src/nm-device-ethernet.c @@ -1229,18 +1229,12 @@ ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_ NMDevice *device = NM_DEVICE (user_data); switch (status) { - case NM_PPP_STATUS_NETWORK: - nm_device_state_changed (device, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); - break; case NM_PPP_STATUS_DISCONNECT: nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_DISCONNECT); break; case NM_PPP_STATUS_DEAD: nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED); break; - case NM_PPP_STATUS_AUTHENTICATE: - nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); - break; default: break; } @@ -1254,6 +1248,10 @@ ppp_ip4_config (NMPPPManager *ppp_manager, { NMDevice *device = NM_DEVICE (user_data); + /* Ignore PPP IP4 events that come in after initial configuration */ + if (nm_device_get_state (device) != NM_DEVICE_STATE_IP_CONFIG) + return; + nm_device_set_ip_iface (device, iface); NM_DEVICE_ETHERNET_GET_PRIVATE (device)->pending_ip4_config = g_object_ref (config); nm_device_activate_schedule_stage4_ip4_config_get (device);