diff --git a/ChangeLog b/ChangeLog index 117f429502..113de15777 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-09-28 Dan Williams + + * src/NetworkManager.c + src/NetworkManagerDevice.c + src/NetworkManagerPolicy.c + - Don't blow away an active wired connection on startup + 2004-09-28 Bryan Clark Changes from J5 diff --git a/src/NetworkManager.c b/src/NetworkManager.c index e1662166c4..0de5cdb5ab 100644 --- a/src/NetworkManager.c +++ b/src/NetworkManager.c @@ -118,7 +118,14 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, cons nm_device_get_iface (dev), nm_device_is_wireless (dev) ? "wireless" : "wired" ); data->dev_list = g_slist_append (data->dev_list, dev); - nm_device_deactivate (dev, TRUE); + + /* We don't take down wired devices that are already set up when NetworkManager gets + * launched. Plays better with the system. + * + * FIXME: IPv6 here too + */ + if (!(data->starting_up && nm_device_is_wired (dev) && nm_device_get_ip4_address (dev))) + nm_device_deactivate (dev, TRUE); nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__); @@ -452,6 +459,7 @@ static NMData *nm_data_new (gboolean enable_test_devices) data->state_modified = TRUE; data->enable_test_devices = enable_test_devices; + data->starting_up = TRUE; return (data); } diff --git a/src/NetworkManager.h b/src/NetworkManager.h index d63f8af44a..c1f510aec3 100644 --- a/src/NetworkManager.h +++ b/src/NetworkManager.h @@ -34,6 +34,7 @@ typedef struct NMData DBusConnection *dbus_connection; gboolean info_daemon_avail; gboolean enable_test_devices; + gboolean starting_up; /* Hack for not taking down an already-set-up wired device when we launch */ GSList *dev_list; GMutex *dev_list_mutex; diff --git a/src/NetworkManagerDevice.c b/src/NetworkManagerDevice.c index 1683688994..f5afc14702 100644 --- a/src/NetworkManagerDevice.c +++ b/src/NetworkManagerDevice.c @@ -329,6 +329,7 @@ NMDevice *nm_device_new (const char *iface, gboolean test_dev, NMDeviceType test } /* Grab IP config data for this device from the system configuration files */ + nm_device_update_ip4_address (dev); nm_system_device_update_config_info (dev); /* Have to bring the device up before checking link status. */ @@ -585,8 +586,6 @@ char * nm_device_get_essid (NMDevice *dev) { int iwlib_socket; int err; - struct iwreq wreq; - char essid[IW_ESSID_MAX_SIZE + 1]; g_return_val_if_fail (dev != NULL, NULL); g_return_val_if_fail (nm_device_is_wireless (dev), NULL); @@ -1093,6 +1092,20 @@ gboolean nm_device_activation_begin (NMDevice *dev) /* Ref the device so it doesn't go away while worker function is active */ nm_device_ref (dev); + /* Don't attempt to actually activate if we are just starting NetworkManager and + * we are about to activate a wired device that's already configured. Plays nicer + * with the system when NM is started after a network is already set up. + * + * FIXME: IPv6 here too, and this really should not be here, it should be part of + * the policy, not the device code itself. + */ + if (data->starting_up && nm_device_is_wired (data->active_device) && nm_device_get_ip4_address (data->active_device)) + { + dev->activating = FALSE; + dev->just_activated = TRUE; + return (TRUE); + } + /* Reset communication flags between worker and main thread */ dev->activating = TRUE; dev->just_activated = FALSE; @@ -1130,7 +1143,6 @@ gboolean nm_device_activation_should_cancel (NMDevice *dev) syslog (LOG_DEBUG, "nm_device_activation_worker(%s): activation canceled.", nm_device_get_iface (dev)); dev->activating = FALSE; dev->just_activated = FALSE; - nm_device_unref (dev); return (TRUE); } @@ -1365,7 +1377,10 @@ static gpointer nm_device_activation_worker (gpointer user_data) /* If we were told to quit activation, stop the thread and return */ if (nm_device_activation_should_cancel (dev)) + { + nm_device_unref (dev); return (NULL); + } /* Since we've got a link, the encryption method must be good */ nm_ap_set_enc_method_good (nm_device_get_best_ap (dev), TRUE); @@ -1399,7 +1414,10 @@ static gpointer nm_device_activation_worker (gpointer user_data) /* If we were told to quit activation, stop the thread and return */ if (nm_device_activation_should_cancel (dev)) + { + nm_device_unref (dev); return (NULL); + } /* Make system aware of any new DNS settings from resolv.conf */ nm_system_update_dns (); @@ -1407,7 +1425,10 @@ static gpointer nm_device_activation_worker (gpointer user_data) /* If we were told to quit activation, stop the thread and return */ if (nm_device_activation_should_cancel (dev)) + { + nm_device_unref (dev); return (NULL); + } dev->just_activated = TRUE; syslog (LOG_DEBUG, "nm_device_activation_worker(%s): device activated", nm_device_get_iface (dev)); diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c index 1eddd017f4..30754e4a87 100644 --- a/src/NetworkManagerPolicy.c +++ b/src/NetworkManagerPolicy.c @@ -329,5 +329,11 @@ gboolean nm_state_modification_monitor (gpointer user_data) syslog (LOG_INFO, "nm_state_modification_monitor() activated device %s", nm_device_get_iface (data->active_device)); } + /* Clear the starting up flag, so we will now take over and have our way with + * any device we find out about. + */ + if (data->starting_up) + data->starting_up = FALSE; + return (TRUE); }