mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 20:18:39 +00:00
all: merge branch 'th/shared-nm-platform'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/716
This commit is contained in:
commit
fef16c3f54
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -135,6 +135,7 @@ test-*.trs
|
|||
|
||||
/shared/nm-glib-aux/tests/test-json-aux
|
||||
/shared/nm-glib-aux/tests/test-shared-general
|
||||
/shared/nm-platform/tests/test-nm-platform
|
||||
/shared/nm-version-macros.h
|
||||
|
||||
/introspection/org.freedesktop.NetworkManager*.[ch]
|
||||
|
|
151
Makefile.am
151
Makefile.am
|
@ -114,6 +114,9 @@ $(libnm_core_lib_h_pub_mkenums): config-extra.h
|
|||
libnm-core/.dirstamp: config-extra.h
|
||||
shared/.dirstamp: config-extra.h
|
||||
shared/nm-glib-aux/.dirstamp: config-extra.h
|
||||
shared/nm-glib-aux/tests/.dirstamp: config-extra.h
|
||||
shared/nm-platform/.dirstamp: config-extra.h
|
||||
shared/nm-platform/tests/.dirstamp: config-extra.h
|
||||
shared/nm-std-aux/.dirstamp: config-extra.h
|
||||
shared/nm-udev-aux/.dirstamp: config-extra.h
|
||||
shared/systemd/.dirstamp: config-extra.h
|
||||
|
@ -461,6 +464,121 @@ shared_nm_udev_aux_libnm_udev_aux_la_LIBADD = \
|
|||
|
||||
###############################################################################
|
||||
|
||||
noinst_LTLIBRARIES += shared/nm-base/libnm-base.la
|
||||
|
||||
shared_nm_base_libnm_base_la_CPPFLAGS = \
|
||||
$(shared_nm_glib_aux_cppflags) \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_base_libnm_base_la_SOURCES = \
|
||||
shared/nm-base/nm-base.h \
|
||||
shared/nm-base/nm-ethtool-base.c \
|
||||
shared/nm-base/nm-ethtool-base.h \
|
||||
shared/nm-base/nm-ethtool-utils-base.h \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_base_libnm_base_la_LDFLAGS = \
|
||||
$(CODE_COVERAGE_LDFLAGS) \
|
||||
$(SANITIZER_LIB_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_base_libnm_base_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
###############################################################################
|
||||
|
||||
noinst_LTLIBRARIES += shared/nm-log-core/libnm-log-core.la
|
||||
|
||||
shared_nm_log_core_libnm_log_core_la_CPPFLAGS = \
|
||||
$(dflt_cppflags) \
|
||||
-I$(srcdir)/shared \
|
||||
$(CODE_COVERAGE_CFLAGS) \
|
||||
$(SANITIZER_LIB_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(SYSTEMD_JOURNAL_CFLAGS) \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION='(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB)' \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_log_core_libnm_log_core_la_SOURCES = \
|
||||
shared/nm-log-core/nm-logging.c \
|
||||
shared/nm-log-core/nm-logging.h \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_log_core_libnm_log_core_la_LDFLAGS = \
|
||||
$(CODE_COVERAGE_LDFLAGS) \
|
||||
$(SANITIZER_LIB_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_log_core_libnm_log_core_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(SYSTEMD_JOURNAL_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
###############################################################################
|
||||
|
||||
noinst_LTLIBRARIES += shared/nm-platform/libnm-platform.la
|
||||
|
||||
shared_nm_platform_libnm_platform_la_CPPFLAGS = \
|
||||
$(shared_nm_glib_aux_cppflags) \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_platform_libnm_platform_la_SOURCES = \
|
||||
shared/nm-platform/nm-netlink.c \
|
||||
shared/nm-platform/nm-netlink.h \
|
||||
shared/nm-platform/nm-platform-utils.c \
|
||||
shared/nm-platform/nm-platform-utils.h \
|
||||
shared/nm-platform/nmp-base.h \
|
||||
shared/nm-platform/nmp-netns.c \
|
||||
shared/nm-platform/nmp-netns.h \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_platform_libnm_platform_la_LDFLAGS = \
|
||||
$(CODE_COVERAGE_LDFLAGS) \
|
||||
$(SANITIZER_LIB_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_platform_libnm_platform_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
###############################################################################
|
||||
|
||||
check_programs += shared/nm-platform/tests/test-nm-platform
|
||||
|
||||
shared_nm_platform_tests_test_nm_platform_CPPFLAGS = \
|
||||
$(dflt_cppflags) \
|
||||
-I$(srcdir)/shared \
|
||||
-DNETWORKMANAGER_COMPILATION_TEST \
|
||||
-DNETWORKMANAGER_COMPILATION='(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG)' \
|
||||
$(CODE_COVERAGE_CFLAGS) \
|
||||
$(SYSTEMD_JOURNAL_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(SANITIZER_LIB_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_platform_tests_test_nm_platform_LDFLAGS = \
|
||||
$(CODE_COVERAGE_LDFLAGS) \
|
||||
$(SANITIZER_EXEC_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
shared_nm_platform_tests_test_nm_platform_LDADD = \
|
||||
shared/nm-platform/libnm-platform.la \
|
||||
shared/nm-log-core/libnm-log-core.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
shared/libcsiphash.la \
|
||||
$(SYSTEMD_JOURNAL_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST += \
|
||||
shared/nm-platform/tests/meson.build \
|
||||
$(NULL)
|
||||
|
||||
###############################################################################
|
||||
|
||||
noinst_LTLIBRARIES += libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la
|
||||
|
||||
libnm_core_nm_libnm_core_intern_libnm_libnm_core_intern_la_CPPFLAGS = \
|
||||
|
@ -480,8 +598,6 @@ libnm_core_nm_libnm_core_intern_libnm_libnm_core_intern_la_SOURCES = \
|
|||
libnm-core/nm-libnm-core-intern/nm-auth-subject.c \
|
||||
libnm-core/nm-libnm-core-intern/nm-auth-subject.h \
|
||||
libnm-core/nm-libnm-core-intern/nm-common-macros.h \
|
||||
libnm-core/nm-libnm-core-intern/nm-ethtool-utils.c \
|
||||
libnm-core/nm-libnm-core-intern/nm-ethtool-utils.h \
|
||||
libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c \
|
||||
libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h \
|
||||
$(NULL)
|
||||
|
@ -613,6 +729,7 @@ EXTRA_DIST += libnm/nm-libnm-aux/README.md
|
|||
|
||||
EXTRA_DIST += \
|
||||
shared/nm-glib-aux/tests/meson.build \
|
||||
shared/README.md \
|
||||
$(NULL)
|
||||
|
||||
###############################################################################
|
||||
|
@ -1266,6 +1383,7 @@ libnm_core_tests_ldadd = \
|
|||
libnm-core/libnm-core.la \
|
||||
$(libnm_crypto_lib) \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
shared/systemd/libnm-systemd-shared.la \
|
||||
shared/systemd/libnm-systemd-logging-stub.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
|
@ -1376,6 +1494,7 @@ libnm_lib_h_pub_real = \
|
|||
libnm/nm-device-wpan.h \
|
||||
libnm/nm-device.h \
|
||||
libnm/nm-dhcp-config.h \
|
||||
libnm/nm-ethtool-utils.h \
|
||||
libnm/nm-ip-config.h \
|
||||
libnm/nm-object.h \
|
||||
libnm/nm-remote-connection.h \
|
||||
|
@ -1497,6 +1616,7 @@ libnm_liblibnm_la_LIBADD = \
|
|||
libnm-core/libnm-core.la \
|
||||
$(libnm_crypto_lib) \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
introspection/libnmdbus.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/systemd/libnm-systemd-shared.la \
|
||||
|
@ -2112,21 +2232,12 @@ src_libNetworkManagerBase_la_SOURCES = \
|
|||
\
|
||||
src/nm-core-utils.c \
|
||||
src/nm-core-utils.h \
|
||||
src/nm-logging.c \
|
||||
src/nm-logging.h \
|
||||
\
|
||||
src/NetworkManagerUtils.c \
|
||||
src/NetworkManagerUtils.h \
|
||||
\
|
||||
src/platform/nm-netlink.c \
|
||||
src/platform/nm-netlink.h \
|
||||
\
|
||||
src/platform/nmp-netns.c \
|
||||
src/platform/nmp-netns.h \
|
||||
src/platform/nmp-object.c \
|
||||
src/platform/nmp-object.h \
|
||||
src/platform/nm-platform-utils.c \
|
||||
src/platform/nm-platform-utils.h \
|
||||
src/platform/nm-platform.c \
|
||||
src/platform/nm-platform.h \
|
||||
src/platform/nm-platform-private.h \
|
||||
|
@ -2192,7 +2303,6 @@ endif
|
|||
|
||||
src_libNetworkManagerBase_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(SYSTEMD_JOURNAL_LIBS) \
|
||||
$(LIBUDEV_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
@ -2389,6 +2499,9 @@ src_libNetworkManager_la_LIBADD = \
|
|||
libnm-core/libnm-core.la \
|
||||
$(libnm_crypto_lib) \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-platform/libnm-platform.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
shared/nm-log-core/libnm-log-core.la \
|
||||
shared/nm-udev-aux/libnm-udev-aux.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
|
@ -2401,6 +2514,7 @@ src_libNetworkManager_la_LIBADD = \
|
|||
$(GLIB_LIBS) \
|
||||
$(LIBUDEV_LIBS) \
|
||||
$(SYSTEMD_LOGIN_LIBS) \
|
||||
$(SYSTEMD_JOURNAL_LIBS) \
|
||||
$(LIBNDP_LIBS) \
|
||||
$(DL_LIBS) \
|
||||
$(SELINUX_LIBS) \
|
||||
|
@ -2499,6 +2613,9 @@ src_nm_iface_helper_LDADD = \
|
|||
libnm-core/libnm-core.la \
|
||||
$(libnm_crypto_lib) \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-platform/libnm-platform.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
shared/nm-log-core/libnm-log-core.la \
|
||||
shared/nm-udev-aux/libnm-udev-aux.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
|
@ -2508,6 +2625,7 @@ src_nm_iface_helper_LDADD = \
|
|||
shared/libndhcp4.la \
|
||||
shared/libcrbtree.la \
|
||||
shared/libcsiphash.la \
|
||||
$(SYSTEMD_JOURNAL_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(LIBUDEV_LIBS) \
|
||||
$(LIBNDP_LIBS) \
|
||||
|
@ -2550,6 +2668,9 @@ src_initrd_nm_initrd_generator_LDADD = \
|
|||
libnm-core/libnm-core.la \
|
||||
$(libnm_crypto_lib) \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-platform/libnm-platform.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
shared/nm-log-core/libnm-log-core.la \
|
||||
shared/nm-udev-aux/libnm-udev-aux.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
|
@ -2558,6 +2679,7 @@ src_initrd_nm_initrd_generator_LDADD = \
|
|||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
shared/libndhcp4.la \
|
||||
shared/libcsiphash.la \
|
||||
$(SYSTEMD_JOURNAL_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
@ -4548,6 +4670,7 @@ clients_common_tests_test_clients_common_LDADD = \
|
|||
clients/common/libnmc-base.la \
|
||||
libnm-core/nm-libnm-core-aux/libnm-libnm-core-aux.la \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
shared/libcsiphash.la \
|
||||
|
@ -4639,6 +4762,7 @@ clients_cli_nmcli_LDADD = \
|
|||
clients/common/libnmc-base.la \
|
||||
libnm-core/nm-libnm-core-aux/libnm-libnm-core-aux.la \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
shared/libcsiphash.la \
|
||||
|
@ -4687,6 +4811,7 @@ clients_cli_generate_docs_nm_settings_nmcli_LDADD = \
|
|||
libnm/nm-libnm-aux/libnm-libnm-aux.la \
|
||||
libnm-core/nm-libnm-core-aux/libnm-libnm-core-aux.la \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
libnm/libnm.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
|
@ -4877,6 +5002,7 @@ clients_tui_nmtui_LDADD = \
|
|||
libnm/nm-libnm-aux/libnm-libnm-aux.la \
|
||||
libnm-core/nm-libnm-core-aux/libnm-libnm-core-aux.la \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
shared/libcsiphash.la \
|
||||
|
@ -4948,6 +5074,7 @@ clients_cloud_setup_nm_cloud_setup_LDADD = \
|
|||
libnm/nm-libnm-aux/libnm-libnm-aux.la \
|
||||
libnm-core/nm-libnm-core-aux/libnm-libnm-core-aux.la \
|
||||
libnm-core/nm-libnm-core-intern/libnm-libnm-core-intern.la \
|
||||
shared/nm-base/libnm-base.la \
|
||||
shared/nm-glib-aux/libnm-glib-aux.la \
|
||||
shared/nm-std-aux/libnm-std-aux.la \
|
||||
shared/libcsiphash.la \
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "nm-glib-aux/nm-obj.h"
|
||||
#include "nm-meta-setting.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
|
||||
struct _NMDevice;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ IGNORE_HFILES= \
|
|||
\
|
||||
nm-auth-subject.h \
|
||||
nm-common-macros.h \
|
||||
nm-ethtool-utils.h \
|
||||
nm-ethtool-base.h \
|
||||
nm-libnm-core-utils.h \
|
||||
\
|
||||
nm-dispatcher-api.h \
|
||||
|
|
|
@ -33,7 +33,7 @@ private_headers = [
|
|||
|
||||
'nm-auth-subject.h',
|
||||
'nm-common-macros.h',
|
||||
'nm-ethtool-utils.h',
|
||||
'nm-ethtool-base.h',
|
||||
'nm-libnm-core-utils.h',
|
||||
|
||||
'nm-dispatcher-api.h',
|
||||
|
|
|
@ -95,17 +95,22 @@ libnm_libnm_core_intern = static_library(
|
|||
'nm-libnm-core-intern',
|
||||
sources: files(
|
||||
'nm-libnm-core-intern/nm-auth-subject.c',
|
||||
'nm-libnm-core-intern/nm-ethtool-utils.c',
|
||||
'nm-libnm-core-intern/nm-libnm-core-utils.c',
|
||||
) + [libnm_core_enum_sources[1]],
|
||||
dependencies: libnm_core_nm_default_dep,
|
||||
dependencies: [
|
||||
libnm_core_nm_default_dep,
|
||||
libnm_base_dep,
|
||||
],
|
||||
c_args: common_c_flags,
|
||||
)
|
||||
|
||||
libnm_libnm_core_intern_dep = declare_dependency(
|
||||
sources: [libnm_core_enum_sources[1], nm_version_macro_header],
|
||||
include_directories: [libnm_core_inc, shared_inc],
|
||||
dependencies: libnm_utils_base_dep,
|
||||
dependencies: [
|
||||
libnm_utils_base_dep,
|
||||
libnm_base_dep,
|
||||
],
|
||||
link_with: libnm_libnm_core_intern,
|
||||
)
|
||||
|
||||
|
@ -232,7 +237,10 @@ libnm_libnm_core_aux = static_library(
|
|||
) + [libnm_core_enum_sources[1]],
|
||||
dependencies: libnm_utils_base_dep,
|
||||
c_args: c_flags,
|
||||
link_with: libnm_libnm_core_intern,
|
||||
link_with: [
|
||||
libnm_libnm_core_intern,
|
||||
libnm_base,
|
||||
],
|
||||
)
|
||||
|
||||
libnm_libnm_core_aux_dep = declare_dependency(
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#error Cannot use this header.
|
||||
#endif
|
||||
|
||||
#include "nm-base/nm-base.h"
|
||||
#include "nm-connection.h"
|
||||
#include "nm-core-enum-types.h"
|
||||
#include "nm-core-types-internal.h"
|
||||
|
@ -215,6 +216,38 @@ nm_bluetooth_capability_to_string(NMBluetoothCapabilities capabilities, char *bu
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline _NMSettingWiredWakeOnLan
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_CAST(NMSettingWiredWakeOnLan v)
|
||||
{
|
||||
/* _NMSettingWiredWakeOnLan and NMSettingWiredWakeOnLan enums are really
|
||||
* the same.
|
||||
*
|
||||
* The former is used by nm-platform (which should have no libnm-core dependency),
|
||||
* the latter is used by libnm-core. A unit test ensures they are exactly the same,
|
||||
* so we can just cast them. */
|
||||
return (_NMSettingWiredWakeOnLan) v;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline NMTernary
|
||||
NM_TERNARY_FROM_OPTION_BOOL(NMOptionBool v)
|
||||
{
|
||||
nm_assert(NM_IN_SET(v, NM_OPTION_BOOL_DEFAULT, NM_OPTION_BOOL_TRUE, NM_OPTION_BOOL_FALSE));
|
||||
|
||||
return (NMTernary) v;
|
||||
}
|
||||
|
||||
static inline NMOptionBool
|
||||
NM_TERNARY_TO_OPTION_BOOL(NMTernary v)
|
||||
{
|
||||
nm_assert(NM_IN_SET(v, NM_TERNARY_DEFAULT, NM_TERNARY_TRUE, NM_TERNARY_FALSE));
|
||||
|
||||
return (NMOptionBool) v;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
NM_SETTING_PARSE_FLAGS_NONE = 0,
|
||||
NM_SETTING_PARSE_FLAGS_STRICT = 1LL << 0,
|
||||
|
@ -327,7 +360,7 @@ gboolean _nm_setting_option_clear(NMSetting *setting, const char *optname);
|
|||
|
||||
guint nm_setting_ethtool_init_features(
|
||||
NMSettingEthtool *setting,
|
||||
NMTernary * requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */);
|
||||
NMOptionBool * requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ NM_CACHED_QUARK_FCN("nm-agent-manager-error-quark", nm_agent_manager_error_quark
|
|||
NM_CACHED_QUARK_FCN("nm-connection-error-quark", nm_connection_error_quark);
|
||||
NM_CACHED_QUARK_FCN("nm-crypto-error-quark", nm_crypto_error_quark);
|
||||
NM_CACHED_QUARK_FCN("nm-device-error-quark", nm_device_error_quark);
|
||||
NM_CACHED_QUARK_FCN("nm-manager-error-quark", nm_manager_error_quark);
|
||||
NM_CACHED_QUARK_FCN("nm-secret-agent-error-quark", nm_secret_agent_error_quark);
|
||||
NM_CACHED_QUARK_FCN("nm-settings-error-quark", nm_settings_error_quark);
|
||||
NM_CACHED_QUARK_FCN("nm-vpn-plugin-error-quark", nm_vpn_plugin_error_quark);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "nm-setting-ethtool.h"
|
||||
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -195,7 +195,7 @@ nm_setting_ethtool_clear_features(NMSettingEthtool *setting)
|
|||
guint
|
||||
nm_setting_ethtool_init_features(
|
||||
NMSettingEthtool *setting,
|
||||
NMTernary * requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */)
|
||||
NMOptionBool * requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */)
|
||||
{
|
||||
GHashTable * hash;
|
||||
GHashTableIter iter;
|
||||
|
@ -208,7 +208,7 @@ nm_setting_ethtool_init_features(
|
|||
nm_assert(requested);
|
||||
|
||||
for (i = 0; i < _NM_ETHTOOL_ID_FEATURE_NUM; i++)
|
||||
requested[i] = NM_TERNARY_DEFAULT;
|
||||
requested[i] = NM_OPTION_BOOL_DEFAULT;
|
||||
|
||||
hash = _nm_setting_option_hash(NM_SETTING(setting), FALSE);
|
||||
if (!hash)
|
||||
|
@ -224,7 +224,7 @@ nm_setting_ethtool_init_features(
|
|||
continue;
|
||||
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(ethtool_id)] =
|
||||
g_variant_get_boolean(variant) ? NM_TERNARY_TRUE : NM_TERNARY_FALSE;
|
||||
g_variant_get_boolean(variant) ? NM_OPTION_BOOL_TRUE : NM_OPTION_BOOL_FALSE;
|
||||
n_req++;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,91 +14,6 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_ESP_HW_OFFLOAD "feature-esp-hw-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_ESP_TX_CSUM_HW_OFFLOAD "feature-esp-tx-csum-hw-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_FCOE_MTU "feature-fcoe-mtu"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_GRO "feature-gro"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_GSO "feature-gso"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_HIGHDMA "feature-highdma"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_HW_TC_OFFLOAD "feature-hw-tc-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_L2_FWD_OFFLOAD "feature-l2-fwd-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_LOOPBACK "feature-loopback"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_LRO "feature-lro"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_NTUPLE "feature-ntuple"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX "feature-rx"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RXHASH "feature-rxhash"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RXVLAN "feature-rxvlan"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_ALL "feature-rx-all"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_FCS "feature-rx-fcs"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_GRO_HW "feature-rx-gro-hw"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_UDP_TUNNEL_PORT_OFFLOAD "feature-rx-udp_tunnel-port-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_VLAN_FILTER "feature-rx-vlan-filter"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_VLAN_STAG_FILTER "feature-rx-vlan-stag-filter"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_VLAN_STAG_HW_PARSE "feature-rx-vlan-stag-hw-parse"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_SG "feature-sg"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TLS_HW_RECORD "feature-tls-hw-record"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TLS_HW_TX_OFFLOAD "feature-tls-hw-tx-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TSO "feature-tso"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX "feature-tx"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TXVLAN "feature-txvlan"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_FCOE_CRC "feature-tx-checksum-fcoe-crc"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_IPV4 "feature-tx-checksum-ipv4"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_IPV6 "feature-tx-checksum-ipv6"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_IP_GENERIC "feature-tx-checksum-ip-generic"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_SCTP "feature-tx-checksum-sctp"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_ESP_SEGMENTATION "feature-tx-esp-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_FCOE_SEGMENTATION "feature-tx-fcoe-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_GRE_CSUM_SEGMENTATION "feature-tx-gre-csum-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_GRE_SEGMENTATION "feature-tx-gre-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_GSO_PARTIAL "feature-tx-gso-partial"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_GSO_ROBUST "feature-tx-gso-robust"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_IPXIP4_SEGMENTATION "feature-tx-ipxip4-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_IPXIP6_SEGMENTATION "feature-tx-ipxip6-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_NOCACHE_COPY "feature-tx-nocache-copy"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_SCATTER_GATHER "feature-tx-scatter-gather"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_SCATTER_GATHER_FRAGLIST "feature-tx-scatter-gather-fraglist"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_SCTP_SEGMENTATION "feature-tx-sctp-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_TCP6_SEGMENTATION "feature-tx-tcp6-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_TCP_ECN_SEGMENTATION "feature-tx-tcp-ecn-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_TCP_MANGLEID_SEGMENTATION \
|
||||
"feature-tx-tcp-mangleid-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_TCP_SEGMENTATION "feature-tx-tcp-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_UDP_SEGMENTATION "feature-tx-udp-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_UDP_TNL_CSUM_SEGMENTATION \
|
||||
"feature-tx-udp_tnl-csum-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_UDP_TNL_SEGMENTATION "feature-tx-udp_tnl-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_VLAN_STAG_HW_INSERT "feature-tx-vlan-stag-hw-insert"
|
||||
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_ADAPTIVE_RX "coalesce-adaptive-rx"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_ADAPTIVE_TX "coalesce-adaptive-tx"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_PKT_RATE_HIGH "coalesce-pkt-rate-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_PKT_RATE_LOW "coalesce-pkt-rate-low"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES "coalesce-rx-frames"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES_HIGH "coalesce-rx-frames-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES_IRQ "coalesce-rx-frames-irq"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES_LOW "coalesce-rx-frames-low"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_USECS "coalesce-rx-usecs"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_USECS_HIGH "coalesce-rx-usecs-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_USECS_IRQ "coalesce-rx-usecs-irq"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_USECS_LOW "coalesce-rx-usecs-low"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_SAMPLE_INTERVAL "coalesce-sample-interval"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_STATS_BLOCK_USECS "coalesce-stats-block-usecs"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES "coalesce-tx-frames"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES_HIGH "coalesce-tx-frames-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES_IRQ "coalesce-tx-frames-irq"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES_LOW "coalesce-tx-frames-low"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS "coalesce-tx-usecs"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS_HIGH "coalesce-tx-usecs-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS_IRQ "coalesce-tx-usecs-irq"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS_LOW "coalesce-tx-usecs-low"
|
||||
|
||||
#define NM_ETHTOOL_OPTNAME_RING_RX "ring-rx"
|
||||
#define NM_ETHTOOL_OPTNAME_RING_RX_JUMBO "ring-rx-jumbo"
|
||||
#define NM_ETHTOOL_OPTNAME_RING_RX_MINI "ring-rx-mini"
|
||||
#define NM_ETHTOOL_OPTNAME_RING_TX "ring-tx"
|
||||
|
||||
NM_AVAILABLE_IN_1_20
|
||||
gboolean nm_ethtool_optname_is_feature(const char *optname);
|
||||
|
||||
|
|
|
@ -3995,16 +3995,13 @@ GByteArray *
|
|||
nm_utils_hwaddr_atoba(const char *asc, gsize length)
|
||||
{
|
||||
GByteArray *ba;
|
||||
gsize l;
|
||||
|
||||
g_return_val_if_fail(asc, NULL);
|
||||
g_return_val_if_fail(length > 0 && length <= NM_UTILS_HWADDR_LEN_MAX, NULL);
|
||||
|
||||
ba = g_byte_array_sized_new(length);
|
||||
g_byte_array_set_size(ba, length);
|
||||
if (!_nm_utils_hwaddr_aton(asc, ba->data, length, &l))
|
||||
goto fail;
|
||||
if (length != l)
|
||||
if (!_nm_utils_hwaddr_aton_exact(asc, ba->data, length))
|
||||
goto fail;
|
||||
|
||||
return ba;
|
||||
|
@ -4029,17 +4026,11 @@ fail:
|
|||
guint8 *
|
||||
nm_utils_hwaddr_aton(const char *asc, gpointer buffer, gsize length)
|
||||
{
|
||||
gsize l;
|
||||
|
||||
g_return_val_if_fail(asc, NULL);
|
||||
g_return_val_if_fail(buffer, NULL);
|
||||
g_return_val_if_fail(length > 0 && length <= NM_UTILS_HWADDR_LEN_MAX, NULL);
|
||||
|
||||
if (!_nm_utils_hwaddr_aton(asc, buffer, length, &l))
|
||||
return NULL;
|
||||
if (length != l)
|
||||
return NULL;
|
||||
return buffer;
|
||||
return _nm_utils_hwaddr_aton_exact(asc, buffer, length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,12 +18,6 @@ enum_sources = gnome.mkenums_simple(
|
|||
body_prefix: '#include "nm-default.h"',
|
||||
)
|
||||
|
||||
deps = [
|
||||
libnm_keyfile_dep,
|
||||
libnm_core_dep,
|
||||
libnm_core_nm_default_dep,
|
||||
]
|
||||
|
||||
c_flags = [
|
||||
'-DNETWORKMANAGER_COMPILATION_TEST',
|
||||
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE',
|
||||
|
@ -45,7 +39,12 @@ foreach test_unit: test_units
|
|||
exe = executable(
|
||||
'libnm-core-' + test_unit,
|
||||
[test_unit + '.c'] + enum_sources,
|
||||
dependencies: deps,
|
||||
dependencies: [
|
||||
libnm_keyfile_dep,
|
||||
libnm_core_dep,
|
||||
libnm_core_nm_default_dep,
|
||||
libnm_base_dep,
|
||||
],
|
||||
c_args: c_flags,
|
||||
link_with: libnm_systemd_logging_stub,
|
||||
)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "nm-glib-aux/nm-enum-utils.h"
|
||||
#include "nm-glib-aux/nm-str-buf.h"
|
||||
#include "nm-glib-aux/nm-json-aux.h"
|
||||
#include "nm-base/nm-base.h"
|
||||
#include "systemd/nm-sd-utils-shared.h"
|
||||
|
||||
#include "nm-utils.h"
|
||||
|
@ -58,7 +59,8 @@
|
|||
#include "nm-simple-connection.h"
|
||||
#include "nm-keyfile/nm-keyfile-internal.h"
|
||||
#include "nm-glib-aux/nm-dedup-multi.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
#include "nm-base/nm-ethtool-utils-base.h"
|
||||
|
||||
#include "test-general-enums.h"
|
||||
|
||||
|
@ -74,6 +76,12 @@ G_STATIC_ASSERT(sizeof(bool) <= sizeof(int));
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* NM_UTILS_HWADDR_LEN_MAX is public API of libnm(-core) and _NM_UTILS_HWADDR_LEN_MAX
|
||||
* is internal API. They are the same, but the latter can be used without including libnm-core. */
|
||||
G_STATIC_ASSERT(NM_UTILS_HWADDR_LEN_MAX == _NM_UTILS_HWADDR_LEN_MAX);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_nm_ascii_spaces(void)
|
||||
{
|
||||
|
@ -97,6 +105,57 @@ test_nm_ascii_spaces(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_wired_wake_on_lan_enum(void)
|
||||
{
|
||||
nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL;
|
||||
gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL);
|
||||
guint i;
|
||||
|
||||
G_STATIC_ASSERT_EXPR(sizeof(NMSettingWiredWakeOnLan) == sizeof(_NMSettingWiredWakeOnLan));
|
||||
G_STATIC_ASSERT_EXPR(sizeof(NMSettingWiredWakeOnLan) < sizeof(gint64));
|
||||
|
||||
G_STATIC_ASSERT_EXPR(sizeof(NMSettingWiredWakeOnLan) < sizeof(gint64));
|
||||
g_assert((((gint64)((NMSettingWiredWakeOnLan) -1)) < 0)
|
||||
== (((gint64)((_NMSettingWiredWakeOnLan) -1)) < 0));
|
||||
|
||||
#define _E(n) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
G_STATIC_ASSERT_EXPR(n == (gint64) _##n); \
|
||||
G_STATIC_ASSERT_EXPR(_##n == (gint64) n); \
|
||||
g_assert(_##n == _NM_SETTING_WIRED_WAKE_ON_LAN_CAST(n)); \
|
||||
if (!g_hash_table_add(vals, GUINT_TO_POINTER(n))) \
|
||||
g_assert_not_reached(); \
|
||||
} \
|
||||
G_STMT_END
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_NONE);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_PHY);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_ARP);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_ALL);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE);
|
||||
_E(NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS);
|
||||
#undef _E
|
||||
|
||||
flags_class = G_FLAGS_CLASS(g_type_class_ref(NM_TYPE_SETTING_WIRED_WAKE_ON_LAN));
|
||||
for (i = 0; i < flags_class->n_values; i++) {
|
||||
const GFlagsValue *value = &flags_class->values[i];
|
||||
|
||||
if (!g_hash_table_contains(vals, GUINT_TO_POINTER(value->value))) {
|
||||
g_error("The enum value %s from NMSettingWiredWakeOnLan is not checked for "
|
||||
"_NMSettingWiredWakeOnLan",
|
||||
value->value_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _nm_packed {
|
||||
int v0;
|
||||
char v1;
|
||||
|
@ -1227,7 +1286,7 @@ _dedup_obj_destroy(NMDedupMultiObj *obj)
|
|||
{
|
||||
DedupObj *o = (DedupObj *) obj;
|
||||
|
||||
nm_assert(o->parent._ref_count == 0);
|
||||
g_assert(o->parent._ref_count == 0);
|
||||
o->parent._ref_count = 1;
|
||||
o = _dedup_obj_assert(obj);
|
||||
g_slice_free(DedupObj, o);
|
||||
|
@ -10222,6 +10281,7 @@ main(int argc, char **argv)
|
|||
nmtst_init(&argc, &argv, TRUE);
|
||||
|
||||
g_test_add_func("/core/general/test_nm_ascii_spaces", test_nm_ascii_spaces);
|
||||
g_test_add_func("/core/general/test_wired_wake_on_lan_enum", test_wired_wake_on_lan_enum);
|
||||
g_test_add_func("/core/general/test_nm_hash", test_nm_hash);
|
||||
g_test_add_func("/core/general/test_nm_g_slice_free_fcn", test_nm_g_slice_free_fcn);
|
||||
g_test_add_func("/core/general/test_c_list_sort", test_c_list_sort);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <net/if.h>
|
||||
|
||||
#include "nm-glib-aux/nm-json-aux.h"
|
||||
#include "nm-base/nm-ethtool-utils-base.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "nm-device.h"
|
||||
#include "nm-dhcp-config.h"
|
||||
#include "nm-enum-types.h"
|
||||
#include "nm-ethtool-utils.h"
|
||||
#include "nm-ip-config.h"
|
||||
#include "nm-keyfile.h"
|
||||
#include "nm-object.h"
|
||||
|
|
|
@ -51,6 +51,7 @@ libnm_headers = files(
|
|||
'nm-device-wpan.h',
|
||||
'nm-device.h',
|
||||
'nm-dhcp-config.h',
|
||||
'nm-ethtool-utils.h',
|
||||
'nm-ip-config.h',
|
||||
'nm-object.h',
|
||||
'nm-remote-connection.h',
|
||||
|
|
100
libnm/nm-ethtool-utils.h
Normal file
100
libnm/nm-ethtool-utils.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
/*
|
||||
* Copyright (C) 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_ETHTOOL_UTILS_H__
|
||||
#define __NM_ETHTOOL_UTILS_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_ESP_HW_OFFLOAD "feature-esp-hw-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_ESP_TX_CSUM_HW_OFFLOAD "feature-esp-tx-csum-hw-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_FCOE_MTU "feature-fcoe-mtu"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_GRO "feature-gro"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_GSO "feature-gso"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_HIGHDMA "feature-highdma"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_HW_TC_OFFLOAD "feature-hw-tc-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_L2_FWD_OFFLOAD "feature-l2-fwd-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_LOOPBACK "feature-loopback"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_LRO "feature-lro"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_NTUPLE "feature-ntuple"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX "feature-rx"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RXHASH "feature-rxhash"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RXVLAN "feature-rxvlan"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_ALL "feature-rx-all"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_FCS "feature-rx-fcs"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_GRO_HW "feature-rx-gro-hw"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_UDP_TUNNEL_PORT_OFFLOAD "feature-rx-udp_tunnel-port-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_VLAN_FILTER "feature-rx-vlan-filter"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_VLAN_STAG_FILTER "feature-rx-vlan-stag-filter"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_RX_VLAN_STAG_HW_PARSE "feature-rx-vlan-stag-hw-parse"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_SG "feature-sg"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TLS_HW_RECORD "feature-tls-hw-record"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TLS_HW_TX_OFFLOAD "feature-tls-hw-tx-offload"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TSO "feature-tso"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX "feature-tx"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TXVLAN "feature-txvlan"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_FCOE_CRC "feature-tx-checksum-fcoe-crc"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_IPV4 "feature-tx-checksum-ipv4"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_IPV6 "feature-tx-checksum-ipv6"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_IP_GENERIC "feature-tx-checksum-ip-generic"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_CHECKSUM_SCTP "feature-tx-checksum-sctp"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_ESP_SEGMENTATION "feature-tx-esp-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_FCOE_SEGMENTATION "feature-tx-fcoe-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_GRE_CSUM_SEGMENTATION "feature-tx-gre-csum-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_GRE_SEGMENTATION "feature-tx-gre-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_GSO_PARTIAL "feature-tx-gso-partial"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_GSO_ROBUST "feature-tx-gso-robust"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_IPXIP4_SEGMENTATION "feature-tx-ipxip4-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_IPXIP6_SEGMENTATION "feature-tx-ipxip6-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_NOCACHE_COPY "feature-tx-nocache-copy"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_SCATTER_GATHER "feature-tx-scatter-gather"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_SCATTER_GATHER_FRAGLIST "feature-tx-scatter-gather-fraglist"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_SCTP_SEGMENTATION "feature-tx-sctp-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_TCP6_SEGMENTATION "feature-tx-tcp6-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_TCP_ECN_SEGMENTATION "feature-tx-tcp-ecn-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_TCP_MANGLEID_SEGMENTATION \
|
||||
"feature-tx-tcp-mangleid-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_TCP_SEGMENTATION "feature-tx-tcp-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_UDP_SEGMENTATION "feature-tx-udp-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_UDP_TNL_CSUM_SEGMENTATION \
|
||||
"feature-tx-udp_tnl-csum-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_UDP_TNL_SEGMENTATION "feature-tx-udp_tnl-segmentation"
|
||||
#define NM_ETHTOOL_OPTNAME_FEATURE_TX_VLAN_STAG_HW_INSERT "feature-tx-vlan-stag-hw-insert"
|
||||
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_ADAPTIVE_RX "coalesce-adaptive-rx"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_ADAPTIVE_TX "coalesce-adaptive-tx"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_PKT_RATE_HIGH "coalesce-pkt-rate-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_PKT_RATE_LOW "coalesce-pkt-rate-low"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES "coalesce-rx-frames"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES_HIGH "coalesce-rx-frames-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES_IRQ "coalesce-rx-frames-irq"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_FRAMES_LOW "coalesce-rx-frames-low"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_USECS "coalesce-rx-usecs"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_USECS_HIGH "coalesce-rx-usecs-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_USECS_IRQ "coalesce-rx-usecs-irq"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_RX_USECS_LOW "coalesce-rx-usecs-low"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_SAMPLE_INTERVAL "coalesce-sample-interval"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_STATS_BLOCK_USECS "coalesce-stats-block-usecs"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES "coalesce-tx-frames"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES_HIGH "coalesce-tx-frames-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES_IRQ "coalesce-tx-frames-irq"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_FRAMES_LOW "coalesce-tx-frames-low"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS "coalesce-tx-usecs"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS_HIGH "coalesce-tx-usecs-high"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS_IRQ "coalesce-tx-usecs-irq"
|
||||
#define NM_ETHTOOL_OPTNAME_COALESCE_TX_USECS_LOW "coalesce-tx-usecs-low"
|
||||
|
||||
#define NM_ETHTOOL_OPTNAME_RING_RX "ring-rx"
|
||||
#define NM_ETHTOOL_OPTNAME_RING_RX_JUMBO "ring-rx-jumbo"
|
||||
#define NM_ETHTOOL_OPTNAME_RING_RX_MINI "ring-rx-mini"
|
||||
#define NM_ETHTOOL_OPTNAME_RING_TX "ring-tx"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_ETHTOOL_UTILS_H__ */
|
|
@ -147,6 +147,7 @@ libnm/nm-vpn-plugin-old.c
|
|||
libnm/nm-vpn-service-plugin.c
|
||||
data/org.freedesktop.NetworkManager.policy.in.in
|
||||
shared/nm-glib-aux/nm-shared-utils.c
|
||||
shared/nm-log-core/nm-logging.c
|
||||
src/NetworkManagerUtils.c
|
||||
src/main.c
|
||||
src/main-utils.c
|
||||
|
@ -179,7 +180,6 @@ src/devices/wifi/nm-wifi-utils.c
|
|||
src/devices/wwan/nm-modem-broadband.c
|
||||
src/nm-config.c
|
||||
src/nm-iface-helper.c
|
||||
src/nm-logging.c
|
||||
src/nm-manager.c
|
||||
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
|
||||
src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
|
||||
|
|
108
shared/README.md
Normal file
108
shared/README.md
Normal file
|
@ -0,0 +1,108 @@
|
|||
The "shared/" Directory
|
||||
=======================
|
||||
|
||||
For NetworkManager we place helper/utility code under "shared/"
|
||||
in static libraries. The idea is to avoid code duplication but also
|
||||
provide high quality helper functions that simplify the higher layers.
|
||||
In NetworkManager there are complicated parts, for example "src/nm-manager.c"
|
||||
is huge. On the other hand, this helper code should be simple and easy
|
||||
to understand, so that we can build more complex code on top of it.
|
||||
|
||||
As we statically link them into our binaries, they are all inherently
|
||||
internal API, that means they cannot be part of libnm's (libnm-core's) public API.
|
||||
It also means that their API/ABI is not stable.
|
||||
|
||||
We don't care these libraries to be minimal and contain only symbols that are
|
||||
used by all users. Instead, we expect the linker to throw away unused symbols.
|
||||
We achieve this by having a symbol versioning file to hide internal symbols
|
||||
(which gives the linker a possibility to remove them if they are unused) and
|
||||
compiling with LTO or `"-Wl,--gc-sections"`. Let the tool solve this and not
|
||||
manual organization.
|
||||
|
||||
Hence these libraries (and their content) are structured this way to satisfy
|
||||
the following questions:
|
||||
|
||||
1) which dependencies (libraries) do they have? That determines which
|
||||
other libraries can use it. For example:
|
||||
|
||||
- "shared/nm-std-aux" and "shared/nm-glib-aux" both provide general
|
||||
purpose helpers, the difference is that the former has no dependency
|
||||
on glib2 library. Both these libraries are a basic dependency for
|
||||
many other parts of the code.
|
||||
|
||||
- "shared/nm-udev-aux" has a dependency on libudev, it thus cannot
|
||||
be in "shared/nm-glib-aux".
|
||||
|
||||
- client code also has a glib2 dependency. That means it can link with
|
||||
"shared/nm-std-aux" and "shared/nm-glib-aux", but must not link
|
||||
with "shared/nm-udev-aux" (as it has no direct udev dependenct --
|
||||
although clients get it indirectly because libnm already requires
|
||||
it).
|
||||
|
||||
2) what is their overall purpose? As said, we rely on the linker to
|
||||
prune unused symbols. But in a few cases we avoid to merge different
|
||||
code in the same library. For example:
|
||||
|
||||
- "shared/nm-glib-aux" and "shared/nm-base" both only have a
|
||||
glib2 dependency. Hence, they could be merged. However we
|
||||
don't do that because "shared/nm-base" is more about NetworkManager
|
||||
specific code, while "shared/nm-glib-aux" is about general
|
||||
purpose helpers.
|
||||
|
||||
3) some of these libraries are forked from an upstream. They are kept
|
||||
separate so that we can re-import future upstream versions.
|
||||
|
||||
Detail
|
||||
======
|
||||
|
||||
- `shared/c-list`
|
||||
- `shared/c-rbtree`
|
||||
- `shared/c-siphash`
|
||||
- `shared/c-stdoux`
|
||||
- `shared/n-acd`
|
||||
- `shared/n-dhcp4`
|
||||
|
||||
These are forked from upstream and imported with git-subtree. They
|
||||
in general only have a libc dependency (or dependencies between each
|
||||
other).
|
||||
|
||||
- `shared/nm-std-aux`
|
||||
|
||||
This contains helper code with only a libc dependency.
|
||||
Almost all C code depends on this library.
|
||||
|
||||
- `shared/nm-glib-aux`
|
||||
|
||||
Like "shared/nm-std-aux" but also has a glib2 dependency.
|
||||
Almost all glib2 code depends on this library.
|
||||
|
||||
- `shared/nm-udev/aux`
|
||||
|
||||
Like "shared/nm-glib-aux" but also has a libudev dependency. It
|
||||
has code related to libudev.
|
||||
|
||||
- `shared/systemd`
|
||||
|
||||
These are forked from upstream systemd and imported with a script.
|
||||
Under "shared/systemd/src" we try to keep the sources as close to
|
||||
the original as possible. There is also some adapter code to make
|
||||
it useable for us. It has a dependency on "shared/nm-glib-aux"
|
||||
and will need a logging implementation for "shared/nm-glib-aux/nm-logging-fwd.h".
|
||||
|
||||
- `shared/nm-base`
|
||||
|
||||
Depends on "shared/nm-glib-aux" and glib2 but it provides helper code
|
||||
that more about NetworkManager specifc things.
|
||||
|
||||
- `shared/nm-log-core`
|
||||
|
||||
This is the logging implementation as used by NetworkManager core ("src/").
|
||||
It is also a dependency for "shared/nm-platform".
|
||||
|
||||
- `shared/nm-platform`
|
||||
|
||||
Platform implementation. It depends on "shared/nm-log-core", "shared/nm-base"
|
||||
and "shared/nm-glib-aux".
|
||||
|
||||
- Other than that, there are still a few unorganized files/directories here.
|
||||
These should be cleaned up.
|
|
@ -182,6 +182,66 @@ libnm_udev_aux_dep = declare_dependency(
|
|||
link_with: libnm_udev_aux,
|
||||
)
|
||||
|
||||
libnm_base = static_library(
|
||||
'nm-base',
|
||||
sources: files(
|
||||
'nm-base/nm-ethtool-base.c',
|
||||
),
|
||||
dependencies: libnm_utils_base_dep,
|
||||
c_args: c_flags,
|
||||
)
|
||||
|
||||
libnm_base_dep = declare_dependency(
|
||||
include_directories: shared_inc,
|
||||
dependencies: libnm_utils_base_dep,
|
||||
link_with: libnm_base,
|
||||
)
|
||||
|
||||
libnm_log_core = static_library(
|
||||
'nm-log-core',
|
||||
sources: 'nm-log-core/nm-logging.c',
|
||||
dependencies: [
|
||||
glib_nm_default_dep,
|
||||
libsystemd_dep,
|
||||
],
|
||||
c_args: [
|
||||
'-DG_LOG_DOMAIN="NetworkManager"',
|
||||
'-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB)',
|
||||
],
|
||||
)
|
||||
|
||||
libnm_log_core_dep = declare_dependency(
|
||||
include_directories: shared_inc,
|
||||
dependencies: [
|
||||
libnm_utils_base_dep,
|
||||
],
|
||||
link_with: libnm_log_core,
|
||||
)
|
||||
|
||||
libnm_platform = static_library(
|
||||
'nm-platform',
|
||||
sources: [
|
||||
'nm-platform/nm-netlink.c',
|
||||
'nm-platform/nm-platform-utils.c',
|
||||
'nm-platform/nmp-netns.c',
|
||||
],
|
||||
dependencies: [
|
||||
glib_nm_default_dep,
|
||||
],
|
||||
c_args: [
|
||||
'-DG_LOG_DOMAIN="NetworkManager"',
|
||||
'-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB)',
|
||||
],
|
||||
)
|
||||
|
||||
libnm_platform_dep = declare_dependency(
|
||||
include_directories: shared_inc,
|
||||
dependencies: [
|
||||
libnm_utils_base_dep,
|
||||
],
|
||||
link_with: libnm_platform,
|
||||
)
|
||||
|
||||
sources = files(
|
||||
'systemd/nm-sd-utils-shared.c',
|
||||
'systemd/src/basic/alloc-util.c',
|
||||
|
@ -257,4 +317,5 @@ libnm_systemd_logging_stub = static_library(
|
|||
|
||||
if enable_tests
|
||||
subdir('nm-glib-aux/tests')
|
||||
subdir('nm-platform/tests')
|
||||
endif
|
||||
|
|
|
@ -3,8 +3,13 @@
|
|||
* Copyright (C) 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_ETHTOOL_UTILS_H__
|
||||
#define __NM_ETHTOOL_UTILS_H__
|
||||
#ifndef __NM_LIBNM_BASE_H__
|
||||
#define __NM_LIBNM_BASE_H__
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* this must be the same as NM_UTILS_HWADDR_LEN_MAX from libnm. */
|
||||
#define _NM_UTILS_HWADDR_LEN_MAX 20
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -119,28 +124,8 @@ typedef enum {
|
|||
NM_ETHTOOL_TYPE_RING,
|
||||
} NMEthtoolType;
|
||||
|
||||
typedef struct {
|
||||
const char *optname;
|
||||
NMEthtoolID id;
|
||||
} NMEthtoolData;
|
||||
|
||||
extern const NMEthtoolData *const nm_ethtool_data[_NM_ETHTOOL_ID_NUM + 1];
|
||||
|
||||
const NMEthtoolData *nm_ethtool_data_get_by_optname(const char *optname);
|
||||
|
||||
NMEthtoolType nm_ethtool_id_to_type(NMEthtoolID id);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static inline NMEthtoolID
|
||||
nm_ethtool_id_get_by_name(const char *optname)
|
||||
{
|
||||
const NMEthtoolData *d;
|
||||
|
||||
d = nm_ethtool_data_get_by_optname(optname);
|
||||
return d ? d->id : NM_ETHTOOL_ID_UNKNOWN;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_ethtool_id_is_feature(NMEthtoolID id)
|
||||
{
|
||||
|
@ -159,6 +144,61 @@ nm_ethtool_id_is_ring(NMEthtoolID id)
|
|||
return id >= _NM_ETHTOOL_ID_RING_FIRST && id <= _NM_ETHTOOL_ID_RING_LAST;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_NONE = 0,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_PHY = 0x2,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST = 0x4,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST = 0x8,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST = 0x10,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_ARP = 0x20,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC = 0x40,
|
||||
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_ALL = 0x7E,
|
||||
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT = 0x1,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE = 0x8000,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS = 0x8001,
|
||||
} _NMSettingWiredWakeOnLan;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
/* In priority order; higher number == higher priority */
|
||||
|
||||
NM_IP_CONFIG_SOURCE_UNKNOWN = 0,
|
||||
|
||||
/* for routes, the source is mapped to the uint8 field rtm_protocol.
|
||||
* Reserve the range [1,0x100] for native RTPROT values. */
|
||||
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_UNSPEC = 1 + 0,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_REDIRECT = 1 + 1,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_KERNEL = 1 + 2,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_BOOT = 1 + 3,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_STATIC = 1 + 4,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_RA = 1 + 9,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_DHCP = 1 + 16,
|
||||
_NM_IP_CONFIG_SOURCE_RTPROT_LAST = 1 + 0xFF,
|
||||
|
||||
NM_IP_CONFIG_SOURCE_KERNEL,
|
||||
NM_IP_CONFIG_SOURCE_SHARED,
|
||||
NM_IP_CONFIG_SOURCE_IP4LL,
|
||||
NM_IP_CONFIG_SOURCE_IP6LL,
|
||||
NM_IP_CONFIG_SOURCE_PPP,
|
||||
NM_IP_CONFIG_SOURCE_WWAN,
|
||||
NM_IP_CONFIG_SOURCE_VPN,
|
||||
NM_IP_CONFIG_SOURCE_DHCP,
|
||||
NM_IP_CONFIG_SOURCE_NDISC,
|
||||
NM_IP_CONFIG_SOURCE_USER,
|
||||
} NMIPConfigSource;
|
||||
|
||||
static inline gboolean
|
||||
NM_IS_IP_CONFIG_SOURCE_RTPROT(NMIPConfigSource source)
|
||||
{
|
||||
return source > NM_IP_CONFIG_SOURCE_UNKNOWN && source <= _NM_IP_CONFIG_SOURCE_RTPROT_LAST;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#endif /* __NM_ETHTOOL_UTILS_H__ */
|
||||
#endif /* __NM_LIBNM_BASE_H__ */
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-ethtool-utils.h"
|
||||
#include "nm-ethtool-base.h"
|
||||
|
||||
#include "nm-setting-ethtool.h"
|
||||
#include "nm-ethtool-utils-base.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
37
shared/nm-base/nm-ethtool-base.h
Normal file
37
shared/nm-base/nm-ethtool-base.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
/*
|
||||
* Copyright (C) 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_ETHTOOL_BASE_H__
|
||||
#define __NM_ETHTOOL_BASE_H__
|
||||
|
||||
#include "nm-base/nm-base.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
const char *optname;
|
||||
NMEthtoolID id;
|
||||
} NMEthtoolData;
|
||||
|
||||
extern const NMEthtoolData *const nm_ethtool_data[_NM_ETHTOOL_ID_NUM + 1];
|
||||
|
||||
const NMEthtoolData *nm_ethtool_data_get_by_optname(const char *optname);
|
||||
|
||||
NMEthtoolType nm_ethtool_id_to_type(NMEthtoolID id);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static inline NMEthtoolID
|
||||
nm_ethtool_id_get_by_name(const char *optname)
|
||||
{
|
||||
const NMEthtoolData *d;
|
||||
|
||||
d = nm_ethtool_data_get_by_optname(optname);
|
||||
return d ? d->id : NM_ETHTOOL_ID_UNKNOWN;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#endif /* __NM_ETHTOOL_BASE_H__ */
|
1
shared/nm-base/nm-ethtool-utils-base.h
Symbolic link
1
shared/nm-base/nm-ethtool-utils-base.h
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../libnm/nm-ethtool-utils.h
|
|
@ -281,7 +281,7 @@ _nm_g_return_if_fail_warning(const char *log_domain, const char *file, int line)
|
|||
#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON
|
||||
#include "nm-core-types.h"
|
||||
#include "nm-types.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-log-core/nm-logging.h"
|
||||
#endif
|
||||
|
||||
#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE
|
||||
|
|
|
@ -2267,6 +2267,8 @@ _nm_utils_ascii_str_to_bool(const char *str, int default_value)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NM_CACHED_QUARK_FCN("nm-manager-error-quark", nm_manager_error_quark);
|
||||
|
||||
NM_CACHED_QUARK_FCN("nm-utils-error-quark", nm_utils_error_quark);
|
||||
|
||||
void
|
||||
|
@ -5136,6 +5138,31 @@ nm_utils_g_main_context_create_integrate_source(GMainContext *inner_context)
|
|||
return &ctx_src->source;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_utils_ifname_cpy(char *dst, const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_if_fail(dst);
|
||||
g_return_if_fail(name && name[0]);
|
||||
|
||||
nm_assert(nm_utils_ifname_valid_kernel(name, NULL));
|
||||
|
||||
/* ensures NUL padding of the entire IFNAMSIZ buffer. */
|
||||
|
||||
for (i = 0; i < (int) IFNAMSIZ && name[i] != '\0'; i++)
|
||||
dst[i] = name[i];
|
||||
|
||||
nm_assert(name[i] == '\0');
|
||||
|
||||
for (; i < (int) IFNAMSIZ; i++)
|
||||
dst[i] = '\0';
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_utils_ifname_valid_kernel(const char *name, GError **error)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,18 @@
|
|||
|
||||
#include <netinet/in.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* An optional boolean (like NMTernary, with identical numerical
|
||||
* enum values). Note that this enum type is _nm_packed! */
|
||||
typedef enum _nm_packed {
|
||||
NM_OPTION_BOOL_DEFAULT = -1,
|
||||
NM_OPTION_BOOL_FALSE = 0,
|
||||
NM_OPTION_BOOL_TRUE = 1,
|
||||
} NMOptionBool;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline gboolean
|
||||
nm_is_ascii(char ch)
|
||||
{
|
||||
|
@ -982,6 +994,12 @@ typedef enum {
|
|||
#define NM_UTILS_ERROR (nm_utils_error_quark())
|
||||
GQuark nm_utils_error_quark(void);
|
||||
|
||||
GQuark nm_manager_error_quark(void);
|
||||
#define _NM_MANAGER_ERROR (nm_manager_error_quark())
|
||||
|
||||
#define _NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL 10
|
||||
#define _NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN 11
|
||||
|
||||
void nm_utils_error_set_cancelled(GError **error, gboolean is_disposing, const char *instance_name);
|
||||
|
||||
static inline GError *
|
||||
|
@ -2092,6 +2110,24 @@ _nm_utils_hwaddr_aton(const char *asc, gpointer buffer, gsize buffer_length, gsi
|
|||
out_length);
|
||||
}
|
||||
|
||||
static inline guint8 *
|
||||
_nm_utils_hwaddr_aton_exact(const char *asc, gpointer buffer, gsize buffer_length)
|
||||
{
|
||||
g_return_val_if_fail(asc, NULL);
|
||||
g_return_val_if_fail(buffer, NULL);
|
||||
g_return_val_if_fail(buffer_length > 0, NULL);
|
||||
|
||||
return nm_utils_hexstr2bin_full(asc,
|
||||
FALSE,
|
||||
TRUE,
|
||||
FALSE,
|
||||
":-",
|
||||
buffer_length,
|
||||
buffer,
|
||||
buffer_length,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
_nm_utils_hwaddr_ntoa(gconstpointer addr,
|
||||
gsize addr_len,
|
||||
|
@ -2261,6 +2297,8 @@ void nm_indirect_g_free(gpointer arg);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void nm_utils_ifname_cpy(char *dst, const char *name);
|
||||
|
||||
typedef enum {
|
||||
NMU_IFACE_ANY,
|
||||
NMU_IFACE_KERNEL,
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include "nm-glib-aux/nm-logging-base.h"
|
||||
#include "nm-glib-aux/nm-time-utils.h"
|
||||
#include "nm-errors.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -247,8 +246,8 @@ match_log_level(const char *level, NMLogLevel *out_level, GError **error)
|
|||
return TRUE;
|
||||
|
||||
g_set_error(error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL,
|
||||
_NM_MANAGER_ERROR,
|
||||
_NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL,
|
||||
_("Unknown log level '%s'"),
|
||||
level);
|
||||
return FALSE;
|
||||
|
@ -355,8 +354,8 @@ nm_logging_setup(const char *level, const char *domains, char **bad_domains, GEr
|
|||
if (!bits) {
|
||||
if (!bad_domains) {
|
||||
g_set_error(error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN,
|
||||
_NM_MANAGER_ERROR,
|
||||
_NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN,
|
||||
_("Unknown log domain '%s'"),
|
||||
s);
|
||||
return FALSE;
|
|
@ -18,11 +18,10 @@
|
|||
#include <fcntl.h>
|
||||
#include <libudev.h>
|
||||
|
||||
#include "nm-utils.h"
|
||||
#include "nm-setting-wired.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
#include "nm-log-core/nm-logging.h"
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
/*****************************************************************************/
|
||||
|
||||
#define ONOFF(bool_val) ((bool_val) ? "on" : "off")
|
||||
|
||||
|
@ -52,6 +51,15 @@ nmp_utils_if_nametoindex(const char *ifname)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NM_UTILS_LOOKUP_STR_DEFINE(nm_platform_link_duplex_type_to_string,
|
||||
NMPlatformLinkDuplexType,
|
||||
NM_UTILS_LOOKUP_DEFAULT_WARN(NULL),
|
||||
NM_UTILS_LOOKUP_STR_ITEM(NM_PLATFORM_LINK_DUPLEX_UNKNOWN, "unknown"),
|
||||
NM_UTILS_LOOKUP_STR_ITEM(NM_PLATFORM_LINK_DUPLEX_FULL, "full"),
|
||||
NM_UTILS_LOOKUP_STR_ITEM(NM_PLATFORM_LINK_DUPLEX_HALF, "half"), );
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
const int ifindex;
|
||||
|
@ -686,8 +694,8 @@ gboolean
|
|||
nmp_utils_ethtool_set_features(
|
||||
int ifindex,
|
||||
const NMEthtoolFeatureStates *features,
|
||||
const NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
||||
gboolean do_set /* or reset */)
|
||||
const NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
||||
gboolean do_set /* or reset */)
|
||||
{
|
||||
nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex);
|
||||
gs_free struct ethtool_sfeatures * sfeatures_free = NULL;
|
||||
|
@ -697,7 +705,7 @@ nmp_utils_ethtool_set_features(
|
|||
guint i, j;
|
||||
struct {
|
||||
const NMEthtoolFeatureState *f_state;
|
||||
NMTernary requested;
|
||||
NMOptionBool requested;
|
||||
} set_states[N_ETHTOOL_KERNEL_FEATURES];
|
||||
guint set_states_n = 0;
|
||||
gboolean success = TRUE;
|
||||
|
@ -711,7 +719,7 @@ nmp_utils_ethtool_set_features(
|
|||
for (i = 0; i < _NM_ETHTOOL_ID_FEATURE_NUM; i++) {
|
||||
const NMEthtoolFeatureState *const *states_indexed;
|
||||
|
||||
if (requested[i] == NM_TERNARY_DEFAULT)
|
||||
if (requested[i] == NM_OPTION_BOOL_DEFAULT)
|
||||
continue;
|
||||
|
||||
if (!(states_indexed = features->states_indexed[i])) {
|
||||
|
@ -742,7 +750,7 @@ nmp_utils_ethtool_set_features(
|
|||
do_set ? "set" : "reset",
|
||||
nm_ethtool_data[i + _NM_ETHTOOL_ID_FEATURE_FIRST]->optname,
|
||||
s->info->kernel_names[s->idx_kernel_name],
|
||||
ONOFF(do_set ? requested[i] == NM_TERNARY_TRUE : s->active),
|
||||
ONOFF(do_set ? requested[i] == NM_OPTION_BOOL_TRUE : s->active),
|
||||
_ethtool_feature_state_to_string(sbuf,
|
||||
sizeof(sbuf),
|
||||
s,
|
||||
|
@ -757,14 +765,14 @@ nmp_utils_ethtool_set_features(
|
|||
do_set ? "set" : "reset",
|
||||
nm_ethtool_data[i + _NM_ETHTOOL_ID_FEATURE_FIRST]->optname,
|
||||
s->info->kernel_names[s->idx_kernel_name],
|
||||
ONOFF(do_set ? requested[i] == NM_TERNARY_TRUE : s->active),
|
||||
ONOFF(do_set ? requested[i] == NM_OPTION_BOOL_TRUE : s->active),
|
||||
_ethtool_feature_state_to_string(sbuf,
|
||||
sizeof(sbuf),
|
||||
s,
|
||||
do_set ? " currently:" : " before:"));
|
||||
|
||||
if (do_set && (!s->available || s->never_changed)
|
||||
&& (s->active != (requested[i] == NM_TERNARY_TRUE))) {
|
||||
&& (s->active != (requested[i] == NM_OPTION_BOOL_TRUE))) {
|
||||
/* we request to change a flag which kernel reported as fixed.
|
||||
* While the ethtool operation will silently succeed, mark the request
|
||||
* as failure. */
|
||||
|
@ -804,7 +812,7 @@ nmp_utils_ethtool_set_features(
|
|||
sfeatures->features[i_block].valid |= i_flag;
|
||||
|
||||
if (do_set)
|
||||
is_requested = (set_states[i].requested == NM_TERNARY_TRUE);
|
||||
is_requested = (set_states[i].requested == NM_OPTION_BOOL_TRUE);
|
||||
else
|
||||
is_requested = s->active;
|
||||
|
||||
|
@ -1116,10 +1124,10 @@ nmp_utils_ethtool_get_permanent_address(int ifindex, guint8 *buf, size_t *length
|
|||
{
|
||||
struct {
|
||||
struct ethtool_perm_addr e;
|
||||
guint8 _extra_data[NM_UTILS_HWADDR_LEN_MAX + 1];
|
||||
guint8 _extra_data[_NM_UTILS_HWADDR_LEN_MAX + 1];
|
||||
} edata = {
|
||||
.e.cmd = ETHTOOL_GPERMADDR,
|
||||
.e.size = NM_UTILS_HWADDR_LEN_MAX,
|
||||
.e.size = _NM_UTILS_HWADDR_LEN_MAX,
|
||||
};
|
||||
const guint8 *pdata;
|
||||
|
||||
|
@ -1130,7 +1138,7 @@ nmp_utils_ethtool_get_permanent_address(int ifindex, guint8 *buf, size_t *length
|
|||
if (_ethtool_call_once(ifindex, &edata, sizeof(edata)) < 0)
|
||||
return FALSE;
|
||||
|
||||
if (edata.e.size > NM_UTILS_HWADDR_LEN_MAX)
|
||||
if (edata.e.size > _NM_UTILS_HWADDR_LEN_MAX)
|
||||
return FALSE;
|
||||
if (edata.e.size < 1)
|
||||
return FALSE;
|
||||
|
@ -1405,9 +1413,9 @@ nmp_utils_ethtool_set_link_settings(int ifindex,
|
|||
}
|
||||
|
||||
gboolean
|
||||
nmp_utils_ethtool_set_wake_on_lan(int ifindex,
|
||||
NMSettingWiredWakeOnLan wol,
|
||||
const char * wol_password)
|
||||
nmp_utils_ethtool_set_wake_on_lan(int ifindex,
|
||||
_NMSettingWiredWakeOnLan wol,
|
||||
const char * wol_password)
|
||||
{
|
||||
struct ethtool_wolinfo wol_info = {
|
||||
.cmd = ETHTOOL_SWOL,
|
||||
|
@ -1416,7 +1424,7 @@ nmp_utils_ethtool_set_wake_on_lan(int ifindex,
|
|||
|
||||
g_return_val_if_fail(ifindex > 0, FALSE);
|
||||
|
||||
if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE)
|
||||
if (wol == _NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE)
|
||||
return TRUE;
|
||||
|
||||
nm_log_dbg(LOGD_PLATFORM,
|
||||
|
@ -1425,21 +1433,21 @@ nmp_utils_ethtool_set_wake_on_lan(int ifindex,
|
|||
(unsigned) wol,
|
||||
wol_password);
|
||||
|
||||
if (NM_FLAGS_HAS(wol, NM_SETTING_WIRED_WAKE_ON_LAN_PHY))
|
||||
if (NM_FLAGS_HAS(wol, _NM_SETTING_WIRED_WAKE_ON_LAN_PHY))
|
||||
wol_info.wolopts |= WAKE_PHY;
|
||||
if (NM_FLAGS_HAS(wol, NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST))
|
||||
if (NM_FLAGS_HAS(wol, _NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST))
|
||||
wol_info.wolopts |= WAKE_UCAST;
|
||||
if (NM_FLAGS_HAS(wol, NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST))
|
||||
if (NM_FLAGS_HAS(wol, _NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST))
|
||||
wol_info.wolopts |= WAKE_MCAST;
|
||||
if (NM_FLAGS_HAS(wol, NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST))
|
||||
if (NM_FLAGS_HAS(wol, _NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST))
|
||||
wol_info.wolopts |= WAKE_BCAST;
|
||||
if (NM_FLAGS_HAS(wol, NM_SETTING_WIRED_WAKE_ON_LAN_ARP))
|
||||
if (NM_FLAGS_HAS(wol, _NM_SETTING_WIRED_WAKE_ON_LAN_ARP))
|
||||
wol_info.wolopts |= WAKE_ARP;
|
||||
if (NM_FLAGS_HAS(wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC))
|
||||
if (NM_FLAGS_HAS(wol, _NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC))
|
||||
wol_info.wolopts |= WAKE_MAGIC;
|
||||
|
||||
if (wol_password) {
|
||||
if (!nm_utils_hwaddr_aton(wol_password, wol_info.sopass, ETH_ALEN)) {
|
||||
if (!_nm_utils_hwaddr_aton_exact(wol_password, wol_info.sopass, ETH_ALEN)) {
|
||||
nm_log_dbg(LOGD_PLATFORM,
|
||||
"ethtool[%d]: couldn't parse Wake-on-LAN password '%s'",
|
||||
ifindex,
|
|
@ -6,9 +6,8 @@
|
|||
#ifndef __NM_PLATFORM_UTILS_H__
|
||||
#define __NM_PLATFORM_UTILS_H__
|
||||
|
||||
#include "nm-platform.h"
|
||||
#include "nm-setting-wired.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-base.h"
|
||||
#include "nm-platform/nmp-base.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -17,9 +16,11 @@ gboolean nmp_utils_ethtool_supports_carrier_detect(int ifindex);
|
|||
gboolean nmp_utils_ethtool_supports_vlans(int ifindex);
|
||||
int nmp_utils_ethtool_get_peer_ifindex(int ifindex);
|
||||
gboolean nmp_utils_ethtool_get_wake_on_lan(int ifindex);
|
||||
gboolean nmp_utils_ethtool_set_wake_on_lan(int ifindex,
|
||||
NMSettingWiredWakeOnLan wol,
|
||||
const char * wol_password);
|
||||
gboolean nmp_utils_ethtool_set_wake_on_lan(int ifindex,
|
||||
_NMSettingWiredWakeOnLan wol,
|
||||
const char * wol_password);
|
||||
|
||||
const char *nm_platform_link_duplex_type_to_string(NMPlatformLinkDuplexType duplex);
|
||||
|
||||
gboolean nmp_utils_ethtool_get_link_settings(int ifindex,
|
||||
gboolean * out_autoneg,
|
||||
|
@ -32,88 +33,20 @@ gboolean nmp_utils_ethtool_set_link_settings(int ifindex,
|
|||
|
||||
gboolean nmp_utils_ethtool_get_permanent_address(int ifindex, guint8 *buf, size_t *length);
|
||||
|
||||
typedef struct {
|
||||
/* We don't want to include <linux/ethtool.h> in header files,
|
||||
* thus create a ABI compatible version of struct ethtool_drvinfo.*/
|
||||
guint32 _private_cmd;
|
||||
char driver[32];
|
||||
char version[32];
|
||||
char fw_version[32];
|
||||
char _private_bus_info[32];
|
||||
char _private_erom_version[32];
|
||||
char _private_reserved2[12];
|
||||
guint32 _private_n_priv_flags;
|
||||
guint32 _private_n_stats;
|
||||
guint32 _private_testinfo_len;
|
||||
guint32 _private_eedump_len;
|
||||
guint32 _private_regdump_len;
|
||||
} NMPUtilsEthtoolDriverInfo;
|
||||
|
||||
gboolean nmp_utils_ethtool_get_driver_info(int ifindex, NMPUtilsEthtoolDriverInfo *data);
|
||||
|
||||
typedef struct {
|
||||
NMEthtoolID ethtool_id;
|
||||
|
||||
guint8 n_kernel_names;
|
||||
|
||||
/* one NMEthtoolID refers to one or more kernel_names. The reason for supporting this complexity
|
||||
* (where one NMSettingEthtool option refers to multiple kernel features) is to follow what
|
||||
* ethtool does, where "tx" is an alias for multiple features. */
|
||||
const char *const *kernel_names;
|
||||
} NMEthtoolFeatureInfo;
|
||||
|
||||
typedef struct {
|
||||
const NMEthtoolFeatureInfo *info;
|
||||
|
||||
guint idx_ss_features;
|
||||
|
||||
/* one NMEthtoolFeatureInfo references one or more kernel_names. This is the index
|
||||
* of the matching info->kernel_names */
|
||||
guint8 idx_kernel_name;
|
||||
|
||||
bool available : 1;
|
||||
bool requested : 1;
|
||||
bool active : 1;
|
||||
bool never_changed : 1;
|
||||
} NMEthtoolFeatureState;
|
||||
|
||||
struct _NMEthtoolFeatureStates {
|
||||
guint n_states;
|
||||
|
||||
guint n_ss_features;
|
||||
|
||||
/* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */
|
||||
const NMEthtoolFeatureState *const *states_indexed[_NM_ETHTOOL_ID_FEATURE_NUM];
|
||||
|
||||
/* the same content, here as a list of n_states entries. */
|
||||
const NMEthtoolFeatureState states_list[];
|
||||
};
|
||||
|
||||
NMEthtoolFeatureStates *nmp_utils_ethtool_get_features(int ifindex);
|
||||
|
||||
gboolean nmp_utils_ethtool_set_features(
|
||||
int ifindex,
|
||||
const NMEthtoolFeatureStates *features,
|
||||
const NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
||||
gboolean do_set /* or reset */);
|
||||
|
||||
struct _NMEthtoolCoalesceState {
|
||||
guint32
|
||||
s[_NM_ETHTOOL_ID_COALESCE_NUM /* indexed by (NMEthtoolID - _NM_ETHTOOL_ID_COALESCE_FIRST) */
|
||||
];
|
||||
};
|
||||
const NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
||||
gboolean do_set /* or reset */);
|
||||
|
||||
gboolean nmp_utils_ethtool_get_coalesce(int ifindex, NMEthtoolCoalesceState *coalesce);
|
||||
|
||||
gboolean nmp_utils_ethtool_set_coalesce(int ifindex, const NMEthtoolCoalesceState *coalesce);
|
||||
|
||||
struct _NMEthtoolRingState {
|
||||
guint32 rx_pending;
|
||||
guint32 rx_mini_pending;
|
||||
guint32 rx_jumbo_pending;
|
||||
guint32 tx_pending;
|
||||
};
|
||||
|
||||
gboolean nmp_utils_ethtool_get_ring(int ifindex, NMEthtoolRingState *ring);
|
||||
|
||||
gboolean nmp_utils_ethtool_set_ring(int ifindex, const NMEthtoolRingState *ring);
|
94
shared/nm-platform/nmp-base.h
Normal file
94
shared/nm-platform/nmp-base.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#ifndef __NMP_FWD_H__
|
||||
#define __NMP_FWD_H__
|
||||
|
||||
#include "nm-base/nm-base.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
NM_PLATFORM_LINK_DUPLEX_UNKNOWN,
|
||||
NM_PLATFORM_LINK_DUPLEX_HALF,
|
||||
NM_PLATFORM_LINK_DUPLEX_FULL,
|
||||
} NMPlatformLinkDuplexType;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
/* We don't want to include <linux/ethtool.h> in header files,
|
||||
* thus create a ABI compatible version of struct ethtool_drvinfo.*/
|
||||
guint32 _private_cmd;
|
||||
char driver[32];
|
||||
char version[32];
|
||||
char fw_version[32];
|
||||
char _private_bus_info[32];
|
||||
char _private_erom_version[32];
|
||||
char _private_reserved2[12];
|
||||
guint32 _private_n_priv_flags;
|
||||
guint32 _private_n_stats;
|
||||
guint32 _private_testinfo_len;
|
||||
guint32 _private_eedump_len;
|
||||
guint32 _private_regdump_len;
|
||||
} NMPUtilsEthtoolDriverInfo;
|
||||
|
||||
typedef struct {
|
||||
NMEthtoolID ethtool_id;
|
||||
|
||||
guint8 n_kernel_names;
|
||||
|
||||
/* one NMEthtoolID refers to one or more kernel_names. The reason for supporting this complexity
|
||||
* (where one NMSettingEthtool option refers to multiple kernel features) is to follow what
|
||||
* ethtool does, where "tx" is an alias for multiple features. */
|
||||
const char *const *kernel_names;
|
||||
} NMEthtoolFeatureInfo;
|
||||
|
||||
typedef struct {
|
||||
const NMEthtoolFeatureInfo *info;
|
||||
|
||||
guint idx_ss_features;
|
||||
|
||||
/* one NMEthtoolFeatureInfo references one or more kernel_names. This is the index
|
||||
* of the matching info->kernel_names */
|
||||
guint8 idx_kernel_name;
|
||||
|
||||
bool available : 1;
|
||||
bool requested : 1;
|
||||
bool active : 1;
|
||||
bool never_changed : 1;
|
||||
} NMEthtoolFeatureState;
|
||||
|
||||
typedef struct {
|
||||
guint n_states;
|
||||
|
||||
guint n_ss_features;
|
||||
|
||||
/* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */
|
||||
const NMEthtoolFeatureState *const *states_indexed[_NM_ETHTOOL_ID_FEATURE_NUM];
|
||||
|
||||
/* the same content, here as a list of n_states entries. */
|
||||
const NMEthtoolFeatureState states_list[];
|
||||
} NMEthtoolFeatureStates;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
guint32
|
||||
s[_NM_ETHTOOL_ID_COALESCE_NUM /* indexed by (NMEthtoolID - _NM_ETHTOOL_ID_COALESCE_FIRST) */
|
||||
];
|
||||
} NMEthtoolCoalesceState;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
guint32 rx_pending;
|
||||
guint32 rx_mini_pending;
|
||||
guint32 rx_jumbo_pending;
|
||||
guint32 tx_pending;
|
||||
} NMEthtoolRingState;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _NMPNetns NMPNetns;
|
||||
|
||||
#endif /* __NMP_FWD_H__ */
|
|
@ -13,6 +13,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "nm-log-core/nm-logging.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* NOTE: NMPNetns and all code used here must be thread-safe! */
|
|
@ -6,6 +6,8 @@
|
|||
#ifndef __NMP_NETNS_UTILS_H__
|
||||
#define __NMP_NETNS_UTILS_H__
|
||||
|
||||
#include "nmp-base.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NMP_TYPE_NETNS (nmp_netns_get_type())
|
||||
|
@ -18,6 +20,7 @@
|
|||
#define NMP_NETNS_FD_NET "fd-net"
|
||||
#define NMP_NETNS_FD_MNT "fd-mnt"
|
||||
|
||||
typedef struct _NMPNetns NMPNetns;
|
||||
typedef struct _NMPNetnsClass NMPNetnsClass;
|
||||
|
||||
GType nmp_netns_get_type(void);
|
21
shared/nm-platform/tests/meson.build
Normal file
21
shared/nm-platform/tests/meson.build
Normal file
|
@ -0,0 +1,21 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
exe = executable(
|
||||
'test-nm-platform',
|
||||
'test-nm-platform.c',
|
||||
c_args: [
|
||||
'-DNETWORKMANAGER_COMPILATION_TEST',
|
||||
'-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG)',
|
||||
],
|
||||
dependencies: [
|
||||
libnm_log_core_dep,
|
||||
libnm_platform_dep,
|
||||
],
|
||||
)
|
||||
|
||||
test(
|
||||
'shared/nm-glib-aux/test-nm-platform',
|
||||
test_script,
|
||||
args: test_args + [exe.full_path()],
|
||||
timeout: default_test_timeout,
|
||||
)
|
118
shared/nm-platform/tests/test-nm-platform.c
Normal file
118
shared/nm-platform/tests/test-nm-platform.c
Normal file
|
@ -0,0 +1,118 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#define NM_TEST_UTILS_NO_LIBNM 1
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-log-core/nm-logging.h"
|
||||
#include "nm-platform/nm-netlink.h"
|
||||
#include "nm-platform/nmp-netns.h"
|
||||
|
||||
#include "nm-utils/nm-test-utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
_nm_logging_clear_platform_logging_cache(void)
|
||||
{
|
||||
/* this symbols is required by nm-log-core library. */
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_use_symbols(void)
|
||||
{
|
||||
static void (*const SYMBOLS[])(void) = {
|
||||
(void (*)(void)) nl_nlmsghdr_to_str,
|
||||
(void (*)(void)) nlmsg_hdr,
|
||||
(void (*)(void)) nlmsg_reserve,
|
||||
(void (*)(void)) nla_reserve,
|
||||
(void (*)(void)) nlmsg_alloc_size,
|
||||
(void (*)(void)) nlmsg_alloc,
|
||||
(void (*)(void)) nlmsg_alloc_convert,
|
||||
(void (*)(void)) nlmsg_alloc_simple,
|
||||
(void (*)(void)) nlmsg_free,
|
||||
(void (*)(void)) nlmsg_append,
|
||||
(void (*)(void)) nlmsg_parse,
|
||||
(void (*)(void)) nlmsg_put,
|
||||
(void (*)(void)) nla_strlcpy,
|
||||
(void (*)(void)) nla_memcpy,
|
||||
(void (*)(void)) nla_put,
|
||||
(void (*)(void)) nla_find,
|
||||
(void (*)(void)) nla_nest_cancel,
|
||||
(void (*)(void)) nla_nest_start,
|
||||
(void (*)(void)) nla_nest_end,
|
||||
(void (*)(void)) nla_parse,
|
||||
(void (*)(void)) nlmsg_get_proto,
|
||||
(void (*)(void)) nlmsg_set_proto,
|
||||
(void (*)(void)) nlmsg_set_src,
|
||||
(void (*)(void)) nlmsg_get_creds,
|
||||
(void (*)(void)) nlmsg_set_creds,
|
||||
(void (*)(void)) genlmsg_put,
|
||||
(void (*)(void)) genlmsg_data,
|
||||
(void (*)(void)) genlmsg_user_hdr,
|
||||
(void (*)(void)) genlmsg_hdr,
|
||||
(void (*)(void)) genlmsg_user_data,
|
||||
(void (*)(void)) genlmsg_attrdata,
|
||||
(void (*)(void)) genlmsg_len,
|
||||
(void (*)(void)) genlmsg_attrlen,
|
||||
(void (*)(void)) genlmsg_valid_hdr,
|
||||
(void (*)(void)) genlmsg_parse,
|
||||
(void (*)(void)) genl_ctrl_resolve,
|
||||
(void (*)(void)) nl_socket_alloc,
|
||||
(void (*)(void)) nl_socket_free,
|
||||
(void (*)(void)) nl_socket_get_fd,
|
||||
(void (*)(void)) nl_socket_get_local_port,
|
||||
(void (*)(void)) nl_socket_get_msg_buf_size,
|
||||
(void (*)(void)) nl_socket_set_passcred,
|
||||
(void (*)(void)) nl_socket_set_msg_buf_size,
|
||||
(void (*)(void)) nlmsg_get_dst,
|
||||
(void (*)(void)) nl_socket_set_nonblocking,
|
||||
(void (*)(void)) nl_socket_set_buffer_size,
|
||||
(void (*)(void)) nl_socket_add_memberships,
|
||||
(void (*)(void)) nl_socket_set_ext_ack,
|
||||
(void (*)(void)) nl_socket_disable_msg_peek,
|
||||
(void (*)(void)) nl_connect,
|
||||
(void (*)(void)) nl_wait_for_ack,
|
||||
(void (*)(void)) nl_recvmsgs,
|
||||
(void (*)(void)) nl_sendmsg,
|
||||
(void (*)(void)) nl_send_iovec,
|
||||
(void (*)(void)) nl_complete_msg,
|
||||
(void (*)(void)) nl_send,
|
||||
(void (*)(void)) nl_send_auto,
|
||||
(void (*)(void)) nl_recv,
|
||||
|
||||
(void (*)(void)) nmp_netns_bind_to_path,
|
||||
(void (*)(void)) nmp_netns_bind_to_path_destroy,
|
||||
(void (*)(void)) nmp_netns_get_current,
|
||||
(void (*)(void)) nmp_netns_get_fd_mnt,
|
||||
(void (*)(void)) nmp_netns_get_fd_net,
|
||||
(void (*)(void)) nmp_netns_get_initial,
|
||||
(void (*)(void)) nmp_netns_is_initial,
|
||||
(void (*)(void)) nmp_netns_new,
|
||||
(void (*)(void)) nmp_netns_pop,
|
||||
(void (*)(void)) nmp_netns_push,
|
||||
(void (*)(void)) nmp_netns_push_type,
|
||||
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* The only (not very exciting) purpose of this test is to see that
|
||||
* we can use various symbols and don't get a linker error. */
|
||||
assert(G_N_ELEMENTS(SYMBOLS) == NM_PTRARRAY_LEN(SYMBOLS) + 1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMTST_DEFINE();
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
nmtst_init(&argc, &argv, TRUE);
|
||||
|
||||
g_test_add_func("/nm-platform/test_use_symbols", test_use_symbols);
|
||||
|
||||
return g_test_run();
|
||||
}
|
|
@ -25,7 +25,7 @@
|
|||
#include "ppp/nm-ppp-manager-call.h"
|
||||
#include "ppp/nm-ppp-status.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "nm-dcb.h"
|
||||
#include "settings/nm-settings-connection.h"
|
||||
#include "nm-config.h"
|
||||
|
@ -1392,7 +1392,7 @@ wake_on_lan_enable(NMDevice *device)
|
|||
found:
|
||||
return nm_platform_ethtool_set_wake_on_lan(nm_device_get_platform(device),
|
||||
nm_device_get_ifindex(device),
|
||||
wol,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_CAST(wol),
|
||||
password);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "nm-glib-aux/nm-random-utils.h"
|
||||
#include "systemd/nm-sd-utils-shared.h"
|
||||
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
#include "nm-libnm-core-intern/nm-common-macros.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-l3cfg.h"
|
||||
|
@ -36,7 +36,7 @@
|
|||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-manager.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "platform/nmp-object.h"
|
||||
#include "platform/nmp-rules-manager.h"
|
||||
#include "ndisc/nm-ndisc.h"
|
||||
|
@ -134,7 +134,7 @@ typedef struct {
|
|||
NMPlatformAsyncCallback callback;
|
||||
gpointer callback_data;
|
||||
guint num_vfs;
|
||||
NMTernary autoprobe;
|
||||
NMOptionBool autoprobe;
|
||||
} SriovOp;
|
||||
|
||||
typedef void (*AcdCallback)(NMDevice *, NMIP4Config **, gboolean);
|
||||
|
@ -205,7 +205,7 @@ struct _NMDeviceConnectivityHandle {
|
|||
typedef struct {
|
||||
int ifindex;
|
||||
NMEthtoolFeatureStates *features;
|
||||
NMTernary requested[_NM_ETHTOOL_ID_FEATURE_NUM];
|
||||
NMOptionBool requested[_NM_ETHTOOL_ID_FEATURE_NUM];
|
||||
NMEthtoolCoalesceState *coalesce;
|
||||
NMEthtoolRingState * ring;
|
||||
} EthtoolState;
|
||||
|
@ -5829,7 +5829,7 @@ sriov_op_queue_op(NMDevice *self, SriovOp *op)
|
|||
static void
|
||||
sriov_op_queue(NMDevice * self,
|
||||
guint num_vfs,
|
||||
NMTernary autoprobe,
|
||||
NMOptionBool autoprobe,
|
||||
NMPlatformAsyncCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
|
@ -5878,7 +5878,7 @@ device_init_static_sriov_num_vfs(NMDevice *self)
|
|||
NULL);
|
||||
num_vfs = _nm_utils_ascii_str_to_int64(value, 10, 0, G_MAXINT32, -1);
|
||||
if (num_vfs >= 0)
|
||||
sriov_op_queue(self, num_vfs, NM_TERNARY_DEFAULT, NULL, NULL);
|
||||
sriov_op_queue(self, num_vfs, NM_OPTION_BOOL_DEFAULT, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8055,7 +8055,8 @@ activate_stage1_device_prepare(NMDevice *self)
|
|||
gs_free_error GError *error = NULL;
|
||||
NMSriovVF * vf;
|
||||
NMTernary autoprobe;
|
||||
guint i, num;
|
||||
guint num;
|
||||
guint i;
|
||||
|
||||
autoprobe = nm_setting_sriov_get_autoprobe_drivers(s_sriov);
|
||||
if (autoprobe == NM_TERNARY_DEFAULT) {
|
||||
|
@ -8063,9 +8064,9 @@ activate_stage1_device_prepare(NMDevice *self)
|
|||
NM_CONFIG_GET_DATA,
|
||||
NM_CON_DEFAULT("sriov.autoprobe-drivers"),
|
||||
self,
|
||||
NM_TERNARY_FALSE,
|
||||
NM_TERNARY_TRUE,
|
||||
NM_TERNARY_TRUE);
|
||||
NM_OPTION_BOOL_FALSE,
|
||||
NM_OPTION_BOOL_TRUE,
|
||||
NM_OPTION_BOOL_TRUE);
|
||||
}
|
||||
|
||||
num = nm_setting_sriov_get_num_vfs(s_sriov);
|
||||
|
@ -8092,7 +8093,7 @@ activate_stage1_device_prepare(NMDevice *self)
|
|||
*/
|
||||
sriov_op_queue(self,
|
||||
nm_setting_sriov_get_total_vfs(s_sriov),
|
||||
autoprobe,
|
||||
NM_TERNARY_TO_OPTION_BOOL(autoprobe),
|
||||
sriov_params_cb,
|
||||
nm_utils_user_data_pack(self, g_steal_pointer(&plat_vfs)));
|
||||
priv->stage1_sriov_state = NM_DEVICE_STAGE_STATE_PENDING;
|
||||
|
@ -16521,7 +16522,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
|
|||
priv->sriov_reset_pending++;
|
||||
sriov_op_queue(self,
|
||||
0,
|
||||
NM_TERNARY_TRUE,
|
||||
NM_OPTION_BOOL_TRUE,
|
||||
sriov_reset_on_deactivate_cb,
|
||||
nm_utils_user_data_pack(self, GINT_TO_POINTER(reason)));
|
||||
}
|
||||
|
@ -16573,7 +16574,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
|
|||
if (priv->ifindex > 0
|
||||
&& (s_sriov = nm_device_get_applied_setting(self, NM_TYPE_SETTING_SRIOV))) {
|
||||
priv->sriov_reset_pending++;
|
||||
sriov_op_queue(self, 0, NM_TERNARY_TRUE, sriov_reset_on_failure_cb, self);
|
||||
sriov_op_queue(self, 0, NM_OPTION_BOOL_TRUE, sriov_reset_on_failure_cb, self);
|
||||
break;
|
||||
}
|
||||
/* Schedule the transition to DISCONNECTED. The device can't transition
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <net/if.h>
|
||||
|
||||
#include "nm-logging.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-manager.h"
|
||||
#include "nm-device-iwd.h"
|
||||
|
|
|
@ -5,7 +5,11 @@ src_inc = include_directories('.')
|
|||
daemon_nm_default_dep = declare_dependency(
|
||||
sources: libnm_core_enum_sources[1],
|
||||
include_directories: src_inc,
|
||||
dependencies: libnm_core_nm_default_dep,
|
||||
dependencies: [
|
||||
libnm_core_nm_default_dep,
|
||||
libnm_log_core_dep,
|
||||
libnm_platform_dep,
|
||||
],
|
||||
)
|
||||
|
||||
install_data(
|
||||
|
@ -28,14 +32,11 @@ sources = files(
|
|||
'dhcp/nm-dhcp-options.c',
|
||||
'ndisc/nm-lndp-ndisc.c',
|
||||
'ndisc/nm-ndisc.c',
|
||||
'platform/nm-netlink.c',
|
||||
'platform/wifi/nm-wifi-utils-nl80211.c',
|
||||
'platform/wifi/nm-wifi-utils.c',
|
||||
'platform/wpan/nm-wpan-utils.c',
|
||||
'platform/nm-linux-platform.c',
|
||||
'platform/nm-platform.c',
|
||||
'platform/nm-platform-utils.c',
|
||||
'platform/nmp-netns.c',
|
||||
'platform/nmp-object.c',
|
||||
'platform/nmp-rules-manager.c',
|
||||
'main-utils.c',
|
||||
|
@ -50,7 +51,6 @@ sources = files(
|
|||
'nm-ip-config.c',
|
||||
'nm-ip4-config.c',
|
||||
'nm-ip6-config.c',
|
||||
'nm-logging.c',
|
||||
)
|
||||
|
||||
deps = [
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "nm-ndisc-private.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nmp-netns.h"
|
||||
#include "nm-platform/nmp-netns.h"
|
||||
|
||||
#define _NMLOG_PREFIX_NAME "ndisc-lndp"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "nm-ndisc-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nmp-netns.h"
|
||||
#include "nm-platform/nmp-netns.h"
|
||||
#include "nm-l3-config-data.h"
|
||||
|
||||
#define _NMLOG_PREFIX_NAME "ndisc"
|
||||
|
|
|
@ -4269,29 +4269,6 @@ nm_utils_g_value_set_strv(GValue *value, GPtrArray *strings)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_utils_ifname_cpy(char *dst, const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_if_fail(dst);
|
||||
g_return_if_fail(name && name[0]);
|
||||
|
||||
nm_assert(nm_utils_ifname_valid_kernel(name, NULL));
|
||||
|
||||
/* ensures NUL padding of the entire IFNAMSIZ buffer. */
|
||||
|
||||
for (i = 0; i < (int) IFNAMSIZ && name[i] != '\0'; i++)
|
||||
dst[i] = name[i];
|
||||
|
||||
nm_assert(name[i] == '\0');
|
||||
|
||||
for (; i < (int) IFNAMSIZ; i++)
|
||||
dst[i] = '\0';
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* Takes a pair @timestamp and @duration, and returns the remaining duration based
|
||||
* on the new timestamp @now.
|
||||
|
|
|
@ -501,8 +501,6 @@ void _nm_utils_set_testing(NMUtilsTestFlags flags);
|
|||
|
||||
void nm_utils_g_value_set_strv(GValue *value, GPtrArray *strings);
|
||||
|
||||
void nm_utils_ifname_cpy(char *dst, const char *name);
|
||||
|
||||
guint32
|
||||
nm_utils_lifetime_rebase_relative_time_on_now(guint32 timestamp, guint32 duration, gint32 now);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "main-utils.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "platform/nm-linux-platform.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "dhcp/nm-dhcp-manager.h"
|
||||
#include "ndisc/nm-ndisc.h"
|
||||
#include "ndisc/nm-lndp-ndisc.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "nm-utils.h"
|
||||
#include "platform/nmp-object.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-dbus-object.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "nm-utils.h"
|
||||
#include "platform/nmp-object.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-ip4-config.h"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "nm-glib-aux/nm-enum-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "platform/nmp-object.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "nm-core-internal.h"
|
||||
#include "nm-l3cfg.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nmp-netns.h"
|
||||
#include "nm-platform/nmp-netns.h"
|
||||
#include "platform/nmp-rules-manager.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#ifndef __NM_NETNS_H__
|
||||
#define __NM_NETNS_H__
|
||||
|
||||
#include "nm-platform/nmp-base.h"
|
||||
|
||||
#define NM_TYPE_NETNS (nm_netns_get_type())
|
||||
#define NM_NETNS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_NETNS, NMNetns))
|
||||
#define NM_NETNS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_NETNS, NMNetnsClass))
|
||||
|
|
|
@ -77,41 +77,6 @@ typedef enum {
|
|||
NM_ACTIVATION_REASON_USER_REQUEST,
|
||||
} NMActivationReason;
|
||||
|
||||
typedef enum {
|
||||
/* In priority order; higher number == higher priority */
|
||||
|
||||
NM_IP_CONFIG_SOURCE_UNKNOWN = 0,
|
||||
|
||||
/* for routes, the source is mapped to the uint8 field rtm_protocol.
|
||||
* Reserve the range [1,0x100] for native RTPROT values. */
|
||||
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_UNSPEC = 1 + 0,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_REDIRECT = 1 + 1,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_KERNEL = 1 + 2,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_BOOT = 1 + 3,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_STATIC = 1 + 4,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_RA = 1 + 9,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_DHCP = 1 + 16,
|
||||
_NM_IP_CONFIG_SOURCE_RTPROT_LAST = 1 + 0xFF,
|
||||
|
||||
NM_IP_CONFIG_SOURCE_KERNEL,
|
||||
NM_IP_CONFIG_SOURCE_SHARED,
|
||||
NM_IP_CONFIG_SOURCE_IP4LL,
|
||||
NM_IP_CONFIG_SOURCE_IP6LL,
|
||||
NM_IP_CONFIG_SOURCE_PPP,
|
||||
NM_IP_CONFIG_SOURCE_WWAN,
|
||||
NM_IP_CONFIG_SOURCE_VPN,
|
||||
NM_IP_CONFIG_SOURCE_DHCP,
|
||||
NM_IP_CONFIG_SOURCE_NDISC,
|
||||
NM_IP_CONFIG_SOURCE_USER,
|
||||
} NMIPConfigSource;
|
||||
|
||||
static inline gboolean
|
||||
NM_IS_IP_CONFIG_SOURCE_RTPROT(NMIPConfigSource source)
|
||||
{
|
||||
return source > NM_IP_CONFIG_SOURCE_UNKNOWN && source <= _NM_IP_CONFIG_SOURCE_RTPROT_LAST;
|
||||
}
|
||||
|
||||
/* platform */
|
||||
typedef struct _NMPlatform NMPlatform;
|
||||
typedef struct _NMPlatformObject NMPlatformObject;
|
||||
|
@ -121,7 +86,6 @@ typedef struct _NMPlatformIP4Route NMPlatformIP4Route;
|
|||
typedef struct _NMPlatformIP6Address NMPlatformIP6Address;
|
||||
typedef struct _NMPlatformIP6Route NMPlatformIP6Route;
|
||||
typedef struct _NMPlatformLink NMPlatformLink;
|
||||
typedef struct _NMPNetns NMPNetns;
|
||||
typedef struct _NMPObject NMPObject;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
#include "nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "nm-platform-private.h"
|
||||
#include "nmp-object.h"
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@
|
|||
|
||||
#include "nm-glib-aux/nm-secret-utils.h"
|
||||
#include "nm-glib-aux/nm-c-list.h"
|
||||
#include "nm-netlink.h"
|
||||
#include "nm-platform/nm-netlink.h"
|
||||
#include "nm-core-utils.h"
|
||||
#include "nmp-object.h"
|
||||
#include "nmp-netns.h"
|
||||
#include "nm-platform-utils.h"
|
||||
#include "nm-platform/nmp-netns.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "nm-platform-private.h"
|
||||
#include "wifi/nm-wifi-utils.h"
|
||||
#include "wifi/nm-wifi-utils-wext.h"
|
||||
|
@ -7653,7 +7653,7 @@ static void
|
|||
link_set_sriov_params_async(NMPlatform * platform,
|
||||
int ifindex,
|
||||
guint num_vfs,
|
||||
NMTernary autoprobe,
|
||||
NMOptionBool autoprobe,
|
||||
NMPlatformAsyncCallback callback,
|
||||
gpointer data,
|
||||
GCancellable * cancellable)
|
||||
|
@ -7726,10 +7726,11 @@ link_set_sriov_params_async(NMPlatform * platform,
|
|||
}
|
||||
|
||||
if (current_num == num_vfs
|
||||
&& (autoprobe == NM_TERNARY_DEFAULT || current_autoprobe == autoprobe))
|
||||
&& (autoprobe == NM_OPTION_BOOL_DEFAULT || current_autoprobe == autoprobe))
|
||||
goto out_idle;
|
||||
|
||||
if (NM_IN_SET(autoprobe, NM_TERNARY_TRUE, NM_TERNARY_FALSE) && current_autoprobe != autoprobe
|
||||
if (NM_IN_SET(autoprobe, NM_OPTION_BOOL_TRUE, NM_OPTION_BOOL_FALSE)
|
||||
&& current_autoprobe != autoprobe
|
||||
&& !nm_platform_sysctl_set(
|
||||
NM_PLATFORM_GET,
|
||||
NMP_SYSCTL_PATHID_NETDIR(dirfd, ifname, "device/sriov_drivers_autoprobe"),
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
#include "nm-glib-aux/nm-secret-utils.h"
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
#include "nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "nm-platform-private.h"
|
||||
#include "nmp-object.h"
|
||||
#include "nmp-netns.h"
|
||||
#include "nm-platform/nmp-netns.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -1842,7 +1842,7 @@ nm_platform_link_supports_sriov(NMPlatform *self, int ifindex)
|
|||
* @ifindex: the index of the interface to change
|
||||
* @num_vfs: the number of VFs to create
|
||||
* @autoprobe: the new autoprobe-drivers value (pass
|
||||
* %NM_TERNARY_DEFAULT to keep current value)
|
||||
* %NM_OPTION_BOOL_DEFAULT to keep current value)
|
||||
* @callback: called when the operation finishes
|
||||
* @callback_data: data passed to @callback
|
||||
* @cancellable: cancellable to abort the operation
|
||||
|
@ -1855,7 +1855,7 @@ void
|
|||
nm_platform_link_set_sriov_params_async(NMPlatform * self,
|
||||
int ifindex,
|
||||
guint num_vfs,
|
||||
NMTernary autoprobe,
|
||||
NMOptionBool autoprobe,
|
||||
NMPlatformAsyncCallback callback,
|
||||
gpointer callback_data,
|
||||
GCancellable * cancellable)
|
||||
|
@ -3282,10 +3282,10 @@ _to_string_ifa_flags(guint32 ifa_flags, char *buf, gsize size)
|
|||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_platform_ethtool_set_wake_on_lan(NMPlatform * self,
|
||||
int ifindex,
|
||||
NMSettingWiredWakeOnLan wol,
|
||||
const char * wol_password)
|
||||
nm_platform_ethtool_set_wake_on_lan(NMPlatform * self,
|
||||
int ifindex,
|
||||
_NMSettingWiredWakeOnLan wol,
|
||||
const char * wol_password)
|
||||
{
|
||||
_CHECK_SELF_NETNS(self, klass, netns, FALSE);
|
||||
|
||||
|
@ -3322,13 +3322,6 @@ nm_platform_ethtool_get_link_settings(NMPlatform * self,
|
|||
return nmp_utils_ethtool_get_link_settings(ifindex, out_autoneg, out_speed, out_duplex);
|
||||
}
|
||||
|
||||
NM_UTILS_LOOKUP_STR_DEFINE(nm_platform_link_duplex_type_to_string,
|
||||
NMPlatformLinkDuplexType,
|
||||
NM_UTILS_LOOKUP_DEFAULT_WARN(NULL),
|
||||
NM_UTILS_LOOKUP_STR_ITEM(NM_PLATFORM_LINK_DUPLEX_UNKNOWN, "unknown"),
|
||||
NM_UTILS_LOOKUP_STR_ITEM(NM_PLATFORM_LINK_DUPLEX_FULL, "full"),
|
||||
NM_UTILS_LOOKUP_STR_ITEM(NM_PLATFORM_LINK_DUPLEX_HALF, "half"), );
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMEthtoolFeatureStates *
|
||||
|
@ -3346,8 +3339,8 @@ nm_platform_ethtool_set_features(
|
|||
NMPlatform * self,
|
||||
int ifindex,
|
||||
const NMEthtoolFeatureStates *features,
|
||||
const NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
||||
gboolean do_set /* or reset */)
|
||||
const NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
||||
gboolean do_set /* or reset */)
|
||||
{
|
||||
_CHECK_SELF_NETNS(self, klass, netns, FALSE);
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
#include "nm-dbus-interface.h"
|
||||
#include "nm-core-types-internal.h"
|
||||
|
||||
#include "nm-platform/nmp-base.h"
|
||||
#include "nm-base/nm-base.h"
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
#include "nm-setting-vlan.h"
|
||||
#include "nm-setting-wired.h"
|
||||
|
@ -975,12 +978,6 @@ typedef struct {
|
|||
guint8 public_key[NMP_WIREGUARD_PUBLIC_KEY_LEN];
|
||||
} NMPlatformLnkWireGuard;
|
||||
|
||||
typedef enum {
|
||||
NM_PLATFORM_LINK_DUPLEX_UNKNOWN,
|
||||
NM_PLATFORM_LINK_DUPLEX_HALF,
|
||||
NM_PLATFORM_LINK_DUPLEX_FULL,
|
||||
} NMPlatformLinkDuplexType;
|
||||
|
||||
typedef enum {
|
||||
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_NONE = 0,
|
||||
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_REPLACE_PEERS = (1LL << 0),
|
||||
|
@ -1038,7 +1035,7 @@ _nm_platform_kernel_support_detected(NMPlatformKernelSupportType type)
|
|||
return G_LIKELY(g_atomic_int_get(&_nm_platform_kernel_support_state[type]) != 0);
|
||||
}
|
||||
|
||||
static inline NMTernary
|
||||
static inline NMOptionBool
|
||||
nm_platform_kernel_support_get_full(NMPlatformKernelSupportType type, gboolean init_if_not_set)
|
||||
{
|
||||
int v;
|
||||
|
@ -1048,7 +1045,7 @@ nm_platform_kernel_support_get_full(NMPlatformKernelSupportType type, gboolean i
|
|||
v = g_atomic_int_get(&_nm_platform_kernel_support_state[type]);
|
||||
if (G_UNLIKELY(v == 0)) {
|
||||
if (!init_if_not_set)
|
||||
return NM_TERNARY_DEFAULT;
|
||||
return NM_OPTION_BOOL_DEFAULT;
|
||||
v = _nm_platform_kernel_support_init(type, 0);
|
||||
}
|
||||
return (v >= 0);
|
||||
|
@ -1057,7 +1054,7 @@ nm_platform_kernel_support_get_full(NMPlatformKernelSupportType type, gboolean i
|
|||
static inline gboolean
|
||||
nm_platform_kernel_support_get(NMPlatformKernelSupportType type)
|
||||
{
|
||||
return nm_platform_kernel_support_get_full(type, TRUE) != NM_TERNARY_FALSE;
|
||||
return nm_platform_kernel_support_get_full(type, TRUE) != NM_OPTION_BOOL_FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1121,7 +1118,7 @@ typedef struct {
|
|||
void (*link_set_sriov_params_async)(NMPlatform * self,
|
||||
int ifindex,
|
||||
guint num_vfs,
|
||||
int autoprobe,
|
||||
NMOptionBool autoprobe,
|
||||
NMPlatformAsyncCallback callback,
|
||||
gpointer callback_data,
|
||||
GCancellable * cancellable);
|
||||
|
@ -1856,7 +1853,7 @@ gboolean nm_platform_link_set_name(NMPlatform *self, int ifindex, const char *na
|
|||
void nm_platform_link_set_sriov_params_async(NMPlatform * self,
|
||||
int ifindex,
|
||||
guint num_vfs,
|
||||
int autoprobe,
|
||||
NMOptionBool autoprobe,
|
||||
NMPlatformAsyncCallback callback,
|
||||
gpointer callback_data,
|
||||
GCancellable * cancellable);
|
||||
|
@ -2325,10 +2322,10 @@ const char *nm_platform_route_scope2str(int scope, char *buf, gsize len);
|
|||
|
||||
int nm_platform_ip_address_cmp_expiry(const NMPlatformIPAddress *a, const NMPlatformIPAddress *b);
|
||||
|
||||
gboolean nm_platform_ethtool_set_wake_on_lan(NMPlatform * self,
|
||||
int ifindex,
|
||||
NMSettingWiredWakeOnLan wol,
|
||||
const char * wol_password);
|
||||
gboolean nm_platform_ethtool_set_wake_on_lan(NMPlatform * self,
|
||||
int ifindex,
|
||||
_NMSettingWiredWakeOnLan wol,
|
||||
const char * wol_password);
|
||||
gboolean nm_platform_ethtool_set_link_settings(NMPlatform * self,
|
||||
int ifindex,
|
||||
gboolean autoneg,
|
||||
|
@ -2340,17 +2337,13 @@ gboolean nm_platform_ethtool_get_link_settings(NMPlatform * self,
|
|||
guint32 * out_speed,
|
||||
NMPlatformLinkDuplexType *out_duplex);
|
||||
|
||||
typedef struct _NMEthtoolFeatureStates NMEthtoolFeatureStates;
|
||||
|
||||
NMEthtoolFeatureStates *nm_platform_ethtool_get_link_features(NMPlatform *self, int ifindex);
|
||||
gboolean nm_platform_ethtool_set_features(
|
||||
NMPlatform * self,
|
||||
int ifindex,
|
||||
const NMEthtoolFeatureStates *features,
|
||||
const NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
||||
gboolean do_set /* or reset */);
|
||||
|
||||
typedef struct _NMEthtoolCoalesceState NMEthtoolCoalesceState;
|
||||
const NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
||||
gboolean do_set /* or reset */);
|
||||
|
||||
gboolean nm_platform_ethtool_get_link_coalesce(NMPlatform * self,
|
||||
int ifindex,
|
||||
|
@ -2360,15 +2353,11 @@ gboolean nm_platform_ethtool_set_coalesce(NMPlatform * self,
|
|||
int ifindex,
|
||||
const NMEthtoolCoalesceState *coalesce);
|
||||
|
||||
typedef struct _NMEthtoolRingState NMEthtoolRingState;
|
||||
|
||||
gboolean nm_platform_ethtool_get_link_ring(NMPlatform *self, int ifindex, NMEthtoolRingState *ring);
|
||||
|
||||
gboolean
|
||||
nm_platform_ethtool_set_ring(NMPlatform *self, int ifindex, const NMEthtoolRingState *ring);
|
||||
|
||||
const char *nm_platform_link_duplex_type_to_string(NMPlatformLinkDuplexType duplex);
|
||||
|
||||
void nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self,
|
||||
int ifindex,
|
||||
GPtrArray * ip4_dev_route_blacklist);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "nm-glib-aux/nm-secret-utils.h"
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
#include "nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
|
||||
#include "wifi/nm-wifi-utils.h"
|
||||
#include "wpan/nm-wpan-utils.h"
|
||||
|
|
|
@ -2274,18 +2274,18 @@ gboolean
|
|||
nmtstp_kernel_support_get(NMPlatformKernelSupportType type)
|
||||
{
|
||||
const NMPlatformLink *pllink;
|
||||
NMTernary v;
|
||||
NMOptionBool v;
|
||||
|
||||
v = nm_platform_kernel_support_get_full(type, FALSE);
|
||||
if (v != NM_TERNARY_DEFAULT)
|
||||
return v != NM_TERNARY_FALSE;
|
||||
if (v != NM_OPTION_BOOL_DEFAULT)
|
||||
return v != NM_OPTION_BOOL_FALSE;
|
||||
|
||||
switch (type) {
|
||||
case NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BR_VLAN_STATS_ENABLED:
|
||||
pllink = nmtstp_link_bridge_add(NULL, -1, "br-test-11", &nm_platform_lnk_bridge_default);
|
||||
nmtstp_link_delete(NULL, -1, pllink->ifindex, NULL, TRUE);
|
||||
v = nm_platform_kernel_support_get_full(type, FALSE);
|
||||
g_assert(v != NM_TERNARY_DEFAULT);
|
||||
g_assert(v != NM_OPTION_BOOL_DEFAULT);
|
||||
return v;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
|
|
|
@ -12,9 +12,10 @@
|
|||
#include <linux/if_tun.h>
|
||||
|
||||
#include "nm-glib-aux/nm-io-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
#include "platform/nmp-object.h"
|
||||
#include "platform/nmp-netns.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nmp-netns.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
|
||||
#include "test-common.h"
|
||||
#include "nm-test-utils-core.h"
|
||||
|
@ -3676,25 +3677,28 @@ test_ethtool_features_get(void)
|
|||
|
||||
for (i_run = 0; i_run < 5; i_run++) {
|
||||
NMEthtoolFeatureStates *features;
|
||||
NMTernary * requested;
|
||||
NMOptionBool * requested;
|
||||
gboolean do_set = TRUE;
|
||||
|
||||
requested = g_new(NMTernary, _NM_ETHTOOL_ID_FEATURE_NUM);
|
||||
requested = g_new(NMOptionBool, _NM_ETHTOOL_ID_FEATURE_NUM);
|
||||
for (i = 0; i < _NM_ETHTOOL_ID_FEATURE_NUM; i++)
|
||||
requested[i] = NM_TERNARY_DEFAULT;
|
||||
requested[i] = NM_OPTION_BOOL_DEFAULT;
|
||||
g_ptr_array_add(gfree_keeper, requested);
|
||||
|
||||
if (i_run == 0) {
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(NM_ETHTOOL_ID_FEATURE_RX)] = NM_TERNARY_FALSE;
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(NM_ETHTOOL_ID_FEATURE_TSO)] = NM_TERNARY_FALSE;
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(NM_ETHTOOL_ID_FEATURE_RX)] =
|
||||
NM_OPTION_BOOL_FALSE;
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(NM_ETHTOOL_ID_FEATURE_TSO)] =
|
||||
NM_OPTION_BOOL_FALSE;
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(NM_ETHTOOL_ID_FEATURE_TX_TCP6_SEGMENTATION)] =
|
||||
NM_TERNARY_FALSE;
|
||||
NM_OPTION_BOOL_FALSE;
|
||||
} else if (i_run == 1)
|
||||
do_set = FALSE;
|
||||
else if (i_run == 2) {
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(NM_ETHTOOL_ID_FEATURE_TSO)] = NM_TERNARY_FALSE;
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(NM_ETHTOOL_ID_FEATURE_TSO)] =
|
||||
NM_OPTION_BOOL_FALSE;
|
||||
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX(NM_ETHTOOL_ID_FEATURE_TX_TCP6_SEGMENTATION)] =
|
||||
NM_TERNARY_TRUE;
|
||||
NM_OPTION_BOOL_TRUE;
|
||||
} else if (i_run == 3)
|
||||
do_set = FALSE;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "platform/nm-linux-platform.h"
|
||||
|
||||
#include "nm-test-utils-core.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <linux/fib_rules.h>
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "platform/nmp-rules-manager.h"
|
||||
|
||||
#include "test-common.h"
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include "nm-test-utils-core.h"
|
||||
#include "platform/nmp-object.h"
|
||||
#include "platform/nmp-netns.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nmp-netns.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "test-common.h"
|
||||
|
||||
static NMPObject *
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include <linux/nl80211.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
#include "platform/nm-netlink.h"
|
||||
#include "nm-platform/nm-netlink.h"
|
||||
#include "nm-wifi-utils-private.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
#define _NMLOG_PREFIX_NAME "wifi-nl80211"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#define __WIFI_UTILS_NL80211_H__
|
||||
|
||||
#include "nm-wifi-utils.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
#include "nm-platform/nm-netlink.h"
|
||||
|
||||
#define NM_TYPE_WIFI_UTILS_NL80211 (nm_wifi_utils_nl80211_get_type())
|
||||
#define NM_WIFI_UTILS_NL80211(obj) \
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
|
||||
#include "nm-wifi-utils-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-core-utils.h"
|
||||
|
||||
typedef struct {
|
||||
NMWifiUtils parent;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#endif
|
||||
#include "nm-core-utils.h"
|
||||
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE(NMWifiUtils, nm_wifi_utils, G_TYPE_OBJECT)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
#include "nm-platform/nm-netlink.h"
|
||||
|
||||
typedef struct NMWifiUtils NMWifiUtils;
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
#include <linux/if.h>
|
||||
|
||||
#include "nm-platform/nm-netlink.h"
|
||||
#include "platform/linux/nl802154.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-platform/nm-platform-utils.h"
|
||||
|
||||
#define _NMLOG_PREFIX_NAME "wpan-nl802154"
|
||||
#define _NMLOG(level, domain, ...) \
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <net/ethernet.h>
|
||||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
#include "nm-platform/nm-netlink.h"
|
||||
|
||||
typedef struct NMWpanUtils NMWpanUtils;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "nm-setting-generic.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
|
||||
#include "platform/nm-platform.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#define _UTILS_H_
|
||||
|
||||
#include "nm-connection.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
|
||||
#include "shvar.h"
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "nm-core-internal.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-meta-setting.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
|
||||
#include "nms-ifcfg-rh-common.h"
|
||||
#include "nms-ifcfg-rh-reader.h"
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
#include "nm-setting-vlan.h"
|
||||
#include "nm-setting-dcb.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-base/nm-ethtool-base.h"
|
||||
#include "nm-base/nm-ethtool-utils-base.h"
|
||||
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
|
|
|
@ -1,33 +1,5 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
sources = files(
|
||||
'src/libsystemd-network/arp-util.c',
|
||||
'src/libsystemd-network/dhcp-identifier.c',
|
||||
'src/libsystemd-network/dhcp-network.c',
|
||||
'src/libsystemd-network/dhcp-option.c',
|
||||
'src/libsystemd-network/dhcp-packet.c',
|
||||
'src/libsystemd-network/dhcp6-network.c',
|
||||
'src/libsystemd-network/dhcp6-option.c',
|
||||
'src/libsystemd-network/lldp-neighbor.c',
|
||||
'src/libsystemd-network/lldp-network.c',
|
||||
'src/libsystemd-network/network-internal.c',
|
||||
'src/libsystemd-network/sd-dhcp-client.c',
|
||||
'src/libsystemd-network/sd-dhcp-lease.c',
|
||||
'src/libsystemd-network/sd-dhcp6-client.c',
|
||||
'src/libsystemd-network/sd-dhcp6-lease.c',
|
||||
'src/libsystemd-network/sd-ipv4acd.c',
|
||||
'src/libsystemd-network/sd-ipv4ll.c',
|
||||
'src/libsystemd-network/sd-lldp.c',
|
||||
'src/libsystemd/sd-event/event-util.c',
|
||||
'src/libsystemd/sd-event/sd-event.c',
|
||||
'src/libsystemd/sd-id128/id128-util.c',
|
||||
'src/libsystemd/sd-id128/sd-id128.c',
|
||||
'nm-sd.c',
|
||||
'nm-sd-utils-core.c',
|
||||
'nm-sd-utils-dhcp.c',
|
||||
'sd-adapt-core/nm-sd-adapt-core.c',
|
||||
)
|
||||
|
||||
incs = include_directories(
|
||||
'sd-adapt-core',
|
||||
'src/libsystemd-network',
|
||||
|
@ -35,16 +7,54 @@ incs = include_directories(
|
|||
'src/systemd',
|
||||
)
|
||||
|
||||
deps = [
|
||||
daemon_nm_default_dep,
|
||||
libnm_systemd_shared_dep,
|
||||
]
|
||||
|
||||
libnm_systemd_core = static_library(
|
||||
'nm-systemd-core',
|
||||
sources: sources,
|
||||
include_directories: incs,
|
||||
dependencies: deps,
|
||||
sources: files(
|
||||
'src/libsystemd-network/arp-util.c',
|
||||
'src/libsystemd-network/dhcp-identifier.c',
|
||||
'src/libsystemd-network/dhcp-network.c',
|
||||
'src/libsystemd-network/dhcp-option.c',
|
||||
'src/libsystemd-network/dhcp-packet.c',
|
||||
'src/libsystemd-network/dhcp6-network.c',
|
||||
'src/libsystemd-network/dhcp6-option.c',
|
||||
'src/libsystemd-network/lldp-neighbor.c',
|
||||
'src/libsystemd-network/lldp-network.c',
|
||||
'src/libsystemd-network/network-internal.c',
|
||||
'src/libsystemd-network/sd-dhcp-client.c',
|
||||
'src/libsystemd-network/sd-dhcp-lease.c',
|
||||
'src/libsystemd-network/sd-dhcp6-client.c',
|
||||
'src/libsystemd-network/sd-dhcp6-lease.c',
|
||||
'src/libsystemd-network/sd-ipv4acd.c',
|
||||
'src/libsystemd-network/sd-ipv4ll.c',
|
||||
'src/libsystemd-network/sd-lldp.c',
|
||||
'src/libsystemd/sd-event/event-util.c',
|
||||
'src/libsystemd/sd-event/sd-event.c',
|
||||
'src/libsystemd/sd-id128/id128-util.c',
|
||||
'src/libsystemd/sd-id128/sd-id128.c',
|
||||
'nm-sd.c',
|
||||
'nm-sd-utils-core.c',
|
||||
'nm-sd-utils-dhcp.c',
|
||||
'sd-adapt-core/nm-sd-adapt-core.c',
|
||||
),
|
||||
include_directories: [
|
||||
incs,
|
||||
src_inc,
|
||||
],
|
||||
dependencies: [
|
||||
glib_nm_default_dep,
|
||||
libnm_core_dep,
|
||||
libnm_systemd_shared_dep,
|
||||
],
|
||||
c_args: '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD',
|
||||
link_with: libc_siphash,
|
||||
)
|
||||
|
||||
libnm_systemd_core_dep = declare_dependency(
|
||||
include_directories: incs,
|
||||
dependencies: [
|
||||
glib_dep,
|
||||
libnm_core_dep,
|
||||
libnm_systemd_shared_dep,
|
||||
],
|
||||
link_with: libnm_systemd_core,
|
||||
)
|
||||
|
|
|
@ -29,28 +29,25 @@ foreach test_unit: test_units
|
|||
)
|
||||
endforeach
|
||||
|
||||
test_unit = 'test-systemd'
|
||||
|
||||
c_flags = [
|
||||
'-DNETWORKMANAGER_COMPILATION_TEST',
|
||||
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD',
|
||||
]
|
||||
|
||||
links = [
|
||||
libnm_systemd_core,
|
||||
libnm_systemd_shared,
|
||||
]
|
||||
|
||||
exe = executable(
|
||||
test_unit,
|
||||
test_unit + '.c',
|
||||
dependencies: daemon_nm_default_dep,
|
||||
c_args: c_flags,
|
||||
link_with: links,
|
||||
'test-systemd',
|
||||
'test-systemd.c',
|
||||
include_directories: [
|
||||
top_inc,
|
||||
src_inc,
|
||||
],
|
||||
dependencies: [
|
||||
libnm_systemd_core_dep,
|
||||
libnm_systemd_shared_dep,
|
||||
],
|
||||
c_args: [
|
||||
'-DNETWORKMANAGER_COMPILATION_TEST',
|
||||
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD',
|
||||
],
|
||||
)
|
||||
|
||||
test(
|
||||
test_unit,
|
||||
'test-systemd',
|
||||
test_script,
|
||||
args: test_args + [exe.full_path()],
|
||||
)
|
||||
|
|
|
@ -104,6 +104,32 @@ test_logging_domains(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_logging_error(void)
|
||||
{
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
g_assert_cmpint(NM_MANAGER_ERROR, ==, _NM_MANAGER_ERROR);
|
||||
G_STATIC_ASSERT_EXPR(NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL == _NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL);
|
||||
G_STATIC_ASSERT_EXPR(NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN
|
||||
== _NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN);
|
||||
|
||||
success = nm_logging_setup("bogus", "ALL", NULL, &error);
|
||||
nmtst_assert_no_success(success, error);
|
||||
g_assert_cmpint(error->domain, ==, NM_MANAGER_ERROR);
|
||||
g_assert_cmpint(error->code, ==, NM_MANAGER_ERROR_UNKNOWN_LOG_LEVEL);
|
||||
nm_clear_pointer(&error, g_error_free);
|
||||
|
||||
success = nm_logging_setup("debug", "bogus", NULL, &error);
|
||||
nmtst_assert_no_success(success, error);
|
||||
g_assert_cmpint(error->domain, ==, NM_MANAGER_ERROR);
|
||||
g_assert_cmpint(error->code, ==, NM_MANAGER_ERROR_UNKNOWN_LOG_DOMAIN);
|
||||
nm_clear_pointer(&error, g_error_free);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_test_same_prefix(const char *a1, const char *a2, guint8 plen)
|
||||
{
|
||||
|
@ -2544,6 +2570,7 @@ main(int argc, char **argv)
|
|||
nmtst_init_with_logging(&argc, &argv, NULL, "ALL");
|
||||
|
||||
g_test_add_func("/general/test_logging_domains", test_logging_domains);
|
||||
g_test_add_func("/general/test_logging_error", test_logging_error);
|
||||
|
||||
g_test_add_func("/general/nm_utils_strbuf_append", test_nm_utils_strbuf_append);
|
||||
|
||||
|
|
Loading…
Reference in a new issue