device: merge branch 'th/device-bring-up-bgo771284'

https://bugzilla.gnome.org/show_bug.cgi?id=771284
This commit is contained in:
Thomas Haller
2016-09-12 18:11:42 +02:00
7 changed files with 49 additions and 106 deletions

View File

@@ -267,20 +267,6 @@ get_generic_capabilities (NMDevice *dev)
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
}
static gboolean
bring_up (NMDevice *dev, gboolean *no_firmware)
{
gboolean success = FALSE;
guint i = 20;
while (i-- > 0 && !success) {
success = NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->bring_up (dev, no_firmware);
g_usleep (50);
}
return success;
}
/******************************************************************/
static gboolean
@@ -616,7 +602,6 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
object_class->set_property = set_property;
device_class->act_stage1_prepare = act_stage1_prepare;
device_class->bring_up = bring_up;
device_class->check_connection_compatible = check_connection_compatible;
device_class->complete_connection = complete_connection;
device_class->connection_type = NM_SETTING_MACVLAN_SETTING_NAME;

View File

@@ -282,20 +282,6 @@ get_generic_capabilities (NMDevice *dev)
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
}
static gboolean
bring_up (NMDevice *dev, gboolean *no_firmware)
{
gboolean success = FALSE;
guint i = 20;
while (i-- > 0 && !success) {
success = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->bring_up (dev, no_firmware);
g_usleep (50);
}
return success;
}
/******************************************************************/
static gboolean
@@ -673,7 +659,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
parent_class->realize_start_notify = realize_start_notify;
parent_class->unrealize_notify = unrealize_notify;
parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->bring_up = bring_up;
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
parent_class->is_available = is_available;

View File

