From 0a30843caae76f6ca800b21b93d187cb4c43b98d Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 19 Sep 2012 10:56:30 -0400 Subject: [PATCH] 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.) --- src/nm-device.c | 7 +++++++ src/nm-device.h | 2 ++ src/nm-manager.c | 11 ++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/nm-device.c b/src/nm-device.c index 7786b0ef76..51c9a580d0 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 f4698928d4..9762c5c363 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 d8c6fbb23c..618c4edaaf 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 {