summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-06-26 11:17:35 -0400
committerDan Winship <danw@gnome.org>2013-06-26 11:37:46 -0400
commit0d873dc4f563228558b59667c97e1017ccd7ecce (patch)
tree345a24480b01458f6481e3a3bcddde050e5f2a30
parentc1ffd4abc9ebdd6827345eed9dcce6c0b04b2138 (diff)
downloadNetworkManager-0d873dc4f563228558b59667c97e1017ccd7ecce.tar.gz
devices: set vlan properties at activate time, not device creation time
Rather than having NMManager set the VLAN flags and ingress/egress maps when/if it creates the VLAN device, set them when activating a particular connection instead, since you could in theory have different connections using the same device with different flags/maps. (This also means that NMManager needs less VLAN-specific logic.)
-rw-r--r--src/devices/nm-device-vlan.c30
-rw-r--r--src/nm-manager.c13
2 files changed, 30 insertions, 13 deletions
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index 18c412e6e9..19ac76e9f1 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -96,6 +96,35 @@ bring_up (NMDevice *dev, gboolean *no_firmware)
return success;
}
+static NMActStageReturn
+act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
+{
+ NMConnection *connection;
+ NMSettingVlan *s_vlan;
+ int ifindex = nm_device_get_ifindex (dev), num, i;
+ guint32 from, to;
+
+ connection = nm_device_get_connection (dev);
+ g_assert (connection);
+
+ s_vlan = nm_connection_get_setting_vlan (connection);
+ nm_platform_vlan_set_flags (ifindex, nm_setting_vlan_get_flags (s_vlan));
+
+ nm_platform_vlan_clear_maps (ifindex);
+ num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_INGRESS_MAP);
+ for (i = 0; i < num; i++) {
+ if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_INGRESS_MAP, i, &from, &to))
+ nm_platform_vlan_set_ingress_map (ifindex, from, to);
+ }
+ num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_EGRESS_MAP);
+ for (i = 0; i < num; i++) {
+ if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, i, &from, &to))
+ nm_platform_vlan_set_egress_map (ifindex, from, to);
+ }
+
+ return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->act_stage1_prepare (dev, reason);
+}
+
/******************************************************************/
static gboolean
@@ -432,6 +461,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->bring_up = bring_up;
+ parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->check_connection_compatible = check_connection_compatible;
parent_class->complete_connection = complete_connection;
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 3faa6cbf49..90660a63f1 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1348,8 +1348,6 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
} else if (nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)) {
NMSettingVlan *s_vlan = nm_connection_get_setting_vlan (connection);
int ifindex = nm_device_get_ip_ifindex (parent);
- int num, i;
- guint32 from, to;
if (!nm_platform_vlan_add (iface, ifindex,
nm_setting_vlan_get_id (s_vlan))) {
@@ -1357,17 +1355,6 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
iface, nm_connection_get_id (connection));
goto out;
}
- nm_platform_vlan_set_flags (ifindex, nm_setting_vlan_get_flags (s_vlan));
- num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_INGRESS_MAP);
- for (i = 0; i < num; i++) {
- if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_INGRESS_MAP, i, &from, &to))
- nm_platform_vlan_set_ingress_map (ifindex, from, to);
- }
- num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_EGRESS_MAP);
- for (i = 0; i < num; i++) {
- if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, i, &from, &to))
- nm_platform_vlan_set_egress_map (ifindex, from, to);
- }
udi = get_virtual_iface_placeholder_udi ();
device = nm_device_vlan_new (udi, iface, parent);
g_free (udi);