mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 11:50:29 +01:00
core: add DNS priority to NMIP6Config
This commit is contained in:
parent
f09f5e1ec8
commit
bfabfb05ae
3 changed files with 69 additions and 1 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"/>
|
||||
|
||||
<!--
|
||||
PropertiesChanged:
|
||||
@properties: A dictionary mapping property names to variant boxed values
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ typedef struct {
|
|||
guint32 mss;
|
||||
int ifindex;
|
||||
gint64 route_metric;
|
||||
gint dns_priority;
|
||||
} NMIP6ConfigPrivate;
|
||||
|
||||
struct _NMIP6Config {
|
||||
|
|
@ -83,6 +84,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMIP6Config,
|
|||
PROP_DOMAINS,
|
||||
PROP_SEARCHES,
|
||||
PROP_DNS_OPTIONS,
|
||||
PROP_DNS_PRIORITY,
|
||||
);
|
||||
|
||||
NMIP6Config *
|
||||
|
|
@ -433,7 +435,7 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, gu
|
|||
NMIP6ConfigPrivate *priv;
|
||||
guint naddresses, nroutes, nnameservers, nsearches;
|
||||
const char *gateway_str;
|
||||
int i;
|
||||
int i, priority;
|
||||
|
||||
if (!setting)
|
||||
return;
|
||||
|
|
@ -527,6 +529,10 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, gu
|
|||
i++;
|
||||
}
|
||||
|
||||
priority = nm_setting_ip_config_get_dns_priority (setting);
|
||||
if (priority)
|
||||
nm_ip6_config_set_dns_priority (config, priority);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (config));
|
||||
}
|
||||
|
||||
|
|
@ -643,6 +649,10 @@ nm_ip6_config_create_setting (const NMIP6Config *config)
|
|||
nm_setting_ip_config_add_dns_option (s_ip6, option);
|
||||
}
|
||||
|
||||
g_object_set (s_ip6,
|
||||
NM_SETTING_IP_CONFIG_DNS_PRIORITY,
|
||||
nm_ip6_config_get_dns_priority (config),
|
||||
NULL);
|
||||
|
||||
return NM_SETTING (s_ip6);
|
||||
}
|
||||
|
|
@ -710,6 +720,10 @@ nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src, NMIPConfigMergeFl
|
|||
if (nm_ip6_config_get_mss (src))
|
||||
nm_ip6_config_set_mss (dst, nm_ip6_config_get_mss (src));
|
||||
|
||||
/* DNS priority */
|
||||
if (nm_ip6_config_get_dns_priority (src))
|
||||
nm_ip6_config_set_dns_priority (dst, nm_ip6_config_get_dns_priority (src));
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (dst));
|
||||
}
|
||||
|
||||
|
|
@ -903,6 +917,10 @@ nm_ip6_config_subtract (NMIP6Config *dst, const NMIP6Config *src)
|
|||
if (nm_ip6_config_get_mss (src) == nm_ip6_config_get_mss (dst))
|
||||
nm_ip6_config_set_mss (dst, 0);
|
||||
|
||||
/* DNS priority */
|
||||
if (nm_ip6_config_get_dns_priority (src) == nm_ip6_config_get_dns_priority (dst))
|
||||
nm_ip6_config_set_dns_priority (dst, 0);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (dst));
|
||||
}
|
||||
|
||||
|
|
@ -1150,6 +1168,12 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev
|
|||
has_minor_changes = TRUE;
|
||||
}
|
||||
|
||||
/* DNS priority */
|
||||
if (src_priv->dns_priority != dst_priv->dns_priority) {
|
||||
nm_ip6_config_set_dns_priority (dst, src_priv->dns_priority);
|
||||
has_relevant_changes = TRUE;
|
||||
}
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
/* config_equal does not compare *all* the fields, therefore, we might have has_minor_changes
|
||||
* regardless of config_equal. But config_equal must correspond to has_relevant_changes. */
|
||||
|
|
@ -1210,6 +1234,8 @@ nm_ip6_config_dump (const NMIP6Config *config, const char *detail)
|
|||
for (i = 0; i < nm_ip6_config_get_num_dns_options (config); i++)
|
||||
g_message (" dnsopt: %s", nm_ip6_config_get_dns_option (config, i));
|
||||
|
||||
g_message (" dnspri: %d", nm_ip6_config_get_dns_priority (config));
|
||||
|
||||
g_message (" mss: %"G_GUINT32_FORMAT, nm_ip6_config_get_mss (config));
|
||||
g_message (" n-dflt: %d", nm_ip6_config_get_never_default (config));
|
||||
}
|
||||
|
|
@ -1781,6 +1807,27 @@ nm_ip6_config_get_dns_option (const NMIP6Config *config, guint i)
|
|||
|
||||
/******************************************************************/
|
||||
|
||||
void
|
||||
nm_ip6_config_set_dns_priority (NMIP6Config *config, gint priority)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
if (priority != priv->dns_priority) {
|
||||
priv->dns_priority = priority;
|
||||
_notify (config, PROP_DNS_PRIORITY);
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
nm_ip6_config_get_dns_priority (const NMIP6Config *config)
|
||||
{
|
||||
const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
return priv->dns_priority;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
void
|
||||
nm_ip6_config_set_mss (NMIP6Config *config, guint32 mss)
|
||||
{
|
||||
|
|
@ -1861,6 +1908,7 @@ nm_ip6_config_hash (const NMIP6Config *config, GChecksum *sum, gboolean dns_only
|
|||
g_checksum_update (sum, (const guint8 *) s, strlen (s));
|
||||
}
|
||||
|
||||
hash_u32 (sum, (guint32) nm_ip6_config_get_dns_priority (config));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2097,6 +2145,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;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -2192,6 +2243,11 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
|
|||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_DNS_PRIORITY] =
|
||||
g_param_spec_int (NM_IP6_CONFIG_DNS_PRIORITY, "", "",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ typedef struct _NMIP6ConfigClass NMIP6ConfigClass;
|
|||
#define NM_IP6_CONFIG_DOMAINS "domains"
|
||||
#define NM_IP6_CONFIG_SEARCHES "searches"
|
||||
#define NM_IP6_CONFIG_DNS_OPTIONS "dns-options"
|
||||
#define NM_IP6_CONFIG_DNS_PRIORITY "dns-priority"
|
||||
|
||||
/* deprecated */
|
||||
#define NM_IP6_CONFIG_ADDRESSES "addresses"
|
||||
|
|
@ -128,6 +129,10 @@ void nm_ip6_config_del_dns_option (NMIP6Config *config, guint i);
|
|||
guint32 nm_ip6_config_get_num_dns_options (const NMIP6Config *config);
|
||||
const char * nm_ip6_config_get_dns_option (const NMIP6Config *config, guint i);
|
||||
|
||||
/* DNS priority */
|
||||
void nm_ip6_config_set_dns_priority (NMIP6Config *config, gint priority);
|
||||
gint nm_ip6_config_get_dns_priority (const NMIP6Config *config);
|
||||
|
||||
/* MSS */
|
||||
void nm_ip6_config_set_mss (NMIP6Config *config, guint32 mss);
|
||||
guint32 nm_ip6_config_get_mss (const NMIP6Config *config);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue