mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 01:20:07 +01:00
core: use default value for ipvx.dns-priority
Fall back to system default value for ipvx.dns-priority when it's zero in the setting. For VPNs the default value is 50; for other connections is 100, but it depends also on the content of [connection*] sections in NetworkManager.conf.
This commit is contained in:
parent
bfabfb05ae
commit
77ded12da4
3 changed files with 39 additions and 0 deletions
|
|
@ -536,6 +536,34 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_reason_to_string, NMDeviceStateReason,
|
|||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
init_ip4_config_dns_priority (NMDevice *self, NMIP4Config *config)
|
||||
{
|
||||
gs_free char *value = NULL;
|
||||
gint priority;
|
||||
|
||||
value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
|
||||
"ipv4.dns-priority",
|
||||
self);
|
||||
priority = _nm_utils_ascii_str_to_int64 (value, 10, G_MININT, G_MAXINT, 0);
|
||||
nm_ip4_config_set_dns_priority (config, priority ?: NM_DNS_PRIORITY_DEFAULT_NORMAL);
|
||||
}
|
||||
|
||||
static void
|
||||
init_ip6_config_dns_priority (NMDevice *self, NMIP6Config *config)
|
||||
{
|
||||
gs_free char *value = NULL;
|
||||
gint priority;
|
||||
|
||||
value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
|
||||
"ipv6.dns-priority",
|
||||
self);
|
||||
priority = _nm_utils_ascii_str_to_int64 (value, 10, G_MININT, G_MAXINT, 0);
|
||||
nm_ip6_config_set_dns_priority (config, priority ?: NM_DNS_PRIORITY_DEFAULT_NORMAL);
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
gboolean
|
||||
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
|
||||
{
|
||||
|
|
@ -4416,6 +4444,7 @@ ip4_config_merge_and_apply (NMDevice *self,
|
|||
}
|
||||
|
||||
composite = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
|
||||
init_ip4_config_dns_priority (self, composite);
|
||||
|
||||
if (commit)
|
||||
ensure_con_ip4_config (self);
|
||||
|
|
@ -5155,9 +5184,11 @@ ip6_config_merge_and_apply (NMDevice *self,
|
|||
|
||||
/* If no config was passed in, create a new one */
|
||||
composite = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
|
||||
init_ip6_config_dns_priority (self, composite);
|
||||
|
||||
if (commit)
|
||||
ensure_con_ip6_config (self);
|
||||
|
||||
g_assert (composite);
|
||||
|
||||
/* Merge all the IP configs into the composite config */
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ typedef enum {
|
|||
NM_DNS_IP_CONFIG_TYPE_VPN
|
||||
} NMDnsIPConfigType;
|
||||
|
||||
enum {
|
||||
NM_DNS_PRIORITY_DEFAULT_NORMAL = 100,
|
||||
NM_DNS_PRIORITY_DEFAULT_VPN = 50,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
gpointer config;
|
||||
NMDnsIPConfigType type;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include "nm-config.h"
|
||||
#include "nm-vpn-plugin-info.h"
|
||||
#include "nm-vpn-manager.h"
|
||||
#include "nm-dns-manager.h"
|
||||
|
||||
#include "nmdbus-vpn-connection.h"
|
||||
|
||||
|
|
@ -1364,6 +1365,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
ifindex = nm_device_get_ip_ifindex (parent_dev);
|
||||
}
|
||||
config = nm_ip4_config_new (ifindex);
|
||||
nm_ip4_config_set_dns_priority (config, NM_DNS_PRIORITY_DEFAULT_VPN);
|
||||
|
||||
memset (&address, 0, sizeof (address));
|
||||
address.plen = 24;
|
||||
|
|
@ -1497,6 +1499,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
}
|
||||
|
||||
config = nm_ip6_config_new (priv->ip_ifindex);
|
||||
nm_ip6_config_set_dns_priority (config, NM_DNS_PRIORITY_DEFAULT_VPN);
|
||||
|
||||
memset (&address, 0, sizeof (address));
|
||||
address.plen = 128;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue