summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-02-11 09:58:25 -0500
committerDan Winship <danw@gnome.org>2014-03-18 16:09:01 -0400
commit659cba17007da5dc9754fcf8a9c1ce626f30d7ed (patch)
tree7e644781e35b6111ef37b367b24722e8147ef131
parentdf851d77b873b949c9392cfc5c93fc9b656c047b (diff)
downloadNetworkManager-danw/slavetypes-dbus.tar.gz
core: export device vlan/bond/bridge/team support via D-Busdanw/slavetypes-dbus
Add flags to NMDeviceCapabilities indicating support for vlan/bond/bridge/team.
-rw-r--r--include/NetworkManager.h14
-rw-r--r--src/devices/nm-device.c25
-rw-r--r--src/devices/nm-device.h4
-rw-r--r--src/nm-manager.c2
4 files changed, 36 insertions, 9 deletions
diff --git a/include/NetworkManager.h b/include/NetworkManager.h
index 89b42aeb82..4a0c1a685a 100644
--- a/include/NetworkManager.h
+++ b/include/NetworkManager.h
@@ -170,13 +170,21 @@ typedef enum {
* @NM_DEVICE_CAP_NONE: device has no special capabilities
* @NM_DEVICE_CAP_NM_SUPPORTED: NetworkManager supports this device
* @NM_DEVICE_CAP_CARRIER_DETECT: this device can indicate carrier status
+ * @NM_DEVICE_CAP_BOND_SUPPORTED: this device can be a bond slave
+ * @NM_DEVICE_CAP_BRIDGE_SUPPORTED: this device can be a bridge slave
+ * @NM_DEVICE_CAP_TEAM_SUPPORTED: this device can be a team slave
+ * @NM_DEVICE_CAP_VLAN_SUPPORTED: this device can be the parent of a vlan
*
* General device capability flags.
**/
typedef enum {
- NM_DEVICE_CAP_NONE = 0x00000000,
- NM_DEVICE_CAP_NM_SUPPORTED = 0x00000001,
- NM_DEVICE_CAP_CARRIER_DETECT = 0x00000002
+ NM_DEVICE_CAP_NONE = 0x00000000,
+ NM_DEVICE_CAP_NM_SUPPORTED = 0x00000001,
+ NM_DEVICE_CAP_CARRIER_DETECT = 0x00000002,
+ NM_DEVICE_CAP_BOND_SUPPORTED = 0x00000004,
+ NM_DEVICE_CAP_BRIDGE_SUPPORTED = 0x00000008,
+ NM_DEVICE_CAP_TEAM_SUPPORTED = 0x00000010,
+ NM_DEVICE_CAP_VLAN_SUPPORTED = 0x00000020,
} NMDeviceCapabilities;
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 8b8e63704d..9149fd6c01 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -483,6 +483,24 @@ device_get_driver_info (const char *iface, char **driver_version, char **firmwar
return TRUE;
}
+static guint32
+get_device_capabilities (NMDevice *device)
+{
+ int ifindex = nm_device_get_ifindex (device);
+ guint32 caps = 0;
+
+ if (nm_platform_link_supports_link_type (ifindex, NM_LINK_TYPE_BOND))
+ caps |= NM_DEVICE_CAP_BOND_SUPPORTED;
+ if (nm_platform_link_supports_link_type (ifindex, NM_LINK_TYPE_BRIDGE))
+ caps |= NM_DEVICE_CAP_BRIDGE_SUPPORTED;
+ if (nm_platform_link_supports_link_type (ifindex, NM_LINK_TYPE_TEAM))
+ caps |= NM_DEVICE_CAP_TEAM_SUPPORTED;
+ if (nm_platform_link_supports_link_type (ifindex, NM_LINK_TYPE_VLAN))
+ caps |= NM_DEVICE_CAP_VLAN_SUPPORTED;
+
+ return caps;
+}
+
static gboolean
device_has_capability (NMDevice *device, NMDeviceCapabilities caps)
{
@@ -520,6 +538,7 @@ constructor (GType type,
priv->udi = g_strdup_printf ("/virtual/device/placeholder/%d", id++);
}
+ priv->capabilities |= get_device_capabilities (dev);
if (NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities)
priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
@@ -7395,10 +7414,10 @@ cp_connection_updated (NMConnectionProvider *cp, NMConnection *connection, gpoin
_signal_available_connections_changed (NM_DEVICE (user_data));
}
-gboolean
-nm_device_supports_vlans (NMDevice *device)
+NMDeviceCapabilities
+nm_device_get_capabilities (NMDevice *dev)
{
- return nm_platform_link_supports_vlans (nm_device_get_ifindex (device));
+ return NM_DEVICE_GET_PRIVATE (dev)->capabilities;
}
gboolean
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 47d7856f34..d92f2cec07 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -232,6 +232,8 @@ const char * nm_device_get_firmware_version (NMDevice *dev);
const char * nm_device_get_type_desc (NMDevice *dev);
NMDeviceType nm_device_get_device_type (NMDevice *dev);
+NMDeviceCapabilities nm_device_get_capabilities (NMDevice *dev);
+
int nm_device_get_priority (NMDevice *dev);
const guint8 * nm_device_get_hw_address (NMDevice *dev, guint *out_len);
@@ -326,8 +328,6 @@ gboolean nm_device_get_firmware_missing (NMDevice *self);
void nm_device_queue_activation (NMDevice *device, NMActRequest *req);
-gboolean nm_device_supports_vlans (NMDevice *device);
-
void nm_device_add_pending_action (NMDevice *device, const char *action);
void nm_device_remove_pending_action (NMDevice *device, const char *action);
gboolean nm_device_has_pending_action (NMDevice *device);
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 1466a429f0..c9a2a0ab28 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -989,7 +989,7 @@ get_virtual_iface_name (NMManager *self,
if (parent) {
ifname = nm_connection_get_virtual_iface_name (connection);
- if (!nm_device_supports_vlans (parent)) {
+ if (!(nm_device_get_capabilities (parent) & NM_DEVICE_CAP_VLAN_SUPPORTED)) {
nm_log_warn (LOGD_DEVICE, "(%s): No support for VLANs on interface %s of type %s",
ifname ? ifname : nm_connection_get_id (connection),
nm_device_get_ip_iface (parent),