From 950989c45c5fa168b638a16867a8a332954990f2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 2 Aug 2014 14:52:49 +0200 Subject: logging: extract logging macros for devices to nm-device-logging.h Signed-off-by: Thomas Haller --- src/Makefile.am | 1 + src/devices/nm-device-logging.h | 45 +++++++++++++++++++++++++++++++++++++++++ src/devices/nm-device.c | 16 +++------------ 3 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 src/devices/nm-device-logging.h diff --git a/src/Makefile.am b/src/Makefile.am index f41d170eef..1d9ba94435 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -78,6 +78,7 @@ nm_sources = \ devices/nm-device-gre.h \ devices/nm-device-infiniband.c \ devices/nm-device-infiniband.h \ + devices/nm-device-logging.h \ devices/nm-device-macvlan.c \ devices/nm-device-macvlan.h \ devices/nm-device-private.h \ diff --git a/src/devices/nm-device-logging.h b/src/devices/nm-device-logging.h new file mode 100644 index 0000000000..b632d0f9f7 --- /dev/null +++ b/src/devices/nm-device-logging.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2014 Red Hat, Inc. + */ + +#ifndef NM_DEVICE_LOGGING_H +#define NM_DEVICE_LOGGING_H + +#include "nm-logging.h" +#include "nm-device.h" + +#define _LOG_DECLARE_SELF(t) \ +inline static NMDevice * \ +_nm_device_log_self_to_device (t *self) \ +{ \ + return (NMDevice *) self; \ +} + +#define _LOG(level, domain, ...) \ + nm_log_obj ((level), (domain), (self), \ + "(%s): " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + (self) ? str_if_set (nm_device_get_iface (_nm_device_log_self_to_device (self)), "(null)") : "(none)" \ + _NM_UTILS_MACRO_REST(__VA_ARGS__)) + +#define _LOGD(domain, ...) _LOG (LOGL_DEBUG, domain, __VA_ARGS__) +#define _LOGI(domain, ...) _LOG (LOGL_INFO, domain, __VA_ARGS__) +#define _LOGW(domain, ...) _LOG (LOGL_WARN, domain, __VA_ARGS__) +#define _LOGE(domain, ...) _LOG (LOGL_ERR, domain, __VA_ARGS__) + +#endif /* NM_DEVICE_LOGGING_H */ diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index d39df5ddce..8acebb90e8 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -73,6 +73,9 @@ #include "nm-config.h" #include "nm-dns-manager.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF (NMDevice); + static void impl_device_disconnect (NMDevice *self, DBusGMethodInvocation *context); static void impl_device_delete (NMDevice *self, DBusGMethodInvocation *context); @@ -82,19 +85,6 @@ G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, G_TYPE_OBJECT) #define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate)) - -#define _LOG(level, domain, ...) \ - nm_log_obj ((level), (domain), (self), \ - "(%s): " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ - (self) ? str_if_set (nm_device_get_iface (self), "(null)") : "(none)" \ - _NM_UTILS_MACRO_REST(__VA_ARGS__)) - -#define _LOGD(domain, ...) _LOG (LOGL_DEBUG, domain, __VA_ARGS__) -#define _LOGI(domain, ...) _LOG (LOGL_INFO, domain, __VA_ARGS__) -#define _LOGW(domain, ...) _LOG (LOGL_WARN, domain, __VA_ARGS__) -#define _LOGE(domain, ...) _LOG (LOGL_ERR, domain, __VA_ARGS__) - - enum { STATE_CHANGED, AUTOCONNECT_ALLOWED, -- cgit v1.2.3 From 4b36f8b35be0d940b5c4cd1871b8a8dc220c736e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 2 Aug 2014 15:14:26 +0200 Subject: logging: use new logging macros in NMDevice subclasses Signed-off-by: Thomas Haller --- src/devices/adsl/nm-device-adsl.c | 104 ++++---- src/devices/bluetooth/nm-device-bt.c | 81 +++--- src/devices/nm-device-bond.c | 46 ++-- src/devices/nm-device-bridge.c | 59 ++--- src/devices/nm-device-ethernet.c | 260 ++++++++---------- src/devices/nm-device-gre.c | 9 +- src/devices/nm-device-infiniband.c | 23 -- src/devices/nm-device-macvlan.c | 7 +- src/devices/nm-device-tun.c | 24 +- src/devices/nm-device-veth.c | 6 +- src/devices/nm-device-vlan.c | 38 ++- src/devices/nm-device-vxlan.c | 7 +- src/devices/nm-device.c | 4 +- src/devices/team/nm-device-team.c | 210 +++++++-------- src/devices/wifi/nm-device-olpc-mesh.c | 52 ++-- src/devices/wifi/nm-device-wifi.c | 468 ++++++++++++++------------------- src/devices/wwan/nm-device-modem.c | 50 ++-- 17 files changed, 637 insertions(+), 811 deletions(-) diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index c4a98fa3ab..89018da7ea 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -47,6 +47,9 @@ #include "nm-device-adsl-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF (NMDeviceAdsl); + G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE) #define NM_DEVICE_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ADSL, NMDeviceAdslPrivate)) @@ -148,9 +151,8 @@ static gboolean br2684_create_iface (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); - const char *iface = nm_device_get_iface (NM_DEVICE (self)); struct atm_newif_br2684 ni; - int err, fd; + int err, fd, errsv; gboolean success = FALSE; guint num = 0; @@ -158,8 +160,8 @@ br2684_create_iface (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) fd = socket (PF_ATMPVC, SOCK_DGRAM, ATM_AAL5); if (fd < 0) { - nm_log_err (LOGD_ADSL, "(%s): failed to open ATM control socket (%d)", - iface, errno); + errsv = errno; + _LOGE (LOGD_ADSL, "failed to open ATM control socket (%d)", errsv); return FALSE; } @@ -180,17 +182,19 @@ br2684_create_iface (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) err = ioctl (fd, ATM_NEWBACKENDIF, &ni); if (err == 0) { set_nas_iface (self, -1, ni.ifname); - nm_log_info (LOGD_ADSL, "(%s): using NAS interface %s (%d)", - iface, priv->nas_ifname, priv->nas_ifindex); + _LOGI (LOGD_ADSL, "using NAS interface %s (%d)", + priv->nas_ifname, priv->nas_ifindex); success = TRUE; break; - } else if (errno == -EEXIST) { - /* Try again */ - num++; } else { - nm_log_warn (LOGD_ADSL, "(%s): failed to create br2684 interface (%d)", - iface, errno); - break; + errsv = errno; + if (errsv == -EEXIST) { + /* Try again */ + num++; + } else { + _LOGW (LOGD_ADSL, "failed to create br2684 interface (%d)", errsv); + break; + } } } @@ -202,11 +206,10 @@ static gboolean br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); - const char *iface = nm_device_get_iface (NM_DEVICE (self)); struct sockaddr_atmpvc addr; struct atm_backend_br2684 be; struct atm_qos qos; - int err, bufsize = 8192; + int errsv, err, bufsize = 8192; const char *encapsulation; gboolean is_llc; @@ -215,15 +218,15 @@ br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) priv->brfd = socket (PF_ATMPVC, SOCK_DGRAM, ATM_AAL5); if (priv->brfd < 0) { - nm_log_err (LOGD_ADSL, "(%s): failed to open ATM control socket (%d)", - iface, errno); + errsv = errno; + _LOGE (LOGD_ADSL, "failed to open ATM control socket (%d)", errsv); return FALSE; } err = setsockopt (priv->brfd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof (bufsize)); if (err != 0) { - nm_log_err (LOGD_ADSL, "(%s): failed to set SNDBUF option (%d)", - iface, errno); + errsv = errno; + _LOGE (LOGD_ADSL, "failed to set SNDBUF option (%d)", errsv); goto error; } @@ -237,8 +240,8 @@ br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) err = setsockopt (priv->brfd, SOL_ATM, SO_ATMQOS, &qos, sizeof (qos)); if (err != 0) { - nm_log_err (LOGD_ADSL, "(%s): failed to set QoS (%d)", - iface, errno); + errsv = errno; + _LOGE (LOGD_ADSL, "failed to set QoS (%d)", errsv); goto error; } @@ -251,15 +254,14 @@ br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) addr.sap_addr.vpi = (guint16) nm_setting_adsl_get_vpi (s_adsl); addr.sap_addr.vci = (int) nm_setting_adsl_get_vci (s_adsl); - nm_log_dbg (LOGD_ADSL, "(%s): assigning address %d.%d.%d encapsulation %s", - nm_device_get_iface (NM_DEVICE (self)), - priv->atm_index, addr.sap_addr.vpi, addr.sap_addr.vci, - encapsulation); + _LOGD (LOGD_ADSL, "assigning address %d.%d.%d encapsulation %s", + priv->atm_index, addr.sap_addr.vpi, addr.sap_addr.vci, + encapsulation); err = connect (priv->brfd, (struct sockaddr*) &addr, sizeof (addr)); if (err != 0) { - nm_log_err (LOGD_ADSL, "(%s): failed to set VPI/VCI (%d)", - iface, errno); + errsv = errno; + _LOGE (LOGD_ADSL, "failed to set VPI/VCI (%d)", errsv); goto error; } @@ -275,8 +277,8 @@ br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) be.encaps = is_llc ? BR2684_ENCAPS_LLC : BR2684_ENCAPS_VC; err = ioctl (priv->brfd, ATM_SETBACKEND, &be); if (err != 0) { - nm_log_err (LOGD_ADSL, "(%s): failed to attach VCC (%d)", - iface, errno); + errsv = errno; + _LOGE (LOGD_ADSL, "failed to attach VCC (%d)", errsv); goto error; } @@ -289,18 +291,17 @@ error: } static void -link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformSignalChangeType change_type, NMPlatformReason reason, NMDeviceAdsl *device_adsl) +link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformSignalChangeType change_type, NMPlatformReason reason, NMDeviceAdsl *self) { if (change_type == NM_PLATFORM_SIGNAL_REMOVED) { - NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (device_adsl); - NMDevice *device = NM_DEVICE (device_adsl); + NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); + NMDevice *device = NM_DEVICE (self); /* This only gets called for PPPoE connections and "nas" interfaces */ if (priv->nas_ifindex >= 0 && ifindex == priv->nas_ifindex) { /* NAS device went away for some reason; kill the connection */ - nm_log_dbg (LOGD_ADSL, "(%s): NAS interface disappeared", - nm_device_get_iface (device)); + _LOGD (LOGD_ADSL, "NAS interface disappeared"); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BR2684_FAILED); @@ -323,8 +324,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason) g_assert (s_adsl); protocol = nm_setting_adsl_get_protocol (s_adsl); - nm_log_dbg (LOGD_ADSL, "(%s): using ADSL protocol '%s'", - nm_device_get_iface (device), protocol); + _LOGD (LOGD_ADSL, "using ADSL protocol '%s'", protocol); if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) == 0) { @@ -345,7 +345,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason) G_CALLBACK (link_changed_cb), self); - nm_log_dbg (LOGD_ADSL, "(%s): ATM setup successful", nm_device_get_iface (device)); + _LOGD (LOGD_ADSL, "ATM setup successful"); /* otherwise we're good for stage3 */ nm_platform_link_set_up (priv->nas_ifindex); @@ -354,10 +354,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason) } else if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) == 0) { /* PPPoA doesn't need anything special */ ret = NM_ACT_STAGE_RETURN_SUCCESS; - } else { - nm_log_warn (LOGD_ADSL, "(%s): unhandled ADSL protocol '%s'", - nm_device_get_iface (device), protocol); - } + } else + _LOGW (LOGD_ADSL, "unhandled ADSL protocol '%s'", protocol); done: return ret; @@ -407,7 +405,6 @@ act_stage3_ip4_config_start (NMDevice *device, NMActRequest *req; GError *err = NULL; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; - const char *iface = nm_device_get_iface (device); const char *ppp_iface; req = nm_device_get_act_request (device); @@ -424,11 +421,10 @@ act_stage3_ip4_config_start (NMDevice *device, g_assert (priv->nas_ifname); ppp_iface = priv->nas_ifname; - nm_log_dbg (LOGD_ADSL, "(%s): starting PPPoE on NAS interface %s", - iface, priv->nas_ifname); + _LOGD (LOGD_ADSL, "starting PPPoE on NAS interface %s", priv->nas_ifname); } else { - ppp_iface = iface; - nm_log_dbg (LOGD_ADSL, "(%s): starting PPPoA", iface); + ppp_iface = nm_device_get_iface (device); + _LOGD (LOGD_ADSL, "starting PPPoA"); } priv->ppp_manager = nm_ppp_manager_new (ppp_iface); @@ -441,7 +437,7 @@ act_stage3_ip4_config_start (NMDevice *device, self); ret = NM_ACT_STAGE_RETURN_POSTPONE; } else { - nm_log_warn (LOGD_ADSL, "(%s): PPP failed to start: %s", iface, err->message); + _LOGW (LOGD_ADSL, "PPP failed to start: %s", err->message); g_error_free (err); g_object_unref (priv->ppp_manager); @@ -489,12 +485,9 @@ carrier_update_cb (gpointer user_data) NMDeviceAdsl *self = NM_DEVICE_ADSL (user_data); int carrier; char *path; - const char *iface; - - iface = nm_device_get_iface (NM_DEVICE (self)); path = g_strdup_printf ("/sys/class/atm/%s/carrier", - ASSERT_VALID_PATH_COMPONENT (iface)); + ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (NM_DEVICE (self)))); carrier = (int) nm_platform_sysctl_get_int_checked (path, 10, 0, 1, -1); g_free (path); @@ -541,6 +534,7 @@ constructor (GType type, GObjectConstructParam *construct_params) { GObject *object; + NMDeviceAdsl *self; NMDeviceAdslPrivate *priv; object = G_OBJECT_CLASS (nm_device_adsl_parent_class)->constructor (type, @@ -549,18 +543,16 @@ constructor (GType type, if (!object) return NULL; + self = NM_DEVICE_ADSL (object); priv = NM_DEVICE_ADSL_GET_PRIVATE (object); priv->atm_index = get_atm_index (nm_device_get_iface (NM_DEVICE (object))); if (priv->atm_index < 0) { - nm_log_err (LOGD_ADSL, "(%s): error reading ATM device index", - nm_device_get_iface (NM_DEVICE (object))); + _LOGE (LOGD_ADSL, "error reading ATM device index"); g_object_unref (object); return NULL; - } else { - nm_log_dbg (LOGD_ADSL, "(%s): ATM device index %d", - nm_device_get_iface (NM_DEVICE (object)), priv->atm_index); - } + } else + _LOGD (LOGD_ADSL, "ATM device index %d", priv->atm_index); /* Poll the carrier */ priv->carrier_poll_id = g_timeout_add_seconds (5, carrier_update_cb, object); diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index ab65a965a8..17cbb8a4ba 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -49,6 +49,9 @@ #define MM_DBUS_SERVICE "org.freedesktop.ModemManager1" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceBt); + G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE) #define NM_DEVICE_BT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BT, NMDeviceBtPrivate)) @@ -427,7 +430,8 @@ modem_prepare_result (NMModem *modem, NMDeviceStateReason reason, gpointer user_data) { - NMDevice *device = NM_DEVICE (user_data); + NMDeviceBt *self = NM_DEVICE_BT (user_data); + NMDevice *device = NM_DEVICE (self); NMDeviceState state; state = nm_device_get_state (device); @@ -460,8 +464,7 @@ modem_prepare_result (NMModem *modem, * the SIM if the incorrect PIN continues to be used. */ g_object_set (G_OBJECT (device), NM_DEVICE_AUTOCONNECT, FALSE, NULL); - nm_log_info (LOGD_MB, "(%s): disabling autoconnect due to failed SIM PIN", - nm_device_get_iface (device)); + _LOGI (LOGD_MB, "disabling autoconnect due to failed SIM PIN"); } nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); @@ -481,21 +484,20 @@ device_state_changed (NMDevice *device, } static void -modem_ip4_config_result (NMModem *self, +modem_ip4_config_result (NMModem *modem, NMIP4Config *config, GError *error, gpointer user_data) { - NMDevice *device = NM_DEVICE (user_data); + NMDeviceBt *self = NM_DEVICE_BT (user_data); + NMDevice *device = NM_DEVICE (self); g_return_if_fail (nm_device_activate_ip4_state_in_conf (device) == TRUE); if (error) { - nm_log_warn (LOGD_MB | LOGD_IP4 | LOGD_BT, - "(%s): retrieving IP4 configuration failed: (%d) %s", - nm_device_get_ip_iface (device), - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + _LOGW (LOGD_MB | LOGD_IP4 | LOGD_BT, + "retrieving IP4 configuration failed: (%d) %s", + error->code, error->message ? error->message : "(unknown)"); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } else @@ -638,16 +640,14 @@ component_added (NMDevice *device, GObject *component) */ state = nm_device_get_state (NM_DEVICE (self)); if (state != NM_DEVICE_STATE_CONFIG) { - nm_log_warn (LOGD_BT | LOGD_MB, - "(%s): modem found but device not in correct state (%d)", - nm_device_get_iface (NM_DEVICE (self)), - nm_device_get_state (NM_DEVICE (self))); + _LOGW (LOGD_BT | LOGD_MB, + "modem found but device not in correct state (%d)", + nm_device_get_state (NM_DEVICE (self))); return TRUE; } - nm_log_info (LOGD_BT | LOGD_MB, - "Activation (%s/bluetooth) Stage 2 of 5 (Device Configure) modem found.", - nm_device_get_iface (NM_DEVICE (self))); + _LOGI (LOGD_BT | LOGD_MB, + "Activation: (bluetooth) Stage 2 of 5 (Device Configure) modem found."); if (priv->modem) { g_warn_if_reached (); @@ -696,11 +696,9 @@ check_connect_continue (NMDeviceBt *self) if (!priv->connected || !priv->have_iface) return; - nm_log_info (LOGD_BT, "Activation (%s %s/bluetooth) Stage 2 of 5 (Device Configure) " - "successful. Will connect via %s.", - nm_device_get_iface (device), - nm_device_get_ip_iface (device), - dun ? "DUN" : (pan ? "PAN" : "unknown")); + _LOGI (LOGD_BT, + "Activation: (bluetooth) Stage 2 of 5 (Device Configure) successful. Will connect via %s.", + dun ? "DUN" : (pan ? "PAN" : "unknown")); /* Kill the connect timeout since we're connected now */ if (priv->timeout_id) { @@ -715,9 +713,8 @@ check_connect_continue (NMDeviceBt *self) /* Wait for ModemManager to find the modem */ priv->timeout_id = g_timeout_add_seconds (30, modem_find_timeout, self); - nm_log_info (LOGD_BT | LOGD_MB, "Activation (%s/bluetooth) Stage 2 of 5 (Device Configure) " - "waiting for modem to appear.", - nm_device_get_iface (device)); + _LOGI (LOGD_BT | LOGD_MB, + "Activation: (bluetooth) Stage 2 of 5 (Device Configure) waiting for modem to appear."); } else g_assert_not_reached (); } @@ -736,8 +733,8 @@ bluez_connect_cb (GObject *object, res, &error); if (!device) { - nm_log_warn (LOGD_BT, "Error connecting with bluez: %s", - error && error->message ? error->message : "(unknown)"); + _LOGW (LOGD_BT, "Error connecting with bluez: %s", + error && error->message ? error->message : "(unknown)"); g_clear_error (&error); nm_device_state_changed (NM_DEVICE (self), @@ -753,8 +750,7 @@ bluez_connect_cb (GObject *object, nm_device_set_ip_iface (NM_DEVICE (self), device); } - nm_log_dbg (LOGD_BT, "(%s): connect request successful", - nm_device_get_iface (NM_DEVICE (self))); + _LOGD (LOGD_BT, "connect request successful"); /* Stage 3 gets scheduled when Bluez says we're connected */ priv->have_iface = TRUE; @@ -775,8 +771,7 @@ bluez_connected_changed (NMBluezDevice *bt_device, connected = nm_bluez_device_get_connected (bt_device); if (connected) { if (state == NM_DEVICE_STATE_CONFIG) { - nm_log_dbg (LOGD_BT, "(%s): connected to the device", - nm_device_get_iface (device)); + _LOGD (LOGD_BT, "connected to the device"); priv->connected = TRUE; check_connect_continue (self); @@ -787,13 +782,10 @@ bluez_connected_changed (NMBluezDevice *bt_device, /* Bluez says we're disconnected from the device. Suck. */ if (nm_device_is_activating (device)) { - nm_log_info (LOGD_BT, - "Activation (%s/bluetooth): bluetooth link disconnected.", - nm_device_get_iface (device)); + _LOGI (LOGD_BT, "Activation: (bluetooth) bluetooth link disconnected."); fail = TRUE; } else if (state == NM_DEVICE_STATE_ACTIVATED) { - nm_log_info (LOGD_BT, "(%s): bluetooth link disconnected.", - nm_device_get_iface (device)); + _LOGI (LOGD_BT, "bluetooth link disconnected."); fail = TRUE; } @@ -809,8 +801,7 @@ bt_connect_timeout (gpointer user_data) { NMDeviceBt *self = NM_DEVICE_BT (user_data); - nm_log_dbg (LOGD_BT, "(%s): initial connection timed out", - nm_device_get_iface (NM_DEVICE (self))); + _LOGD (LOGD_BT, "initial connection timed out"); NM_DEVICE_BT_GET_PRIVATE (self)->timeout_id = 0; nm_device_state_changed (NM_DEVICE (self), @@ -822,6 +813,7 @@ bt_connect_timeout (gpointer user_data) static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { + NMDeviceBt *self = NM_DEVICE_BT (device); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); NMConnection *connection; @@ -838,8 +830,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) return NM_ACT_STAGE_RETURN_FAILURE; } - nm_log_dbg (LOGD_BT, "(%s): requesting connection to the device", - nm_device_get_iface (device)); + _LOGD (LOGD_BT, "requesting connection to the device"); /* Connect to the BT device */ nm_bluez_device_connect_async (priv->bt_device, @@ -963,8 +954,7 @@ handle_availability_change (NMDeviceBt *self, state = nm_device_get_state (device); if (state < NM_DEVICE_STATE_UNAVAILABLE) { - nm_log_dbg (LOGD_BT, "(%s): availability blocked by UNMANAGED state", - nm_device_get_iface (device)); + _LOGD (LOGD_BT, "availability blocked by UNMANAGED state"); return; } @@ -974,7 +964,7 @@ handle_availability_change (NMDeviceBt *self, if (available) { if (state != NM_DEVICE_STATE_UNAVAILABLE) - nm_log_warn (LOGD_CORE | LOGD_BT, "not in expected unavailable state!"); + _LOGW (LOGD_CORE | LOGD_BT, "not in expected unavailable state!"); nm_device_state_changed (device, NM_DEVICE_STATE_DISCONNECTED, @@ -995,9 +985,8 @@ set_mm_running (NMDeviceBt *self, gboolean running) if (priv->mm_running == running) return; - nm_log_dbg (LOGD_BT, "(%s): ModemManager now %s", - nm_device_get_iface (NM_DEVICE (self)), - running ? "available" : "unavailable"); + _LOGD (LOGD_BT, "ModemManager now %s", + running ? "available" : "unavailable"); old_available = nm_device_is_available (NM_DEVICE (self)); priv->mm_running = running; diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index cd5e95f908..b94bc5a2ce 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -40,6 +40,8 @@ #include "nm-device-bond-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceBond); G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) @@ -181,14 +183,13 @@ complete_connection (NMDevice *device, static gboolean set_bond_attr (NMDevice *device, const char *attr, const char *value) { + NMDeviceBond *self = NM_DEVICE_BOND (device); gboolean ret; int ifindex = nm_device_get_ifindex (device); ret = nm_platform_master_set_option (ifindex, attr, value); - if (!ret) { - nm_log_warn (LOGD_HW, "(%s): failed to set bonding attribute " - "'%s' to '%s'", nm_device_get_ip_iface (device), attr, value); - } + if (!ret) + _LOGW (LOGD_HW, "failed to set bonding attribute '%s' to '%s'", attr, value); return ret; } @@ -423,8 +424,8 @@ enslave_slave (NMDevice *device, NMConnection *connection, gboolean configure) { + NMDeviceBond *self = NM_DEVICE_BOND (device); gboolean success = TRUE, no_firmware = FALSE; - const char *iface = nm_device_get_ip_iface (device); const char *slave_iface = nm_device_get_ip_iface (slave); nm_device_master_check_slave_physical_port (device, slave, LOGD_BOND); @@ -438,9 +439,9 @@ enslave_slave (NMDevice *device, if (!success) return FALSE; - nm_log_info (LOGD_BOND, "(%s): enslaved bond slave %s", iface, slave_iface); + _LOGI (LOGD_BOND, "enslaved bond slave %s", slave_iface); } else - nm_log_info (LOGD_BOND, "(%s): bond slave %s was enslaved", iface, slave_iface); + _LOGI (LOGD_BOND, "bond slave %s was enslaved", slave_iface); g_object_notify (G_OBJECT (device), NM_DEVICE_BOND_SLAVES); return TRUE; @@ -451,6 +452,7 @@ release_slave (NMDevice *device, NMDevice *slave, gboolean configure) { + NMDeviceBond *self = NM_DEVICE_BOND (device); gboolean success = TRUE, no_firmware = FALSE; if (configure) { @@ -458,17 +460,14 @@ release_slave (NMDevice *device, nm_device_get_ip_ifindex (slave)); if (success) { - nm_log_info (LOGD_BOND, "(%s): released bond slave %s", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); + _LOGI (LOGD_BOND, "released bond slave %s", + nm_device_get_ip_iface (slave)); } else { - nm_log_warn (LOGD_BOND, "(%s): failed to release bond slave %s", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); + _LOGW (LOGD_BOND, "failed to release bond slave %s", + nm_device_get_ip_iface (slave)); } } else { - nm_log_info (LOGD_BOND, "(%s): bond slave %s was released", - nm_device_get_ip_iface (device), + _LOGI (LOGD_BOND, "bond slave %s was released", nm_device_get_ip_iface (slave)); } @@ -480,10 +479,8 @@ release_slave (NMDevice *device, * IFF_UP), so we must bring it back up here to ensure carrier changes and * other state is noticed by the now-released slave. */ - if (!nm_device_bring_up (slave, TRUE, &no_firmware)) { - nm_log_warn (LOGD_BOND, "(%s): released bond slave could not be brought up.", - nm_device_get_iface (slave)); - } + if (!nm_device_bring_up (slave, TRUE, &no_firmware)) + _LOGW (LOGD_BOND, "released bond slave could not be brought up."); } return success; @@ -532,16 +529,6 @@ nm_device_bond_new_for_connection (NMConnection *connection) NULL); } -static void -constructed (GObject *object) -{ - G_OBJECT_CLASS (nm_device_bond_parent_class)->constructed (object); - - nm_log_dbg (LOGD_HW | LOGD_BOND, "(%s): kernel ifindex %d", - nm_device_get_iface (NM_DEVICE (object)), - nm_device_get_ifindex (NM_DEVICE (object))); -} - static void nm_device_bond_init (NMDeviceBond * self) { @@ -592,7 +579,6 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) parent_class->connection_type = NM_SETTING_BOND_SETTING_NAME; /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index b00446af0c..0b4366b1c8 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -39,6 +39,8 @@ #include "nm-device-bridge-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceBridge); G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE) @@ -292,6 +294,7 @@ commit_slave_options (NMDevice *device, NMSettingBridgePort *setting) static void update_connection (NMDevice *device, NMConnection *connection) { + NMDeviceBridge *self = NM_DEVICE_BRIDGE (device); NMSettingBridge *s_bridge = nm_connection_get_setting_bridge (connection); const char *ifname = nm_device_get_iface (device); int ifindex = nm_device_get_ifindex (device); @@ -315,23 +318,22 @@ update_connection (NMDevice *device, NMConnection *connection) value /= 100; g_object_set (s_bridge, option->name, value, NULL); - } else { - nm_log_warn (LOGD_BRIDGE, "(%s): failed to read bridge setting '%s'", - nm_device_get_iface (device), option->sysname); - } + } else + _LOGW (LOGD_BRIDGE, "failed to read bridge setting '%s'", option->sysname); } } static gboolean -master_update_slave_connection (NMDevice *self, +master_update_slave_connection (NMDevice *device, NMDevice *slave, NMConnection *connection, GError **error) { + NMDeviceBridge *self = NM_DEVICE_BRIDGE (device); NMSettingConnection *s_con; NMSettingBridgePort *s_port; int ifindex_slave = nm_device_get_ifindex (slave); - const char *iface = nm_device_get_iface (self); + const char *iface = nm_device_get_iface (device); const Option *option; g_return_val_if_fail (ifindex_slave > 0, FALSE); @@ -355,10 +357,8 @@ master_update_slave_connection (NMDevice *self, value /= 100; g_object_set (s_port, option->name, value, NULL); - } else { - nm_log_warn (LOGD_BRIDGE, "(%s): failed to read bridge port setting '%s'", - nm_device_get_iface (slave), option->sysname); - } + } else + _LOGW (LOGD_BRIDGE, "failed to read bridge port setting '%s'", option->sysname); } g_object_set (s_con, @@ -391,19 +391,19 @@ enslave_slave (NMDevice *device, NMConnection *connection, gboolean configure) { + NMDeviceBridge *self = NM_DEVICE_BRIDGE (device); + if (configure) { if (!nm_platform_link_enslave (nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave))) return FALSE; commit_slave_options (slave, nm_connection_get_setting_bridge_port (connection)); - nm_log_info (LOGD_BRIDGE, "(%s): attached bridge port %s", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); + _LOGI (LOGD_BRIDGE, "attached bridge port %s", + nm_device_get_ip_iface (slave)); } else { - nm_log_info (LOGD_BRIDGE, "(%s): bridge port %s was attached", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); + _LOGI (LOGD_BRIDGE, "bridge port %s was attached", + nm_device_get_ip_iface (slave)); } g_object_notify (G_OBJECT (device), NM_DEVICE_BRIDGE_SLAVES); @@ -416,6 +416,7 @@ release_slave (NMDevice *device, NMDevice *slave, gboolean configure) { + NMDeviceBridge *self = NM_DEVICE_BRIDGE (device); gboolean success = TRUE; if (configure) { @@ -423,18 +424,15 @@ release_slave (NMDevice *device, nm_device_get_ip_ifindex (slave)); if (success) { - nm_log_info (LOGD_BRIDGE, "(%s): detached bridge port %s", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); + _LOGI (LOGD_BRIDGE, "detached bridge port %s", + nm_device_get_ip_iface (slave)); } else { - nm_log_warn (LOGD_BRIDGE, "(%s): failed to detach bridge port %s", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); + _LOGW (LOGD_BRIDGE, "failed to detach bridge port %s", + nm_device_get_ip_iface (slave)); } } else { - nm_log_info (LOGD_BRIDGE, "(%s): bridge port %s was detached", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); + _LOGI (LOGD_BRIDGE, "bridge port %s was detached", + nm_device_get_ip_iface (slave)); } g_object_notify (G_OBJECT (device), NM_DEVICE_BRIDGE_SLAVES); @@ -493,16 +491,6 @@ nm_device_bridge_new_for_connection (NMConnection *connection) NULL); } -static void -constructed (GObject *object) -{ - G_OBJECT_CLASS (nm_device_bridge_parent_class)->constructed (object); - - nm_log_dbg (LOGD_HW | LOGD_BRIDGE, "(%s): kernel ifindex %d", - nm_device_get_iface (NM_DEVICE (object)), - nm_device_get_ifindex (NM_DEVICE (object))); -} - static void nm_device_bridge_init (NMDeviceBridge * self) { @@ -553,7 +541,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass) parent_class->connection_type = NM_SETTING_BRIDGE_SETTING_NAME; /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 41c4dfb9c5..a41f9bde32 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -60,6 +60,8 @@ #include "nm-device-ethernet-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceEthernet); G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) @@ -167,7 +169,6 @@ static void _update_s390_subchannels (NMDeviceEthernet *self) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - const char *iface; GUdevClient *client; GUdevDevice *dev; GUdevDevice *parent = NULL; @@ -176,17 +177,16 @@ _update_s390_subchannels (NMDeviceEthernet *self) GDir *dir; GError *error = NULL; - iface = nm_device_get_iface (NM_DEVICE (self)); - client = g_udev_client_new (subsystems); if (!client) { - nm_log_warn (LOGD_DEVICE | LOGD_HW, "(%s): failed to initialize GUdev client", iface); + _LOGW (LOGD_DEVICE | LOGD_HW, "failed to initialize GUdev client"); return; } - dev = g_udev_client_query_by_subsystem_and_name (client, "net", iface); + dev = g_udev_client_query_by_subsystem_and_name (client, "net", + nm_device_get_iface (NM_DEVICE (self))); if (!dev) { - nm_log_warn (LOGD_DEVICE | LOGD_HW, "(%s): failed to find device with udev", iface); + _LOGW (LOGD_DEVICE | LOGD_HW, "failed to find device with udev"); goto out; } @@ -203,9 +203,8 @@ _update_s390_subchannels (NMDeviceEthernet *self) parent_path = g_udev_device_get_sysfs_path (parent); dir = g_dir_open (parent_path, 0, &error); if (!dir) { - nm_log_warn (LOGD_DEVICE | LOGD_HW, "(%s): failed to open directory '%s': %s", - iface, parent_path, - error && error->message ? error->message : "(unknown)"); + _LOGW (LOGD_DEVICE | LOGD_HW, "failed to open directory '%s': %s", + parent_path, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); goto out; } @@ -228,12 +227,12 @@ _update_s390_subchannels (NMDeviceEthernet *self) if (value && *value) g_hash_table_insert (priv->s390_options, g_strdup (item), g_strdup (value)); else - nm_log_warn (LOGD_DEVICE | LOGD_HW, "(%s): error reading %s", iface, path); + _LOGW (LOGD_DEVICE | LOGD_HW, "error reading %s", path); g_free (path); g_free (value); } if (error) { - nm_log_warn (LOGD_DEVICE | LOGD_HW, "(%s): %s", iface, error->message); + _LOGW (LOGD_DEVICE | LOGD_HW, "%s", error->message); g_clear_error (&error); } } @@ -253,9 +252,8 @@ _update_s390_subchannels (NMDeviceEthernet *self) priv->subchannels = g_strdup (priv->subchan1); driver = nm_device_get_driver (NM_DEVICE (self)); - nm_log_info (LOGD_DEVICE | LOGD_HW, - "(%s): found s390 '%s' subchannels [%s]", - iface, driver ? driver : "(unknown driver)", priv->subchannels); + _LOGI (LOGD_DEVICE | LOGD_HW, "found s390 '%s' subchannels [%s]", + driver ? driver : "(unknown driver)", priv->subchannels); out: if (parent) @@ -271,25 +269,20 @@ constructor (GType type, GObjectConstructParam *construct_params) { GObject *object; - NMDevice *self; - int ifindex; object = G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructor (type, n_construct_params, construct_params); if (object) { - self = NM_DEVICE (object); - ifindex = nm_device_get_ifindex (self); - - g_assert ( nm_platform_link_get_type (ifindex) == NM_LINK_TYPE_ETHERNET - || nm_platform_link_get_type (ifindex) == NM_LINK_TYPE_VETH); +#ifndef G_DISABLE_ASSERT + int ifindex = nm_device_get_ifindex (NM_DEVICE (object)); + NMLinkType link_type = nm_platform_link_get_type (ifindex); - nm_log_dbg (LOGD_HW | LOGD_ETHER, "(%s): kernel ifindex %d", - nm_device_get_iface (NM_DEVICE (self)), - nm_device_get_ifindex (NM_DEVICE (self))); + g_assert (link_type == NM_LINK_TYPE_ETHERNET || link_type == NM_LINK_TYPE_VETH); +#endif /* s390 stuff */ - _update_s390_subchannels (NM_DEVICE_ETHERNET (self)); + _update_s390_subchannels (NM_DEVICE_ETHERNET (object)); } return object; @@ -347,12 +340,12 @@ update_permanent_hw_address (NMDevice *dev) NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); struct ifreq req; struct ethtool_perm_addr *epaddr = NULL; - int fd, ret; + int fd, ret, errsv; const guint8 *mac; fd = socket (PF_INET, SOCK_DGRAM, 0); if (fd < 0) { - nm_log_warn (LOGD_HW, "couldn't open control socket."); + _LOGW (LOGD_HW, "couldn't open control socket."); return; } @@ -367,9 +360,9 @@ update_permanent_hw_address (NMDevice *dev) errno = 0; ret = ioctl (fd, SIOCETHTOOL, &req); + errsv = errno; if ((ret < 0) || !nm_ethernet_address_is_valid ((struct ether_addr *) epaddr->data)) { - nm_log_dbg (LOGD_HW | LOGD_ETHER, "(%s): unable to read permanent MAC address (error %d)", - nm_device_get_iface (dev), errno); + _LOGD (LOGD_HW | LOGD_ETHER, "unable to read permanent MAC address (error %d)", errsv); /* Fall back to current address */ mac = nm_device_get_hw_address (dev, NULL); if (mac) @@ -392,7 +385,7 @@ update_initial_hw_address (NMDevice *dev) { NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - char *mac_str; + gs_free char *tmp_str = NULL; const guint8 *mac; /* This sets initial MAC address from current MAC address. It should only @@ -402,22 +395,20 @@ update_initial_hw_address (NMDevice *dev) if (mac) memcpy (priv->initial_hw_addr, mac, ETH_ALEN); - mac_str = nm_utils_hwaddr_ntoa (priv->initial_hw_addr, ARPHRD_ETHER); - nm_log_dbg (LOGD_DEVICE | LOGD_ETHER, "(%s): read initial MAC address %s", - nm_device_get_iface (dev), mac_str); - g_free (mac_str); + _LOGD (LOGD_DEVICE | LOGD_ETHER, "read initial MAC address %s", + (tmp_str = nm_utils_hwaddr_ntoa (priv->initial_hw_addr, ARPHRD_ETHER))); } static guint32 -get_generic_capabilities (NMDevice *dev) +get_generic_capabilities (NMDevice *device) { - if (nm_platform_link_supports_carrier_detect (nm_device_get_ifindex (dev))) + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); + + if (nm_platform_link_supports_carrier_detect (nm_device_get_ifindex (device))) return NM_DEVICE_CAP_CARRIER_DETECT; else { - nm_log_info (LOGD_HW, - "(%s): driver '%s' does not support carrier detection.", - nm_device_get_iface (dev), - nm_device_get_driver (dev)); + _LOGI (LOGD_HW, "driver '%s' does not support carrier detection.", + nm_device_get_driver (device)); return NM_DEVICE_CAP_NONE; } } @@ -588,14 +579,15 @@ wired_secrets_cb (NMActRequest *req, GError *error, gpointer user_data) { - NMDevice *dev = NM_DEVICE (user_data); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data); + NMDevice *dev = NM_DEVICE (self); g_return_if_fail (req == nm_device_get_act_request (dev)); g_return_if_fail (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH); g_return_if_fail (nm_act_request_get_connection (req) == connection); if (error) { - nm_log_warn (LOGD_ETHER, "%s", error->message); + _LOGW (LOGD_ETHER, "%s", error->message); nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS); @@ -637,10 +629,8 @@ link_timeout_cb (gpointer user_data) if (!setting_name) goto time_out; - nm_log_info (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired): disconnected during authentication," - " asking for new key.", - nm_device_get_iface (dev)); + _LOGI (LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) disconnected during authentication, asking for new key."); supplicant_interface_release (self); nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT); @@ -654,8 +644,7 @@ link_timeout_cb (gpointer user_data) return FALSE; time_out: - nm_log_warn (LOGD_DEVICE | LOGD_ETHER, - "(%s): link timed out.", nm_device_get_iface (dev)); + _LOGW (LOGD_DEVICE | LOGD_ETHER, "link timed out."); nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT); return FALSE; @@ -677,7 +666,7 @@ build_supplicant_config (NMDeviceEthernet *self) security = nm_connection_get_setting_802_1x (connection); if (!nm_supplicant_config_add_setting_8021x (config, security, con_uuid, TRUE)) { - nm_log_warn (LOGD_DEVICE, "Couldn't add 802.1X security setting to supplicant config."); + _LOGW (LOGD_DEVICE, "Couldn't add 802.1X security setting to supplicant config."); g_object_unref (config); config = NULL; } @@ -702,11 +691,9 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, if (new_state == old_state) return; - nm_log_info (LOGD_DEVICE | LOGD_ETHER, - "(%s): supplicant interface state: %s -> %s", - nm_device_get_iface (device), - nm_supplicant_interface_state_to_string (old_state), - nm_supplicant_interface_state_to_string (new_state)); + _LOGI (LOGD_DEVICE | LOGD_ETHER, "supplicant interface state: %s -> %s", + nm_supplicant_interface_state_to_string (old_state), + nm_supplicant_interface_state_to_string (new_state)); devstate = nm_device_get_state (device); @@ -718,15 +705,12 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, g_object_unref (config); if (!success) { - nm_log_err (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired): couldn't send security " - "configuration to the supplicant.", - nm_device_get_iface (device)); + _LOGE (LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) couldn't send security configuration to the supplicant."); } } else { - nm_log_warn (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired): couldn't build security configuration.", - nm_device_get_iface (device)); + _LOGW (LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) couldn't build security configuration."); } if (!success) { @@ -743,9 +727,8 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, * schedule the next activation stage. */ if (devstate == NM_DEVICE_STATE_CONFIG) { - nm_log_info (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired) Stage 2 of 5 (Device Configure) successful.", - nm_device_get_iface (device)); + _LOGI (LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) Stage 2 of 5 (Device Configure) successful."); nm_device_activate_schedule_stage3_ip_config_start (device); } break; @@ -794,9 +777,9 @@ supplicant_iface_connection_error_cb (NMSupplicantInterface *iface, NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); guint id; - nm_log_warn (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired): association request to the supplicant failed: %s - %s", - nm_device_get_iface (NM_DEVICE (self)), name, message); + _LOGW (LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) association request to the supplicant failed: %s - %s", + name, message); if (priv->supplicant.iface_con_error_cb_id) g_source_remove (priv->supplicant.iface_con_error_cb_id); @@ -833,9 +816,8 @@ handle_auth_or_fail (NMDeviceEthernet *self, nm_act_request_get_secrets (req, setting_name, flags, NULL, wired_secrets_cb, self); g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); - } else { - nm_log_info (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); - } + } else + _LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); return NM_ACT_STAGE_RETURN_POSTPONE; } @@ -848,19 +830,16 @@ supplicant_connection_timeout_cb (gpointer user_data) NMDevice *device = NM_DEVICE (self); NMActRequest *req; NMConnection *connection; - const char *iface; guint64 timestamp = 0; gboolean new_secrets = TRUE; priv->supplicant.con_timeout_id = 0; - iface = nm_device_get_iface (device); - /* Authentication failed; either driver problems, the encryption key is * wrong, the passwords or certificates were wrong or the Ethernet switch's * port is not configured for 802.1x. */ - nm_log_warn (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired): association took too long.", iface); + _LOGW (LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) association took too long."); supplicant_interface_release (self); req = nm_device_get_act_request (device); @@ -876,10 +855,9 @@ supplicant_connection_timeout_cb (gpointer user_data) if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), ×tamp)) new_secrets = !timestamp; - if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE) { - nm_log_info (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired): asking for new secrets", iface); - } else + if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE) + _LOGW (LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) asking for new secrets"); + else nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS); return FALSE; @@ -889,16 +867,14 @@ static gboolean supplicant_interface_init (NMDeviceEthernet *self) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - const char *iface; - - iface = nm_device_get_iface (NM_DEVICE (self)); /* Create supplicant interface */ - priv->supplicant.iface = nm_supplicant_manager_iface_get (priv->supplicant.mgr, iface, FALSE); + priv->supplicant.iface = nm_supplicant_manager_iface_get (priv->supplicant.mgr, + nm_device_get_iface (NM_DEVICE (self)), + FALSE); if (!priv->supplicant.iface) { - nm_log_err (LOGD_DEVICE | LOGD_ETHER, - "Couldn't initialize supplicant interface for %s.", - iface); + _LOGE (LOGD_DEVICE | LOGD_ETHER, + "Couldn't initialize supplicant interface"); supplicant_interface_release (self); return FALSE; } @@ -924,13 +900,12 @@ supplicant_interface_init (NMDeviceEthernet *self) static gboolean pppoe_reconnect_delay (gpointer user_data) { - NMDevice *device = NM_DEVICE (user_data); - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); priv->pppoe_wait_id = 0; - nm_log_info (LOGD_DEVICE, "(%s) PPPoE reconnect delay complete, resuming connection...", - nm_device_get_iface (device)); - nm_device_activate_schedule_stage2_device_config (device); + _LOGI (LOGD_DEVICE, "PPPoE reconnect delay complete, resuming connection..."); + nm_device_activate_schedule_stage2_device_config (NM_DEVICE (self)); return FALSE; } @@ -968,8 +943,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) gint32 delay = nm_utils_get_monotonic_timestamp_s () - priv->last_pppoe_time; if (delay < PPPOE_RECONNECT_DELAY && device_get_setting (dev, NM_TYPE_SETTING_PPPOE)) { - nm_log_info (LOGD_DEVICE, "(%s) delaying PPPoE reconnect for %d seconds to ensure peer is ready...", - nm_device_get_iface (dev), delay); + _LOGI (LOGD_DEVICE, "delaying PPPoE reconnect for %d seconds to ensure peer is ready...", + delay); g_assert (!priv->pppoe_wait_id); priv->pppoe_wait_id = g_timeout_add_seconds (delay, pppoe_reconnect_delay, @@ -990,14 +965,13 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason) NMConnection *connection; NMSetting8021x *security; const char *setting_name; - const char *iface; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; connection = nm_device_get_connection (NM_DEVICE (self)); g_assert (connection); security = nm_connection_get_setting_802_1x (connection); if (!security) { - nm_log_err (LOGD_DEVICE, "Invalid or missing 802.1X security"); + _LOGE (LOGD_DEVICE, "Invalid or missing 802.1X security"); *reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED; return ret; } @@ -1005,24 +979,22 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason) if (!priv->supplicant.mgr) priv->supplicant.mgr = nm_supplicant_manager_get (); - iface = nm_device_get_iface (NM_DEVICE (self)); - /* If we need secrets, get them */ setting_name = nm_connection_need_secrets (connection, NULL); if (setting_name) { NMActRequest *req = nm_device_get_act_request (NM_DEVICE (self)); - nm_log_info (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired): connection '%s' has security, but secrets are required.", - iface, nm_connection_get_id (connection)); + _LOGI (LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) connection '%s' has security, but secrets are required.", + nm_connection_get_id (connection)); ret = handle_auth_or_fail (self, req, FALSE); if (ret != NM_ACT_STAGE_RETURN_POSTPONE) *reason = NM_DEVICE_STATE_REASON_NO_SECRETS; } else { - nm_log_info (LOGD_DEVICE | LOGD_ETHER, - "Activation (%s/wired): connection '%s' requires no security. No secrets needed.", - iface, nm_connection_get_id (connection)); + _LOGI (LOGD_DEVICE | LOGD_ETHER, + "Activation: (ethernet) connection '%s' requires no security. No secrets needed.", + nm_connection_get_id (connection)); if (supplicant_interface_init (self)) ret = NM_ACT_STAGE_RETURN_POSTPONE; @@ -1097,8 +1069,7 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas self); ret = NM_ACT_STAGE_RETURN_POSTPONE; } else { - nm_log_warn (LOGD_DEVICE, "(%s): PPPoE failed to start: %s", - nm_device_get_iface (NM_DEVICE (self)), err->message); + _LOGW (LOGD_DEVICE, "PPPoE failed to start: %s", err->message); g_error_free (err); g_object_unref (priv->ppp_manager); @@ -1139,17 +1110,16 @@ static void dcb_state (NMDevice *device, gboolean timeout); static gboolean dcb_carrier_timeout (gpointer user_data) { + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDevice *device = NM_DEVICE (user_data); - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); g_return_val_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG, G_SOURCE_REMOVE); priv->dcb_timeout_id = 0; if (priv->dcb_wait != DCB_WAIT_CARRIER_POSTCONFIG_DOWN) { - nm_log_warn (LOGD_DCB, - "(%s): DCB: timed out waiting for carrier (step %d)", - nm_device_get_iface (device), - priv->dcb_wait); + _LOGW (LOGD_DCB, "DCB: timed out waiting for carrier (step %d)", + priv->dcb_wait); } dcb_state (device, TRUE); return G_SOURCE_REMOVE; @@ -1158,19 +1128,18 @@ dcb_carrier_timeout (gpointer user_data) static gboolean dcb_configure (NMDevice *device) { + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); NMSettingDcb *s_dcb; - const char *iface = nm_device_get_iface (device); GError *error = NULL; dcb_timeout_cleanup (device); s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB); g_assert (s_dcb); - if (!nm_dcb_setup (iface, s_dcb, &error)) { - nm_log_warn (LOGD_DCB, - "Activation (%s/wired) failed to enable DCB/FCoE: %s", - iface, error->message); + if (!nm_dcb_setup (nm_device_get_iface (device), s_dcb, &error)) { + _LOGW (LOGD_DCB, "Activation: (ethernet) failed to enable DCB/FCoE: %s", + error->message); g_clear_error (&error); return FALSE; } @@ -1178,7 +1147,7 @@ dcb_configure (NMDevice *device) /* Pause again just in case the device takes the carrier down when * setting specific DCB attributes. */ - nm_log_dbg (LOGD_DCB, "(%s): waiting for carrier (postconfig down)", iface); + _LOGD (LOGD_DCB, "waiting for carrier (postconfig down)"); priv->dcb_wait = DCB_WAIT_CARRIER_POSTCONFIG_DOWN; priv->dcb_timeout_id = g_timeout_add_seconds (3, dcb_carrier_timeout, device); return TRUE; @@ -1187,15 +1156,14 @@ dcb_configure (NMDevice *device) static gboolean dcb_enable (NMDevice *device) { - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); - const char *iface = nm_device_get_iface (device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); GError *error = NULL; dcb_timeout_cleanup (device); - if (!nm_dcb_enable (iface, TRUE, &error)) { - nm_log_warn (LOGD_DCB, - "Activation (%s/wired) failed to enable DCB/FCoE: %s", - iface, error->message); + if (!nm_dcb_enable (nm_device_get_iface (device), TRUE, &error)) { + _LOGW (LOGD_DCB, "Activation: (ethernet) failed to enable DCB/FCoE: %s", + error->message); g_clear_error (&error); return FALSE; } @@ -1207,7 +1175,7 @@ dcb_enable (NMDevice *device) * is down. But NM might get the carrier-down signal long after calling * "dcbtool dcb on", so we have to first wait for the carrier to go down. */ - nm_log_dbg (LOGD_DCB, "(%s): waiting for carrier (preconfig down)", iface); + _LOGD (LOGD_DCB, "waiting for carrier (preconfig down)"); priv->dcb_wait = DCB_WAIT_CARRIER_PRECONFIG_DOWN; priv->dcb_timeout_id = g_timeout_add_seconds (3, dcb_carrier_timeout, device); return TRUE; @@ -1216,20 +1184,20 @@ dcb_enable (NMDevice *device) static void dcb_state (NMDevice *device, gboolean timeout) { - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); - const char *iface = nm_device_get_iface (device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); gboolean carrier; g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG); carrier = nm_platform_link_is_connected (nm_device_get_ifindex (device)); - nm_log_dbg (LOGD_DCB, "(%s): dcb_state() wait %d carrier %d timeout %d", iface, priv->dcb_wait, carrier, timeout); + _LOGD (LOGD_DCB, "dcb_state() wait %d carrier %d timeout %d", priv->dcb_wait, carrier, timeout); switch (priv->dcb_wait) { case DCB_WAIT_CARRIER_PREENABLE_UP: if (timeout || carrier) { - nm_log_dbg (LOGD_DCB, "(%s): dcb_state() enabling DCB", iface); + _LOGD (LOGD_DCB, "dcb_state() enabling DCB"); dcb_timeout_cleanup (device); if (!dcb_enable (device)) { dcb_carrier_cleanup (device); @@ -1245,15 +1213,15 @@ dcb_state (NMDevice *device, gboolean timeout) if (!carrier) { /* Wait for the carrier to come back up */ - nm_log_dbg (LOGD_DCB, "(%s): waiting for carrier (preconfig up)", iface); + _LOGD (LOGD_DCB, "waiting for carrier (preconfig up)"); priv->dcb_timeout_id = g_timeout_add_seconds (5, dcb_carrier_timeout, device); break; } - nm_log_dbg (LOGD_DCB, "(%s): dcb_state() preconfig down falling through", iface); + _LOGD (LOGD_DCB, "dcb_state() preconfig down falling through"); /* carrier never went down? fall through */ case DCB_WAIT_CARRIER_PRECONFIG_UP: if (timeout || carrier) { - nm_log_dbg (LOGD_DCB, "(%s): dcb_state() preconfig up configuring DCB", iface); + _LOGD (LOGD_DCB, "dcb_state() preconfig up configuring DCB"); dcb_timeout_cleanup (device); if (!dcb_configure (device)) { dcb_carrier_cleanup (device); @@ -1269,15 +1237,15 @@ dcb_state (NMDevice *device, gboolean timeout) if (!carrier) { /* Wait for the carrier to come back up */ - nm_log_dbg (LOGD_DCB, "(%s): waiting for carrier (postconfig up)", iface); + _LOGD (LOGD_DCB, "waiting for carrier (postconfig up)"); priv->dcb_timeout_id = g_timeout_add_seconds (5, dcb_carrier_timeout, device); break; } - nm_log_dbg (LOGD_DCB, "(%s): dcb_state() postconfig down falling through", iface); + _LOGD (LOGD_DCB, "dcb_state() postconfig down falling through"); /* carrier never went down? fall through */ case DCB_WAIT_CARRIER_POSTCONFIG_UP: if (timeout || carrier) { - nm_log_dbg (LOGD_DCB, "(%s): dcb_state() postconfig up starting IP", iface); + _LOGD (LOGD_DCB, "dcb_state() postconfig up starting IP"); dcb_timeout_cleanup (device); dcb_carrier_cleanup (device); priv->dcb_wait = DCB_WAIT_UNKNOWN; @@ -1292,12 +1260,13 @@ dcb_state (NMDevice *device, gboolean timeout) static void dcb_carrier_changed (NMDevice *device, GParamSpec *pspec, gpointer unused) { - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG); if (priv->dcb_timeout_id) { - nm_log_dbg (LOGD_DCB, "(%s): carrier_changed() calling dcb_state()", nm_device_get_iface (device)); + _LOGD (LOGD_DCB, "carrier_changed() calling dcb_state()"); dcb_state (device, FALSE); } } @@ -1307,7 +1276,8 @@ dcb_carrier_changed (NMDevice *device, GParamSpec *pspec, gpointer unused) static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMSettingConnection *s_con; const char *connection_type; NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; @@ -1331,7 +1301,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) security = (NMSetting8021x *) device_get_setting (device, NM_TYPE_SETTING_802_1X); if (security) { /* FIXME: for now 802.1x is mutually exclusive with DCB */ - return nm_8021x_stage2_config (NM_DEVICE_ETHERNET (device), reason); + return nm_8021x_stage2_config (self, reason); } } @@ -1345,8 +1315,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) return NM_ACT_STAGE_RETURN_FAILURE; } } else { - nm_log_dbg (LOGD_DCB, "(%s): waiting for carrier (preenable up)", - nm_device_get_iface (device)); + _LOGD (LOGD_DCB, "waiting for carrier (preenable up)"); priv->dcb_wait = DCB_WAIT_CARRIER_PREENABLE_UP; priv->dcb_timeout_id = g_timeout_add_seconds (4, dcb_carrier_timeout, device); } @@ -1442,9 +1411,8 @@ deactivate (NMDevice *device) s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB); if (s_dcb) { if (!nm_dcb_cleanup (nm_device_get_iface (device), &error)) { - nm_log_warn (LOGD_DEVICE | LOGD_HW, - "(%s) failed to disable DCB/FCoE: %s", - nm_device_get_iface (device), error->message); + _LOGW (LOGD_DEVICE | LOGD_HW, "failed to disable DCB/FCoE: %s", + error->message); g_clear_error (&error); } } @@ -1595,7 +1563,8 @@ update_connection (NMDevice *device, NMConnection *connection) static void get_link_speed (NMDevice *device) { - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); + NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); struct ifreq ifr; struct ethtool_cmd edata = { .cmd = ETHTOOL_GSET, @@ -1605,7 +1574,7 @@ get_link_speed (NMDevice *device) fd = socket (PF_INET, SOCK_DGRAM, 0); if (fd < 0) { - nm_log_warn (LOGD_HW | LOGD_ETHER, "couldn't open ethtool control socket."); + _LOGW (LOGD_HW | LOGD_ETHER, "couldn't open ethtool control socket."); return; } @@ -1633,8 +1602,7 @@ get_link_speed (NMDevice *device) priv->speed = speed; g_object_notify (G_OBJECT (device), "speed"); - nm_log_dbg (LOGD_HW | LOGD_ETHER, "(%s): speed is now %d Mb/s", - nm_device_get_iface (device), speed); + _LOGD (LOGD_HW | LOGD_ETHER, "speed is now %d Mb/s", speed); } static void diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c index 2230379978..eded6777a2 100644 --- a/src/devices/nm-device-gre.c +++ b/src/devices/nm-device-gre.c @@ -31,6 +31,9 @@ #include "nm-device-gre-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceGre); + G_DEFINE_TYPE (NMDeviceGre, nm_device_gre, NM_TYPE_DEVICE_GENERIC) #define NM_DEVICE_GRE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_GRE, NMDeviceGrePrivate)) @@ -60,13 +63,13 @@ enum { static void update_properties (NMDevice *device) { - NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (device); + NMDeviceGre *self = NM_DEVICE_GRE (device); + NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (self); GObject *object = G_OBJECT (device); NMPlatformGreProperties props; if (!nm_platform_gre_get_properties (nm_device_get_ifindex (device), &props)) { - nm_log_warn (LOGD_HW, "(%s): could not read gre properties", - nm_device_get_iface (device)); + _LOGW (LOGD_HW, "could not read gre properties"); return; } diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 5861e0f473..068294abb9 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -65,28 +65,6 @@ nm_infiniband_error_quark (void) return quark; } -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMDevice *self; - - object = G_OBJECT_CLASS (nm_device_infiniband_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - self = NM_DEVICE (object); - - nm_log_dbg (LOGD_HW | LOGD_INFINIBAND, "(%s): kernel ifindex %d", - nm_device_get_iface (self), - nm_device_get_ifindex (self)); - return object; -} - static void nm_device_infiniband_init (NMDeviceInfiniband * self) { @@ -392,7 +370,6 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) g_type_class_add_private (object_class, sizeof (NMDeviceInfinibandPrivate)); /* virtual methods */ - object_class->constructor = constructor; object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index e5f90543d9..cd49a9b50f 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -31,6 +31,9 @@ #include "nm-device-macvlan-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceMacvlan); + G_DEFINE_TYPE (NMDeviceMacvlan, nm_device_macvlan, NM_TYPE_DEVICE_GENERIC) #define NM_DEVICE_MACVLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MACVLAN, NMDeviceMacvlanPrivate)) @@ -55,13 +58,13 @@ enum { static void update_properties (NMDevice *device) { + NMDeviceMacvlan *self = NM_DEVICE_MACVLAN (device); NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device); GObject *object = G_OBJECT (device); NMPlatformMacvlanProperties props; if (!nm_platform_macvlan_get_properties (nm_device_get_ifindex (device), &props)) { - nm_log_warn (LOGD_HW, "(%s): could not read macvlan properties", - nm_device_get_iface (device)); + _LOGW (LOGD_HW, "could not read macvlan properties"); return; } diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 873d330a39..030c2e23bf 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -31,6 +31,9 @@ #include "nm-device-tun-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceTun); + G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE_GENERIC) #define NM_DEVICE_TUN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_TUN, NMDeviceTunPrivate)) @@ -55,15 +58,14 @@ enum { }; static void -reload_tun_properties (NMDeviceTun *device) +reload_tun_properties (NMDeviceTun *self) { - NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (device); - GObject *object = G_OBJECT (device); + NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); + GObject *object = G_OBJECT (self); NMPlatformTunProperties props; - if (!nm_platform_tun_get_properties (nm_device_get_ifindex (NM_DEVICE (device)), &props)) { - nm_log_warn (LOGD_HW, "(%s): could not read tun properties", - nm_device_get_iface (NM_DEVICE (device))); + if (!nm_platform_tun_get_properties (nm_device_get_ifindex (NM_DEVICE (self)), &props)) { + _LOGD (LOGD_HW, "could not read tun properties"); return; } @@ -137,18 +139,18 @@ nm_device_tun_init (NMDeviceTun *self) static void constructed (GObject *object) { + NMDeviceTun *self = NM_DEVICE_TUN (object); gboolean properties_read; - NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (object); + NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); - properties_read = nm_platform_tun_get_properties (nm_device_get_ifindex (NM_DEVICE (object)), &priv->props); + properties_read = nm_platform_tun_get_properties (nm_device_get_ifindex (NM_DEVICE (self)), &priv->props); G_OBJECT_CLASS (nm_device_tun_parent_class)->constructed (object); if (!properties_read) { /* Error reading the tun properties. Maybe this was due to a race. Try again a bit later. */ - nm_log_dbg (LOGD_HW, "(%s): could not read tun properties (retry)", - nm_device_get_iface (NM_DEVICE (object))); - priv->delay_tun_get_properties_id = g_timeout_add_seconds (1, delay_tun_get_properties_cb, object); + _LOGD (LOGD_HW, "could not read tun properties (retry)"); + priv->delay_tun_get_properties_id = g_timeout_add_seconds (1, delay_tun_get_properties_cb, self); } } diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index 0bdd810218..ce417be504 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -36,6 +36,9 @@ #include "nm-device-veth-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceVeth); + G_DEFINE_TYPE (NMDeviceVeth, nm_device_veth, NM_TYPE_DEVICE_ETHERNET) #define NM_DEVICE_VETH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VETH, NMDeviceVethPrivate)) @@ -79,8 +82,7 @@ get_peer (NMDeviceVeth *self) return priv->peer; if (!nm_platform_veth_get_properties (nm_device_get_ifindex (device), &props)) { - nm_log_warn (LOGD_HW, "(%s): could not read veth properties", - nm_device_get_iface (device)); + _LOGW (LOGD_HW, "could not read veth properties"); return NULL; } diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 4ee89cd00b..a04180c751 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -43,6 +43,8 @@ #include "nm-device-vlan-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceVlan); G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) @@ -88,14 +90,12 @@ update_initial_hw_address (NMDevice *dev) { NMDeviceVlan *self = NM_DEVICE_VLAN (dev); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); - char *mac_str; + gs_free char *mac_str = NULL; memcpy (priv->initial_hw_addr, nm_device_get_hw_address (dev, NULL), ETH_ALEN); - mac_str = nm_utils_hwaddr_ntoa (priv->initial_hw_addr, ARPHRD_ETHER); - nm_log_dbg (LOGD_DEVICE | LOGD_VLAN, "(%s): read initial MAC address %s", - nm_device_get_iface (dev), mac_str); - g_free (mac_str); + _LOGD (LOGD_DEVICE | LOGD_VLAN, "read initial MAC address %s", + (mac_str = nm_utils_hwaddr_ntoa (priv->initial_hw_addr, ARPHRD_ETHER))); } static guint32 @@ -283,6 +283,7 @@ nm_device_vlan_set_parent (NMDeviceVlan *device, NMDevice *parent) static void update_connection (NMDevice *device, NMConnection *connection) { + NMDeviceVlan *self = NM_DEVICE_VLAN (device); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device); NMSettingVlan *s_vlan = nm_connection_get_setting_vlan (connection); int ifindex = nm_device_get_ifindex (device); @@ -297,8 +298,7 @@ update_connection (NMDevice *device, NMConnection *connection) } if (!nm_platform_vlan_get_info (ifindex, &parent_ifindex, &vlan_id)) { - nm_log_warn (LOGD_VLAN, "(%s): failed to get VLAN interface info while updating connection.", - nm_device_get_iface (device)); + _LOGW (LOGD_VLAN, "failed to get VLAN interface info while updating connection."); return; } @@ -485,7 +485,7 @@ nm_device_vlan_new_for_connection (NMConnection *connection, NMDevice *parent) nm_setting_vlan_get_id (s_vlan), nm_setting_vlan_get_flags (s_vlan)) && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) { - nm_log_warn (LOGD_DEVICE | LOGD_VLAN, "(%s): failed to add VLAN interface for '%s'", + nm_log_warn (LOGD_DEVICE | LOGD_VLAN, "(%s) failed to add VLAN interface for '%s'", iface, nm_connection_get_id (connection)); g_free (iface); return NULL; @@ -515,10 +515,9 @@ nm_device_vlan_init (NMDeviceVlan * self) static void constructed (GObject *object) { - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); - NMDevice *device = NM_DEVICE (object); - const char *iface = nm_device_get_iface (device); - int ifindex = nm_device_get_ifindex (device); + NMDeviceVlan *self = NM_DEVICE_VLAN (object); + NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); + int ifindex = nm_device_get_ifindex (NM_DEVICE (self)); int parent_ifindex = -1, itype; int vlan_id; @@ -526,20 +525,20 @@ constructed (GObject *object) G_OBJECT_CLASS (nm_device_vlan_parent_class)->constructed (object); if (!priv->parent) { - nm_log_err (LOGD_VLAN, "(%s): no parent specified.", iface); + _LOGE (LOGD_VLAN, "no parent specified."); priv->invalid = TRUE; return; } itype = nm_platform_link_get_type (ifindex); if (itype != NM_LINK_TYPE_VLAN) { - nm_log_err (LOGD_VLAN, "(%s): failed to get VLAN interface type.", iface); + _LOGE (LOGD_VLAN, "failed to get VLAN interface type."); priv->invalid = TRUE; return; } if (!nm_platform_vlan_get_info (ifindex, &parent_ifindex, &vlan_id)) { - nm_log_warn (LOGD_VLAN, "(%s): failed to get VLAN interface info.", iface); + _LOGW (LOGD_VLAN, "failed to get VLAN interface info."); priv->invalid = TRUE; return; } @@ -547,16 +546,15 @@ constructed (GObject *object) if ( parent_ifindex < 0 || parent_ifindex != nm_device_get_ip_ifindex (priv->parent) || vlan_id < 0) { - nm_log_warn (LOGD_VLAN, "(%s): VLAN parent ifindex (%d) or VLAN ID (%d) invalid.", - iface, parent_ifindex, priv->vlan_id); + _LOGW (LOGD_VLAN, "VLAN parent ifindex (%d) or VLAN ID (%d) invalid.", + parent_ifindex, priv->vlan_id); priv->invalid = TRUE; return; } priv->vlan_id = vlan_id; - nm_log_dbg (LOGD_HW | LOGD_VLAN, "(%s): kernel ifindex %d", iface, ifindex); - nm_log_info (LOGD_HW | LOGD_VLAN, "(%s): VLAN ID %d with parent %s", - iface, priv->vlan_id, nm_device_get_iface (priv->parent)); + _LOGI (LOGD_HW | LOGD_VLAN, "VLAN ID %d with parent %s", + priv->vlan_id, nm_device_get_iface (priv->parent)); } static void diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index c01b2acc36..7c92e2a384 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -32,6 +32,9 @@ #include "nm-device-vxlan-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceVxlan); + G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE_GENERIC) #define NM_DEVICE_VXLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VXLAN, NMDeviceVxlanPrivate)) @@ -67,13 +70,13 @@ enum { static void update_properties (NMDevice *device) { + NMDeviceVxlan *self = NM_DEVICE_VXLAN (device); NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (device); GObject *object = G_OBJECT (device); NMPlatformVxlanProperties props; if (!nm_platform_vxlan_get_properties (nm_device_get_ifindex (device), &props)) { - nm_log_warn (LOGD_HW, "(%s): could not read vxlan properties", - nm_device_get_iface (device)); + _LOGW (LOGD_HW, "could not read vxlan properties"); return; } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 8acebb90e8..90182d5fe9 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -499,7 +499,7 @@ nm_device_get_udi (NMDevice *self) const char * nm_device_get_iface (NMDevice *self) { - g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (NM_IS_DEVICE (self), 0); return NM_DEVICE_GET_PRIVATE (self)->iface; } @@ -7122,7 +7122,7 @@ constructor (GType type, self = NM_DEVICE (object); priv = NM_DEVICE_GET_PRIVATE (self); - _LOGD (LOGD_DEVICE, "constructor(): %s", G_OBJECT_TYPE_NAME (self)); + _LOGD (LOGD_DEVICE, "constructor(): %s, kernel ifindex %d", G_OBJECT_TYPE_NAME (self), priv->ifindex); if (!priv->iface) { _LOGE (LOGD_DEVICE, "No device interface provided, ignoring"); diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index f29ad5eaca..f833d1c952 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -45,6 +45,8 @@ #include "nm-device-team-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceTeam); G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) @@ -52,7 +54,7 @@ G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) #define NM_DEVICE_TEAM_ERROR (nm_device_team_error_quark ()) -static gboolean teamd_start (NMDevice *dev, NMSettingTeam *s_team); +static gboolean teamd_start (NMDevice *device, NMSettingTeam *s_team); typedef struct { struct teamdctl *tdc; @@ -83,16 +85,16 @@ nm_device_team_error_quark (void) /******************************************************************/ static guint32 -get_generic_capabilities (NMDevice *dev) +get_generic_capabilities (NMDevice *device) { return NM_DEVICE_CAP_CARRIER_DETECT; } static gboolean -is_available (NMDevice *dev) +is_available (NMDevice *device) { - if (NM_DEVICE_GET_CLASS (dev)->is_up) - return NM_DEVICE_GET_CLASS (dev)->is_up (dev); + if (NM_DEVICE_GET_CLASS (device)->is_up) + return NM_DEVICE_GET_CLASS (device)->is_up (device); return FALSE; } @@ -188,8 +190,9 @@ complete_connection (NMDevice *device, } static gboolean -ensure_teamd_connection (NMDevice *self) +ensure_teamd_connection (NMDevice *device) { + NMDeviceTeam *self = NM_DEVICE_TEAM (device); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); int err; @@ -198,10 +201,9 @@ ensure_teamd_connection (NMDevice *self) priv->tdc = teamdctl_alloc (); g_assert (priv->tdc); - err = teamdctl_connect (priv->tdc, nm_device_get_iface (self), NULL, NULL); + err = teamdctl_connect (priv->tdc, nm_device_get_iface (device), NULL, NULL); if (err != 0) { - nm_log_err (LOGD_TEAM, "(%s): failed to connect to teamd (err=%d)", - nm_device_get_iface (self), err); + _LOGE (LOGD_TEAM, "failed to connect to teamd (err=%d)", err); teamdctl_free (priv->tdc); priv->tdc = NULL; } @@ -212,13 +214,14 @@ ensure_teamd_connection (NMDevice *self) static void update_connection (NMDevice *device, NMConnection *connection) { + NMDeviceTeam *self = NM_DEVICE_TEAM (device); NMSettingTeam *s_team = nm_connection_get_setting_team (connection); - const char *iface = nm_device_get_iface (device); if (!s_team) { s_team = (NMSettingTeam *) nm_setting_team_new (); nm_connection_add_setting (connection, (NMSetting *) s_team); - g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_INTERFACE_NAME, iface, NULL); + g_object_set (G_OBJECT (s_team), + NM_SETTING_TEAM_INTERFACE_NAME, nm_device_get_iface (device), NULL); } g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_CONFIG, NULL, NULL); @@ -232,7 +235,7 @@ update_connection (NMDevice *device, NMConnection *connection) if (err == 0) g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_CONFIG, config, NULL); else - nm_log_err (LOGD_TEAM, "(%s): failed to read teamd config (err=%d)", iface, err); + _LOGE (LOGD_TEAM, "failed to read teamd config (err=%d)", err); } } @@ -305,9 +308,9 @@ master_update_slave_connection (NMDevice *self, /******************************************************************/ static void -teamd_timeout_remove (NMDevice *dev) +teamd_timeout_remove (NMDevice *device) { - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); if (priv->teamd_timeout) { g_source_remove (priv->teamd_timeout); @@ -316,9 +319,9 @@ teamd_timeout_remove (NMDevice *dev) } static void -teamd_cleanup (NMDevice *dev, gboolean device_state_failed) +teamd_cleanup (NMDevice *device, gboolean device_state_failed) { - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); if (priv->teamd_dbus_watch) { g_bus_unwatch_name (priv->teamd_dbus_watch); @@ -341,25 +344,26 @@ teamd_cleanup (NMDevice *dev, gboolean device_state_failed) priv->tdc = NULL; } - teamd_timeout_remove (dev); + teamd_timeout_remove (device); if (device_state_failed) { - if (nm_device_is_activating (dev) || - (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED)) - nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED); + if (nm_device_is_activating (device) || + (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED)) + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED); } } static gboolean teamd_timeout_cb (gpointer user_data) { - NMDevice *dev = NM_DEVICE (user_data); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + NMDeviceTeam *self = NM_DEVICE_TEAM (user_data); + NMDevice *device = NM_DEVICE (self); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); g_return_val_if_fail (priv->teamd_timeout, FALSE); - nm_log_info (LOGD_TEAM, "(%s): teamd timed out.", nm_device_get_iface (dev)); - teamd_cleanup (dev, TRUE); + _LOGI (LOGD_TEAM, "teamd timed out."); + teamd_cleanup (device, TRUE); return FALSE; } @@ -370,18 +374,19 @@ teamd_dbus_appeared (GDBusConnection *connection, const gchar *name_owner, gpointer user_data) { - NMDevice *dev = NM_DEVICE (user_data); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + NMDeviceTeam *self = NM_DEVICE_TEAM (user_data); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); + NMDevice *device = NM_DEVICE (self); g_return_if_fail (priv->teamd_dbus_watch); - nm_log_info (LOGD_TEAM, "(%s): teamd appeared on D-Bus", nm_device_get_iface (dev)); - teamd_timeout_remove (dev); - if (!ensure_teamd_connection (dev)) { - nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED); + _LOGI (LOGD_TEAM, "teamd appeared on D-Bus"); + teamd_timeout_remove (device); + if (!ensure_teamd_connection (device)) { + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED); return; } - nm_device_activate_schedule_stage2_device_config (dev); + nm_device_activate_schedule_stage2_device_config (device); } static void @@ -389,8 +394,9 @@ teamd_dbus_vanished (GDBusConnection *connection, const gchar *name, gpointer user_data) { - NMDevice *dev = NM_DEVICE (user_data); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + NMDeviceTeam *self = NM_DEVICE_TEAM (user_data); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); + NMDevice *device = NM_DEVICE (self); g_return_if_fail (priv->teamd_dbus_watch); @@ -402,26 +408,27 @@ teamd_dbus_vanished (GDBusConnection *connection, * Note that g_bus_watch_name is guaranteed to alternate vanished/appeared signals, * so we won't hit this condition again (because the next signal is either 'appeared' * or 'timeout'). */ - nm_log_dbg (LOGD_TEAM, "(%s): teamd vanished from D-Bus (ignored)", nm_device_get_iface (dev)); + _LOGD (LOGD_TEAM, "teamd vanished from D-Bus (ignored)"); return; } - nm_log_info (LOGD_TEAM, "(%s): teamd vanished from D-Bus", nm_device_get_iface (dev)); - teamd_cleanup (dev, TRUE); + _LOGI (LOGD_TEAM, "teamd vanished from D-Bus"); + teamd_cleanup (device, TRUE); } static void teamd_process_watch_cb (GPid pid, gint status, gpointer user_data) { - NMDevice *dev = NM_DEVICE (user_data); - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + NMDeviceTeam *self = NM_DEVICE_TEAM (user_data); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); + NMDevice *device = NM_DEVICE (self); g_return_if_fail (priv->teamd_process_watch); - nm_log_info (LOGD_TEAM, "(%s): teamd died", nm_device_get_iface (dev)); + _LOGI (LOGD_TEAM, "teamd died with status %d", status); priv->teamd_process_watch = 0; priv->teamd_pid = 0; - teamd_cleanup (dev, TRUE); + teamd_cleanup (device, TRUE); } static void @@ -442,11 +449,12 @@ teamd_child_setup (gpointer user_data G_GNUC_UNUSED) } static gboolean -teamd_start (NMDevice *dev, NMSettingTeam *s_team) +teamd_start (NMDevice *device, NMSettingTeam *s_team) { - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); - const char *iface = nm_device_get_ip_iface (dev); - char *tmp_str; + NMDeviceTeam *self = NM_DEVICE_TEAM (device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); + const char *iface = nm_device_get_ip_iface (device); + char *tmp_str = NULL; const char *config; const char **teamd_binary = NULL; static const char *teamd_paths[] = { @@ -477,9 +485,7 @@ teamd_start (NMDevice *dev, NMSettingTeam *s_team) } if (!*teamd_binary) { - nm_log_warn (LOGD_TEAM, - "Activation (%s) failed to start teamd: teamd binary not found", - iface); + _LOGW (LOGD_TEAM, "Activation: (team) failed to start teamd: teamd binary not found"); return FALSE; } @@ -491,9 +497,9 @@ teamd_start (NMDevice *dev, NMSettingTeam *s_team) g_ptr_array_add (argv, (gpointer) iface); g_ptr_array_add (argv, NULL); - tmp_str = g_strjoinv (" ", (gchar **) argv->pdata); - nm_log_dbg (LOGD_TEAM, "running: %s", tmp_str); - g_free (tmp_str); + _LOGD (LOGD_TEAM, "running: %s", + (tmp_str = g_strjoinv (" ", (gchar **) argv->pdata))); + g_clear_pointer (&tmp_str, g_free); ret = g_spawn_sync ("/", (char **) argv->pdata, NULL, 0, nm_unblock_posix_signals, NULL, NULL, NULL, &status, &error); g_ptr_array_free (argv, TRUE); @@ -518,12 +524,12 @@ teamd_start (NMDevice *dev, NMSettingTeam *s_team) g_ptr_array_add (argv, (gpointer) "-gg"); g_ptr_array_add (argv, NULL); - tmp_str = g_strjoinv (" ", (gchar **) argv->pdata); - nm_log_dbg (LOGD_TEAM, "running: %s", tmp_str); - g_free (tmp_str); + _LOGD (LOGD_TEAM, "running: %s", + (tmp_str = g_strjoinv (" ", (gchar **) argv->pdata))); + g_clear_pointer (&tmp_str, g_free); /* Start a timeout for teamd to appear at D-Bus */ - priv->teamd_timeout = g_timeout_add_seconds (5, teamd_timeout_cb, dev); + priv->teamd_timeout = g_timeout_add_seconds (5, teamd_timeout_cb, device); /* Register D-Bus name watcher */ tmp_str = g_strdup_printf ("org.libteam.teamd.%s", iface); @@ -532,7 +538,7 @@ teamd_start (NMDevice *dev, NMSettingTeam *s_team) G_BUS_NAME_WATCHER_FLAGS_NONE, teamd_dbus_appeared, teamd_dbus_vanished, - dev, + device, NULL); g_free (tmp_str); @@ -540,41 +546,36 @@ teamd_start (NMDevice *dev, NMSettingTeam *s_team) &teamd_child_setup, NULL, &priv->teamd_pid, &error); g_ptr_array_free (argv, TRUE); if (!ret) { - nm_log_warn (LOGD_TEAM, - "Activation (%s) failed to start teamd: %s", - iface, error->message); + _LOGW (LOGD_TEAM, "Activation: (team) failed to start teamd: %s", error->message); g_clear_error (&error); - teamd_cleanup (dev, FALSE); + teamd_cleanup (device, FALSE); return FALSE; } /* Monitor the child process so we know when it dies */ priv->teamd_process_watch = g_child_watch_add (priv->teamd_pid, teamd_process_watch_cb, - dev); + device); - nm_log_info (LOGD_TEAM, - "Activation (%s) started teamd...", iface); + _LOGI (LOGD_TEAM, "Activation: (team) started teamd..."); return TRUE; } static void -teamd_stop (NMDevice *dev) +teamd_stop (NMDevice *device) { - NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + NMDeviceTeam *self = NM_DEVICE_TEAM (device); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); - if (priv->teamd_pid > 0) { - nm_log_info (LOGD_TEAM, "Deactivation (%s) stopping teamd...", - nm_device_get_ip_iface (dev)); - } else { - nm_log_dbg (LOGD_TEAM, "Deactivation (%s) stopping teamd (not started)...", - nm_device_get_ip_iface (dev)); - } - teamd_cleanup (dev, FALSE); + if (priv->teamd_pid > 0) + _LOGI (LOGD_TEAM, "Deactivation: stopping teamd..."); + else + _LOGD (LOGD_TEAM, "Deactivation: stopping teamd (not started)..."); + teamd_cleanup (device, FALSE); } static NMActStageReturn -act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) +act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMConnection *connection; @@ -582,13 +583,13 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); - ret = NM_DEVICE_CLASS (nm_device_team_parent_class)->act_stage1_prepare (dev, reason); + ret = NM_DEVICE_CLASS (nm_device_team_parent_class)->act_stage1_prepare (device, reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - connection = nm_device_get_connection (dev); + connection = nm_device_get_connection (device); g_assert (connection); s_team = nm_connection_get_setting_team (connection); g_assert (s_team); - if (teamd_start (dev, s_team)) + if (teamd_start (device, s_team)) ret = NM_ACT_STAGE_RETURN_POSTPONE; else ret = NM_ACT_STAGE_RETURN_FAILURE; @@ -597,9 +598,9 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) } static void -deactivate (NMDevice *dev) +deactivate (NMDevice *device) { - teamd_stop (dev); + teamd_stop (device); } static gboolean @@ -608,9 +609,9 @@ enslave_slave (NMDevice *device, NMConnection *connection, gboolean configure) { + NMDeviceTeam *self = NM_DEVICE_TEAM (device); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (device); gboolean success = TRUE, no_firmware = FALSE; - const char *iface = nm_device_get_ip_iface (device); const char *slave_iface = nm_device_get_ip_iface (slave); NMSettingTeamPort *s_team_port; @@ -625,8 +626,8 @@ enslave_slave (NMDevice *device, if (config) { if (!priv->tdc) { - nm_log_warn (LOGD_TEAM, "(%s): enslaved team port %s config not changed, not connected to teamd", - iface, slave_iface); + _LOGW (LOGD_TEAM, "enslaved team port %s config not changed, not connected to teamd", + slave_iface); } else { int err; char *sanitized_config; @@ -635,8 +636,8 @@ enslave_slave (NMDevice *device, err = teamdctl_port_config_update_raw (priv->tdc, slave_iface, sanitized_config); g_free (sanitized_config); if (err != 0) { - nm_log_err (LOGD_TEAM, "(%s): failed to update config for port %s (err=%d)", - iface, slave_iface, err); + _LOGE (LOGD_TEAM, "failed to update config for port %s (err=%d)", + slave_iface, err); return FALSE; } } @@ -649,9 +650,9 @@ enslave_slave (NMDevice *device, if (!success) return FALSE; - nm_log_info (LOGD_TEAM, "(%s): enslaved team port %s", iface, slave_iface); + _LOGI (LOGD_TEAM, "enslaved team port %s", slave_iface); } else - nm_log_info (LOGD_TEAM, "(%s): team port %s was enslaved", iface, slave_iface); + _LOGI (LOGD_TEAM, "team port %s was enslaved", slave_iface); g_object_notify (G_OBJECT (device), NM_DEVICE_TEAM_SLAVES); @@ -663,26 +664,19 @@ release_slave (NMDevice *device, NMDevice *slave, gboolean configure) { + NMDeviceTeam *self = NM_DEVICE_TEAM (device); gboolean success = TRUE, no_firmware = FALSE; if (configure) { success = nm_platform_link_release (nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); - if (success) { - nm_log_info (LOGD_TEAM, "(%s): released team port %s", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); - } else { - nm_log_warn (LOGD_TEAM, "(%s): failed to release team port %s", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); - } - } else { - nm_log_info (LOGD_TEAM, "(%s): team port %s was released", - nm_device_get_ip_iface (device), - nm_device_get_ip_iface (slave)); - } + if (success) + _LOGI (LOGD_TEAM, "released team port %s", nm_device_get_ip_iface (slave)); + else + _LOGW (LOGD_TEAM, "failed to release team port %s", nm_device_get_ip_iface (slave)); + } else + _LOGI (LOGD_TEAM, "team port %s was released", nm_device_get_ip_iface (slave)); if (success) g_object_notify (G_OBJECT (device), NM_DEVICE_TEAM_SLAVES); @@ -692,10 +686,9 @@ release_slave (NMDevice *device, * IFF_UP), so we must bring it back up here to ensure carrier changes and * other state is noticed by the now-released port. */ - if (!nm_device_bring_up (slave, TRUE, &no_firmware)) { - nm_log_warn (LOGD_TEAM, "(%s): released team port could not be brought up.", - nm_device_get_iface (slave)); - } + if (!nm_device_bring_up (slave, TRUE, &no_firmware)) + _LOGW (LOGD_TEAM, "released team port %s could not be brought up", + nm_device_get_ip_iface (slave)); } return success; @@ -747,16 +740,6 @@ nm_device_team_new_for_connection (NMConnection *connection, GError **error) NULL); } -static void -constructed (GObject *object) -{ - G_OBJECT_CLASS (nm_device_team_parent_class)->constructed (object); - - nm_log_dbg (LOGD_HW | LOGD_TEAM, "(%s): kernel ifindex %d", - nm_device_get_iface (NM_DEVICE (object)), - nm_device_get_ifindex (NM_DEVICE (object))); -} - static void nm_device_team_init (NMDeviceTeam * self) { @@ -815,7 +798,6 @@ nm_device_team_class_init (NMDeviceTeamClass *klass) parent_class->connection_type = NM_SETTING_TEAM_SETTING_NAME; /* virtual methods */ - object_class->constructed = constructed; object_class->get_property = get_property; object_class->set_property = set_property; object_class->dispose = dispose; diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index e030c413e2..5ac1d32e5c 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -62,6 +62,9 @@ #include "nm-device-olpc-mesh-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceOlpcMesh); + G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) #define NM_DEVICE_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshPrivate)) @@ -172,28 +175,27 @@ complete_connection (NMDevice *device, /****************************************************************************/ static NMActStageReturn -act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) +act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (dev); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); + NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); NMActStageReturn ret; gboolean scanning; - ret = NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->act_stage1_prepare (dev, reason); + ret = NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->act_stage1_prepare (device, reason); if (ret != NM_ACT_STAGE_RETURN_SUCCESS) return ret; /* disconnect companion device, if it is connected */ if (nm_device_get_act_request (NM_DEVICE (priv->companion))) { - nm_log_info (LOGD_OLPC, "(%s): disconnecting companion device %s", - nm_device_get_iface (dev), - nm_device_get_iface (priv->companion)); + _LOGI (LOGD_OLPC, "disconnecting companion device %s", + nm_device_get_iface (priv->companion)); /* FIXME: VPN stuff here is a bug; but we can't really change API now... */ nm_device_state_changed (NM_DEVICE (priv->companion), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_USER_REQUESTED); - nm_log_info (LOGD_OLPC, "(%s): companion %s disconnected", - nm_device_get_iface (dev), - nm_device_get_iface (priv->companion)); + _LOGI (LOGD_OLPC, "companion %s disconnected", + nm_device_get_iface (priv->companion)); } @@ -219,16 +221,16 @@ _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel) } static NMActStageReturn -act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) +act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { - NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (dev); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); NMConnection *connection; NMSettingOlpcMesh *s_mesh; guint32 channel; const GByteArray *anycast_addr_array; guint8 *anycast_addr = NULL; - connection = nm_device_get_connection (dev); + connection = nm_device_get_connection (device); g_assert (connection); s_mesh = nm_connection_get_setting_olpc_mesh (connection); @@ -237,25 +239,24 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) channel = nm_setting_olpc_mesh_get_channel (s_mesh); if (channel != 0) _mesh_set_channel (self, channel); - nm_platform_mesh_set_ssid (nm_device_get_ifindex (dev), + nm_platform_mesh_set_ssid (nm_device_get_ifindex (device), nm_setting_olpc_mesh_get_ssid (s_mesh)); anycast_addr_array = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh); if (anycast_addr_array) anycast_addr = anycast_addr_array->data; - nm_device_set_dhcp_anycast_address (dev, anycast_addr); + nm_device_set_dhcp_anycast_address (device, anycast_addr); return NM_ACT_STAGE_RETURN_SUCCESS; } static gboolean -is_available (NMDevice *dev) +is_available (NMDevice *device) { - NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (dev); + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); if (!NM_DEVICE_OLPC_MESH_GET_PRIVATE (self)->companion) { - nm_log_dbg (LOGD_WIFI, "(%s): not available because companion not found", - nm_device_get_iface (dev)); + _LOGD (LOGD_WIFI, "not available because companion not found"); return FALSE; } @@ -311,8 +312,7 @@ companion_state_changed_cb (NMDeviceWifi *companion, || state > NM_DEVICE_STATE_ACTIVATED) return; - nm_log_dbg (LOGD_OLPC, "(%s): disconnecting mesh due to companion connectivity", - nm_device_get_iface (NM_DEVICE (self))); + _LOGD (LOGD_OLPC, "disconnecting mesh due to companion connectivity"); /* FIXME: VPN stuff here is a bug; but we can't really change API now... */ nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_DISCONNECTED, @@ -359,9 +359,8 @@ check_companion (NMDeviceOlpcMesh *self, NMDevice *other) g_assert (priv->companion == NULL); priv->companion = g_object_ref (other); - nm_log_info (LOGD_OLPC, "(%s): found companion WiFi device %s", - nm_device_get_iface (NM_DEVICE (self)), - nm_device_get_iface (other)); + _LOGI (LOGD_OLPC, "found companion WiFi device %s", + nm_device_get_iface (other)); g_signal_connect (G_OBJECT (other), "state-changed", G_CALLBACK (companion_state_changed_cb), self); @@ -472,13 +471,8 @@ constructor (GType type, self = NM_DEVICE_OLPC_MESH (object); - nm_log_dbg (LOGD_HW | LOGD_OLPC, "(%s): kernel ifindex %d", - nm_device_get_iface (NM_DEVICE (self)), - nm_device_get_ifindex (NM_DEVICE (self))); - if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)), &caps)) { - nm_log_warn (LOGD_HW | LOGD_OLPC, "(%s): failed to initialize WiFi driver", - nm_device_get_iface (NM_DEVICE (self))); + _LOGW (LOGD_HW | LOGD_OLPC, "failed to initialize WiFi driver"); g_object_unref (object); return NULL; } diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 046a95355d..dccfece140 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -77,6 +77,8 @@ static void impl_device_request_scan (NMDeviceWifi *device, #include "nm-device-wifi-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceWifi); /* All of these are in seconds */ #define SCAN_INTERVAL_MIN 3 @@ -224,22 +226,15 @@ constructor (GType type, self = NM_DEVICE_WIFI (object); priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - nm_log_dbg (LOGD_HW | LOGD_WIFI, "(%s): kernel ifindex %d", - nm_device_get_iface (NM_DEVICE (self)), - nm_device_get_ifindex (NM_DEVICE (self))); - if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)), &priv->capabilities)) { - nm_log_warn (LOGD_HW | LOGD_WIFI, "(%s): failed to initialize WiFi driver", - nm_device_get_iface (NM_DEVICE (self))); + _LOGW (LOGD_HW | LOGD_WIFI, "failed to initialize WiFi driver"); g_object_unref (object); return NULL; } - if (priv->capabilities & NM_WIFI_DEVICE_CAP_AP) { - nm_log_info (LOGD_HW | LOGD_WIFI, "(%s): driver supports Access Point (AP) mode", - nm_device_get_iface (NM_DEVICE (self))); - } + if (priv->capabilities & NM_WIFI_DEVICE_CAP_AP) + _LOGI (LOGD_HW | LOGD_WIFI, "driver supports Access Point (AP) mode"); /* Connect to the supplicant manager */ priv->sup_mgr = nm_supplicant_manager_get (); @@ -261,8 +256,7 @@ supplicant_interface_acquire (NMDeviceWifi *self) nm_device_get_iface (NM_DEVICE (self)), TRUE); if (priv->sup_iface == NULL) { - nm_log_err (LOGD_WIFI, "Couldn't initialize supplicant interface for %s.", - nm_device_get_iface (NM_DEVICE (self))); + _LOGE (LOGD_WIFI, "Couldn't initialize supplicant interface"); return FALSE; } @@ -310,9 +304,8 @@ supplicant_interface_release (NMDeviceWifi *self) /* Reset the scan interval to be pretty frequent when disconnected */ priv->scan_interval = SCAN_INTERVAL_MIN + SCAN_INTERVAL_STEP; - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): reset scanning interval to %d seconds", - nm_device_get_iface (NM_DEVICE (self)), - priv->scan_interval); + _LOGD (LOGD_WIFI_SCAN, "reset scanning interval to %d seconds", + priv->scan_interval); if (priv->scanlist_cull_id) { g_source_remove (priv->scanlist_cull_id); @@ -371,7 +364,6 @@ find_active_ap (NMDeviceWifi *self, gboolean match_hidden) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - const char *iface = nm_device_get_iface (NM_DEVICE (self)); int ifindex = nm_device_get_ifindex (NM_DEVICE (self)); struct ether_addr bssid; GByteArray *ssid; @@ -384,21 +376,19 @@ find_active_ap (NMDeviceWifi *self, guint32 devfreq; nm_platform_wifi_get_bssid (ifindex, &bssid); - nm_log_dbg (LOGD_WIFI, "(%s): active BSSID: %02x:%02x:%02x:%02x:%02x:%02x", - iface, - bssid.ether_addr_octet[0], bssid.ether_addr_octet[1], - bssid.ether_addr_octet[2], bssid.ether_addr_octet[3], - bssid.ether_addr_octet[4], bssid.ether_addr_octet[5]); + _LOGD (LOGD_WIFI, "active BSSID: %02x:%02x:%02x:%02x:%02x:%02x", + bssid.ether_addr_octet[0], bssid.ether_addr_octet[1], + bssid.ether_addr_octet[2], bssid.ether_addr_octet[3], + bssid.ether_addr_octet[4], bssid.ether_addr_octet[5]); if (!nm_ethernet_address_is_valid (&bssid)) return NULL; ssid = nm_platform_wifi_get_ssid (ifindex); - nm_log_dbg (LOGD_WIFI, "(%s): active SSID: %s%s%s", - iface, - ssid ? "'" : "", - ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)", - ssid ? "'" : ""); + _LOGD (LOGD_WIFI, "active SSID: %s%s%s", + ssid ? "'" : "", + ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)", + ssid ? "'" : ""); devmode = nm_platform_wifi_get_mode (ifindex); devfreq = nm_platform_wifi_get_frequency (ifindex); @@ -408,7 +398,7 @@ find_active_ap (NMDeviceWifi *self, * and therefore it won't get matched the first time around. */ while (i++ < (match_hidden ? 2 : 1)) { - nm_log_dbg (LOGD_WIFI, " Pass #%d %s", i, i > 1 ? "(ignoring SSID)" : ""); + _LOGD (LOGD_WIFI, " Pass #%d %s", i, i > 1 ? "(ignoring SSID)" : ""); /* Find this SSID + BSSID in the device's AP list */ for (iter = priv->ap_list; iter; iter = g_slist_next (iter)) { @@ -418,40 +408,40 @@ find_active_ap (NMDeviceWifi *self, NM80211Mode apmode; guint32 apfreq; - nm_log_dbg (LOGD_WIFI, " AP: %s%s%s %02x:%02x:%02x:%02x:%02x:%02x", - ap_ssid ? "'" : "", - ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)", - ap_ssid ? "'" : "", - ap_bssid->ether_addr_octet[0], ap_bssid->ether_addr_octet[1], - ap_bssid->ether_addr_octet[2], ap_bssid->ether_addr_octet[3], - ap_bssid->ether_addr_octet[4], ap_bssid->ether_addr_octet[5]); + _LOGD (LOGD_WIFI, " AP: %s%s%s %02x:%02x:%02x:%02x:%02x:%02x", + ap_ssid ? "'" : "", + ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)", + ap_ssid ? "'" : "", + ap_bssid->ether_addr_octet[0], ap_bssid->ether_addr_octet[1], + ap_bssid->ether_addr_octet[2], ap_bssid->ether_addr_octet[3], + ap_bssid->ether_addr_octet[4], ap_bssid->ether_addr_octet[5]); if (ap == ignore_ap) { - nm_log_dbg (LOGD_WIFI, " ignored"); + _LOGD (LOGD_WIFI, " ignored"); continue; } if (memcmp (bssid.ether_addr_octet, ap_bssid->ether_addr_octet, ETH_ALEN)) { - nm_log_dbg (LOGD_WIFI, " BSSID mismatch"); + _LOGD (LOGD_WIFI, " BSSID mismatch"); continue; } if ((i == 0) && !nm_utils_same_ssid (ssid, ap_ssid, TRUE)) { - nm_log_dbg (LOGD_WIFI, " SSID mismatch"); + _LOGD (LOGD_WIFI, " SSID mismatch"); continue; } apmode = nm_ap_get_mode (ap); if (devmode != apmode) { - nm_log_dbg (LOGD_WIFI, " mode mismatch (device %d, ap %d)", - devmode, apmode); + _LOGD (LOGD_WIFI, " mode mismatch (device %d, ap %d)", + devmode, apmode); continue; } apfreq = nm_ap_get_freq (ap); if (devfreq != apfreq) { - nm_log_dbg (LOGD_WIFI, " frequency mismatch (device %u, ap %u)", - devfreq, apfreq); + _LOGD (LOGD_WIFI, " frequency mismatch (device %u, ap %u)", + devfreq, apfreq); if (match_nofreq == NULL) match_nofreq = ap; @@ -464,7 +454,7 @@ find_active_ap (NMDeviceWifi *self, } // FIXME: handle security settings here too - nm_log_dbg (LOGD_WIFI, " matched"); + _LOGD (LOGD_WIFI, " matched"); active_ap = ap; goto done; } @@ -486,19 +476,19 @@ find_active_ap (NMDeviceWifi *self, const struct ether_addr *ap_bssid = nm_ap_get_address (match_nofreq); const GByteArray *ap_ssid = nm_ap_get_ssid (match_nofreq); - nm_log_dbg (LOGD_WIFI, " matched %s%s%s %02x:%02x:%02x:%02x:%02x:%02x", - ap_ssid ? "'" : "", - ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)", - ap_ssid ? "'" : "", - ap_bssid->ether_addr_octet[0], ap_bssid->ether_addr_octet[1], - ap_bssid->ether_addr_octet[2], ap_bssid->ether_addr_octet[3], - ap_bssid->ether_addr_octet[4], ap_bssid->ether_addr_octet[5]); + _LOGD (LOGD_WIFI, " matched %s%s%s %02x:%02x:%02x:%02x:%02x:%02x", + ap_ssid ? "'" : "", + ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)", + ap_ssid ? "'" : "", + ap_bssid->ether_addr_octet[0], ap_bssid->ether_addr_octet[1], + ap_bssid->ether_addr_octet[2], ap_bssid->ether_addr_octet[3], + ap_bssid->ether_addr_octet[4], ap_bssid->ether_addr_octet[5]); active_ap = match_nofreq; goto done; } - nm_log_dbg (LOGD_WIFI, " No matching AP found."); + _LOGD (LOGD_WIFI, " No matching AP found."); done: if (ssid) @@ -655,12 +645,11 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap) old_ssid = nm_ap_get_ssid (priv->current_ap); } - nm_log_info (LOGD_WIFI, "(%s): roamed from BSSID %s (%s) to %s (%s)", - nm_device_get_iface (NM_DEVICE (self)), - old_addr ? old_addr : "(none)", - old_ssid ? nm_utils_escape_ssid (old_ssid->data, old_ssid->len) : "(none)", - new_addr ? new_addr : "(none)", - new_ssid ? nm_utils_escape_ssid (new_ssid->data, new_ssid->len) : "(none)"); + _LOGI (LOGD_WIFI, "roamed from BSSID %s (%s) to %s (%s)", + old_addr ? old_addr : "(none)", + old_ssid ? nm_utils_escape_ssid (old_ssid->data, old_ssid->len) : "(none)", + new_addr ? new_addr : "(none)", + new_ssid ? nm_utils_escape_ssid (new_ssid->data, new_ssid->len) : "(none)"); g_free (old_addr); g_free (new_addr); @@ -735,15 +724,15 @@ remove_all_aps (NMDeviceWifi *self) } static void -deactivate (NMDevice *dev) +deactivate (NMDevice *device) { - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - int ifindex = nm_device_get_ifindex (dev); + int ifindex = nm_device_get_ifindex (device); NMConnection *connection; NM80211Mode old_mode = priv->mode; - connection = nm_device_get_connection (dev); + connection = nm_device_get_connection (device); if (connection) { /* Clear wireless secrets tries when deactivating */ g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL); @@ -769,7 +758,7 @@ deactivate (NMDevice *dev) nm_platform_wifi_indicate_addressing_running (ifindex, FALSE); /* Reset MAC address back to initial address */ - nm_device_set_hw_addr (dev, priv->initial_hw_addr, "reset", LOGD_WIFI); + nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_WIFI); /* Ensure we're in infrastructure mode after deactivation; some devices * (usually older ones) don't scan well in adhoc mode. @@ -1166,29 +1155,26 @@ complete_connection (NMDevice *device, } static gboolean -is_available (NMDevice *dev) +is_available (NMDevice *device) { - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); guint32 state; if (!priv->enabled) { - nm_log_dbg (LOGD_WIFI, "(%s): not available because not enabled", - nm_device_get_iface (dev)); + _LOGD (LOGD_WIFI, "not available because not enabled"); return FALSE; } if (!priv->sup_iface) { - nm_log_dbg (LOGD_WIFI, "(%s): not available because supplicant not running", - nm_device_get_iface (dev)); + _LOGD (LOGD_WIFI, "not available because supplicant not running"); return FALSE; } state = nm_supplicant_interface_get_state (priv->sup_iface); if ( state < NM_SUPPLICANT_INTERFACE_STATE_READY || state > NM_SUPPLICANT_INTERFACE_STATE_COMPLETED) { - nm_log_dbg (LOGD_WIFI, "(%s): not available because supplicant interface not ready", - nm_device_get_iface (dev)); + _LOGD (LOGD_WIFI, "not available because supplicant interface not ready"); return FALSE; } @@ -1196,17 +1182,17 @@ is_available (NMDevice *dev) } static gboolean -can_auto_connect (NMDevice *dev, +can_auto_connect (NMDevice *device, NMConnection *connection, char **specific_object) { - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); GSList *ap_iter; const char *method = NULL; guint64 timestamp = 0; - if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (dev, connection, specific_object)) + if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, specific_object)) return FALSE; /* Don't autoconnect to networks that have been tried at least once @@ -1245,12 +1231,12 @@ ap_list_dump (NMDeviceWifi *self) g_return_if_fail (NM_IS_DEVICE_WIFI (self)); - nm_log_dbg (LOGD_WIFI_SCAN, "Current AP list:"); + _LOGD (LOGD_WIFI_SCAN, "Current AP list:"); for (elt = priv->ap_list; elt; elt = g_slist_next (elt), i++) { NMAccessPoint * ap = NM_AP (elt->data); nm_ap_dump (ap, "List AP: "); } - nm_log_dbg (LOGD_WIFI_SCAN, "Current AP list: done"); + _LOGD (LOGD_WIFI_SCAN, "Current AP list: done"); } static gboolean @@ -1533,8 +1519,7 @@ request_wireless_scan (gpointer user_data) } if (check_scanning_allowed (self)) { - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scanning requested", - nm_device_get_iface (NM_DEVICE (self))); + _LOGD (LOGD_WIFI_SCAN, "scanning requested"); ssids = build_hidden_probe_list (self); @@ -1545,15 +1530,12 @@ request_wireless_scan (gpointer user_data) for (i = 0; i < ssids->len; i++) { foo = nm_utils_ssid_to_utf8 (g_ptr_array_index (ssids, i)); - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): (%d) probe scanning SSID '%s'", - nm_device_get_iface (NM_DEVICE (self)), + _LOGD (LOGD_WIFI_SCAN, "(%d) probe scanning SSID '%s'", i, foo ? foo : ""); g_free (foo); } - } else { - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): no SSIDs to probe scan", - nm_device_get_iface (NM_DEVICE (self))); - } + } else + _LOGD (LOGD_WIFI_SCAN, "no SSIDs to probe scan"); } if (nm_supplicant_interface_request_scan (priv->sup_iface, ssids)) { @@ -1567,10 +1549,8 @@ request_wireless_scan (gpointer user_data) /* Elements owned by the connections, so we don't free them here */ g_ptr_array_free (ssids, TRUE); } - } else { - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scan requested but not allowed at this time", - nm_device_get_iface (NM_DEVICE (self))); - } + } else + _LOGD (LOGD_WIFI_SCAN, "scan requested but not allowed at this time"); priv->pending_scan_id = 0; schedule_scan (self, backoff); @@ -1621,11 +1601,8 @@ schedule_scan (NMDeviceWifi *self, gboolean backoff) priv->scan_interval = 5; } - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scheduled scan in %d seconds (interval now %d seconds)", - nm_device_get_iface (NM_DEVICE (self)), - next_scan, - priv->scan_interval); - + _LOGD (LOGD_WIFI_SCAN, "scheduled scan in %d seconds (interval now %d seconds)", + next_scan, priv->scan_interval); } } @@ -1648,9 +1625,7 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface, { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scan %s", - nm_device_get_iface (NM_DEVICE (self)), - success ? "successful" : "failed"); + _LOGD (LOGD_WIFI_SCAN, "scan %s", success ? "successful" : "failed"); schedule_scan (self, success); @@ -1733,16 +1708,14 @@ merge_scanned_ap (NMDeviceWifi *self, ssid = nm_ap_get_ssid (merge_ap); if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) { /* Yay, matched it, no longer treat as hidden */ - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): matched hidden AP " MAC_FMT " => '%s'", - nm_device_get_iface (NM_DEVICE (self)), + _LOGD (LOGD_WIFI_SCAN, "matched hidden AP " MAC_FMT " => '%s'", MAC_ARG (bssid->ether_addr_octet), nm_utils_escape_ssid (ssid->data, ssid->len)); nm_ap_set_broadcast (merge_ap, FALSE); } else { /* Didn't have an entry for this AP in the database */ - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): failed to match hidden AP " MAC_FMT, - nm_device_get_iface (NM_DEVICE (self)), - MAC_ARG (bssid->ether_addr_octet)); + _LOGD (LOGD_WIFI_SCAN, "failed to match hidden AP " MAC_FMT, + MAC_ARG (bssid->ether_addr_octet)); } } @@ -1759,8 +1732,7 @@ merge_scanned_ap (NMDeviceWifi *self, if (!found_ap) found_ap = nm_ap_match_in_list (merge_ap, priv->ap_list, strict_match); if (found_ap) { - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): merging AP '%s' " MAC_FMT " (%p) with existing (%p)", - nm_device_get_iface (NM_DEVICE (self)), + _LOGD (LOGD_WIFI_SCAN, "merging AP '%s' " MAC_FMT " (%p) with existing (%p)", ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)", MAC_ARG (bssid->ether_addr_octet), merge_ap, @@ -1782,11 +1754,10 @@ merge_scanned_ap (NMDeviceWifi *self, nm_ap_set_fake (found_ap, FALSE); } else { /* New entry in the list */ - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): adding new AP '%s' " MAC_FMT " (%p)", - nm_device_get_iface (NM_DEVICE (self)), - ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)", - MAC_ARG (bssid->ether_addr_octet), - merge_ap); + _LOGD (LOGD_WIFI_SCAN, "adding new AP '%s' " MAC_FMT " (%p)", + ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)", + MAC_ARG (bssid->ether_addr_octet), + merge_ap); g_object_ref (merge_ap); priv->ap_list = g_slist_prepend (priv->ap_list, merge_ap); @@ -1808,8 +1779,7 @@ cull_scan_list (NMDeviceWifi *self) priv->scanlist_cull_id = 0; - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): checking scan list for outdated APs", - nm_device_get_iface (NM_DEVICE (self))); + _LOGD (LOGD_WIFI_SCAN, "checking scan list for outdated APs"); /* Walk the access point list and remove any access points older than * three times the inactive scan interval. @@ -1848,23 +1818,22 @@ cull_scan_list (NMDeviceWifi *self) bssid = nm_ap_get_address (outdated_ap); ssid = nm_ap_get_ssid (outdated_ap); - nm_log_dbg (LOGD_WIFI_SCAN, - " removing %02x:%02x:%02x:%02x:%02x:%02x (%s%s%s)", - bssid->ether_addr_octet[0], bssid->ether_addr_octet[1], - bssid->ether_addr_octet[2], bssid->ether_addr_octet[3], - bssid->ether_addr_octet[4], bssid->ether_addr_octet[5], - ssid ? "'" : "", - ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)", - ssid ? "'" : ""); + _LOGD (LOGD_WIFI_SCAN, + " removing %02x:%02x:%02x:%02x:%02x:%02x (%s%s%s)", + bssid->ether_addr_octet[0], bssid->ether_addr_octet[1], + bssid->ether_addr_octet[2], bssid->ether_addr_octet[3], + bssid->ether_addr_octet[4], bssid->ether_addr_octet[5], + ssid ? "'" : "", + ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)", + ssid ? "'" : ""); remove_access_point (self, outdated_ap); removed++; } g_slist_free (outdated_list); - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): removed %d APs (of %d)", - nm_device_get_iface (NM_DEVICE (self)), - removed, total); + _LOGD (LOGD_WIFI_SCAN, "removed %d APs (of %d)", + removed, total); ap_list_dump (self); @@ -1912,10 +1881,8 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface, /* Add the AP to the device's AP list */ merge_scanned_ap (self, ap); g_object_unref (ap); - } else { - nm_log_warn (LOGD_WIFI_SCAN, "(%s): invalid AP properties received", - nm_device_get_iface (NM_DEVICE (self))); - } + } else + _LOGW (LOGD_WIFI_SCAN, "invalid AP properties received"); /* Remove outdated access points */ schedule_scanlist_cull (self); @@ -1997,19 +1964,20 @@ wifi_secrets_cb (NMActRequest *req, GError *error, gpointer user_data) { - NMDevice *dev = NM_DEVICE (user_data); + NMDevice *device = NM_DEVICE (user_data); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); - g_return_if_fail (req == nm_device_get_act_request (dev)); - g_return_if_fail (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH); + g_return_if_fail (req == nm_device_get_act_request (device)); + g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH); g_return_if_fail (nm_act_request_get_connection (req) == connection); if (error) { - nm_log_warn (LOGD_WIFI, "%s", error->message); - nm_device_state_changed (dev, + _LOGW (LOGD_WIFI, "%s", error->message); + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS); } else - nm_device_activate_schedule_stage1_device_prepare (dev); + nm_device_activate_schedule_stage1_device_prepare (device); } /* @@ -2021,11 +1989,11 @@ wifi_secrets_cb (NMActRequest *req, static gboolean link_timeout_cb (gpointer user_data) { - NMDevice *dev = NM_DEVICE (user_data); - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDevice *device = NM_DEVICE (user_data); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - nm_log_warn (LOGD_WIFI, "(%s): link timed out.", nm_device_get_iface (dev)); + _LOGW (LOGD_WIFI, "link timed out."); priv->link_timeout_id = 0; @@ -2033,7 +2001,7 @@ link_timeout_cb (gpointer user_data) * to reassociate within the timeout period, so the connection must * fail. */ - if (nm_device_get_state (dev) != NM_DEVICE_STATE_ACTIVATED) + if (nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED) return FALSE; /* If the access point failed, and wasn't found by the supplicant when it @@ -2044,7 +2012,7 @@ link_timeout_cb (gpointer user_data) if (priv->ssid_found == FALSE && priv->current_ap) set_current_ap (self, NULL, TRUE, TRUE); - nm_device_state_changed (dev, + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, priv->ssid_found ? NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT : NM_DEVICE_STATE_REASON_SSID_NOT_FOUND); @@ -2159,9 +2127,8 @@ handle_8021x_or_psk_auth_fail (NMDeviceWifi *self, nm_connection_clear_secrets (connection); - nm_log_info (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): disconnected during association," - " asking for new key.", nm_device_get_iface (device)); + _LOGI (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) disconnected during association, asking for new key"); cleanup_association_attempt (self, TRUE); nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT); @@ -2194,11 +2161,10 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, if (new_state == old_state) return; - nm_log_info (LOGD_DEVICE | LOGD_WIFI, - "(%s): supplicant interface state: %s -> %s", - nm_device_get_iface (device), - nm_supplicant_interface_state_to_string (old_state), - nm_supplicant_interface_state_to_string (new_state)); + _LOGI (LOGD_DEVICE | LOGD_WIFI, + "supplicant interface state: %s -> %s", + nm_supplicant_interface_state_to_string (old_state), + nm_supplicant_interface_state_to_string (new_state)); devstate = nm_device_get_state (device); scanning = nm_supplicant_interface_get_scanning (iface); @@ -2221,9 +2187,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE); } - nm_log_dbg (LOGD_WIFI_SCAN, - "(%s): supplicant ready, requesting initial scan", - nm_device_get_iface (device)); + _LOGD (LOGD_WIFI_SCAN, "supplicant ready, requesting initial scan"); /* Request a scan to get latest results */ cancel_pending_scan (self); @@ -2253,13 +2217,11 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, ssid = nm_setting_wireless_get_ssid (s_wifi); g_return_if_fail (ssid); - nm_log_info (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless) Stage 2 of 5 (Device Configure) " - "successful. %s '%s'.", - nm_device_get_iface (device), - priv->mode == NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot" : - "Connected to wireless network", - ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)"); + _LOGI (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) Stage 2 of 5 (Device Configure) successful. %s '%s'.", + priv->mode == NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot" : + "Connected to wireless network", + ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)"); nm_device_activate_schedule_stage3_ip_config_start (device); } else if (devstate == NM_DEVICE_STATE_ACTIVATED) periodic_update (self, NULL); @@ -2325,9 +2287,9 @@ supplicant_iface_connection_error_cb (NMSupplicantInterface *iface, NMDevice *device = NM_DEVICE (self); if (nm_device_is_activating (device)) { - nm_log_warn (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): supplicant association failed: %s - %s", - nm_device_get_iface (device), name, message); + _LOGW (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) supplicant association failed: %s - %s", + name, message); cleanup_association_attempt (self, TRUE); nm_device_queue_state (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); @@ -2355,9 +2317,7 @@ supplicant_iface_notify_scanning_cb (NMSupplicantInterface *iface, gboolean scanning; scanning = nm_supplicant_interface_get_scanning (iface); - nm_log_dbg (LOGD_WIFI_SCAN, "(%s): now %s", - nm_device_get_iface (NM_DEVICE (self)), - scanning ? "scanning" : "idle"); + _LOGD (LOGD_WIFI_SCAN, "now %s", scanning ? "scanning" : "idle"); g_object_notify (G_OBJECT (self), "scanning"); @@ -2405,7 +2365,7 @@ handle_auth_or_fail (NMDeviceWifi *self, g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); ret = NM_ACT_STAGE_RETURN_POSTPONE; } else - nm_log_warn (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); + _LOGW (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); return ret; } @@ -2419,7 +2379,7 @@ handle_auth_or_fail (NMDeviceWifi *self, static gboolean supplicant_connection_timeout_cb (gpointer user_data) { - NMDevice *dev = NM_DEVICE (user_data); + NMDevice *device = NM_DEVICE (user_data); NMDeviceWifi *self = NM_DEVICE_WIFI (user_data); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMActRequest *req; @@ -2427,7 +2387,7 @@ supplicant_connection_timeout_cb (gpointer user_data) cleanup_association_attempt (self, TRUE); - if (!nm_device_is_activating (dev)) + if (!nm_device_is_activating (device)) return FALSE; /* Timed out waiting for a successful connection to the AP; if the AP's @@ -2436,7 +2396,7 @@ supplicant_connection_timeout_cb (gpointer user_data) * information (passwords, pin codes, etc) are wrong. */ - req = nm_device_get_act_request (dev); + req = nm_device_get_act_request (device); g_assert (req); connection = nm_act_request_get_connection (req); @@ -2448,12 +2408,10 @@ supplicant_connection_timeout_cb (gpointer user_data) * (if any), so supplicant timeouts here are almost certainly the wifi * driver being really stupid. */ - nm_log_warn (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): %s network creation took " - "too long, failing activation.", - nm_device_get_iface (dev), - priv->mode == NM_802_11_MODE_ADHOC ? "Ad-Hoc" : "Hotspot"); - nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, + _LOGW (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) %s network creation took too long, failing activation", + priv->mode == NM_802_11_MODE_ADHOC ? "Ad-Hoc" : "Hotspot"); + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT); return FALSE; } @@ -2467,9 +2425,8 @@ supplicant_connection_timeout_cb (gpointer user_data) /* Connection failed; either driver problems, the encryption key is * wrong, or the passwords or certificates were wrong. */ - nm_log_warn (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): association took too long.", - nm_device_get_iface (dev)); + _LOGW (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) association took too long"); /* Ask for new secrets only if we've never activated this connection * before. If we've connected before, don't bother the user with @@ -2479,20 +2436,16 @@ supplicant_connection_timeout_cb (gpointer user_data) if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), ×tamp)) new_secrets = !timestamp; - if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE) { - nm_log_warn (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): asking for new secrets", - nm_device_get_iface (dev)); - } else { - nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, + if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE) + _LOGW (LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) asking for new secrets"); + else { + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS); } } else { - nm_log_warn (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): association took too long, " - "failing activation.", - nm_device_get_iface (dev)); - nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, + _LOGW (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) association took too long, failing activation"); + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, priv->ssid_found ? NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT : NM_DEVICE_STATE_REASON_SSID_NOT_FOUND); } @@ -2522,13 +2475,13 @@ build_supplicant_config (NMDeviceWifi *self, /* Warn if AP mode may not be supported */ if ( g_strcmp0 (nm_setting_wireless_get_mode (s_wireless), NM_SETTING_WIRELESS_MODE_AP) == 0 && nm_supplicant_interface_get_ap_support (priv->sup_iface) == AP_SUPPORT_UNKNOWN) { - nm_log_warn (LOGD_WIFI, "Supplicant may not support AP mode; connection may time out."); + _LOGW (LOGD_WIFI, "Supplicant may not support AP mode; connection may time out."); } if (!nm_supplicant_config_add_setting_wireless (config, s_wireless, fixed_freq)) { - nm_log_err (LOGD_WIFI, "Couldn't add 802-11-wireless setting to supplicant config."); + _LOGE (LOGD_WIFI, "Couldn't add 802-11-wireless setting to supplicant config."); goto error; } @@ -2543,13 +2496,12 @@ build_supplicant_config (NMDeviceWifi *self, s_wireless_sec, s_8021x, con_uuid)) { - nm_log_err (LOGD_WIFI, "Couldn't add 802-11-wireless-security setting to " - "supplicant config."); + _LOGE (LOGD_WIFI, "Couldn't add 802-11-wireless-security setting to supplicant config."); goto error; } } else { if (!nm_supplicant_config_add_no_security (config)) { - nm_log_err (LOGD_WIFI, "Couldn't add unsecured option to supplicant config."); + _LOGE (LOGD_WIFI, "Couldn't add unsecured option to supplicant config."); goto error; } } @@ -2564,23 +2516,23 @@ error: /****************************************************************************/ static void -update_permanent_hw_address (NMDevice *dev) +update_permanent_hw_address (NMDevice *device) { - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); struct ifreq req; struct ethtool_perm_addr *epaddr = NULL; - int fd, ret; + int fd, ret, errsv; fd = socket (PF_INET, SOCK_DGRAM, 0); if (fd < 0) { - nm_log_err (LOGD_HW, "could not open control socket."); + _LOGE (LOGD_HW, "could not open control socket."); return; } /* Get permanent MAC address */ memset (&req, 0, sizeof (struct ifreq)); - strncpy (req.ifr_name, nm_device_get_iface (dev), IFNAMSIZ); + strncpy (req.ifr_name, nm_device_get_iface (device), IFNAMSIZ); epaddr = g_malloc0 (sizeof (struct ethtool_perm_addr) + ETH_ALEN); epaddr->cmd = ETHTOOL_GPERMADDR; @@ -2589,16 +2541,17 @@ update_permanent_hw_address (NMDevice *dev) errno = 0; ret = ioctl (fd, SIOCETHTOOL, &req); + errsv = errno; if ((ret < 0) || !nm_ethernet_address_is_valid ((struct ether_addr *) epaddr->data)) { - nm_log_dbg (LOGD_HW | LOGD_ETHER, "(%s): unable to read permanent MAC address (error %d)", - nm_device_get_iface (dev), errno); + _LOGD (LOGD_HW | LOGD_ETHER, "unable to read permanent MAC address (error %d)", + errsv); /* Fall back to current address */ - memcpy (epaddr->data, nm_device_get_hw_address (dev, NULL), ETH_ALEN); + memcpy (epaddr->data, nm_device_get_hw_address (device, NULL), ETH_ALEN); } if (memcmp (&priv->perm_hw_addr, epaddr->data, ETH_ALEN)) { memcpy (&priv->perm_hw_addr, epaddr->data, ETH_ALEN); - g_object_notify (G_OBJECT (dev), NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS); + g_object_notify (G_OBJECT (device), NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS); } g_free (epaddr); @@ -2606,27 +2559,26 @@ update_permanent_hw_address (NMDevice *dev) } static void -update_initial_hw_address (NMDevice *dev) +update_initial_hw_address (NMDevice *device) { - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - char *mac_str; + char *mac_str = NULL; /* This sets initial MAC address from current MAC address. It should only * be called from NMDevice constructor() to really get the initial address. */ - memcpy (priv->initial_hw_addr, nm_device_get_hw_address (dev, NULL), ETH_ALEN); + memcpy (priv->initial_hw_addr, nm_device_get_hw_address (device, NULL), ETH_ALEN); - mac_str = nm_utils_hwaddr_ntoa (priv->initial_hw_addr, ARPHRD_ETHER); - nm_log_dbg (LOGD_DEVICE | LOGD_ETHER, "(%s): read initial MAC address %s", - nm_device_get_iface (dev), mac_str); + _LOGD (LOGD_DEVICE | LOGD_ETHER, "read initial MAC address %s", + (mac_str = nm_utils_hwaddr_ntoa (priv->initial_hw_addr, ARPHRD_ETHER))); g_free (mac_str); } static NMActStageReturn -act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) +act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMActStageReturn ret; NMAccessPoint *ap = NULL; @@ -2638,7 +2590,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) const char *mode; const char *ap_path; - ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage1_prepare (dev, reason); + ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage1_prepare (device, reason); if (ret != NM_ACT_STAGE_RETURN_SUCCESS) return ret; @@ -2669,7 +2621,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) * 2.6.30 or so; until that's fixed, disable WPA-protected Ad-Hoc networks. */ if (is_adhoc_wpa (connection)) { - nm_log_warn (LOGD_WIFI, "Ad-Hoc WPA disabled due to kernel bugs"); + _LOGW (LOGD_WIFI, "Ad-Hoc WPA disabled due to kernel bugs"); *reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; return NM_ACT_STAGE_RETURN_FAILURE; } @@ -2677,7 +2629,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) /* Set spoof MAC to the interface */ cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless); if (cloned_mac && (cloned_mac->len == ETH_ALEN)) - nm_device_set_hw_addr (dev, (const guint8 *) cloned_mac->data, "set", LOGD_WIFI); + nm_device_set_hw_addr (device, (const guint8 *) cloned_mac->data, "set", LOGD_WIFI); /* AP mode never uses a specific object or existing scanned AP */ if (priv->mode != NM_802_11_MODE_AP) { @@ -2715,7 +2667,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) if (nm_ap_get_mode (ap) == NM_802_11_MODE_INFRA) nm_ap_set_broadcast (ap, FALSE); else if (nm_ap_is_hotspot (ap)) - nm_ap_set_address (ap, (const struct ether_addr *) nm_device_get_hw_address (dev, NULL)); + nm_ap_set_address (ap, (const struct ether_addr *) nm_device_get_hw_address (device, NULL)); priv->ap_list = g_slist_prepend (priv->ap_list, ap); nm_ap_export_to_dbus (ap); @@ -2758,12 +2710,11 @@ ensure_hotspot_frequency (NMDeviceWifi *self, } static NMActStageReturn -act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) +act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; - const char *iface = nm_device_get_iface (dev); NMSupplicantConfig *config = NULL; NMActRequest *req; NMAccessPoint *ap; @@ -2775,7 +2726,7 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) remove_supplicant_timeouts (self); - req = nm_device_get_act_request (dev); + req = nm_device_get_act_request (device); g_assert (req); ap = priv->current_ap; @@ -2793,10 +2744,9 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) /* If we need secrets, get them */ setting_name = nm_connection_need_secrets (connection, NULL); if (setting_name) { - nm_log_info (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): access point '%s' has security," - " but secrets are required.", - iface, nm_connection_get_id (connection)); + _LOGI (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) access point '%s' has security, but secrets are required.", + nm_connection_get_id (connection)); ret = handle_auth_or_fail (self, req, FALSE); if (ret == NM_ACT_STAGE_RETURN_FAILURE) @@ -2806,15 +2756,13 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) /* have secrets, or no secrets required */ if (nm_connection_get_setting_wireless_security (connection)) { - nm_log_info (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): connection '%s' has security" - ", and secrets exist. No new secrets needed.", - iface, nm_connection_get_id (connection)); + _LOGI (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) connection '%s' has security, and secrets exist. No new secrets needed.", + nm_connection_get_id (connection)); } else { - nm_log_info (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): connection '%s' requires no " - "security. No secrets needed.", - iface, nm_connection_get_id (connection)); + _LOGI (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) connection '%s' requires no security. No secrets needed.", + nm_connection_get_id (connection)); } priv->ssid_found = FALSE; @@ -2829,9 +2777,8 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) /* Build up the supplicant configuration */ config = build_supplicant_config (self, connection, nm_ap_get_freq (ap)); if (config == NULL) { - nm_log_err (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): couldn't build wireless configuration.", - iface); + _LOGE (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) couldn't build wireless configuration."); *reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; goto out; } @@ -2843,9 +2790,8 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) self); if (!nm_supplicant_interface_set_config (priv->sup_iface, config)) { - nm_log_err (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): couldn't send wireless " - "configuration to the supplicant.", iface); + _LOGE (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) couldn't send wireless configuration to the supplicant."); *reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; goto out; } @@ -2983,17 +2929,14 @@ handle_ip_config_timeout (NMDeviceWifi *self, */ if (!may_fail && is_static_wep (connection)) { /* Activation failed, we must have bad encryption key */ - nm_log_warn (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): could not get IP configuration for " - "connection '%s'.", - nm_device_get_iface (NM_DEVICE (self)), - nm_connection_get_id (connection)); + _LOGW (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) could not get IP configuration for connection '%s'.", + nm_connection_get_id (connection)); ret = handle_auth_or_fail (self, NULL, TRUE); if (ret == NM_ACT_STAGE_RETURN_POSTPONE) { - nm_log_info (LOGD_DEVICE | LOGD_WIFI, - "Activation (%s/wireless): asking for new secrets", - nm_device_get_iface (NM_DEVICE (self))); + _LOGI (LOGD_DEVICE | LOGD_WIFI, + "Activation: (wifi) asking for new secrets"); } else { *reason = NM_DEVICE_STATE_REASON_NO_SECRETS; } @@ -3007,60 +2950,60 @@ handle_ip_config_timeout (NMDeviceWifi *self, static NMActStageReturn -act_stage4_ip4_config_timeout (NMDevice *dev, NMDeviceStateReason *reason) +act_stage4_ip4_config_timeout (NMDevice *device, NMDeviceStateReason *reason) { NMConnection *connection; NMSettingIP4Config *s_ip4; gboolean may_fail = FALSE, chain_up = FALSE; NMActStageReturn ret; - connection = nm_device_get_connection (dev); + connection = nm_device_get_connection (device); g_assert (connection); s_ip4 = nm_connection_get_setting_ip4_config (connection); may_fail = nm_setting_ip4_config_get_may_fail (s_ip4); - ret = handle_ip_config_timeout (NM_DEVICE_WIFI (dev), connection, may_fail, &chain_up, reason); + ret = handle_ip_config_timeout (NM_DEVICE_WIFI (device), connection, may_fail, &chain_up, reason); if (chain_up) - ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip4_config_timeout (dev, reason); + ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip4_config_timeout (device, reason); return ret; } static NMActStageReturn -act_stage4_ip6_config_timeout (NMDevice *dev, NMDeviceStateReason *reason) +act_stage4_ip6_config_timeout (NMDevice *device, NMDeviceStateReason *reason) { NMConnection *connection; NMSettingIP6Config *s_ip6; gboolean may_fail = FALSE, chain_up = FALSE; NMActStageReturn ret; - connection = nm_device_get_connection (dev); + connection = nm_device_get_connection (device); g_assert (connection); s_ip6 = nm_connection_get_setting_ip6_config (connection); may_fail = nm_setting_ip6_config_get_may_fail (s_ip6); - ret = handle_ip_config_timeout (NM_DEVICE_WIFI (dev), connection, may_fail, &chain_up, reason); + ret = handle_ip_config_timeout (NM_DEVICE_WIFI (device), connection, may_fail, &chain_up, reason); if (chain_up) - ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip6_config_timeout (dev, reason); + ret = NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage4_ip6_config_timeout (device, reason); return ret; } static void -activation_success_handler (NMDevice *dev) +activation_success_handler (NMDevice *device) { - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); + NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - int ifindex = nm_device_get_ifindex (dev); + int ifindex = nm_device_get_ifindex (device); NMAccessPoint *ap; struct ether_addr bssid = { {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} }; NMAccessPoint *tmp_ap = NULL; NMActRequest *req; NMConnection *connection; - req = nm_device_get_act_request (dev); + req = nm_device_get_act_request (device); g_assert (req); connection = nm_act_request_get_connection (req); @@ -3129,18 +3072,18 @@ done: } static void -activation_failure_handler (NMDevice *dev) +activation_failure_handler (NMDevice *device) { NMConnection *connection; - connection = nm_device_get_connection (dev); + connection = nm_device_get_connection (device); g_assert (connection); /* Clear wireless secrets tries on failure */ g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL); /* Clear any critical protocol notification in the wifi stack */ - nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (dev), FALSE); + nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), FALSE); } static void @@ -3224,15 +3167,12 @@ set_enabled (NMDevice *device, gboolean enabled) priv->enabled = enabled; - nm_log_dbg (LOGD_WIFI, "(%s): device now %s", - nm_device_get_iface (NM_DEVICE (device)), - enabled ? "enabled" : "disabled"); + _LOGD (LOGD_WIFI, "device now %s", enabled ? "enabled" : "disabled"); state = nm_device_get_state (NM_DEVICE (self)); if (state < NM_DEVICE_STATE_UNAVAILABLE) { - nm_log_dbg (LOGD_WIFI, "(%s): %s blocked by UNMANAGED state", - enabled ? "enable" : "disable", - nm_device_get_iface (NM_DEVICE (device))); + _LOGD (LOGD_WIFI, "(%s): device blocked by UNMANAGED state", + enabled ? "enable" : "disable"); return; } @@ -3240,11 +3180,10 @@ set_enabled (NMDevice *device, gboolean enabled) gboolean no_firmware = FALSE; if (state != NM_DEVICE_STATE_UNAVAILABLE) - nm_log_warn (LOGD_CORE, "not in expected unavailable state!"); + _LOGW (LOGD_CORE, "not in expected unavailable state!"); if (!nm_device_bring_up (NM_DEVICE (self), TRUE, &no_firmware)) { - nm_log_dbg (LOGD_WIFI, "(%s): enable blocked by failure to bring device up", - nm_device_get_iface (NM_DEVICE (device))); + _LOGD (LOGD_WIFI, "enable blocked by failure to bring device up"); if (no_firmware) nm_device_set_firmware_missing (NM_DEVICE (device), TRUE); @@ -3260,8 +3199,7 @@ set_enabled (NMDevice *device, gboolean enabled) supplicant_interface_release (self); supplicant_interface_acquire (self); - nm_log_dbg (LOGD_WIFI, "(%s): enable waiting on supplicant state", - nm_device_get_iface (NM_DEVICE (device))); + _LOGD (LOGD_WIFI, "enable waiting on supplicant state"); } else { nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_UNAVAILABLE, diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index fd1b7f2868..ea331a7948 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -33,6 +33,9 @@ #include "nm-modem-broadband.h" #include "NetworkManagerUtils.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceModem); + G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) #define NM_DEVICE_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MODEM, NMDeviceModemPrivate)) @@ -89,7 +92,8 @@ modem_prepare_result (NMModem *modem, NMDeviceStateReason reason, gpointer user_data) { - NMDevice *device = NM_DEVICE (user_data); + NMDeviceModem *self = NM_DEVICE_MODEM (user_data); + NMDevice *device = NM_DEVICE (self); NMDeviceState state; state = nm_device_get_state (device); @@ -104,8 +108,7 @@ modem_prepare_result (NMModem *modem, * the SIM if the incorrect PIN continues to be used. */ g_object_set (G_OBJECT (device), NM_DEVICE_AUTOCONNECT, FALSE, NULL); - nm_log_info (LOGD_MB, "(%s): disabling autoconnect due to failed SIM PIN", - nm_device_get_iface (device)); + _LOGI (LOGD_MB, "disabling autoconnect due to failed SIM PIN"); } nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); @@ -145,19 +148,19 @@ modem_auth_result (NMModem *modem, GError *error, gpointer user_data) } static void -modem_ip4_config_result (NMModem *self, +modem_ip4_config_result (NMModem *modem, NMIP4Config *config, GError *error, gpointer user_data) { - NMDevice *device = NM_DEVICE (user_data); + NMDeviceModem *self = NM_DEVICE_MODEM (user_data); + NMDevice *device = NM_DEVICE (self); g_return_if_fail (nm_device_activate_ip4_state_in_conf (device) == TRUE); if (error) { - nm_log_warn (LOGD_MB | LOGD_IP4, "retrieving IPv4 configuration failed: (%d) %s", - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + _LOGW (LOGD_MB | LOGD_IP4, "retrieving IPv4 configuration failed: (%d) %s", + error->code, error->message ? error->message : "(unknown)"); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } else { @@ -167,13 +170,14 @@ modem_ip4_config_result (NMModem *self, } static void -modem_ip6_config_result (NMModem *self, +modem_ip6_config_result (NMModem *modem, NMIP6Config *config, gboolean do_slaac, GError *error, gpointer user_data) { - NMDevice *device = NM_DEVICE (user_data); + NMDeviceModem *self = NM_DEVICE_MODEM (user_data); + NMDevice *device = NM_DEVICE (self); NMActStageReturn ret; NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; NMIP6Config *ignored = NULL; @@ -182,9 +186,8 @@ modem_ip6_config_result (NMModem *self, g_return_if_fail (nm_device_activate_ip6_state_in_conf (device) == TRUE); if (error) { - nm_log_warn (LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: (%d) %s", - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + _LOGW (LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: (%d) %s", + error->code, error->message ? error->message : "(unknown)"); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); return; @@ -200,7 +203,7 @@ modem_ip6_config_result (NMModem *self, if (got_config) nm_device_activate_schedule_ip6_config_result (device); else { - nm_log_warn (LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: SLAAC not requested and no addresses"); + _LOGW (LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: SLAAC not requested and no addresses"); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } return; @@ -333,6 +336,7 @@ device_state_changed (NMDevice *device, NMDeviceState old_state, NMDeviceStateReason reason) { + NMDeviceModem *self = NM_DEVICE_MODEM (device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); NMConnection *connection = nm_device_get_connection (device); @@ -341,9 +345,8 @@ device_state_changed (NMDevice *device, if (new_state == NM_DEVICE_STATE_UNAVAILABLE && old_state < NM_DEVICE_STATE_UNAVAILABLE) { /* Log initial modem state */ - nm_log_info (LOGD_MB, "(%s): modem state '%s'", - nm_device_get_iface (device), - nm_modem_state_to_string (nm_modem_get_state (priv->modem))); + _LOGI (LOGD_MB, "modem state '%s'", + nm_modem_state_to_string (nm_modem_get_state (priv->modem))); } nm_modem_device_state_changed (priv->modem, new_state, old_state, reason); @@ -526,23 +529,22 @@ set_enabled (NMDevice *device, gboolean enabled) } static gboolean -is_available (NMDevice *dev) +is_available (NMDevice *device) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (dev); + NMDeviceModem *self = NM_DEVICE_MODEM (device); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); NMModemState modem_state; if (!priv->rf_enabled) { - nm_log_dbg (LOGD_MB, "(%s): not available because WWAN airplane mode is on", - nm_device_get_iface (dev)); + _LOGD (LOGD_MB, "not available because WWAN airplane mode is on"); return FALSE; } g_assert (priv->modem); modem_state = nm_modem_get_state (priv->modem); if (modem_state <= NM_MODEM_STATE_INITIALIZING) { - nm_log_dbg (LOGD_MB, "(%s): not available because modem is not ready (%s)", - nm_device_get_iface (dev), - nm_modem_state_to_string (modem_state)); + _LOGD (LOGD_MB, "not available because modem is not ready (%s)", + nm_modem_state_to_string (modem_state)); return FALSE; } -- cgit v1.2.3