diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index bc99065e71..e26d547aeb 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -876,7 +876,7 @@ NMSettingConnectionMdns nm_setting_connection_get_mdns (NMSettingConnection *setting) { g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), - NM_SETTING_CONNECTION_MDNS_UNKNOWN); + NM_SETTING_CONNECTION_MDNS_DEFAULT); return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->mdns; } @@ -1076,7 +1076,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if ( priv->mdns < NM_SETTING_CONNECTION_MDNS_UNKNOWN + if ( priv->mdns < NM_SETTING_CONNECTION_MDNS_DEFAULT || priv->mdns > NM_SETTING_CONNECTION_MDNS_RESOLVE) { g_set_error (error, NM_CONNECTION_ERROR, @@ -1244,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 @@ -2048,8 +2051,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) (object_class, PROP_MDNS, g_param_spec_int (NM_SETTING_CONNECTION_MDNS, "", "", G_MININT32, G_MAXINT32, - NM_SETTING_CONNECTION_MDNS_UNKNOWN, + NM_SETTING_CONNECTION_MDNS_DEFAULT, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)); } diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h index ac8cc2cc6e..ec3b38a758 100644 --- a/libnm-core/nm-setting-connection.h +++ b/libnm-core/nm-setting-connection.h @@ -100,20 +100,20 @@ typedef enum { /** * NMSettingConnectionMdns: - * @NM_SETTING_CONNECTION_MDNS_UNKNOWN: default value - * @NM_SETTING_CONNECTION_MDNS_YES: disable mDNS - * @NM_SETTING_CONNECTION_MDNS_NO: enable mDNS + * @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.10.14 */ typedef enum { - NM_SETTING_CONNECTION_MDNS_UNKNOWN = 0, - NM_SETTING_CONNECTION_MDNS_YES = 1, - NM_SETTING_CONNECTION_MDNS_NO = 2, - NM_SETTING_CONNECTION_MDNS_RESOLVE = 3, + 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; /** diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index 6cdacd2e79..01d5384d6b 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -1440,7 +1440,10 @@ nm_dns_manager_add_connection_config (NMDnsManager *self, g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (iface != NULL && iface[0], FALSE); - g_return_val_if_fail (mdns != NM_SETTING_CONNECTION_MDNS_UNKNOWN, FALSE); + g_return_val_if_fail (NM_IN_SET (mdns, + NM_SETTING_CONNECTION_MDNS_NO, + NM_SETTING_CONNECTION_MDNS_YES, + NM_SETTING_CONNECTION_MDNS_RESOLVE), FALSE); priv = NM_DNS_MANAGER_GET_PRIVATE (self); plugin = priv->plugin; diff --git a/src/nm-policy.c b/src/nm-policy.c index d7aa7168aa..112965f033 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -1072,11 +1072,12 @@ add_connection_dns (NMPolicy *self, NMConnection *connection, const char *iface, if (s_con) { NMSettingConnectionMdns mdns = nm_setting_connection_get_mdns (s_con); - if (mdns != NM_SETTING_CONNECTION_MDNS_UNKNOWN) + if (mdns != NM_SETTING_CONNECTION_MDNS_DEFAULT) { nm_dns_manager_add_connection_config (NM_POLICY_GET_PRIVATE (self)->dns_manager, - iface, - ifindex, - mdns); + iface, + ifindex, + mdns); + } } } @@ -2173,9 +2174,9 @@ vpn_connection_deactivated (NMPolicy *self, NMVpnConnection *vpn) nm_dns_manager_end_updates (priv->dns_manager, __func__); - remove_connection_dns(self, - nm_vpn_connection_get_ip_iface (vpn, TRUE), - nm_vpn_connection_get_ip_ifindex (vpn, TRUE)); + remove_connection_dns (self, + nm_vpn_connection_get_ip_iface (vpn, TRUE), + nm_vpn_connection_get_ip_ifindex (vpn, TRUE)); } static void diff --git a/src/nm-types.h b/src/nm-types.h index 794b0a1c39..5084454f80 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -238,4 +238,6 @@ typedef struct _NMSettingsConnection NMSettingsConnection; /* utils */ typedef struct _NMUtilsIPv6IfaceId NMUtilsIPv6IfaceId; +#define NM_SETTING_CONNECTION_MDNS_UNKNOWN ((NMSettingConnectionMdns) -42) + #endif /* NM_TYPES_H */ diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 366dd83476..827ba92b06 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -338,11 +338,11 @@ make_connection_setting (const char *file, vint64 = svGetValueInt64 (ifcfg, "AUTH_RETRIES", 10, -1, G_MAXINT32, -1); g_object_set (s_con, NM_SETTING_CONNECTION_AUTH_RETRIES, (gint) vint64, NULL); - i_val = NM_SETTING_CONNECTION_MDNS_UNKNOWN; + i_val = NM_SETTING_CONNECTION_MDNS_DEFAULT; if (!svGetValueEnum (ifcfg, "MDNS", nm_setting_connection_mdns_get_type (), - &i_val, NULL)) { - } + &i_val, NULL)) + PARSE_WARNING ("invalid MDNS setting"); g_object_set (s_con, NM_SETTING_CONNECTION_MDNS, i_val, NULL); return NM_SETTING (s_con); diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index e2c2a5d2a2..33cc172a0b 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -1727,7 +1727,8 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) guint32 n, i; GString *str; const char *master, *master_iface = NULL, *type; - gint vint, i_val; + gint vint; + NMSettingConnectionMdns mdns; guint32 vuint32; const char *tmp; @@ -1889,10 +1890,10 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) vint = nm_setting_connection_get_auth_retries (s_con); svSetValueInt64_cond (ifcfg, "AUTH_RETRIES", vint >= 0, vint); - i_val = nm_setting_connection_get_mdns (s_con); - if (i_val != NM_SETTING_CONNECTION_MDNS_UNKNOWN) { + mdns = nm_setting_connection_get_mdns (s_con); + if (mdns != NM_SETTING_CONNECTION_MDNS_DEFAULT) { svSetValueEnum (ifcfg, "MDNS", nm_setting_connection_mdns_get_type (), - i_val); + mdns); } else { svUnsetValue (ifcfg, "MDNS"); }