summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-10-20 18:53:24 +0200
committerThomas Haller <thaller@redhat.com>2017-10-25 14:04:36 +0200
commit2e07a0f92ed2192756284e68ce9c8f185f361b1d (patch)
tree69b25f96c9b31a5c85c0efc47f2b5645c7f0ca4a /src
parent720db2ae60c255d5031bd93f8ff0f35138e54d42 (diff)
downloadNetworkManager-2e07a0f92ed2192756284e68ce9c8f185f361b1d.tar.gz
ifcfg-rh: use svUnsetAll() to clear IPv4 address properties
Diffstat (limited to 'src')
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c8
-rw-r--r--src/settings/plugins/ifcfg-rh/shvar.c7
-rw-r--r--src/settings/plugins/ifcfg-rh/shvar.h1
3 files changed, 9 insertions, 7 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 84d4c1c682..c279f60115 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -2085,13 +2085,7 @@ write_ip4_setting (NMConnection *connection,
* Some IPv4 setting related options are not cleared,
* for no strong reason. */
svUnsetValue (ifcfg, "BOOTPROTO");
-
- for (j = -1; j < 256; j++) {
- svUnsetValue (ifcfg, numbered_tag (tag, "IPADDR", j));
- svUnsetValue (ifcfg, numbered_tag (tag, "PREFIX", j));
- svUnsetValue (ifcfg, numbered_tag (tag, "NETMASK", j));
- svUnsetValue (ifcfg, numbered_tag (tag, "GATEWAY", j));
- }
+ svUnsetAll (ifcfg, SV_KEY_TYPE_IP4_ADDRESS);
return TRUE;
}
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c
index 683339ac0b..f814f9a852 100644
--- a/src/settings/plugins/ifcfg-rh/shvar.c
+++ b/src/settings/plugins/ifcfg-rh/shvar.c
@@ -1159,6 +1159,13 @@ svUnsetAll (shvarFile *s, SvKeyType match_key_type)
|| IS_NUMBERED_TAG (line->key, "OPTIONS"))
goto do_clear;
}
+ if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_IP4_ADDRESS)) {
+ if ( IS_NUMBERED_TAG (line->key, "IPADDR")
+ || IS_NUMBERED_TAG (line->key, "PREFIX")
+ || IS_NUMBERED_TAG (line->key, "NETMASK")
+ || IS_NUMBERED_TAG (line->key, "GATEWAY"))
+ goto do_clear;
+ }
continue;
do_clear:
diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h
index 2cf1c30b7d..9bd6c17cd0 100644
--- a/src/settings/plugins/ifcfg-rh/shvar.h
+++ b/src/settings/plugins/ifcfg-rh/shvar.h
@@ -89,6 +89,7 @@ gboolean svUnsetValue (shvarFile *s, const char *key);
typedef enum {
SV_KEY_TYPE_ANY = (1LL << 0),
SV_KEY_TYPE_ROUTE_SVFORMAT = (1LL << 1),
+ SV_KEY_TYPE_IP4_ADDRESS = (1LL << 2),
} SvKeyType;
gboolean svUnsetAll (shvarFile *s, SvKeyType match_key_type);