#include "nm-dhcp4-config.h"
#include "nm-dhcp6-config.h"
+#define _NMLOG_PREFIX_NAME "policy"
+#define _NMLOG(level, domain, ...) \
+ G_STMT_START { \
+ nm_log ((level), (domain), \
+ "%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
+ } G_STMT_END
+
typedef struct {
NMManager *manager;
NMFirewallManager *firewall_manager;
errno = 0;
ret = gethostname (old_hostname, HOST_NAME_MAX);
if (ret != 0) {
- nm_log_warn (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
- errno, strerror (errno));
+ _LOGW (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
+ errno, strerror (errno));
} else {
/* Don't set the hostname if it isn't actually changing */
if ( (new_hostname && !strcmp (old_hostname, new_hostname))
name = (new_hostname && strlen (new_hostname)) ? new_hostname : FALLBACK_HOSTNAME4;
- nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
+ _LOGI (LOGD_DNS, "setting system hostname to '%s' (%s)", name, msg);
ret = sethostname (name, strlen (name));
if (ret != 0) {
int errsv = errno;
- nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
- name, errsv, strerror (errsv));
+ _LOGW (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
+ name, errsv, strerror (errsv));
if (errsv == EPERM)
- nm_log_warn (LOGD_DNS, "You should use hostnamed when systemd hardening is in effect!");
+ _LOGW (LOGD_DNS, "you should use hostnamed when systemd hardening is in effect!");
}
return (ret == 0);
return;
}
}
- nm_log_warn (LOGD_DNS, "DHCPv4-provided hostname '%s' looks invalid; ignoring it",
- dhcp_hostname);
+ _LOGW (LOGD_DNS, "DHCPv4-provided hostname '%s' looks invalid; ignoring it",
+ dhcp_hostname);
}
}
} else if (best6) {
return;
}
}
- nm_log_warn (LOGD_DNS, "DHCPv6-provided hostname '%s' looks invalid; ignoring it",
- dhcp_hostname);
+ _LOGW (LOGD_DNS, "DHCPv6-provided hostname '%s' looks invalid; ignoring it",
+ dhcp_hostname);
}
}
}
priv->default_device4 = default_device;
connection = nm_active_connection_get_applied_connection (best_ac);
- nm_log_info (LOGD_CORE, "Policy set '%s' (%s) as default for IPv4 routing and DNS.",
- nm_connection_get_id (connection), ip_iface);
+ _LOGI (LOGD_CORE, "set '%s' (%s) as default for IPv4 routing and DNS",
+ nm_connection_get_id (connection), ip_iface);
g_object_notify (G_OBJECT (policy), NM_POLICY_DEFAULT_IP4_DEVICE);
}
priv->default_device6 = default_device6;
connection = nm_active_connection_get_applied_connection (best_ac);
- nm_log_info (LOGD_CORE, "Policy set '%s' (%s) as default for IPv6 routing and DNS.",
- nm_connection_get_id (connection), ip_iface);
+ _LOGI (LOGD_CORE, "set '%s' (%s) as default for IPv6 routing and DNS",
+ nm_connection_get_id (connection), ip_iface);
g_object_notify (G_OBJECT (policy), NM_POLICY_DEFAULT_IP6_DEVICE);
}
GError *error = NULL;
NMAuthSubject *subject;
- nm_log_info (LOGD_DEVICE, "Auto-activating connection '%s'.",
- nm_settings_connection_get_id (best_connection));
+ _LOGI (LOGD_DEVICE, "auto-activating connection '%s'",
+ nm_settings_connection_get_id (best_connection));
subject = nm_auth_subject_new_internal ();
if (!nm_manager_activate_connection (priv->manager,
best_connection,
data->device,
subject,
&error)) {
- nm_log_info (LOGD_DEVICE, "Connection '%s' auto-activation failed: (%d) %s",
- nm_settings_connection_get_id (best_connection),
- error->code,
- error->message);
+ _LOGI (LOGD_DEVICE, "connection '%s' auto-activation failed: (%d) %s",
+ nm_settings_connection_get_id (best_connection),
+ error->code,
+ error->message);
g_error_free (error);
}
g_object_unref (subject);
continue;
if (connected) {
- nm_log_dbg (LOGD_DEVICE, "Secondary connection '%s' SUCCEEDED; active path '%s'",
- nm_active_connection_get_settings_connection_id (active),
- nm_exported_object_get_path (NM_EXPORTED_OBJECT (active)));
+ _LOGD (LOGD_DEVICE, "secondary connection '%s' succeeded; active path '%s'",
+ nm_active_connection_get_settings_connection_id (active),
+ nm_exported_object_get_path (NM_EXPORTED_OBJECT (active)));
/* Secondary connection activated */
secondary_data->secondaries = g_slist_remove (secondary_data->secondaries, secondary_active);
break;
}
} else {
- nm_log_dbg (LOGD_DEVICE, "Secondary connection '%s' FAILED; active path '%s'",
- nm_active_connection_get_settings_connection_id (active),
- nm_exported_object_get_path (NM_EXPORTED_OBJECT (active)));
+ _LOGD (LOGD_DEVICE, "secondary connection '%s' failed; active path '%s'",
+ nm_active_connection_get_settings_connection_id (active),
+ nm_exported_object_get_path (NM_EXPORTED_OBJECT (active)));
/* Secondary connection failed -> do not watch other connections */
priv->pending_secondaries = g_slist_remove (priv->pending_secondaries, secondary_data);
GSList *connections, *iter;
if (device) {
- nm_log_dbg (LOGD_DEVICE, "Re-enabling autoconnect for all connections on %s",
- nm_device_get_iface (device));
+ _LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections on %s",
+ nm_device_get_iface (device));
} else
- nm_log_dbg (LOGD_DEVICE, "Re-enabling autoconnect for all connections");
+ _LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections");
connections = nm_settings_get_connections (priv->settings);
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
GSList *connections, *iter;
- nm_log_dbg (LOGD_DEVICE, "Re-enabling autoconnect for all connections with failed secrets");
+ _LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections with failed secrets");
connections = nm_settings_get_connections (priv->settings);
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
GSList *connections, *iter;
- nm_log_dbg (LOGD_DEVICE, "Blocking autoconnect for all connections on %s",
- nm_device_get_iface (device));
+ _LOGD (LOGD_DEVICE, "blocking autoconnect for all connections on %s",
+ nm_device_get_iface (device));
/* NMDevice keeps its own autoconnect-able-ness state; we only need to
* explicitly block connections for software devices, where the NMDevice
settings_con = nm_settings_get_connection_by_uuid (priv->settings, sec_uuid);
if (!settings_con) {
- nm_log_warn (LOGD_DEVICE, "Secondary connection '%s' auto-activation failed: The connection doesn't exist.",
- sec_uuid);
+ _LOGW (LOGD_DEVICE, "secondary connection '%s' auto-activation failed: The connection doesn't exist.",
+ sec_uuid);
success = FALSE;
break;
}
if (!nm_connection_is_type (NM_CONNECTION (settings_con), NM_SETTING_VPN_SETTING_NAME)) {
- nm_log_warn (LOGD_DEVICE, "Secondary connection '%s (%s)' auto-activation failed: The connection is not a VPN.",
- nm_settings_connection_get_id (settings_con), sec_uuid);
+ _LOGW (LOGD_DEVICE, "secondary connection '%s (%s)' auto-activation failed: The connection is not a VPN.",
+ nm_settings_connection_get_id (settings_con), sec_uuid);
success = FALSE;
break;
}
req = nm_device_get_act_request (device);
g_assert (req);
- nm_log_dbg (LOGD_DEVICE, "Activating secondary connection '%s (%s)' for base connection '%s (%s)'",
- nm_settings_connection_get_id (settings_con), sec_uuid,
- nm_connection_get_id (connection), nm_connection_get_uuid (connection));
+ _LOGD (LOGD_DEVICE, "activating secondary connection '%s (%s)' for base connection '%s (%s)'",
+ nm_settings_connection_get_id (settings_con), sec_uuid,
+ nm_connection_get_id (connection), nm_connection_get_uuid (connection));
ac = nm_manager_activate_connection (priv->manager,
settings_con,
nm_exported_object_get_path (NM_EXPORTED_OBJECT (req)),
if (ac)
secondary_ac_list = g_slist_append (secondary_ac_list, g_object_ref (ac));
else {
- nm_log_warn (LOGD_DEVICE, "Secondary connection '%s (%s)' auto-activation failed: (%d) %s",
- nm_settings_connection_get_id (settings_con), sec_uuid,
- error->code,
- error->message);
+ _LOGW (LOGD_DEVICE, "secondary connection '%s (%s)' auto-activation failed: (%d) %s",
+ nm_settings_connection_get_id (settings_con), sec_uuid,
+ error->code,
+ error->message);
g_clear_error (&error);
success = FALSE;
break;
guint32 tries = nm_settings_connection_get_autoconnect_retries (connection);
if (reason == NM_DEVICE_STATE_REASON_NO_SECRETS) {
- nm_log_dbg (LOGD_DEVICE, "Connection '%s' now blocked from autoconnect due to no secrets",
- nm_settings_connection_get_id (connection));
+ _LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
+ nm_settings_connection_get_id (connection));
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NO_SECRETS);
} else if (tries > 0) {
- nm_log_dbg (LOGD_DEVICE, "Connection '%s' failed to autoconnect; %d tries left",
- nm_settings_connection_get_id (connection), tries);
+ _LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left",
+ nm_settings_connection_get_id (connection), tries);
nm_settings_connection_set_autoconnect_retries (connection, tries - 1);
}
if (nm_settings_connection_get_autoconnect_retries (connection) == 0) {
- nm_log_info (LOGD_DEVICE, "Disabling autoconnect for connection '%s'.",
- nm_settings_connection_get_id (connection));
+ _LOGI (LOGD_DEVICE, "disabling autoconnect for connection '%s'.",
+ nm_settings_connection_get_id (connection));
/* Schedule a handler to reset retries count */
if (!priv->reset_retries_id) {
gint32 retry_time = nm_settings_connection_get_autoconnect_retry_time (connection);
} else {
if (connection) {
/* The connection was deactivated, so block just this connection */
- nm_log_dbg (LOGD_DEVICE, "Blocking autoconnect of connection '%s' by user request",
- nm_settings_connection_get_id (connection));
+ _LOGD (LOGD_DEVICE, "blocking autoconnect of connection '%s' by user request",
+ nm_settings_connection_get_id (connection));
nm_settings_connection_set_autoconnect_blocked_reason (connection,
NM_DEVICE_STATE_REASON_USER_REQUESTED);
}
NULL,
nm_active_connection_get_subject (ac),
&error)) {
- nm_log_warn (LOGD_DEVICE, "VPN '%s' reconnect failed: %s",
- nm_settings_connection_get_id (connection),
- error->message ? error->message : "unknown");
+ _LOGW (LOGD_DEVICE, "VPN '%s' reconnect failed: %s",
+ nm_settings_connection_get_id (connection),
+ error->message ? error->message : "unknown");
g_clear_error (&error);
}
}
if (priv->lookup_addr) {
char *str = NULL;
- nm_log_dbg (LOGD_DNS, "restarting reverse-lookup thread for address %s",
- (str = g_inet_address_to_string (priv->lookup_addr)));
+ _LOGD (LOGD_DNS, "restarting reverse-lookup thread for address %s",
+ (str = g_inet_address_to_string (priv->lookup_addr)));
g_free (str);
priv->lookup_cancellable = g_cancellable_new ();
nm_exported_object_get_path (NM_EXPORTED_OBJECT (ac)),
NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,
&error)) {
- nm_log_warn (LOGD_DEVICE, "Connection '%s' disappeared, but error deactivating it: (%d) %s",
- nm_settings_connection_get_id (connection),
- error ? error->code : -1,
- error ? error->message : "(unknown)");
+ _LOGW (LOGD_DEVICE, "connection '%s' disappeared, but error deactivating it: (%d) %s",
+ nm_settings_connection_get_id (connection),
+ error ? error->code : -1,
+ error ? error->message : "(unknown)");
g_clear_error (&error);
}
}