2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-09-25 13:13:40 +02:00
|
|
|
/*
|
2014-08-02 14:52:49 +02:00
|
|
|
* Copyright (C) 2014 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#ifndef __NETWORKMANAGER_DEVICE_LOGGING_H__
|
|
|
|
|
#define __NETWORKMANAGER_DEVICE_LOGGING_H__
|
2014-08-02 14:52:49 +02:00
|
|
|
|
|
|
|
|
#include "nm-device.h"
|
|
|
|
|
|
2020-11-06 18:22:11 +01:00
|
|
|
#if !_NM_CC_SUPPORT_GENERIC
|
2021-07-09 08:48:48 +02:00
|
|
|
#define _NM_DEVICE_CAST(self) ((NMDevice *) (self))
|
2020-11-06 18:22:11 +01:00
|
|
|
#elif !defined(_NMLOG_DEVICE_TYPE)
|
2022-10-11 11:07:25 +02:00
|
|
|
#define _NM_DEVICE_CAST(self) _Generic((self), NMDevice *: ((NMDevice *) (self)))
|
2020-11-06 18:22:11 +01:00
|
|
|
#else
|
2022-10-11 11:07:25 +02:00
|
|
|
#define _NM_DEVICE_CAST(self) \
|
|
|
|
|
_Generic((self), _NMLOG_DEVICE_TYPE *: ((NMDevice *) (self)), NMDevice *: ((NMDevice *) (self)))
|
2020-11-06 18:22:11 +01:00
|
|
|
#endif
|
2014-08-02 14:52:49 +02:00
|
|
|
|
2015-08-20 00:07:14 +02:00
|
|
|
#undef _NMLOG_ENABLED
|
|
|
|
|
#define _NMLOG_ENABLED(level, domain) (nm_logging_enabled((level), (domain)))
|
core: log the device type when it can be ambiguous
Use the nm_device_get_type_desc_for_log() helper function defined
earlier to show the device type when it can be ambiguous.
With this, the log becomes a bit more explicative when there are OVS
devices involved:
<info> device (ovs-br)[Open vSwitch Bridge]: state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br)[Open vSwitch Port]: state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br)[Open vSwitch Port]: state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br)[Open vSwitch Port]: Activation: successful, device activated.
<info> device (ovs-br)[Open vSwitch Bridge]: state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br)[Open vSwitch Bridge]: state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br)[Open vSwitch Bridge]: Activation: successful, device activated.
<info> device (ovs-br)[Open vSwitch Interface]: state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
<info> device (ovs-br)[Open vSwitch Interface]: state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br)[Open vSwitch Interface]: Activation: starting connection 'ovs-interface+' (d3d429b1-3193-4462-a17a-034255c43776)
instead of:
<info> device (ovs-br): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br): Activation: successful, device activated.
<info> device (ovs-br): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br): Activation: successful, device activated.
<info> device (ovs-br): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
<info> device (ovs-br): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
<info> device (ovs-br): Activation: starting connection 'ovs-interface+' (d3d429b1-3193-4462-a17a-034255c43776)
2023-05-22 17:56:22 +02:00
|
|
|
#define _NMLOG(level, domain, ...) \
|
|
|
|
|
G_STMT_START \
|
|
|
|
|
{ \
|
|
|
|
|
const NMLogLevel _level = (level); \
|
|
|
|
|
const NMLogDomain _domain = (domain); \
|
|
|
|
|
\
|
|
|
|
|
if (nm_logging_enabled(_level, _domain)) { \
|
|
|
|
|
typeof(*self) *const _self = (self); \
|
|
|
|
|
const char *const _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \
|
|
|
|
|
const char *_type = nm_device_get_type_desc_for_log(_NM_DEVICE_CAST(_self)); \
|
|
|
|
|
\
|
|
|
|
|
nm_log_obj(_level, \
|
|
|
|
|
_domain, \
|
|
|
|
|
_ifname, \
|
|
|
|
|
NULL, \
|
|
|
|
|
_self, \
|
|
|
|
|
"device", \
|
|
|
|
|
"%s%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
|
|
|
|
NM_PRINT_FMT_QUOTED(_ifname, "(", _ifname, ")", "[null]"), \
|
|
|
|
|
NM_PRINT_FMT_QUOTED(_type, "[", _type, "]", "") \
|
|
|
|
|
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
2017-06-07 12:18:21 +02:00
|
|
|
G_STMT_END
|
2014-08-02 14:52:49 +02:00
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#endif /* __NETWORKMANAGER_DEVICE_LOGGING_H__ */
|