Commit 5eea9be9 authored by Thomas Haller's avatar Thomas Haller

all: merge branch 'th/policy-and-mdns'

https://github.com/NetworkManager/NetworkManager/pull/44
parents 08a91094 d1de905e
......@@ -1479,16 +1479,16 @@ src_libNetworkManager_la_SOURCES = \
src/dhcp/nm-dhcp-dhclient-utils.c \
src/dhcp/nm-dhcp-dhclient-utils.h \
\
src/dns/nm-dns-manager.c \
src/dns/nm-dns-manager.h \
src/dns/nm-dns-plugin.c \
src/dns/nm-dns-plugin.h \
src/dns/nm-dns-dnsmasq.c \
src/dns/nm-dns-dnsmasq.h \
src/dns/nm-dns-systemd-resolved.c \
src/dns/nm-dns-systemd-resolved.h \
src/dns/nm-dns-unbound.c \
src/dns/nm-dns-unbound.h \
src/dns/nm-dns-manager.c \
src/dns/nm-dns-manager.h \
src/dns/nm-dns-plugin.c \
src/dns/nm-dns-plugin.h \
\
src/dnsmasq/nm-dnsmasq-manager.c \
src/dnsmasq/nm-dnsmasq-manager.h \
......@@ -4498,6 +4498,7 @@ EXTRA_DIST += \
shared/nm-utils/c-list-util.c \
shared/nm-utils/c-list-util.h \
shared/nm-utils/gsystem-local-alloc.h \
shared/nm-utils/nm-c-list.h \
shared/nm-utils/nm-compat.c \
shared/nm-utils/nm-compat.h \
shared/nm-utils/nm-glib.h \
......
......@@ -5577,6 +5577,14 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
| NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PRETTY_TEXT,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_MDNS,
.property_type = &_pt_gobject_enum,
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
PROPERTY_TYP_DATA_SUBTYPE (gobject_enum,
.get_gtype = nm_setting_connection_mdns_get_type,
),
),
),
NULL
};
......
......@@ -144,6 +144,7 @@
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_INTERFACE_NAME N_("The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_LLDP N_("Whether LLDP is enabled for the connection.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MASTER N_("Interface name of the master device or UUID of the master connection.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MDNS N_("Whether mDNS is enabled for the connection. The permitted values are: yes: register hostname and resolving for the connection, no: disable mDNS for the interface, resolve: do not register hostname but allow resolving of mDNS host names. When updating this property on a currently activated connection, the change takes effect immediately. This feature requires a plugin which supports mDNS. One such plugin is dns-systemd-resolved.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_METERED N_("Whether the connection is metered. When updating this property on a currently activated connection, the change takes effect immediately.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_PERMISSIONS N_("An array of strings defining what access a given user has to this connection. If this is NULL or empty, all users are allowed to access this connection; otherwise users are allowed if and only if they are in this list. When this is not empty, the connection can be active only when one of the specified users is logged into an active session. Each entry is of the form \"[type]:[id]:[reserved]\"; for example, \"user:dcbw:blah\". At this time only the \"user\" [type] is allowed. Any other values are ignored and reserved for future use. [id] is the username that this permission refers to, which may not contain the \":\" character. Any [reserved] information present must be ignored and is reserved for future use. All of [type], [id], and [reserved] must be valid UTF-8.")
......
......@@ -81,6 +81,7 @@ typedef struct {
NMMetered metered;
NMSettingConnectionLldp lldp;
gint auth_retries;
int mdns;
} NMSettingConnectionPrivate;
enum {
......@@ -103,6 +104,7 @@ enum {
PROP_GATEWAY_PING_TIMEOUT,
PROP_METERED,
PROP_LLDP,
PROP_MDNS,
PROP_STABLE_ID,
PROP_AUTH_RETRIES,
......@@ -862,6 +864,23 @@ nm_setting_connection_get_lldp (NMSettingConnection *setting)
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->lldp;
}
/**
* nm_setting_connection_get_mdns:
* @setting: the #NMSettingConnection
*
* Returns: the #NMSettingConnection:mdns property of the setting.
*
* Since: 1.12
**/
NMSettingConnectionMdns
nm_setting_connection_get_mdns (NMSettingConnection *setting)
{
g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting),
NM_SETTING_CONNECTION_MDNS_DEFAULT);
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->mdns;
}
static void
_set_error_missing_base_setting (GError **error, const char *type)
{
......@@ -1057,6 +1076,17 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return FALSE;
}
if ( priv->mdns < NM_SETTING_CONNECTION_MDNS_DEFAULT
|| priv->mdns > NM_SETTING_CONNECTION_MDNS_RESOLVE) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("mdns value %d is not valid"), priv->mdns);
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME,
NM_SETTING_CONNECTION_MDNS);
return FALSE;
}
/* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */
if (!priv->uuid) {
......@@ -1214,6 +1244,9 @@ compare_property (NMSetting *setting,
static void
nm_setting_connection_init (NMSettingConnection *setting)
{
NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT;
}
static void
......@@ -1332,6 +1365,9 @@ set_property (GObject *object, guint prop_id,
case PROP_AUTH_RETRIES:
priv->auth_retries = g_value_get_int (value);
break;
case PROP_MDNS:
priv->mdns = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -1420,6 +1456,9 @@ get_property (GObject *object, guint prop_id,
case PROP_AUTH_RETRIES:
g_value_set_int (value, priv->auth_retries);
break;
case PROP_MDNS:
g_value_set_int (value, priv->mdns);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -1982,4 +2021,37 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
G_PARAM_CONSTRUCT |
NM_SETTING_PARAM_FUZZY_IGNORE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingConnection:mdns:
*
* Whether mDNS is enabled for the connection.
*
* The permitted values are: yes: register hostname and resolving
* for the connection, no: disable mDNS for the interface, resolve:
* do not register hostname but allow resolving of mDNS host names.
* When updating this property on a currently activated connection,
* the change takes effect immediately.
*
* This feature requires a plugin which supports mDNS. One such
* plugin is dns-systemd-resolved.
*
* Since: 1.12
**/
/* ---ifcfg-rh---
* property: mdns
* variable: CONNECTION_MDNS(+)
* values: yes,no,resolve
* default: missing variable means global default
* description: Whether or not mDNS is enabled for the connection
* example: CONNECTION_MDNS=yes
* ---end---
*/
g_object_class_install_property
(object_class, PROP_MDNS,
g_param_spec_int (NM_SETTING_CONNECTION_MDNS, "", "",
G_MININT32, G_MAXINT32,
NM_SETTING_CONNECTION_MDNS_DEFAULT,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
}
......@@ -64,6 +64,7 @@ G_BEGIN_DECLS
#define NM_SETTING_CONNECTION_METERED "metered"
#define NM_SETTING_CONNECTION_LLDP "lldp"
#define NM_SETTING_CONNECTION_AUTH_RETRIES "auth-retries"
#define NM_SETTING_CONNECTION_MDNS "mdns"
/* Types for property values */
/**
......@@ -97,6 +98,24 @@ typedef enum {
NM_SETTING_CONNECTION_LLDP_ENABLE_RX = 1,
} NMSettingConnectionLldp;
/**
* NMSettingConnectionMdns:
* @NM_SETTING_CONNECTION_MDNS_DEFAULT: default value
* @NM_SETTING_CONNECTION_MDNS_NO: disable mDNS
* @NM_SETTING_CONNECTION_MDNS_RESOLVE: support only resolving, do not register hostname
* @NM_SETTING_CONNECTION_MDNS_YES: enable mDNS
*
* #NMSettingConnectionMdns values indicate whether mDNS should be enabled.
*
* Since: 1.12
*/
typedef enum {
NM_SETTING_CONNECTION_MDNS_DEFAULT = -1,
NM_SETTING_CONNECTION_MDNS_NO = 0,
NM_SETTING_CONNECTION_MDNS_RESOLVE = 1,
NM_SETTING_CONNECTION_MDNS_YES = 2,
} NMSettingConnectionMdns;
/**
* NMSettingConnection:
*
......@@ -170,6 +189,8 @@ NMSettingConnectionLldp nm_setting_connection_get_lldp (NMSettingConnection *set
NM_AVAILABLE_IN_1_10
gint nm_setting_connection_get_auth_retries (NMSettingConnection *setting);
NM_AVAILABLE_IN_1_12
NMSettingConnectionMdns nm_setting_connection_get_mdns (NMSettingConnection *setting);
G_END_DECLS
#endif /* __NM_SETTING_CONNECTION_H__ */
......@@ -2604,6 +2604,7 @@ test_connection_diff_a_only (void)
{ NM_SETTING_CONNECTION_METERED, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_LLDP, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_AUTH_RETRIES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_MDNS, NM_SETTING_DIFF_RESULT_IN_A },
{ NULL, NM_SETTING_DIFF_RESULT_UNKNOWN }
} },
{ NM_SETTING_WIRED_SETTING_NAME, {
......
......@@ -1347,6 +1347,8 @@ global:
nm_client_get_checkpoints;
nm_device_ip_tunnel_get_flags;
nm_ip_tunnel_flags_get_type;
nm_setting_connection_get_mdns;
nm_setting_connection_mdns_get_type;
nm_setting_ip_tunnel_get_flags;
nm_setting_vpn_get_data_keys;
nm_setting_vpn_get_secret_keys;
......
......@@ -654,6 +654,9 @@ ipv6.ip6-privacy=0
<varlistentry>
<term><varname>connection.lldp</varname></term>
</varlistentry>
<varlistentry>
<term><varname>connection.mdns</varname></term>
</varlistentry>
<varlistentry>
<term><varname>connection.stable-id</varname></term>
</varlistentry>
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2014 Red Hat, Inc.
*/
#ifndef __NM_C_LIST_H__
#define __NM_C_LIST_H__
#include "c-list.h"
/*****************************************************************************/
typedef struct {
CList lst;
void *data;
} NMCListElem;
static inline NMCListElem *
nm_c_list_elem_new_stale (void *data)
{
NMCListElem *elem;
elem = g_slice_new (NMCListElem);
elem->data = data;
return elem;
}
static inline void *
nm_c_list_elem_get (CList *lst)
{
if (!lst)
return NULL;
return c_list_entry (lst, NMCListElem, lst)->data;
}
static inline void
nm_c_list_elem_free (NMCListElem *elem)
{
if (elem) {
c_list_unlink_stale (&elem->lst);
g_slice_free (NMCListElem, elem);
}
}
static inline void
nm_c_list_elem_free_all (CList *head, GDestroyNotify free_fcn)
{
NMCListElem *elem;
while ((elem = c_list_first_entry (head, NMCListElem, lst))) {
if (free_fcn)
free_fcn (elem->data);
c_list_unlink_stale (&elem->lst);
g_slice_free (NMCListElem, elem);
}
}
#endif /* __NM_C_LIST_H__ */
......@@ -1049,6 +1049,25 @@ nm_cmp_uint32_p_with_data (gconstpointer p_a, gconstpointer p_b, gpointer user_d
return 0;
}
static inline int
nm_cmp_int2ptr_p_with_data (gconstpointer p_a, gconstpointer p_b, gpointer user_data)
{
/* p_a and p_b are two pointers to a pointer, where the pointer is
* interpreted as a integer using GPOINTER_TO_INT().
*
* That is the case of a hash-table that uses GINT_TO_POINTER() to
* convert integers as pointers, and the resulting keys-as-array
* array. */
const int a = GPOINTER_TO_INT (*((gconstpointer *) p_a));
const int b = GPOINTER_TO_INT (*((gconstpointer *) p_b));
if (a < b)
return -1;
if (a > b)
return 1;
return 0;
}
/*****************************************************************************/
/* Taken from systemd's UNIQ_T and UNIQ macros. */
......
......@@ -1878,6 +1878,34 @@ out:
return nm_utils_ip_route_metric_normalize (addr_family, route_metric);
}
static NMSettingConnectionMdns
_get_mdns (NMDevice *self)
{
NMConnection *connection;
NMSettingConnectionMdns mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT;
g_return_val_if_fail (NM_IS_DEVICE (self), NM_SETTING_CONNECTION_MDNS_DEFAULT);
connection = nm_device_get_applied_connection (self);
if (connection)
mdns = nm_setting_connection_get_mdns (nm_connection_get_setting_connection (connection));
if (mdns == NM_SETTING_CONNECTION_MDNS_DEFAULT) {
gs_free char *value = NULL;
value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
"connection.mdns",
self);
mdns = _nm_utils_ascii_str_to_int64 (value,
10,
NM_SETTING_CONNECTION_MDNS_NO,
NM_SETTING_CONNECTION_MDNS_YES,
NM_SETTING_CONNECTION_MDNS_DEFAULT);
}
return mdns;
}
guint32
nm_device_get_route_table (NMDevice *self,
int addr_family,
......@@ -5922,6 +5950,7 @@ ensure_con_ip4_config (NMDevice *self)
priv->con_ip4_config = _ip4_config_new (self);
nm_ip4_config_merge_setting (priv->con_ip4_config,
nm_connection_get_setting_ip4_config (connection),
_get_mdns (self),
nm_device_get_route_table (self, AF_INET, TRUE),
nm_device_get_route_metric (self, AF_INET));
......@@ -6217,6 +6246,7 @@ dhcp4_state_changed (NMDhcpClient *client,
manual = _ip4_config_new (self);
nm_ip4_config_merge_setting (manual,
nm_connection_get_setting_ip4_config (connection),
NM_SETTING_CONNECTION_MDNS_DEFAULT,
nm_device_get_route_table (self, AF_INET, TRUE),
nm_device_get_route_metric (self, AF_INET));
......@@ -6596,6 +6626,7 @@ act_stage3_ip4_config_start (NMDevice *self,
config = _ip4_config_new (self);
nm_ip4_config_merge_setting (config,
nm_connection_get_setting_ip4_config (connection),
NM_SETTING_CONNECTION_MDNS_DEFAULT,
nm_device_get_route_table (self, AF_INET, TRUE),
nm_device_get_route_metric (self, AF_INET));
......@@ -9313,6 +9344,7 @@ nm_device_reactivate_ip4_config (NMDevice *self,
priv->con_ip4_config = _ip4_config_new (self);
nm_ip4_config_merge_setting (priv->con_ip4_config,
s_ip4_new,
_get_mdns (self),
nm_device_get_route_table (self, AF_INET, TRUE),
nm_device_get_route_metric (self, AF_INET));
......
......@@ -24,6 +24,7 @@
#include <netinet/in.h>
#include "nm-setting-connection.h"
#include "nm-exported-object.h"
#include "nm-dbus-interface.h"
#include "nm-connection.h"
......
This diff is collapsed.
This diff is collapsed.
......@@ -26,11 +26,14 @@
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"
#include "nm-setting-connection.h"
typedef enum {
NM_DNS_IP_CONFIG_TYPE_REMOVED = -1,
NM_DNS_IP_CONFIG_TYPE_DEFAULT = 0,
NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE,
NM_DNS_IP_CONFIG_TYPE_VPN
NM_DNS_IP_CONFIG_TYPE_VPN,
} NMDnsIPConfigType;
enum {
......@@ -38,12 +41,23 @@ enum {
NM_DNS_PRIORITY_DEFAULT_VPN = 50,
};
struct _NMDnsConfigData;
struct _NMDnsManager;
typedef struct {
gpointer config;
NMDnsIPConfigType type;
char *iface;
struct _NMDnsConfigData *data;
NMIPConfig *ip_config;
CList data_lst;
CList ip_config_lst;
NMDnsIPConfigType ip_config_type;
} NMDnsIPConfigData;
typedef struct _NMDnsConfigData {
struct _NMDnsManager *self;
CList data_lst_head;
int ifindex;
} NMDnsConfigData;
#define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ())
#define NM_DNS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_DNS_MANAGER, NMDnsManager))
#define NM_DNS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_DNS_MANAGER, NMDnsManagerClass))
......@@ -70,12 +84,9 @@ NMDnsManager * nm_dns_manager_get (void);
void nm_dns_manager_begin_updates (NMDnsManager *self, const char *func);
void nm_dns_manager_end_updates (NMDnsManager *self, const char *func);
gboolean nm_dns_manager_add_ip_config (NMDnsManager *self,
const char *iface,
gpointer config,
NMDnsIPConfigType cfg_type);
gboolean nm_dns_manager_remove_ip_config (NMDnsManager *self, gpointer config);
gboolean nm_dns_manager_set_ip_config (NMDnsManager *self,
NMIPConfig *ip_config,
NMDnsIPConfigType ip_config_type);
void nm_dns_manager_set_initial_hostname (NMDnsManager *self,
const char *hostname);
......
......@@ -77,15 +77,15 @@ G_DEFINE_TYPE_EXTENDED (NMDnsPlugin, nm_dns_plugin, G_TYPE_OBJECT, G_TYPE_FLAG_A
gboolean
nm_dns_plugin_update (NMDnsPlugin *self,
const GPtrArray *configs,
const NMGlobalDnsConfig *global_config,
const CList *ip_config_lst_head,
const char *hostname)
{
g_return_val_if_fail (NM_DNS_PLUGIN_GET_CLASS (self)->update != NULL, FALSE);
return NM_DNS_PLUGIN_GET_CLASS (self)->update (self,
configs,
global_config,
ip_config_lst_head,
hostname);
}
......
......@@ -50,8 +50,8 @@ typedef struct {
* configuration.
*/
gboolean (*update) (NMDnsPlugin *self,
const GPtrArray *configs,
const NMGlobalDnsConfig *global_config,
const CList *ip_config_lst_head,
const char *hostname);
/* Subclasses should override and return TRUE if they start a local
......@@ -80,8 +80,8 @@ gboolean nm_dns_plugin_is_caching (NMDnsPlugin *self);
const char *nm_dns_plugin_get_name (NMDnsPlugin *self);
gboolean nm_dns_plugin_update (NMDnsPlugin *self,
const GPtrArray *configs,
const NMGlobalDnsConfig *global_config,
const CList *ip_config_lst_head,
const char *hostname);
void nm_dns_plugin_stop (NMDnsPlugin *self);
......
This diff is collapsed.
......@@ -39,8 +39,8 @@ G_DEFINE_TYPE (NMDnsUnbound, nm_dns_unbound, NM_TYPE_DNS_PLUGIN)
static gboolean
update (NMDnsPlugin *plugin,
const GPtrArray *configs,
const NMGlobalDnsConfig *global_config,
const CList *ip_config_lst_head,
const char *hostname)
{
char *argv[] = { DNSSEC_TRIGGER_SCRIPT, "--async", "--update", NULL };
......
......@@ -293,6 +293,7 @@ typedef struct {
int ifindex;
NMIPConfigSource mtu_source;
gint dns_priority;
NMSettingConnectionMdns mdns;
GArray *nameservers;
GPtrArray *domains;
GPtrArray *searches;
......@@ -901,6 +902,7 @@ _nm_ip_config_merge_route_attributes (int addr_family,
void
nm_ip4_config_merge_setting (NMIP4Config *self,
NMSettingIPConfig *setting,
NMSettingConnectionMdns mdns,
guint32 route_table,
guint32 route_metric)
{
......@@ -1017,6 +1019,8 @@ nm_ip4_config_merge_setting (NMIP4Config *self,
if (priority)
nm_ip4_config_set_dns_priority (self, priority);
nm_ip4_config_mdns_set (self, mdns);
g_object_thaw_notify (G_OBJECT (self));
}
......@@ -1232,6 +1236,11 @@ nm_ip4_config_merge (NMIP4Config *dst,
if (nm_ip4_config_get_dns_priority (src))
nm_ip4_config_set_dns_priority (dst, nm_ip4_config_get_dns_priority (src));
/* mdns */
nm_ip4_config_mdns_set (dst,
NM_MAX (nm_ip4_config_mdns_get (src),
nm_ip4_config_mdns_get (dst)));
g_object_thaw_notify (G_OBJECT (dst));
}
......@@ -1468,6 +1477,10 @@ nm_ip4_config_subtract (NMIP4Config *dst,
if (nm_ip4_config_get_dns_priority (src) == nm_ip4_config_get_dns_priority (dst))
nm_ip4_config_set_dns_priority (dst, 0);
/* mdns */
if (nm_ip4_config_mdns_get (src) == nm_ip4_config_mdns_get (dst))
nm_ip4_config_mdns_set (dst, NM_SETTING_CONNECTION_MDNS_DEFAULT);
g_object_thaw_notify (G_OBJECT (dst));
}
......@@ -1568,6 +1581,7 @@ _nm_ip4_config_intersect_helper (NMIP4Config *dst,
/* ignore dns options */
/* ignore NIS */
/* ignore WINS */
/* ignore mdns */
if (update_dst)
g_object_thaw_notify (G_OBJECT (dst));
......@@ -1846,6 +1860,8 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
has_relevant_changes = TRUE;
}
dst_priv->mdns = src_priv->mdns;
/* DNS priority */
if (src_priv->dns_priority != dst_priv->dns_priority) {
nm_ip4_config_set_dns_priority (dst, src_priv->dns_priority);
......@@ -2523,6 +2539,21 @@ nm_ip4_config_get_dns_option (const NMIP4Config *self, guint i)
/*****************************************************************************/
NMSettingConnectionMdns
nm_ip4_config_mdns_get (const NMIP4Config *self)
{
return NM_IP4_CONFIG_GET_PRIVATE (self)->mdns;
}
void
nm_ip4_config_mdns_set (NMIP4Config *self,
NMSettingConnectionMdns mdns)
{
NM_IP4_CONFIG_GET_PRIVATE (self)->mdns = mdns;
}
/*****************************************************************************/
void
nm_ip4_config_set_dns_priority (NMIP4Config *self, gint priority)
{
......@@ -3133,6 +3164,7 @@ nm_ip4_config_init (NMIP4Config *self)
nm_ip_config_dedup_multi_idx_type_init ((NMIPConfigDedupMultiIdxType *) &priv->idx_ip4_routes,
NMP_OBJECT_TYPE_IP4_ROUTE);
priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT;
priv->nameservers = g_array_new (FALSE, FALSE, sizeof (guint32));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
......
......@@ -21,6 +21,8 @@
#ifndef __NETWORKMANAGER_IP4_CONFIG_H__
#define __NETWORKMANAGER_IP4_CONFIG_H__
#include "nm-setting-connection.h"
#include "nm-exported-object.h"
#include "nm-setting-ip4-config.h"
......@@ -172,6 +174,7 @@ gboolean nm_ip4_config_commit (const NMIP4Config *self,
void nm_ip4_config_merge_setting (NMIP4Config *self,
NMSettingIPConfig *setting,
NMSettingConnectionMdns mdns,
guint32 route_table,
guint32 route_metric);
NMSetting *nm_ip4_config_create_setting (const NMIP4Config *self);
......@@ -198,6 +201,10 @@ const NMPObject *_nm_ip4_config_best_default_route_find (const NMIP4Config *self
in_addr_t nmtst_ip4_config_get_gateway (NMIP4Config *config);
NMSettingConnectionMdns nm_ip4_config_mdns_get (const NMIP4Config *self);
void nm_ip4_config_mdns_set (NMIP4Config *self,
NMSettingConnectionMdns mdns);
const NMDedupMultiHeadEntry *nm_ip4_config_lookup_addresses (const NMIP4Config *self);
void nm_ip4_config_reset_addresses (NMIP4Config *self);
void nm_ip4_config_add_address (NMIP4Config *self, const NMPlatformIP4Address *address);
......@@ -373,6 +380,18 @@ nm_ip_config_get_addr_family (const NMIPConfig *config)
} \
} G_STMT_END
static inline int
nm_ip_config_get_ifindex (const NMIPConfig *self)
{
_NM_IP_CONFIG_DISPATCH (self, nm_ip4_config_get_ifindex, nm_ip6_config_get_ifindex);
}
static inline void
nm_ip_config_hash (const NMIPConfig *self, GChecksum *sum, gboolean dns_only)
{
_NM_IP_CONFIG_DISPATCH_VOID (self, nm_ip4_config_hash, nm_ip6_config_hash, sum, dns_only);
}
static inline void
nm_ip_config_add_address (NMIPConfig *self, const NMPlatformIPAddress *address)
{
......
......@@ -1065,22 +1065,19 @@ update_ip_dns (NMPolicy *self, int addr_family)
gpointer ip_config;
const char *ip_iface = NULL;
NMVpnConnection *vpn = NULL;
NMDnsIPConfigType dns_type = NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE;
nm_assert_addr_family (addr_family);
ip_config = get_best_ip_config (self, addr_family, &ip_iface, NULL, NULL, &vpn);
if (ip_config) {
if (vpn)
dns_type = NM_DNS_IP_CONFIG_TYPE_VPN;
/* Tell the DNS manager this config is preferred by re-adding it with
* a different IP config type.
*/
nm_dns_manager_add_ip_config (NM_POLICY_GET_PRIVATE (self)->dns_manager,
ip_iface,
nm_dns_manager_set_ip_config (NM_POLICY_GET_PRIVATE (self)->dns_manager,
ip_config,
dns_type);
vpn