From 23d4973835d90dd4cb05fb7a8ec6b8119e439065 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 3 Sep 2013 14:03:52 -0400 Subject: [PATCH] core: set VLAN ingress/egress maps at activation time Rather than setting the VLAN maps when the device is created, set them at activation time, which is more in line with how other device types work. Like the old code, this doesn't attempt to reset any existing ingress/egress mappings on the device. --- src/devices/nm-device-vlan.c | 42 ++++++++++++++++++++++++++++++++++++ src/nm-manager.c | 12 ----------- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 4ac5be3c04..e6343fb9ef 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -273,6 +273,47 @@ match_l2_config (NMDevice *device, NMConnection *connection) return TRUE; } +static NMActStageReturn +act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) +{ + NMActRequest *req; + NMConnection *connection; + NMSettingVlan *s_vlan; + NMActStageReturn ret; + + g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); + + ret = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->act_stage1_prepare (dev, reason); + if (ret != NM_ACT_STAGE_RETURN_SUCCESS) + return ret; + + req = nm_device_get_act_request (dev); + g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE); + + connection = nm_act_request_get_connection (req); + g_return_val_if_fail (connection != NULL, NM_ACT_STAGE_RETURN_FAILURE); + + s_vlan = nm_connection_get_setting_vlan (connection); + if (s_vlan) { + int ifindex = nm_device_get_ifindex (dev); + int num, i; + guint32 from, to; + + 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 ret; +} + /******************************************************************/ static void @@ -429,6 +470,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 cab51eb968..6e3a0c23df 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1463,8 +1463,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), @@ -1474,16 +1472,6 @@ system_create_virtual_device (NMManager *self, NMConnection *connection) iface, nm_connection_get_id (connection)); goto unblock; } - 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); - } device = nm_device_vlan_new (iface, parent); } else if (nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) { NMSettingInfiniband *s_infiniband = nm_connection_get_setting_infiniband (connection);