mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-11 09:50:22 +01:00
core: add IS_MASTER property to NMDevice
We can't just check whether there are slaves or not, because the master device may be started before any slaves exist, and the slaves get added later.
This commit is contained in:
parent
d4f5c40abe
commit
e64bcae092
4 changed files with 34 additions and 2 deletions
|
|
@ -496,6 +496,7 @@ nm_device_bond_new (const char *udi, const char *iface)
|
|||
NM_DEVICE_DRIVER, "bonding",
|
||||
NM_DEVICE_TYPE_DESC, "Bond",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND,
|
||||
NM_DEVICE_IS_MASTER, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -560,6 +560,7 @@ nm_device_bridge_new (const char *udi, const char *iface)
|
|||
NM_DEVICE_DRIVER, "bridge",
|
||||
NM_DEVICE_TYPE_DESC, "Bridge",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BRIDGE,
|
||||
NM_DEVICE_IS_MASTER, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ enum {
|
|||
PROP_RFKILL_TYPE,
|
||||
PROP_IFINDEX,
|
||||
PROP_AVAILABLE_CONNECTIONS,
|
||||
PROP_IS_MASTER,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
|
|
@ -250,8 +251,9 @@ typedef struct {
|
|||
NMDevice * master;
|
||||
gboolean enslaved;
|
||||
|
||||
/* list of SlaveInfo for bond/bridge master */
|
||||
GSList * slaves;
|
||||
/* slave management */
|
||||
gboolean is_master;
|
||||
GSList * slaves; /* list of SlaveInfo */
|
||||
|
||||
NMConnectionProvider *con_provider;
|
||||
|
||||
|
|
@ -1000,6 +1002,18 @@ nm_device_master_get_slaves (NMDevice *dev)
|
|||
return slaves;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_is_master:
|
||||
* @dev: the device
|
||||
*
|
||||
* Returns: whether @dev can enslave other devices (eg, bridge or bond)
|
||||
*/
|
||||
gboolean
|
||||
nm_device_is_master (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_GET_PRIVATE (dev)->is_master;
|
||||
}
|
||||
|
||||
/* release all slaves */
|
||||
static void
|
||||
nm_device_master_release_slaves (NMDevice *self, gboolean failed)
|
||||
|
|
@ -4292,6 +4306,9 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_RFKILL_TYPE:
|
||||
priv->rfkill_type = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_IS_MASTER:
|
||||
priv->is_master = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -4414,6 +4431,9 @@ get_property (GObject *object, guint prop_id,
|
|||
g_ptr_array_add (array, g_strdup (nm_connection_get_path (connection)));
|
||||
g_value_take_boxed (value, array);
|
||||
break;
|
||||
case PROP_IS_MASTER:
|
||||
g_value_set_boolean (value, priv->is_master);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -4635,6 +4655,14 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IS_MASTER,
|
||||
g_param_spec_boolean (NM_DEVICE_IS_MASTER,
|
||||
"IsMaster",
|
||||
"IsMaster",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/* Signals */
|
||||
signals[STATE_CHANGED] =
|
||||
g_signal_new ("state-changed",
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
#define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */
|
||||
#define NM_DEVICE_RFKILL_TYPE "rfkill-type" /* Internal only */
|
||||
#define NM_DEVICE_IFINDEX "ifindex" /* Internal only */
|
||||
#define NM_DEVICE_IS_MASTER "is-master" /* Internal only */
|
||||
#define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
|
||||
|
||||
/* Internal signals */
|
||||
|
|
@ -224,6 +225,7 @@ NMIP6Config * nm_device_get_ip6_config (NMDevice *dev);
|
|||
/* Master */
|
||||
gboolean nm_device_master_add_slave (NMDevice *dev, NMDevice *slave);
|
||||
GSList * nm_device_master_get_slaves (NMDevice *dev);
|
||||
gboolean nm_device_is_master (NMDevice *dev);
|
||||
|
||||
/* Slave */
|
||||
void nm_device_slave_notify_enslaved (NMDevice *dev,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue