summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-09-19 10:56:30 -0400
committerDan Winship <danw@gnome.org>2012-09-27 13:57:47 -0400
commit0a30843caae76f6ca800b21b93d187cb4c43b98d (patch)
treef37123bc945188fd411ffc8430804f7def4b41dc
parentde0163fc5c46eb9d04eb97075557012f81cd7567 (diff)
core: don't try to create VLANs on devices that don't support them
VLANs are only supported on certain kinds of devices, so don't try to create them on other devices. (In fact, NM currently assumes that VLANs are only created on Ethernet devices, so we need to be even more picky than that.)
-rw-r--r--src/nm-device.c7
-rw-r--r--src/nm-device.h2
-rw-r--r--src/nm-manager.c11
3 files changed, 19 insertions, 1 deletions
diff --git a/src/nm-device.c b/src/nm-device.c
index 7786b0ef..51c9a580 100644
--- a/src/nm-device.c
+++ b/src/nm-device.c
@@ -40,6 +40,7 @@
#include "nm-glib-compat.h"
#include "nm-device.h"
#include "nm-device-private.h"
+#include "nm-device-ethernet.h"
#include "NetworkManagerUtils.h"
#include "nm-system.h"
#include "nm-dhcp-manager.h"
@@ -5117,3 +5118,9 @@ cp_connection_updated (NMConnectionProvider *cp, NMConnection *connection, gpoin
_signal_available_connections_changed (NM_DEVICE (user_data));
}
+gboolean
+nm_device_supports_vlans (NMDevice *device)
+{
+ /* At the moment, NM's VLAN code assumes all VLANs are over ethernet. */
+ return NM_IS_DEVICE_ETHERNET (device);
+}
diff --git a/src/nm-device.h b/src/nm-device.h
index f4698928..9762c5c3 100644
--- a/src/nm-device.h
+++ b/src/nm-device.h
@@ -288,6 +288,8 @@ gboolean nm_device_activate (NMDevice *device, NMActRequest *req, GError **error
void nm_device_set_connection_provider (NMDevice *device, NMConnectionProvider *provider);
+gboolean nm_device_supports_vlans (NMDevice *device);
+
G_END_DECLS
#endif /* NM_DEVICE_H */
diff --git a/src/nm-manager.c b/src/nm-manager.c
index d8c6fbb2..618c4eda 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1026,11 +1026,20 @@ get_virtual_iface_name (NMManager *self,
parent = find_vlan_parent (self, connection, TRUE);
if (parent) {
+ ifname = nm_connection_get_virtual_iface_name (connection);
+
+ if (!nm_device_supports_vlans (parent)) {
+ 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),
+ nm_device_get_type_desc (parent));
+ return NULL;
+ }
+
/* If the connection doesn't specify the interface name for the VLAN
* device, we create one for it using the VLAN ID and the parent
* interface's name.
*/
- ifname = nm_connection_get_virtual_iface_name (connection);
if (ifname)
vname = g_strdup (ifname);
else {