core: add support for connection.llmnr

This commit is contained in:
Beniamino Galvani 2018-08-31 15:14:39 +02:00
parent e83c31bbe0
commit bc7efc750a
6 changed files with 85 additions and 4 deletions

View File

@ -653,6 +653,9 @@ ipv6.ip6-privacy=0
<varlistentry>
<term><varname>connection.lldp</varname></term>
</varlistentry>
<varlistentry>
<term><varname>connection.llmnr</varname></term>
</varlistentry>
<varlistentry>
<term><varname>connection.mdns</varname></term>
</varlistentry>

View File

@ -2177,6 +2177,28 @@ _get_mdns (NMDevice *self)
NM_SETTING_CONNECTION_MDNS_DEFAULT);
}
static NMSettingConnectionLlmnr
_get_llmnr (NMDevice *self)
{
NMConnection *connection;
NMSettingConnectionLlmnr llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT;
g_return_val_if_fail (NM_IS_DEVICE (self), NM_SETTING_CONNECTION_LLMNR_DEFAULT);
connection = nm_device_get_applied_connection (self);
if (connection)
llmnr = nm_setting_connection_get_llmnr (nm_connection_get_setting_connection (connection));
if (llmnr != NM_SETTING_CONNECTION_LLMNR_DEFAULT)
return llmnr;
return nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
"connection.llmnr",
self,
NM_SETTING_CONNECTION_LLMNR_NO,
NM_SETTING_CONNECTION_LLMNR_YES,
NM_SETTING_CONNECTION_LLMNR_DEFAULT);
}
guint32
nm_device_get_route_table (NMDevice *self,
int addr_family,
@ -6883,6 +6905,7 @@ ensure_con_ip_config (NMDevice *self, int addr_family)
nm_ip4_config_merge_setting (NM_IP4_CONFIG (con_ip_config),
nm_connection_get_setting_ip4_config (connection),
_get_mdns (self),
_get_llmnr (self),
nm_device_get_route_table (self, addr_family, TRUE),
nm_device_get_route_metric (self, addr_family));
} else {
@ -7295,6 +7318,7 @@ dhcp4_state_changed (NMDhcpClient *client,
nm_ip4_config_merge_setting (manual,
nm_connection_get_setting_ip4_config (connection),
NM_SETTING_CONNECTION_MDNS_DEFAULT,
NM_SETTING_CONNECTION_LLMNR_DEFAULT,
nm_device_get_route_table (self, AF_INET, TRUE),
nm_device_get_route_metric (self, AF_INET));
@ -7817,6 +7841,7 @@ act_stage3_ip4_config_start (NMDevice *self,
nm_ip4_config_merge_setting (config,
nm_connection_get_setting_ip4_config (connection),
NM_SETTING_CONNECTION_MDNS_DEFAULT,
NM_SETTING_CONNECTION_LLMNR_DEFAULT,
nm_device_get_route_table (self, AF_INET, TRUE),
nm_device_get_route_metric (self, AF_INET));
configs = g_new0 (NMIP4Config *, 2);
@ -10682,6 +10707,7 @@ nm_device_reactivate_ip4_config (NMDevice *self,
nm_ip4_config_merge_setting (priv->con_ip_config_4,
s_ip4_new,
_get_mdns (self),
_get_llmnr (self),
nm_device_get_route_table (self, AF_INET, TRUE),
nm_device_get_route_metric (self, AF_INET));

View File

@ -65,7 +65,6 @@ typedef struct {
GDBusProxy *resolve;
GCancellable *init_cancellable;
GCancellable *update_cancellable;
GCancellable *mdns_cancellable;
CList request_queue_lst_head;
} NMDnsSystemdResolvedPrivate;
@ -192,7 +191,8 @@ prepare_one_interface (NMDnsSystemdResolved *self, InterfaceConfig *ic)
GVariantBuilder dns, domains;
NMCListElem *elem;
NMSettingConnectionMdns mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT;
const char *mdns_arg = NULL;
NMSettingConnectionLlmnr llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT;
const char *mdns_arg = NULL, *llmnr_arg = NULL;
g_variant_builder_init (&dns, G_VARIANT_TYPE ("(ia(iay))"));
g_variant_builder_add (&dns, "i", ic->ifindex);
@ -208,8 +208,10 @@ prepare_one_interface (NMDnsSystemdResolved *self, InterfaceConfig *ic)
update_add_ip_config (self, &dns, &domains, data);
if (NM_IS_IP4_CONFIG (ip_config))
if (NM_IS_IP4_CONFIG (ip_config)) {
mdns = NM_MAX (mdns, nm_ip4_config_mdns_get (NM_IP4_CONFIG (ip_config)));
llmnr = NM_MAX (llmnr, nm_ip4_config_llmnr_get (NM_IP4_CONFIG (ip_config)));
}
}
g_variant_builder_close (&dns);
@ -231,6 +233,22 @@ prepare_one_interface (NMDnsSystemdResolved *self, InterfaceConfig *ic)
}
nm_assert (mdns_arg);
switch (llmnr) {
case NM_SETTING_CONNECTION_LLMNR_NO:
llmnr_arg = "no";
break;
case NM_SETTING_CONNECTION_LLMNR_RESOLVE:
llmnr_arg = "resolve";
break;
case NM_SETTING_CONNECTION_LLMNR_YES:
llmnr_arg = "yes";
break;
case NM_SETTING_CONNECTION_LLMNR_DEFAULT:
llmnr_arg = "";
break;
}
nm_assert (llmnr_arg);
_request_item_append (&priv->request_queue_lst_head,
"SetLinkDNS",
g_variant_builder_end (&dns));
@ -240,6 +258,9 @@ prepare_one_interface (NMDnsSystemdResolved *self, InterfaceConfig *ic)
_request_item_append (&priv->request_queue_lst_head,
"SetLinkMulticastDNS",
g_variant_new ("(is)", ic->ifindex, mdns_arg ?: ""));
_request_item_append (&priv->request_queue_lst_head,
"SetLinkLLMNR",
g_variant_new ("(is)", ic->ifindex, llmnr_arg ?: ""));
}
static void
@ -410,7 +431,6 @@ dispose (GObject *object)
g_clear_object (&priv->resolve);
nm_clear_g_cancellable (&priv->init_cancellable);
nm_clear_g_cancellable (&priv->update_cancellable);
nm_clear_g_cancellable (&priv->mdns_cancellable);
G_OBJECT_CLASS (nm_dns_systemd_resolved_parent_class)->dispose (object);
}

