mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-09 15:50:26 +01:00
logging: update VPN manager logging
This commit is contained in:
parent
b7288577fe
commit
893315ece6
3 changed files with 85 additions and 76 deletions
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2009 Red Hat, Inc.
|
||||
* Copyright (C) 2005 - 2010 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -36,6 +36,7 @@
|
|||
#include "nm-dbus-manager.h"
|
||||
#include "nm-manager.h"
|
||||
#include "nm-system.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-vpn-plugin-bindings.h"
|
||||
#include "nm-marshal.h"
|
||||
|
|
@ -269,7 +270,7 @@ plugin_failed (DBusGProxy *proxy,
|
|||
{
|
||||
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (user_data);
|
||||
|
||||
nm_info ("VPN plugin failed: %d", plugin_failure);
|
||||
nm_log_warn (LOGD_VPN, "VPN plugin failed: %d", plugin_failure);
|
||||
|
||||
switch (plugin_failure) {
|
||||
case NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED:
|
||||
|
|
@ -291,7 +292,7 @@ plugin_state_changed (DBusGProxy *proxy,
|
|||
NMVPNConnection *connection = NM_VPN_CONNECTION (user_data);
|
||||
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
nm_info ("VPN plugin state changed: %d", state);
|
||||
nm_log_info (LOGD_VPN, "VPN plugin state changed: %d", state);
|
||||
|
||||
if (state == NM_VPN_SERVICE_STATE_STOPPED) {
|
||||
/* Clear connection secrets to ensure secrets get requested each time the
|
||||
|
|
@ -305,7 +306,7 @@ plugin_state_changed (DBusGProxy *proxy,
|
|||
case NM_VPN_CONNECTION_STATE_CONNECT:
|
||||
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
|
||||
case NM_VPN_CONNECTION_STATE_ACTIVATED:
|
||||
nm_info ("VPN plugin state change reason: %d", priv->failure_reason);
|
||||
nm_log_info (LOGD_VPN, "VPN plugin state change reason: %d", priv->failure_reason);
|
||||
nm_vpn_connection_set_vpn_state (connection,
|
||||
NM_VPN_CONNECTION_STATE_FAILED,
|
||||
priv->failure_reason);
|
||||
|
|
@ -331,8 +332,8 @@ ip_address_to_string (guint32 numeric)
|
|||
if (inet_ntop (AF_INET, &temp_addr, buf, INET_ADDRSTRLEN)) {
|
||||
return buf;
|
||||
} else {
|
||||
nm_warning ("%s: error converting IP4 address 0x%X",
|
||||
__func__, ntohl (temp_addr.s_addr));
|
||||
nm_log_warn (LOGD_VPN, "error converting IP4 address 0x%X",
|
||||
ntohl (temp_addr.s_addr));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -351,38 +352,44 @@ print_vpn_config (NMIP4Config *config,
|
|||
|
||||
addr = nm_ip4_config_get_address (config, 0);
|
||||
|
||||
nm_info ("VPN Gateway: %s", ip_address_to_string (nm_ip4_address_get_gateway (addr)));
|
||||
nm_log_info (LOGD_VPN, "VPN Gateway: %s", ip_address_to_string (nm_ip4_address_get_gateway (addr)));
|
||||
if (internal_gw)
|
||||
nm_info ("Internal Gateway: %s", ip_address_to_string (internal_gw));
|
||||
nm_info ("Tunnel Device: %s", tundev);
|
||||
nm_info ("Internal IP4 Address: %s", ip_address_to_string (nm_ip4_address_get_address (addr)));
|
||||
nm_info ("Internal IP4 Prefix: %d", nm_ip4_address_get_prefix (addr));
|
||||
nm_info ("Internal IP4 Point-to-Point Address: %s",
|
||||
ip_address_to_string (nm_ip4_config_get_ptp_address (config)));
|
||||
nm_info ("Maximum Segment Size (MSS): %d", nm_ip4_config_get_mss (config));
|
||||
nm_log_info (LOGD_VPN, "Internal Gateway: %s", ip_address_to_string (internal_gw));
|
||||
nm_log_info (LOGD_VPN, "Tunnel Device: %s", tundev);
|
||||
nm_log_info (LOGD_VPN, "Internal IP4 Address: %s", ip_address_to_string (nm_ip4_address_get_address (addr)));
|
||||
nm_log_info (LOGD_VPN, "Internal IP4 Prefix: %d", nm_ip4_address_get_prefix (addr));
|
||||
nm_log_info (LOGD_VPN, "Internal IP4 Point-to-Point Address: %s",
|
||||
ip_address_to_string (nm_ip4_config_get_ptp_address (config)));
|
||||
nm_log_info (LOGD_VPN, "Maximum Segment Size (MSS): %d", nm_ip4_config_get_mss (config));
|
||||
|
||||
num = nm_ip4_config_get_num_routes (config);
|
||||
for (i = 0; i < num; i++) {
|
||||
NMIP4Route *route;
|
||||
|
||||
route = nm_ip4_config_get_route (config, i);
|
||||
nm_info ("Static Route: %s/%d Next Hop: %s",
|
||||
ip_address_to_string (nm_ip4_route_get_dest (route)),
|
||||
nm_ip4_route_get_prefix (route),
|
||||
ip_address_to_string (nm_ip4_route_get_next_hop (route)));
|
||||
nm_log_info (LOGD_VPN, "Static Route: %s/%d Next Hop: %s",
|
||||
ip_address_to_string (nm_ip4_route_get_dest (route)),
|
||||
nm_ip4_route_get_prefix (route),
|
||||
ip_address_to_string (nm_ip4_route_get_next_hop (route)));
|
||||
}
|
||||
|
||||
num = nm_ip4_config_get_num_nameservers (config);
|
||||
for (i = 0; i < num; i++)
|
||||
nm_info ("Internal IP4 DNS: %s", ip_address_to_string (nm_ip4_config_get_nameserver (config, i)));
|
||||
for (i = 0; i < num; i++) {
|
||||
nm_log_info (LOGD_VPN, "Internal IP4 DNS: %s",
|
||||
ip_address_to_string (nm_ip4_config_get_nameserver (config, i)));
|
||||
}
|
||||
|
||||
if (nm_ip4_config_get_num_domains (config) > 0)
|
||||
dns_domain = (char *) nm_ip4_config_get_domain (config, 0);
|
||||
nm_info ("DNS Domain: '%s'", dns_domain ? dns_domain : "(none)");
|
||||
nm_info ("Login Banner:");
|
||||
nm_info ("-----------------------------------------");
|
||||
nm_info ("%s", banner);
|
||||
nm_info ("-----------------------------------------");
|
||||
|
||||
nm_log_info (LOGD_VPN, "DNS Domain: '%s'", dns_domain ? dns_domain : "(none)");
|
||||
|
||||
if (banner && strlen (banner)) {
|
||||
nm_log_info (LOGD_VPN, "Login Banner:");
|
||||
nm_log_info (LOGD_VPN, "-----------------------------------------");
|
||||
nm_log_info (LOGD_VPN, "%s", banner);
|
||||
nm_log_info (LOGD_VPN, "-----------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -399,8 +406,8 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||
int i;
|
||||
guint32 vpn_ext_gw = 0;
|
||||
|
||||
nm_info ("VPN connection '%s' (IP Config Get) reply received.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP Config Get) reply received.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
|
||||
g_source_remove (priv->ipconfig_timeout);
|
||||
priv->ipconfig_timeout = 0;
|
||||
|
|
@ -411,7 +418,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||
if (val)
|
||||
priv->tundev = g_strdup (g_value_get_string (val));
|
||||
else {
|
||||
nm_warning ("%s: invalid or missing tunnel device received!", __func__);
|
||||
nm_log_err (LOGD_VPN, "invalid or missing tunnel device received!");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
@ -445,7 +452,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||
if (nm_ip4_address_get_address (addr) && nm_ip4_address_get_prefix (addr)) {
|
||||
nm_ip4_config_take_address (config, addr);
|
||||
} else {
|
||||
nm_warning ("%s: invalid IP4 config received!", __func__);
|
||||
nm_log_err (LOGD_VPN, "invalid IP4 config received!");
|
||||
nm_ip4_address_unref (addr);
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -532,8 +539,8 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||
|
||||
priv->ip4_config = config;
|
||||
|
||||
nm_info ("VPN connection '%s' (IP Config Get) complete.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP Config Get) complete.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
nm_vpn_connection_set_vpn_state (connection,
|
||||
NM_VPN_CONNECTION_STATE_ACTIVATED,
|
||||
NM_VPN_CONNECTION_STATE_REASON_NONE);
|
||||
|
|
@ -541,8 +548,8 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||
}
|
||||
|
||||
error:
|
||||
nm_warning ("VPN connection '%s' did not receive valid IP config information.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
nm_log_warn (LOGD_VPN, "VPN connection '%s' did not receive valid IP config information.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
nm_vpn_connection_set_vpn_state (connection,
|
||||
NM_VPN_CONNECTION_STATE_FAILED,
|
||||
NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID);
|
||||
|
|
@ -561,8 +568,8 @@ nm_vpn_connection_ip_config_timeout (gpointer user_data)
|
|||
* in this timeout, cancel activation because it's taken too long.
|
||||
*/
|
||||
if (nm_vpn_connection_get_vpn_state (connection) == NM_VPN_CONNECTION_STATE_IP_CONFIG_GET) {
|
||||
nm_info ("VPN connection '%s' (IP Config Get) timeout exceeded.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
nm_log_warn (LOGD_VPN, "VPN connection '%s' (IP Config Get) timeout exceeded.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
nm_vpn_connection_set_vpn_state (connection,
|
||||
NM_VPN_CONNECTION_STATE_FAILED,
|
||||
NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT);
|
||||
|
|
@ -577,12 +584,12 @@ nm_vpn_connection_connect_cb (DBusGProxy *proxy, GError *err, gpointer user_data
|
|||
NMVPNConnection *connection = NM_VPN_CONNECTION (user_data);
|
||||
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
nm_info ("VPN connection '%s' (Connect) reply received.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
nm_log_info (LOGD_VPN, "VPN connection '%s' (Connect) reply received.",
|
||||
nm_vpn_connection_get_name (connection));
|
||||
|
||||
if (err) {
|
||||
nm_warning ("VPN connection '%s' failed to connect: '%s'.",
|
||||
nm_vpn_connection_get_name (connection), err->message);
|
||||
nm_log_warn (LOGD_VPN, "VPN connection '%s' failed to connect: '%s'.",
|
||||
nm_vpn_connection_get_name (connection), err->message);
|
||||
nm_vpn_connection_set_vpn_state (connection,
|
||||
NM_VPN_CONNECTION_STATE_FAILED,
|
||||
NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED);
|
||||
|
|
@ -777,9 +784,9 @@ secrets_update_setting (NMSecretsProviderInterface *interface,
|
|||
return FALSE;
|
||||
|
||||
if (!nm_connection_update_secrets (priv->connection, NM_SETTING_VPN_SETTING_NAME, new, &error)) {
|
||||
nm_warning ("Failed to update VPN secrets: %d %s",
|
||||
error ? error->code : -1,
|
||||
error && error->message ? error->message : "(none)");
|
||||
nm_log_warn (LOGD_VPN, "Failed to update VPN secrets: %d %s",
|
||||
error ? error->code : -1,
|
||||
error && error->message ? error->message : "(none)");
|
||||
g_clear_error (&error);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -823,9 +830,9 @@ connection_need_secrets_cb (DBusGProxy *proxy,
|
|||
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
|
||||
|
||||
if (error) {
|
||||
g_warning ("%s.%d: NeedSecrets failed: %s %s",
|
||||
__FILE__, __LINE__,
|
||||
g_quark_to_string (error->domain), error->message);
|
||||
nm_log_err (LOGD_VPN, "NeedSecrets failed: %s %s",
|
||||
g_quark_to_string (error->domain),
|
||||
error->message);
|
||||
nm_vpn_connection_fail (self, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS);
|
||||
return;
|
||||
}
|
||||
|
|
@ -893,7 +900,7 @@ vpn_cleanup (NMVPNConnection *connection)
|
|||
nm_device_get_ip4_config (priv->parent_dev),
|
||||
nm_device_get_priority (priv->parent_dev),
|
||||
NM_IP4_COMPARE_FLAG_ADDRESSES | NM_IP4_COMPARE_FLAG_ROUTES)) {
|
||||
nm_warning ("%s: failed to re-apply VPN parent device addresses and routes.", __func__);
|
||||
nm_log_err (LOGD_VPN, "failed to re-apply VPN parent device addresses and routes.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -940,7 +947,7 @@ connection_state_changed (NMVPNConnection *connection,
|
|||
|
||||
org_freedesktop_NetworkManager_VPN_Plugin_disconnect (priv->proxy, &err);
|
||||
if (err) {
|
||||
nm_warning ("%s", err->message);
|
||||
nm_log_warn (LOGD_VPN, "error disconnecting VPN: %s", err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "nm-setting-vpn.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "NetworkManagerVPN.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-marshal.h"
|
||||
|
||||
G_DEFINE_TYPE (NMVPNManager, nm_vpn_manager, G_TYPE_OBJECT)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "nm-vpn-service.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-vpn-manager.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
|
|
@ -198,18 +198,20 @@ vpn_service_watch_cb (GPid pid, gint status, gpointer user_data)
|
|||
if (WIFEXITED (status)) {
|
||||
guint err = WEXITSTATUS (status);
|
||||
|
||||
if (err != 0)
|
||||
nm_warning ("VPN service '%s' exited with error: %d",
|
||||
nm_vpn_service_get_name (service), WSTOPSIG (status));
|
||||
} else if (WIFSTOPPED (status))
|
||||
nm_warning ("VPN service '%s' stopped unexpectedly with signal %d",
|
||||
nm_vpn_service_get_name (service), WSTOPSIG (status));
|
||||
else if (WIFSIGNALED (status))
|
||||
nm_warning ("VPN service '%s' died with signal %d",
|
||||
nm_vpn_service_get_name (service), WTERMSIG (status));
|
||||
else
|
||||
nm_warning ("VPN service '%s' died from an unknown cause",
|
||||
nm_vpn_service_get_name (service));
|
||||
if (err != 0) {
|
||||
nm_log_warn (LOGD_VPN, "VPN service '%s' exited with error: %d",
|
||||
nm_vpn_service_get_name (service), WSTOPSIG (status));
|
||||
}
|
||||
} else if (WIFSTOPPED (status)) {
|
||||
nm_log_warn (LOGD_VPN, "VPN service '%s' stopped unexpectedly with signal %d",
|
||||
nm_vpn_service_get_name (service), WSTOPSIG (status));
|
||||
} else if (WIFSIGNALED (status)) {
|
||||
nm_log_warn (LOGD_VPN, "VPN service '%s' died with signal %d",
|
||||
nm_vpn_service_get_name (service), WTERMSIG (status));
|
||||
} else {
|
||||
nm_log_warn (LOGD_VPN, "VPN service '%s' died from an unknown cause",
|
||||
nm_vpn_service_get_name (service));
|
||||
}
|
||||
|
||||
priv->pid = 0;
|
||||
priv->service_child_watch = 0;
|
||||
|
|
@ -222,8 +224,8 @@ nm_vpn_service_timeout (gpointer data)
|
|||
{
|
||||
NMVPNService *service = NM_VPN_SERVICE (data);
|
||||
|
||||
nm_info ("VPN service '%s' did not start in time, cancelling connections",
|
||||
nm_vpn_service_get_name (service));
|
||||
nm_log_warn (LOGD_VPN, "VPN service '%s' did not start in time, cancelling connections",
|
||||
nm_vpn_service_get_name (service));
|
||||
|
||||
NM_VPN_SERVICE_GET_PRIVATE (service)->service_start_timeout = 0;
|
||||
nm_vpn_service_connections_stop (service, TRUE, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT);
|
||||
|
|
@ -250,14 +252,14 @@ nm_vpn_service_daemon_exec (NMVPNService *service, GError **error)
|
|||
nm_vpn_service_child_setup, NULL, &priv->pid,
|
||||
&spawn_error);
|
||||
if (success) {
|
||||
nm_info ("VPN service '%s' started (%s), PID %d",
|
||||
nm_vpn_service_get_name (service), priv->dbus_service, priv->pid);
|
||||
nm_log_info (LOGD_VPN, "VPN service '%s' started (%s), PID %d",
|
||||
nm_vpn_service_get_name (service), priv->dbus_service, priv->pid);
|
||||
|
||||
priv->service_child_watch = g_child_watch_add (priv->pid, vpn_service_watch_cb, service);
|
||||
priv->service_start_timeout = g_timeout_add_seconds (5, nm_vpn_service_timeout, service);
|
||||
} else {
|
||||
nm_warning ("VPN service '%s': could not launch the VPN service. error: (%d) %s.",
|
||||
nm_vpn_service_get_name (service), spawn_error->code, spawn_error->message);
|
||||
nm_log_warn (LOGD_VPN, "VPN service '%s': could not launch the VPN service. error: (%d) %s.",
|
||||
nm_vpn_service_get_name (service), spawn_error->code, spawn_error->message);
|
||||
|
||||
g_set_error (error,
|
||||
NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_SERVICE_START_FAILED,
|
||||
|
|
@ -334,7 +336,8 @@ nm_vpn_service_activate (NMVPNService *service,
|
|||
// FIXME: fill in error when errors happen
|
||||
nm_vpn_connection_activate (vpn);
|
||||
} else if (priv->service_start_timeout == 0) {
|
||||
nm_info ("Starting VPN service '%s'...", nm_vpn_service_get_name (service));
|
||||
nm_log_info (LOGD_VPN, "Starting VPN service '%s'...",
|
||||
nm_vpn_service_get_name (service));
|
||||
if (!nm_vpn_service_daemon_exec (service, error))
|
||||
vpn = NULL;
|
||||
}
|
||||
|
|
@ -378,16 +381,16 @@ nm_vpn_service_name_owner_changed (NMDBusManager *mgr,
|
|||
/* service just appeared */
|
||||
GSList *iter;
|
||||
|
||||
nm_info ("VPN service '%s' just appeared, activating connections",
|
||||
nm_vpn_service_get_name (service));
|
||||
nm_log_info (LOGD_VPN, "VPN service '%s' appeared, activating connections",
|
||||
nm_vpn_service_get_name (service));
|
||||
|
||||
for (iter = priv->connections; iter; iter = iter->next)
|
||||
nm_vpn_connection_activate (NM_VPN_CONNECTION (iter->data));
|
||||
|
||||
} else if (old_owner_good && !new_owner_good) {
|
||||
/* service went away */
|
||||
nm_info ("VPN service '%s' disappeared, cancelling connections",
|
||||
nm_vpn_service_get_name (service));
|
||||
nm_log_info (LOGD_VPN, "VPN service '%s' disappeared, cancelling connections",
|
||||
nm_vpn_service_get_name (service));
|
||||
nm_vpn_service_connections_stop (service, TRUE, NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED);
|
||||
}
|
||||
}
|
||||
|
|
@ -415,9 +418,9 @@ ensure_killed (gpointer data)
|
|||
kill (pid, SIGKILL);
|
||||
|
||||
/* ensure the child is reaped */
|
||||
nm_debug ("waiting for vpn service pid %d to exit", pid);
|
||||
nm_log_dbg (LOGD_VPN, "waiting for VPN service pid %d to exit", pid);
|
||||
waitpid (pid, NULL, 0);
|
||||
nm_debug ("vpn service pid %d cleaned up", pid);
|
||||
nm_log_dbg (LOGD_VPN, "VPN service pid %d cleaned up", pid);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -446,9 +449,9 @@ finalize (GObject *object)
|
|||
kill (priv->pid, SIGKILL);
|
||||
|
||||
/* ensure the child is reaped */
|
||||
nm_debug ("waiting for vpn service pid %d to exit", priv->pid);
|
||||
nm_log_dbg (LOGD_VPN, "waiting for VPN service pid %d to exit", priv->pid);
|
||||
waitpid (priv->pid, NULL, 0);
|
||||
nm_debug ("vpn service pid %d cleaned up", priv->pid);
|
||||
nm_log_dbg (LOGD_VPN, "VPN service pid %d cleaned up", priv->pid);
|
||||
}
|
||||
|
||||
priv->pid = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue