summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-09-19 11:21:33 -0400
committerDan Winship <danw@gnome.org>2012-09-27 13:57:47 -0400
commita7ad36987a4c12c4d22cb462d2407c0acffdd226 (patch)
tree65fd9171ca48760204eb148da1b8ec7a807e0e95
parent0a30843caae76f6ca800b21b93d187cb4c43b98d (diff)
ifcfg-rh: write out wired settings on vlan connections
VLAN connections can have "hardware" settings in addition to the VLAN-specific ones. ifcfg-rh was reading in wired settings for VLANs, but was not writing them back out.
-rw-r--r--src/settings/plugins/ifcfg-rh/writer.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c
index 6df60238..f55741b6 100644
--- a/src/settings/plugins/ifcfg-rh/writer.c
+++ b/src/settings/plugins/ifcfg-rh/writer.c
@@ -1122,7 +1122,8 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
return TRUE;
}
-static GString *vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVlanPriorityMap map)
+static GString *
+vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVlanPriorityMap map)
{
GSList *strlist = NULL, *iter;
GString *value = NULL;
@@ -1144,10 +1145,11 @@ static GString *vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVl
}
static gboolean
-write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
+write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error)
{
NMSettingVlan *s_vlan;
NMSettingConnection *s_con;
+ NMSettingWired *s_wired;
char *tmp;
guint32 vlan_flags = 0;
GString *text = NULL;
@@ -1199,6 +1201,39 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
if (text)
g_string_free (text, TRUE);
+ svSetValue (ifcfg, "HWADDR", NULL, FALSE);
+ svSetValue (ifcfg, "MACADDR", NULL, FALSE);
+ svSetValue (ifcfg, "MTU", NULL, FALSE);
+
+ s_wired = nm_connection_get_setting_wired (connection);
+ if (s_wired) {
+ const GByteArray *device_mac, *cloned_mac;
+ guint32 mtu;
+
+ *wired = TRUE;
+
+ device_mac = nm_setting_wired_get_mac_address (s_wired);
+ if (device_mac) {
+ tmp = nm_utils_hwaddr_ntoa (device_mac->data, ARPHRD_ETHER);
+ svSetValue (ifcfg, "HWADDR", tmp, FALSE);
+ g_free (tmp);
+ }
+
+ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
+ if (cloned_mac) {
+ tmp = nm_utils_hwaddr_ntoa (cloned_mac->data, ARPHRD_ETHER);
+ svSetValue (ifcfg, "MACADDR", tmp, FALSE);
+ g_free (tmp);
+ }
+
+ mtu = nm_setting_wired_get_mtu (s_wired);
+ if (mtu) {
+ tmp = g_strdup_printf ("%u", mtu);
+ svSetValue (ifcfg, "MTU", tmp, FALSE);
+ g_free (tmp);
+ }
+ }
+
return TRUE;
}
@@ -2008,7 +2043,7 @@ write_connection (NMConnection *connection,
goto out;
wired = TRUE;
} else if (!strcmp (type, NM_SETTING_VLAN_SETTING_NAME)) {
- if (!write_vlan_setting (connection, ifcfg, error))
+ if (!write_vlan_setting (connection, ifcfg, &wired, error))
goto out;
} else if (!strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME)) {
if (!write_wireless_setting (connection, ifcfg, &no_8021x, error))