View File

@ -295,6 +295,7 @@ typedef struct {
NMIPConfigSource mtu_source;
int dns_priority;
NMSettingConnectionMdns mdns;
NMSettingConnectionLlmnr llmnr;
GArray *nameservers;
GPtrArray *domains;
GPtrArray *searches;
@ -916,6 +917,7 @@ void
nm_ip4_config_merge_setting (NMIP4Config *self,
NMSettingIPConfig *setting,
NMSettingConnectionMdns mdns,
NMSettingConnectionLlmnr llmnr,
guint32 route_table,
guint32 route_metric)
{
@ -1033,6 +1035,7 @@ nm_ip4_config_merge_setting (NMIP4Config *self,
nm_ip4_config_set_dns_priority (self, priority);
nm_ip4_config_mdns_set (self, mdns);
nm_ip4_config_llmnr_set (self, llmnr);
g_object_thaw_notify (G_OBJECT (self));
}
@ -1253,6 +1256,10 @@ nm_ip4_config_merge (NMIP4Config *dst,
nm_ip4_config_mdns_set (dst,
NM_MAX (nm_ip4_config_mdns_get (src),
nm_ip4_config_mdns_get (dst)));
/* LLMNR */
nm_ip4_config_llmnr_set (dst,
NM_MAX (nm_ip4_config_llmnr_get (src),
nm_ip4_config_llmnr_get (dst)));
g_object_thaw_notify (G_OBJECT (dst));
}
@ -1494,6 +1501,10 @@ nm_ip4_config_subtract (NMIP4Config *dst,
if (nm_ip4_config_mdns_get (src) == nm_ip4_config_mdns_get (dst))
nm_ip4_config_mdns_set (dst, NM_SETTING_CONNECTION_MDNS_DEFAULT);
/* LLMNR */
if (nm_ip4_config_llmnr_get (src) == nm_ip4_config_llmnr_get (dst))
nm_ip4_config_llmnr_set (dst, NM_SETTING_CONNECTION_LLMNR_DEFAULT);
g_object_thaw_notify (G_OBJECT (dst));
}
@ -1595,6 +1606,7 @@ _nm_ip4_config_intersect_helper (NMIP4Config *dst,
/* ignore NIS */
/* ignore WINS */
/* ignore mdns */
/* ignore LLMNR */
if (update_dst)
g_object_thaw_notify (G_OBJECT (dst));
@ -1874,6 +1886,7 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
}
dst_priv->mdns = src_priv->mdns;
dst_priv->llmnr = src_priv->llmnr;
/* DNS priority */
if (src_priv->dns_priority != dst_priv->dns_priority) {
@ -2562,6 +2575,19 @@ nm_ip4_config_mdns_set (NMIP4Config *self,
NM_IP4_CONFIG_GET_PRIVATE (self)->mdns = mdns;
}
NMSettingConnectionLlmnr
nm_ip4_config_llmnr_get (const NMIP4Config *self)
{
return NM_IP4_CONFIG_GET_PRIVATE (self)->llmnr;
}
void
nm_ip4_config_llmnr_set (NMIP4Config *self,
NMSettingConnectionLlmnr llmnr)
{
NM_IP4_CONFIG_GET_PRIVATE (self)->llmnr = llmnr;
}
/*****************************************************************************/
void
@ -3212,6 +3238,7 @@ nm_ip4_config_init (NMIP4Config *self)
NMP_OBJECT_TYPE_IP4_ROUTE);
priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT;
priv->llmnr = NM_SETTING_CONNECTION_LLMNR_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);

View File

@ -175,6 +175,7 @@ gboolean nm_ip4_config_commit (const NMIP4Config *self,
void nm_ip4_config_merge_setting (NMIP4Config *self,
NMSettingIPConfig *setting,
NMSettingConnectionMdns mdns,
NMSettingConnectionLlmnr llmnr,
guint32 route_table,
guint32 route_metric);
NMSetting *nm_ip4_config_create_setting (const NMIP4Config *self);
@ -203,6 +204,9 @@ 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);
NMSettingConnectionLlmnr nm_ip4_config_llmnr_get (const NMIP4Config *self);
void nm_ip4_config_llmnr_set (NMIP4Config *self,
NMSettingConnectionLlmnr llmnr);
const NMDedupMultiHeadEntry *nm_ip4_config_lookup_addresses (const NMIP4Config *self);
void nm_ip4_config_reset_addresses (NMIP4Config *self);

View File

@ -1619,6 +1619,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
nm_ip4_config_merge_setting (config,
s_ip,
nm_setting_connection_get_mdns (s_con),
nm_setting_connection_get_llmnr (s_con),
route_table,
route_metric);