summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-07-15 17:27:09 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2020-08-26 17:28:45 +0200
commit757fa4711f87bf31f0de47facc4127e8ae915f54 (patch)
tree8368334b7b6a1e64b42324ef0eb8cedf9e0c28dc /src
parentc25aed5051814163be6caadc45be58e6fb875b1a (diff)
downloadNetworkManager-757fa4711f87bf31f0de47facc4127e8ae915f54.tar.gz
all: add ipv4.dhcp-reject-servers property
Add a new dhcp-reject-servers property to the ipv4 setting, that allows specifying a list of server-ids from which offers should be rejected.
Diffstat (limited to 'src')
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c12
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c1
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h2
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c23
4 files changed, 30 insertions, 8 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index 5c52bbb1a9..7b94da22c7 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -1979,6 +1979,18 @@ make_ip4_setting (shvarFile *ifcfg,
}
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DAD_TIMEOUT, (int) i64, NULL);
+ nm_clear_g_free (&value);
+ v = svGetValueStr (ifcfg, "DHCP_REJECT_SERVERS", &value);
+ if (v) {
+ gs_free const char **strv = NULL;
+
+ strv = nm_utils_escaped_tokens_split (v, NM_ASCII_SPACES);
+ if (strv) {
+ for (item = strv; *item; item++)
+ nm_setting_ip_config_add_dhcp_reject_server (s_ip4, *item);
+ }
+ }
+
return NM_SETTING (g_steal_pointer (&s_ip4));
}
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
index 6eb4348f94..8a7e0b9bd7 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
@@ -872,6 +872,7 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = {
_KEY_TYPE ("DHCP_HOSTNAME", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("DHCP_HOSTNAME_FLAGS", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("DHCP_IAID", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
+ _KEY_TYPE ("DHCP_REJECT_SERVERS", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("DHCP_SEND_HOSTNAME", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("DHCP_VENDOR_CLASS_IDENTIFIER", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("DHCPv6_DUID", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
index 1b377c78b7..3ece8771dd 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
@@ -33,7 +33,7 @@ typedef struct {
NMSIfcfgKeyTypeFlags key_flags;
} NMSIfcfgKeyTypeInfo;
-extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[242];
+extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[243];
const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info (const char *key, gssize *out_idx);
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 9445c6de05..847fab2c8e 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -2529,10 +2529,11 @@ write_ip4_setting (NMConnection *connection,
NMIPRouteTableSyncMode route_table;
int priority;
int timeout;
- GString *searches;
+ nm_auto_free_gstring GString *str = NULL;
const char *method = NULL;
gboolean has_netmask;
NMDhcpHostnameFlags flags;
+ const char *const *strv;
NM_SET_OUT (out_route_content_svformat, NULL);
NM_SET_OUT (out_route_content, NULL);
@@ -2619,14 +2620,12 @@ write_ip4_setting (NMConnection *connection,
num = nm_setting_ip_config_get_num_dns_searches (s_ip4);
if (num > 0) {
- searches = g_string_new (NULL);
+ nm_gstring_prepare (&str);
for (i = 0; i < num; i++) {
- if (i > 0)
- g_string_append_c (searches, ' ');
- g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip4, i));
+ nm_gstring_add_space_delimiter (str);
+ g_string_append (str, nm_setting_ip_config_get_dns_search (s_ip4, i));
}
- svSetValueStr (ifcfg, "DOMAIN", searches->str);
- g_string_free (searches, TRUE);
+ svSetValueStr (ifcfg, "DOMAIN", str->str);
}
/* DEFROUTE; remember that it has the opposite meaning from never-default */
@@ -2709,6 +2708,16 @@ write_ip4_setting (NMConnection *connection,
write_res_options (ifcfg, s_ip4, "RES_OPTIONS");
+ strv = nm_setting_ip_config_get_dhcp_reject_servers (s_ip4, &num);
+ if (num > 0) {
+ nm_gstring_prepare (&str);
+ for (i = 0; i < num; i++) {
+ nm_gstring_add_space_delimiter (str);
+ nm_utils_escaped_tokens_escape_gstr (strv[i], NM_ASCII_SPACES, str);
+ }
+ svSetValueStr (ifcfg, "DHCP_REJECT_SERVERS", str->str);
+ }
+
return TRUE;
}