diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-04-23 15:57:17 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-05-12 17:13:50 +0200 |
commit | bfabfb05ae642112b7fde23da0d78689c2046745 (patch) | |
tree | 3ec8db9de1f86ff0b241c81ec2d4aa700b172e97 /src/nm-ip6-config.c | |
parent | f09f5e1ec84b1e8b0e6231f72655f6446ae4646a (diff) | |
download | NetworkManager-bfabfb05ae642112b7fde23da0d78689c2046745.tar.gz |
core: add DNS priority to NMIP6Config
Diffstat (limited to 'src/nm-ip6-config.c')
-rw-r--r-- | src/nm-ip6-config.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index fce06706ff..e525c10287 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -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)); } @@ -1782,6 +1808,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) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); @@ -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); |