2007-03-12 Dan Williams <dcbw@redhat.com>
Get rid of 2 second poll of sysfs 'carrier' file for wired devices. Useless for non-carrier-detect capable devices, and useless for carrier-detect devices since we get notifications from netlink about carrier status anyway. * src/nm-device-802-3-ethernet.c - remove 'link_source_id' member from private data - (probe_link): remove and collapse into real_update_link() - (nm_device_802_3_periodic_update): remove - (real_is_up): check for sup_iface rather than link_source_id - (real_bring_up): return gboolean for success/fail; require that sup_iface be valid for device bringup to succeed - (real_bring_down): zero out link signal ids * src/nm-device.c - (nm_device_activate_stage2_device_config): fail activation if device bringup fails - (real_act_stage4_get_ip4_config): fail activation if device bringup fails - (nm_device_bring_up): return success/fail * src/nm-device.h - bring_up now returns success/fail * src/nm-device-802-11-wireless.c - (real_bring_up): return success from bringup git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2464 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
28
ChangeLog
28
ChangeLog
@@ -1,3 +1,31 @@
|
||||
2007-03-12 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Get rid of 2 second poll of sysfs 'carrier' file for wired devices. Useless
|
||||
for non-carrier-detect capable devices, and useless for carrier-detect
|
||||
devices since we get notifications from netlink about carrier status anyway.
|
||||
|
||||
* src/nm-device-802-3-ethernet.c
|
||||
- remove 'link_source_id' member from private data
|
||||
- (probe_link): remove and collapse into real_update_link()
|
||||
- (nm_device_802_3_periodic_update): remove
|
||||
- (real_is_up): check for sup_iface rather than link_source_id
|
||||
- (real_bring_up): return gboolean for success/fail; require that
|
||||
sup_iface be valid for device bringup to succeed
|
||||
- (real_bring_down): zero out link signal ids
|
||||
|
||||
* src/nm-device.c
|
||||
- (nm_device_activate_stage2_device_config): fail activation if device
|
||||
bringup fails
|
||||
- (real_act_stage4_get_ip4_config): fail activation if device bringup
|
||||
fails
|
||||
- (nm_device_bring_up): return success/fail
|
||||
|
||||
* src/nm-device.h
|
||||
- bring_up now returns success/fail
|
||||
|
||||
* src/nm-device-802-11-wireless.c
|
||||
- (real_bring_up): return success from bringup
|
||||
|
||||
2007-03-07 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Simon Geard <delgarde@ihug.co.nz> (Gnome.org #394956)
|
||||
|
@@ -570,7 +570,7 @@ real_is_up (NMDevice *device)
|
||||
return NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (device)->periodic_source_id != 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
real_bring_up (NMDevice *dev)
|
||||
{
|
||||
NMDevice80211Wireless *self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
@@ -589,6 +589,8 @@ real_bring_up (NMDevice *dev)
|
||||
|
||||
/* Peridoically update link status and signal strength */
|
||||
priv->periodic_source_id = g_timeout_add (2000, nm_device_802_11_periodic_update, self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -53,7 +53,6 @@ typedef struct {
|
||||
char * carrier_file_path;
|
||||
gulong link_connected_id;
|
||||
gulong link_disconnected_id;
|
||||
guint link_source_id;
|
||||
|
||||
NMSupplicantInterface * sup_iface;
|
||||
} NMDevice8023EthernetPrivate;
|
||||
@@ -100,7 +99,6 @@ nm_device_802_3_ethernet_init (NMDevice8023Ethernet * self)
|
||||
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
|
||||
|
||||
priv->dispose_has_run = FALSE;
|
||||
priv->link_source_id = 0;
|
||||
|
||||
memset (&(priv->hw_addr), 0, sizeof (struct ether_addr));
|
||||
|
||||
@@ -132,93 +130,85 @@ nm_device_802_3_ethernet_link_deactivated (NMNetlinkMonitor *monitor,
|
||||
nm_device_set_active_link (dev, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
probe_link (NMDevice8023Ethernet *self)
|
||||
{
|
||||
gboolean have_link = FALSE;
|
||||
gchar * contents;
|
||||
gsize length;
|
||||
|
||||
if (g_file_get_contents (NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self)->carrier_file_path,
|
||||
&contents, &length, NULL))
|
||||
{
|
||||
have_link = (gboolean) atoi (contents);
|
||||
g_free (contents);
|
||||
}
|
||||
|
||||
/* We say that non-carrier-detect devices always have a link, because
|
||||
* they never get auto-selected by NM. The user has to force them on us,
|
||||
* so we just hope the user knows whether or not the cable's plugged in.
|
||||
*/
|
||||
if (!have_link && !(nm_device_get_capabilities (NM_DEVICE (self)) & NM_DEVICE_CAP_CARRIER_DETECT))
|
||||
have_link = TRUE;
|
||||
|
||||
return have_link;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
real_update_link (NMDevice *dev)
|
||||
{
|
||||
nm_device_set_active_link (dev, probe_link NM_DEVICE_802_3_ETHERNET (dev));
|
||||
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (dev);
|
||||
gboolean have_link = FALSE;
|
||||
guint32 caps;
|
||||
gchar * contents;
|
||||
gsize length;
|
||||
|
||||
/* Devices that don't support carrier detect are always "on" and
|
||||
* must be manually chosen by the user.
|
||||
*/
|
||||
caps = nm_device_get_capabilities (dev);
|
||||
if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT)) {
|
||||
have_link = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (g_file_get_contents (priv->carrier_file_path, &contents, &length, NULL)) {
|
||||
have_link = atoi (contents) > 0 ? TRUE : FALSE;
|
||||
g_free (contents);
|
||||
}
|
||||
|
||||
out:
|
||||
nm_device_set_active_link (dev, have_link);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_device_802_3_periodic_update
|
||||
*
|
||||
* Periodically update device statistics and link state.
|
||||
*
|
||||
*/
|
||||
static gboolean
|
||||
nm_device_802_3_periodic_update (gpointer data)
|
||||
{
|
||||
nm_device_set_active_link (NM_DEVICE (data),
|
||||
probe_link NM_DEVICE_802_3_ETHERNET (data));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
real_is_up (NMDevice *device)
|
||||
{
|
||||
if (!NM_DEVICE_CLASS (nm_device_802_3_ethernet_parent_class)->is_up (device))
|
||||
return FALSE;
|
||||
|
||||
return NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device)->link_source_id != 0;
|
||||
return !!NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device)->sup_iface;
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
real_bring_up (NMDevice *dev)
|
||||
{
|
||||
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (dev);
|
||||
NMNetlinkMonitor *monitor;
|
||||
NMSupplicantManager *sup_mgr;
|
||||
const char *iface;
|
||||
|
||||
monitor = nm_netlink_monitor_get ();
|
||||
priv->link_connected_id = g_signal_connect (monitor, "interface-connected",
|
||||
G_CALLBACK (nm_device_802_3_ethernet_link_activated),
|
||||
dev);
|
||||
priv->link_disconnected_id = g_signal_connect (monitor, "interface-disconnected",
|
||||
G_CALLBACK (nm_device_802_3_ethernet_link_deactivated),
|
||||
dev);
|
||||
g_object_unref (monitor);
|
||||
guint32 caps;
|
||||
|
||||
iface = nm_device_get_iface (dev);
|
||||
sup_mgr = nm_supplicant_manager_get ();
|
||||
priv->sup_iface = nm_supplicant_manager_get_iface (sup_mgr, iface, FALSE);
|
||||
if (priv->sup_iface)
|
||||
g_signal_connect (priv->sup_iface,
|
||||
"state",
|
||||
G_CALLBACK (supplicant_iface_state_cb),
|
||||
dev);
|
||||
else
|
||||
if (!priv->sup_iface) {
|
||||
nm_warning ("Couldn't initialize supplicant interface for %s.", iface);
|
||||
g_object_unref (sup_mgr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_signal_connect (priv->sup_iface,
|
||||
"state",
|
||||
G_CALLBACK (supplicant_iface_state_cb),
|
||||
dev);
|
||||
|
||||
g_object_unref (sup_mgr);
|
||||
|
||||
/* Peridoically update link status */
|
||||
priv->link_source_id = g_timeout_add (2000, nm_device_802_3_periodic_update, dev);
|
||||
caps = nm_device_get_capabilities (dev);
|
||||
if (caps & NM_DEVICE_CAP_CARRIER_DETECT) {
|
||||
/* Only listen to netlink for cards that support carrier detect */
|
||||
NMNetlinkMonitor * monitor = nm_netlink_monitor_get ();
|
||||
priv->link_connected_id = g_signal_connect (monitor, "interface-connected",
|
||||
G_CALLBACK (nm_device_802_3_ethernet_link_activated),
|
||||
dev);
|
||||
priv->link_disconnected_id = g_signal_connect (monitor, "interface-disconnected",
|
||||
G_CALLBACK (nm_device_802_3_ethernet_link_deactivated),
|
||||
dev);
|
||||
g_object_unref (monitor);
|
||||
} else {
|
||||
priv->link_connected_id = 0;
|
||||
priv->link_disconnected_id = 0;
|
||||
nm_device_set_active_link (dev, TRUE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -229,11 +219,6 @@ real_bring_down (NMDevice *dev)
|
||||
NMSupplicantManager *sup_mgr;
|
||||
NMNetlinkMonitor *monitor;
|
||||
|
||||
if (priv->link_source_id) {
|
||||
g_source_remove (priv->link_source_id);
|
||||
priv->link_source_id = 0;
|
||||
}
|
||||
|
||||
sup_mgr = nm_supplicant_manager_get ();
|
||||
nm_supplicant_manager_release_iface (sup_mgr, priv->sup_iface);
|
||||
priv->sup_iface = NULL;
|
||||
@@ -241,7 +226,9 @@ real_bring_down (NMDevice *dev)
|
||||
|
||||
monitor = nm_netlink_monitor_get ();
|
||||
g_signal_handler_disconnect (monitor, priv->link_connected_id);
|
||||
priv->link_connected_id = 0;
|
||||
g_signal_handler_disconnect (monitor, priv->link_disconnected_id);
|
||||
priv->link_disconnected_id = 0;
|
||||
g_object_unref (monitor);
|
||||
}
|
||||
|
||||
|
@@ -487,7 +487,10 @@ nm_device_activate_stage2_device_config (gpointer user_data)
|
||||
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface);
|
||||
nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG);
|
||||
|
||||
nm_device_bring_up (self, FALSE);
|
||||
if (!nm_device_bring_up (self, FALSE)) {
|
||||
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self, req);
|
||||
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
||||
@@ -698,7 +701,8 @@ real_act_stage4_get_ip4_config (NMDevice *self,
|
||||
else
|
||||
{
|
||||
/* Make sure device is up even if config fails */
|
||||
nm_device_bring_up (self, FALSE);
|
||||
if (!nm_device_bring_up (self, FALSE))
|
||||
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1276,13 +1280,15 @@ nm_completion_device_is_up_test (int tries,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
nm_device_bring_up (NMDevice *self, gboolean wait)
|
||||
{
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
||||
|
||||
if (nm_device_is_up (self))
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
nm_info ("Bringing up device %s", nm_device_get_iface (self));
|
||||
|
||||
@@ -1290,8 +1296,11 @@ nm_device_bring_up (NMDevice *self, gboolean wait)
|
||||
nm_device_update_ip4_address (self);
|
||||
nm_device_set_address (self);
|
||||
|
||||
if (NM_DEVICE_GET_CLASS (self)->bring_up)
|
||||
NM_DEVICE_GET_CLASS (self)->bring_up (self);
|
||||
if (NM_DEVICE_GET_CLASS (self)->bring_up) {
|
||||
success = NM_DEVICE_GET_CLASS (self)->bring_up (self);
|
||||
if (!success)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (wait) {
|
||||
nm_completion_args args;
|
||||
@@ -1301,6 +1310,8 @@ nm_device_bring_up (NMDevice *self, gboolean wait)
|
||||
}
|
||||
|
||||
nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -83,7 +83,7 @@ struct _NMDeviceClass
|
||||
void (* update_link) (NMDevice *self);
|
||||
|
||||
gboolean (* is_up) (NMDevice *self);
|
||||
void (* bring_up) (NMDevice *self);
|
||||
gboolean (* bring_up) (NMDevice *self);
|
||||
void (* bring_down) (NMDevice *self);
|
||||
|
||||
void (* set_hw_address) (NMDevice *self);
|
||||
@@ -139,7 +139,7 @@ void nm_device_set_ip4_config (NMDevice *dev,
|
||||
NMIP4Config *config);
|
||||
|
||||
gboolean nm_device_is_up (NMDevice *dev);
|
||||
void nm_device_bring_up (NMDevice *dev, gboolean wait);
|
||||
gboolean nm_device_bring_up (NMDevice *dev, gboolean wait);
|
||||
void nm_device_bring_down (NMDevice *dev, gboolean wait);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user