logging: use new logging macros in NMDevice subclasses

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2014-08-02 15:14:26 +02:00
parent 950989c45c
commit 4b36f8b35b
17 changed files with 637 additions and 811 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);
#ifndef G_DISABLE_ASSERT
int ifindex = nm_device_get_ifindex (NM_DEVICE (object));
NMLinkType link_type = nm_platform_link_get_type (ifindex);
g_assert ( nm_platform_link_get_type (ifindex) == NM_LINK_TYPE_ETHERNET
|| nm_platform_link_get_type (ifindex) == NM_LINK_TYPE_VETH);
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), &timestamp))
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

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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

View file

@ -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;
}

View file

@ -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");

View file

@ -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;

View file

@ -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;
}

File diff suppressed because it is too large Load diff

View file

@ -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;
}