ifcfg-rh: add support for DNS priority

This commit is contained in:
Beniamino Galvani 2016-04-23 15:57:07 +02:00
parent bdd0e7fec0
commit c5f17531b9
4 changed files with 52 additions and 0 deletions

View file

@ -654,6 +654,17 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class)
* ---end---
*/
/* ---ifcfg-rh---
* property: dns-priority
* variable: IPV4_DNS_PRIORITY(+)
* description: The priority for DNS servers of this connection. Lower values have higher priority.
* If zero, the default value will be used (50 for VPNs, 100 for other connections).
* A negative value prevents DNS from other connections with greater values to be used.
* default: 0
* example: IPV4_DNS_PRIORITY=20
* ---end---
*/
/**
* NMSettingIP4Config:dhcp-client-id:
*

View file

@ -556,6 +556,17 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *ip6_class)
* ---end---
*/
/* ---ifcfg-rh---
* property: dns-priority
* variable: IPV6_DNS_PRIORITY(+)
* description: The priority for DNS servers of this connection. Lower values have higher priority.
* If zero, the default value will be used (50 for VPNs, 100 for other connections).
* A negative value prevents DNS from other connections with greater values to be used.
* default: 0
* example: IPV6_DNS_PRIORITY=20
* ---end---
*/
/**
* NMSettingIP6Config:ip6-privacy:
*

View file

@ -919,6 +919,7 @@ make_ip4_setting (shvarFile *ifcfg,
shvarFile *route_ifcfg;
gboolean never_default = FALSE;
gint64 timeout;
gint priority;
s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new ();
@ -1141,6 +1142,13 @@ make_ip4_setting (shvarFile *ifcfg,
g_free (dns_options);
dns_options = NULL;
/* DNS priority */
priority = svGetValueInt64 (ifcfg, "IPV4_DNS_PRIORITY", 10, G_MININT32, G_MAXINT32, 0);
g_object_set (s_ip4,
NM_SETTING_IP_CONFIG_DNS_PRIORITY,
priority,
NULL);
/* Static routes - route-<name> file */
route_path = utils_get_route_path (ifcfg->fileName);
@ -1323,6 +1331,7 @@ make_ip6_setting (shvarFile *ifcfg,
char *ipv6addr, *ipv6addr_secondaries;
char **list = NULL, **iter;
guint32 i;
gint priority;
shvarFile *network_ifcfg;
gboolean never_default = FALSE;
gboolean ip6_privacy = FALSE, ip6_privacy_prefer_public_ip;
@ -1572,6 +1581,13 @@ make_ip6_setting (shvarFile *ifcfg,
g_free (value);
g_free (dns_options);
/* DNS priority */
priority = svGetValueInt64 (ifcfg, "IPV6_DNS_PRIORITY", 10, G_MININT32, G_MAXINT32, 0);
g_object_set (s_ip6,
NM_SETTING_IP_CONFIG_DNS_PRIORITY,
priority,
NULL);
return NM_SETTING (s_ip6);
error:

View file

@ -1970,6 +1970,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
gint32 j;
guint32 i, n, num;
gint64 route_metric;
gint priority;
int timeout;
GString *searches;
gboolean success = FALSE;
@ -2281,6 +2282,12 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
svSetValueInt64 (ifcfg, "ARPING_WAIT", (timeout - 1) / 1000 + 1);
}
priority = nm_setting_ip_config_get_dns_priority (s_ip4);
if (priority)
svSetValueInt64 (ifcfg, "IPV4_DNS_PRIORITY", priority);
else
svSetValue (ifcfg, "IPV4_DNS_PRIORITY", NULL, FALSE);
success = TRUE;
out:
@ -2440,6 +2447,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
char *addr_key;
char *tmp;
guint32 i, num, num4;
gint priority;
GString *searches;
NMIPAddress *addr;
const char *dns;
@ -2606,6 +2614,12 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
g_free (tmp);
}
priority = nm_setting_ip_config_get_dns_priority (s_ip6);
if (priority)
svSetValueInt64 (ifcfg, "IPV6_DNS_PRIORITY", priority);
else
svSetValue (ifcfg, "IPV6_DNS_PRIORITY", NULL, FALSE);
/* Static routes go to route6-<dev> file */
route6_path = utils_get_route6_path (ifcfg->fileName);
if (!route6_path) {