@@ -9093,19 +9093,11 @@ carrier_wait_timeout (gpointer user_data)
static gboolean
nm_device_is_up (NMDevice *self)
{
int ifindex;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
if (NM_DEVICE_GET_CLASS (self)->is_up)
return NM_DEVICE_GET_CLASS (self)->is_up (self);
return TRUE;
}
static gboolean
is_up (NMDevice *self)
{
int ifindex = nm_device_get_ip_ifindex (self);
ifindex = nm_device_get_ip_ifindex (self);
return ifindex > 0 ? nm_platform_link_is_up (NM_PLATFORM_GET, ifindex) : TRUE;
}
@@ -9115,13 +9107,23 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
gboolean device_is_up = FALSE;
NMDeviceCapabilities capabilities;
int ifindex;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
_LOGD (LOGD_HW, "bringing up device");
NM_SET_OUT (no_firmware, FALSE);
if (NM_DEVICE_GET_CLASS (self)->bring_up) {
if (!NM_DEVICE_GET_CLASS (self)->bring_up (self, no_firmware))
if (!nm_device_get_enabled (self)) {
_LOGD (LOGD_HW, "bringing up device ignored due to disabled");
return FALSE;
}
ifindex = nm_device_get_ip_ifindex (self);
_LOGD (LOGD_HW, "bringing up device %d", ifindex);
if (ifindex <= 0) {
/* assume success. */
} else {
if (!nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, no_firmware))
return FALSE;
}
@@ -9131,7 +9133,6 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
device_is_up = nm_device_is_up (self);
if (block && !device_is_up) {
int ifindex = nm_device_get_ip_ifindex (self);
gint64 wait_until = nm_utils_get_monotonic_timestamp_us () + 10000 /* microseconds */;
do {
@@ -9186,40 +9187,26 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
return TRUE;
}
static gboolean
bring_up (NMDevice *self, gboolean *no_firmware)
{
int ifindex = nm_device_get_ip_ifindex (self);
gboolean result;
if (ifindex <= 0) {
if (no_firmware)
*no_firmware = FALSE;
return TRUE;
}
result = nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, no_firmware);
return result;
}
void
nm_device_take_down (NMDevice *self, gboolean block)
{
int ifindex;
gboolean device_is_up;
g_return_if_fail (NM_IS_DEVICE (self));
_LOGD (LOGD_HW, "taking down device");
if (NM_DEVICE_GET_CLASS (self)->take_down) {
if (!NM_DEVICE_GET_CLASS (self)->take_down (self))
return;
ifindex = nm_device_get_ip_ifindex (self);
_LOGD (LOGD_HW, "taking down device %d", ifindex);
if (ifindex <= 0) {
/* devices without ifindex are always up. */
return;
}
if (!nm_platform_link_set_down (NM_PLATFORM_GET, ifindex))
return;
device_is_up = nm_device_is_up (self);
if (block && device_is_up) {
int ifindex = nm_device_get_ip_ifindex (self);
gint64 wait_until = nm_utils_get_monotonic_timestamp_us () + 10000 /* microseconds */;
do {
@@ -9238,19 +9225,6 @@ nm_device_take_down (NMDevice *self, gboolean block)
}
}
static gboolean
take_down (NMDevice *self)
{
int ifindex = nm_device_get_ip_ifindex (self);
if (ifindex > 0)
return nm_platform_link_set_down (NM_PLATFORM_GET, ifindex);
/* devices without ifindex are always up. */
_LOGD (LOGD_HW, "cannot take down device without ifindex");
return FALSE;
}
void
nm_device_set_firmware_missing (NMDevice *self, gboolean new_missing)
{
@@ -12684,9 +12658,6 @@ nm_device_class_init (NMDeviceClass *klass)
klass->can_unmanaged_external_down = can_unmanaged_external_down;
klass->realize_start_notify = realize_start_notify;
klass->unrealize_notify = unrealize_notify;
klass->is_up = is_up;
klass->bring_up = bring_up;
klass->take_down = take_down;
klass->carrier_changed = carrier_changed;
klass->get_ip_iface_identifier = get_ip_iface_identifier;
klass->unmanaged_on_quit = unmanaged_on_quit;
@@ -12921,7 +12892,7 @@ nm_device_class_init (NMDeviceClass *klass)
G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
signals[AUTOCONNECT_ALLOWED] =
g_signal_new ("autoconnect-allowed",
g_signal_new (NM_DEVICE_AUTOCONNECT_ALLOWED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
0,

View File

@@ -87,6 +87,7 @@
#define NM_DEVICE_RECHECK_ASSUME "recheck-assume"
#define NM_DEVICE_STATE_CHANGED "state-changed"
#define NM_DEVICE_LINK_INITIALIZED "link-initialized"
#define NM_DEVICE_AUTOCONNECT_ALLOWED "autoconnect-allowed"
#define NM_DEVICE_STATISTICS_REFRESH_RATE_MS "refresh-rate-ms"
#define NM_DEVICE_STATISTICS_TX_BYTES "tx-bytes"
@@ -204,9 +205,6 @@ typedef struct {
/* Hardware state (IFF_UP) */
gboolean (*can_unmanaged_external_down) (NMDevice *self);
gboolean (*is_up) (NMDevice *self);
gboolean (*bring_up) (NMDevice *self, gboolean *no_firmware);
gboolean (*take_down) (NMDevice *self);
/* Carrier state (IFF_LOWER_UP) */
void (*carrier_changed) (NMDevice *, gboolean carrier);

View File

@@ -178,7 +178,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
/* wait with continuing configuration untill the companion device is done scanning */
g_object_get (priv->companion, "scanning", &scanning, NULL);
g_object_get (priv->companion, NM_DEVICE_WIFI_SCANNING, &scanning, NULL);
if (scanning) {
priv->stage1_waiting = TRUE;
return NM_ACT_STAGE_RETURN_POSTPONE;
@@ -267,7 +267,7 @@ companion_notify_cb (NMDeviceWifi *companion, GParamSpec *pspec, gpointer user_d
if (!priv->stage1_waiting)
return;
g_object_get (companion, "scanning", &scanning, NULL);
g_object_get (companion, NM_DEVICE_WIFI_SCANNING, &scanning, NULL);
if (!scanning) {
priv->stage1_waiting = FALSE;
@@ -343,13 +343,13 @@ check_companion (NMDeviceOlpcMesh *self, NMDevice *other)
g_signal_connect (G_OBJECT (other), NM_DEVICE_STATE_CHANGED,
G_CALLBACK (companion_state_changed_cb), self);
g_signal_connect (G_OBJECT (other), "notify::scanning",
g_signal_connect (G_OBJECT (other), "notify::" NM_DEVICE_WIFI_SCANNING,
G_CALLBACK (companion_notify_cb), self);
g_signal_connect (G_OBJECT (other), "scanning-allowed",
g_signal_connect (G_OBJECT (other), NM_DEVICE_WIFI_SCANNING_ALLOWED,
G_CALLBACK (companion_scan_allowed_cb), self);
g_signal_connect (G_OBJECT (other), "autoconnect-allowed",
g_signal_connect (G_OBJECT (other), NM_DEVICE_AUTOCONNECT_ALLOWED,
G_CALLBACK (companion_autoconnect_allowed_cb), self);
g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_COMPANION);

View File

@@ -452,15 +452,6 @@ periodic_update_cb (gpointer user_data)
return TRUE;
}
static gboolean
bring_up (NMDevice *device, gboolean *no_firmware)
{
if (!NM_DEVICE_WIFI_GET_PRIVATE ((NMDeviceWifi *) device)->enabled)
return FALSE;
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->bring_up (device, no_firmware);
}
static void
ap_add_remove (NMDeviceWifi *self,
guint signum,
@@ -2945,6 +2936,12 @@ device_state_changed (NMDevice *device,
remove_all_aps (self);
}
static gboolean
get_enabled (NMDevice *device)
{
return NM_DEVICE_WIFI_GET_PRIVATE ((NMDeviceWifi *) device)->enabled;
}
static void
set_enabled (NMDevice *device, gboolean enabled)
{
@@ -3132,12 +3129,12 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
object_class->dispose = dispose;
object_class->finalize = finalize;
parent_class->bring_up = bring_up;
parent_class->can_auto_connect = can_auto_connect;
parent_class->is_available = is_available;
parent_class->check_connection_compatible = check_connection_compatible;
parent_class->check_connection_available = check_connection_available;
parent_class->complete_connection = complete_connection;
parent_class->get_enabled = get_enabled;
parent_class->set_enabled = set_enabled;
parent_class->act_stage1_prepare = act_stage1_prepare;
@@ -3199,7 +3196,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
/* Signals */
signals[ACCESS_POINT_ADDED] =
g_signal_new ("access-point-added",
g_signal_new (NM_DEVICE_WIFI_ACCESS_POINT_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
@@ -3208,7 +3205,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
NM_TYPE_AP);
signals[ACCESS_POINT_REMOVED] =
g_signal_new ("access-point-removed",
g_signal_new (NM_DEVICE_WIFI_ACCESS_POINT_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
@@ -3217,7 +3214,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
NM_TYPE_AP);
signals[SCANNING_ALLOWED] =
g_signal_new ("scanning-allowed",
g_signal_new (NM_DEVICE_WIFI_SCANNING_ALLOWED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NMDeviceWifiClass, scanning_allowed),

View File

@@ -39,6 +39,13 @@
#define NM_DEVICE_WIFI_CAPABILITIES "wireless-capabilities"
#define NM_DEVICE_WIFI_SCANNING "scanning"
/* signals */
#define NM_DEVICE_WIFI_ACCESS_POINT_ADDED "access-point-added"
#define NM_DEVICE_WIFI_ACCESS_POINT_REMOVED "access-point-removed"
/* internal signals */
#define NM_DEVICE_WIFI_SCANNING_ALLOWED "scanning-allowed"
typedef struct _NMDeviceWifi NMDeviceWifi;
typedef struct _NMDeviceWifiClass NMDeviceWifiClass;