From 9e668595fee2127c20310f50e405cd3450f88f5b Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 26 Apr 2017 20:26:07 +0200 Subject: [PATCH] ifcfg-rh: preserve the archaic NETMASK key py-kickstart writes this out and there apparently are users using this. Let them have one less problem. Co-Authored-By: Thomas Haller https://bugzilla.redhat.com/show_bug.cgi?id=1445414 --- .../plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index a670ba5d1e..c6957e8816 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -2102,6 +2102,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) */ for (i = n = 0; i < num; i++) { NMIPAddress *addr; + guint prefix; addr = nm_setting_ip_config_get_address (s_ip4, i); @@ -2131,9 +2132,18 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) } svSetValueStr (ifcfg, addr_key, nm_ip_address_get_address (addr)); - svSetValueInt64 (ifcfg, prefix_key, nm_ip_address_get_prefix (addr)); - svUnsetValue (ifcfg, netmask_key); + prefix = nm_ip_address_get_prefix (addr); + svSetValueInt64 (ifcfg, prefix_key, prefix); + + /* If the legacy "NETMASK" is present, keep it. */ + if (svGetValue (ifcfg, netmask_key, &tmp)) { + char buf[INET_ADDRSTRLEN]; + + g_free (tmp); + svSetValueStr (ifcfg, netmask_key, nm_utils_inet4_ntop (prefix, buf)); + } + svUnsetValue (ifcfg, gw_key); n++; }