mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-27 23:30:50 +02:00
core: add DNS priority to NMIP4Config
(cherry picked from commit f09f5e1ec8)
This commit is contained in:
parent
ad1cdcf657
commit
83908c5cec
3 changed files with 69 additions and 2 deletions
|
|
@ -76,6 +76,13 @@
|
|||
-->
|
||||
<property name="DnsOptions" type="as" access="read"/>
|
||||
|
||||
<!--
|
||||
DnsPriority:
|
||||
|
||||
The relative priority of DNS servers.
|
||||
-->
|
||||
<property name="DnsPriority" type="i" access="read"/>
|
||||
|
||||
<!--
|
||||
WinsServers:
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ typedef struct _NMIP4ConfigPrivate {
|
|||
int ifindex;
|
||||
gint64 route_metric;
|
||||
gboolean metered;
|
||||
gint dns_priority;
|
||||
} NMIP4ConfigPrivate;
|
||||
|
||||
/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */
|
||||
|
|
@ -76,6 +77,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMIP4Config,
|
|||
PROP_SEARCHES,
|
||||
PROP_DNS_OPTIONS,
|
||||
PROP_WINS_SERVERS,
|
||||
PROP_DNS_PRIORITY,
|
||||
);
|
||||
|
||||
NMIP4Config *
|
||||
|
|
@ -427,7 +429,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu
|
|||
{
|
||||
NMIP4ConfigPrivate *priv;
|
||||
guint naddresses, nroutes, nnameservers, nsearches;
|
||||
int i;
|
||||
int i, priority;
|
||||
|
||||
if (!setting)
|
||||
return;
|
||||
|
|
@ -526,6 +528,10 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu
|
|||
i++;
|
||||
}
|
||||
|
||||
priority = nm_setting_ip_config_get_dns_priority (setting);
|
||||
if (priority)
|
||||
nm_ip4_config_set_dns_priority (config, priority);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (config));
|
||||
}
|
||||
|
||||
|
|
@ -635,6 +641,11 @@ nm_ip4_config_create_setting (const NMIP4Config *config)
|
|||
nm_setting_ip_config_add_dns_option (s_ip4, option);
|
||||
}
|
||||
|
||||
g_object_set (s_ip4,
|
||||
NM_SETTING_IP_CONFIG_DNS_PRIORITY,
|
||||
nm_ip4_config_get_dns_priority (config),
|
||||
NULL);
|
||||
|
||||
return NM_SETTING (s_ip4);
|
||||
}
|
||||
|
||||
|
|
@ -725,6 +736,10 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFl
|
|||
nm_ip4_config_set_metered (dst, nm_ip4_config_get_metered (dst) ||
|
||||
nm_ip4_config_get_metered (src));
|
||||
|
||||
/* DNS priority */
|
||||
if (nm_ip4_config_get_dns_priority (src))
|
||||
nm_ip4_config_set_dns_priority (dst, nm_ip4_config_get_dns_priority (src));
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (dst));
|
||||
}
|
||||
|
||||
|
|
@ -948,6 +963,10 @@ nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src)
|
|||
nm_ip4_config_del_wins (dst, idx);
|
||||
}
|
||||
|
||||
/* DNS priority */
|
||||
if (nm_ip4_config_get_dns_priority (src) == nm_ip4_config_get_dns_priority (dst))
|
||||
nm_ip4_config_set_dns_priority (dst, 0);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (dst));
|
||||
}
|
||||
|
||||
|
|
@ -1188,6 +1207,12 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
|
|||
has_relevant_changes = TRUE;
|
||||
}
|
||||
|
||||
/* DNS priority */
|
||||
if (src_priv->dns_priority != dst_priv->dns_priority) {
|
||||
nm_ip4_config_set_dns_priority (dst, src_priv->dns_priority);
|
||||
has_relevant_changes = TRUE;
|
||||
}
|
||||
|
||||
/* mss */
|
||||
if (src_priv->mss != dst_priv->mss) {
|
||||
nm_ip4_config_set_mss (dst, src_priv->mss);
|
||||
|
|
@ -1311,6 +1336,7 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail)
|
|||
for (i = 0; i < nm_ip4_config_get_num_dns_options (config); i++)
|
||||
g_message (" dnsopt: %s", nm_ip4_config_get_dns_option (config, i));
|
||||
|
||||
g_message (" dnspri: %d", nm_ip4_config_get_dns_priority (config));
|
||||
|
||||
g_message (" mss: %"G_GUINT32_FORMAT, nm_ip4_config_get_mss (config));
|
||||
g_message (" mtu: %"G_GUINT32_FORMAT, nm_ip4_config_get_mtu (config));
|
||||
|
|
@ -1900,6 +1926,27 @@ nm_ip4_config_get_dns_option (const NMIP4Config *config, guint i)
|
|||
|
||||
/******************************************************************/
|
||||
|
||||
void
|
||||
nm_ip4_config_set_dns_priority (NMIP4Config *config, gint priority)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
if (priority != priv->dns_priority) {
|
||||
priv->dns_priority = priority;
|
||||
_notify (config, PROP_DNS_PRIORITY);
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
nm_ip4_config_get_dns_priority (const NMIP4Config *config)
|
||||
{
|
||||
const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->dns_priority;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
void
|
||||
nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss)
|
||||
{
|
||||
|
|
@ -2152,6 +2199,7 @@ nm_ip4_config_hash (const NMIP4Config *config, GChecksum *sum, gboolean dns_only
|
|||
g_checksum_update (sum, (const guint8 *) s, strlen (s));
|
||||
}
|
||||
|
||||
hash_u32 (sum, (guint32) nm_ip4_config_get_dns_priority (config));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2386,6 +2434,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_DNS_OPTIONS:
|
||||
nm_utils_g_value_set_strv (value, priv->dns_options);
|
||||
break;
|
||||
case PROP_DNS_PRIORITY:
|
||||
g_value_set_int (value, priv->dns_priority);
|
||||
break;
|
||||
case PROP_WINS_SERVERS:
|
||||
g_value_take_variant (value,
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32,
|
||||
|
|
@ -2488,7 +2539,11 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
|
|||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_DNS_PRIORITY] =
|
||||
g_param_spec_int (NM_IP4_CONFIG_DNS_PRIORITY, "", "",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_WINS_SERVERS] =
|
||||
g_param_spec_variant (NM_IP4_CONFIG_WINS_SERVERS, "", "",
|
||||
G_VARIANT_TYPE ("au"),
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ typedef struct {
|
|||
#define NM_IP4_CONFIG_DOMAINS "domains"
|
||||
#define NM_IP4_CONFIG_SEARCHES "searches"
|
||||
#define NM_IP4_CONFIG_DNS_OPTIONS "dns-options"
|
||||
#define NM_IP4_CONFIG_DNS_PRIORITY "dns-priority"
|
||||
#define NM_IP4_CONFIG_WINS_SERVERS "wins-servers"
|
||||
|
||||
/* deprecated */
|
||||
|
|
@ -137,6 +138,10 @@ void nm_ip4_config_del_dns_option (NMIP4Config *config, guint i);
|
|||
guint32 nm_ip4_config_get_num_dns_options (const NMIP4Config *config);
|
||||
const char * nm_ip4_config_get_dns_option (const NMIP4Config *config, guint i);
|
||||
|
||||
/* DNS priority */
|
||||
void nm_ip4_config_set_dns_priority (NMIP4Config *config, gint priority);
|
||||
gint nm_ip4_config_get_dns_priority (const NMIP4Config *config);
|
||||
|
||||
/* MSS */
|
||||
void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss);
|
||||
guint32 nm_ip4_config_get_mss (const NMIP4Config *config);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue