mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 11:58:12 +02: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.
(cherry picked from commit 77ded12da4)
This commit is contained in:
parent
c47882625f
commit
95310a5dec
3 changed files with 39 additions and 0 deletions
|
|
@ -524,6 +524,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
|
gboolean
|
||||||
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
|
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
|
||||||
{
|
{
|
||||||
|
|
@ -4368,6 +4396,7 @@ ip4_config_merge_and_apply (NMDevice *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
composite = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
|
composite = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
|
||||||
|
init_ip4_config_dns_priority (self, composite);
|
||||||
|
|
||||||
if (commit)
|
if (commit)
|
||||||
ensure_con_ip4_config (self);
|
ensure_con_ip4_config (self);
|
||||||
|
|
@ -5094,9 +5123,11 @@ ip6_config_merge_and_apply (NMDevice *self,
|
||||||
|
|
||||||
/* If no config was passed in, create a new one */
|
/* If no config was passed in, create a new one */
|
||||||
composite = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
|
composite = nm_ip6_config_new (nm_device_get_ip_ifindex (self));
|
||||||
|
init_ip6_config_dns_priority (self, composite);
|
||||||
|
|
||||||
if (commit)
|
if (commit)
|
||||||
ensure_con_ip6_config (self);
|
ensure_con_ip6_config (self);
|
||||||
|
|
||||||
g_assert (composite);
|
g_assert (composite);
|
||||||
|
|
||||||
/* Merge all the IP configs into the composite config */
|
/* Merge all the IP configs into the composite config */
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ typedef enum {
|
||||||
NM_DNS_IP_CONFIG_TYPE_VPN
|
NM_DNS_IP_CONFIG_TYPE_VPN
|
||||||
} NMDnsIPConfigType;
|
} NMDnsIPConfigType;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NM_DNS_PRIORITY_DEFAULT_NORMAL = 100,
|
||||||
|
NM_DNS_PRIORITY_DEFAULT_VPN = 50,
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gpointer config;
|
gpointer config;
|
||||||
NMDnsIPConfigType type;
|
NMDnsIPConfigType type;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
#include "nm-config.h"
|
#include "nm-config.h"
|
||||||
#include "nm-vpn-plugin-info.h"
|
#include "nm-vpn-plugin-info.h"
|
||||||
#include "nm-vpn-manager.h"
|
#include "nm-vpn-manager.h"
|
||||||
|
#include "nm-dns-manager.h"
|
||||||
|
|
||||||
#include "nmdbus-vpn-connection.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);
|
ifindex = nm_device_get_ip_ifindex (parent_dev);
|
||||||
}
|
}
|
||||||
config = nm_ip4_config_new (ifindex);
|
config = nm_ip4_config_new (ifindex);
|
||||||
|
nm_ip4_config_set_dns_priority (config, NM_DNS_PRIORITY_DEFAULT_VPN);
|
||||||
|
|
||||||
memset (&address, 0, sizeof (address));
|
memset (&address, 0, sizeof (address));
|
||||||
address.plen = 24;
|
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);
|
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));
|
memset (&address, 0, sizeof (address));
|
||||||
address.plen = 128;
|
address.plen = 128;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue