summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-01-15 12:17:27 +0100
committerThomas Haller <thaller@redhat.com>2021-01-15 12:23:48 +0100
commitfef16c3f54d497fa45c1ec30c6c4745ed89187c7 (patch)
tree0fbd56f931e4a7ee0a85edb7275a90b457d00b54
parentcda8badc571a477bf722f63a55522e6f572f65c4 (diff)
parenta288de4b3d8fc753b1b350d5f620b3a1426aaaf6 (diff)
downloadNetworkManager-fef16c3f54d497fa45c1ec30c6c4745ed89187c7.tar.gz
all: merge branch 'th/shared-nm-platform'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/716
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am151
-rw-r--r--clients/common/nm-meta-setting-desc.h2
-rw-r--r--docs/libnm/Makefile.am2
-rw-r--r--docs/libnm/meson.build2
-rw-r--r--libnm-core/meson.build16
-rw-r--r--libnm-core/nm-core-internal.h35
-rw-r--r--libnm-core/nm-errors.c1
-rw-r--r--libnm-core/nm-setting-ethtool.c8
-rw-r--r--libnm-core/nm-setting-ethtool.h85
-rw-r--r--libnm-core/nm-utils.c13
-rw-r--r--libnm-core/tests/meson.build13
-rw-r--r--libnm-core/tests/test-general.c64
-rw-r--r--libnm-core/tests/test-setting.c1
-rw-r--r--libnm/NetworkManager.h1
-rw-r--r--libnm/meson.build1
-rw-r--r--libnm/nm-ethtool-utils.h100
-rw-r--r--po/POTFILES.in2
-rw-r--r--shared/README.md108
-rw-r--r--shared/meson.build61
-rw-r--r--shared/nm-base/nm-base.h (renamed from libnm-core/nm-libnm-core-intern/nm-ethtool-utils.h)86
-rw-r--r--shared/nm-base/nm-ethtool-base.c (renamed from libnm-core/nm-libnm-core-intern/nm-ethtool-utils.c)4
-rw-r--r--shared/nm-base/nm-ethtool-base.h37
l---------shared/nm-base/nm-ethtool-utils-base.h1
-rw-r--r--shared/nm-default.h2
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.c27
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h38
-rw-r--r--shared/nm-log-core/nm-logging.c (renamed from src/nm-logging.c)9
-rw-r--r--shared/nm-log-core/nm-logging.h (renamed from src/nm-logging.h)0
-rw-r--r--shared/nm-platform/nm-netlink.c (renamed from src/platform/nm-netlink.c)0
-rw-r--r--shared/nm-platform/nm-netlink.h (renamed from src/platform/nm-netlink.h)0
-rw-r--r--shared/nm-platform/nm-platform-utils.c (renamed from src/platform/nm-platform-utils.c)60
-rw-r--r--shared/nm-platform/nm-platform-utils.h (renamed from src/platform/nm-platform-utils.h)85
-rw-r--r--shared/nm-platform/nmp-base.h94
-rw-r--r--shared/nm-platform/nmp-netns.c (renamed from src/platform/nmp-netns.c)2
-rw-r--r--shared/nm-platform/nmp-netns.h (renamed from src/platform/nmp-netns.h)3
-rw-r--r--shared/nm-platform/tests/meson.build21
-rw-r--r--shared/nm-platform/tests/test-nm-platform.c118
-rw-r--r--src/devices/nm-device-ethernet.c4
-rw-r--r--src/devices/nm-device.c27
-rw-r--r--src/devices/wifi/nm-iwd-manager.c1
-rw-r--r--src/meson.build10
-rw-r--r--src/ndisc/nm-lndp-ndisc.c2
-rw-r--r--src/ndisc/nm-ndisc.c2
-rw-r--r--src/nm-core-utils.c23
-rw-r--r--src/nm-core-utils.h2
-rw-r--r--src/nm-iface-helper.c2
-rw-r--r--src/nm-ip4-config.c2
-rw-r--r--src/nm-ip6-config.c2
-rw-r--r--src/nm-l3-config-data.c2
-rw-r--r--src/nm-netns.c2
-rw-r--r--src/nm-netns.h2
-rw-r--r--src/nm-types.h36
-rw-r--r--src/platform/nm-fake-platform.c2
-rw-r--r--src/platform/nm-linux-platform.c13
-rw-r--r--src/platform/nm-platform.c27
-rw-r--r--src/platform/nm-platform.h39
-rw-r--r--src/platform/nmp-object.c2
-rw-r--r--src/platform/tests/test-common.c8
-rw-r--r--src/platform/tests/test-link.c24
-rw-r--r--src/platform/tests/test-platform-general.c2
-rw-r--r--src/platform/tests/test-route.c2
-rw-r--r--src/platform/tests/test-tc.c4
-rw-r--r--src/platform/wifi/nm-wifi-utils-nl80211.c4
-rw-r--r--src/platform/wifi/nm-wifi-utils-nl80211.h2
-rw-r--r--src/platform/wifi/nm-wifi-utils-wext.c3
-rw-r--r--src/platform/wifi/nm-wifi-utils.c2
-rw-r--r--src/platform/wifi/nm-wifi-utils.h2
-rw-r--r--src/platform/wpan/nm-wpan-utils.c4
-rw-r--r--src/platform/wpan/nm-wpan-utils.h2
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c2
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h2
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c2
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c3
-rw-r--r--src/systemd/meson.build82
-rw-r--r--src/tests/meson.build33
-rw-r--r--src/tests/test-core.c27
77 files changed, 1178 insertions, 488 deletions
diff --git a/.gitignore b/.gitignore
index b21bbf5c09..e9c4ba3590 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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]
diff --git a/Makefile.am b/Makefile.am
index e8bd7bdfc1..0735882dec 100644
--- a/Makefile.am
+++ b/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 \
diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h
index e278f19435..288880a31d 100644
--- a/clients/common/nm-meta-setting-desc.h
+++ b/clients/common/nm-meta-setting-desc.h
@@ -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;
diff --git a/docs/libnm/Makefile.am b/docs/libnm/Makefile.am
index 5328bd6586..c8f095f215 100644
--- a/docs/libnm/Makefile.am
+++ b/docs/libnm/Makefile.am
@@ -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 \
diff --git a/docs/libnm/meson.build b/docs/libnm/meson.build
index d3a0dd1fdc..2f70eb5c84 100644
--- a/docs/libnm/meson.build
+++ b/docs/libnm/meson.build
@@ -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',
diff --git a/libnm-core/meson.build b/libnm-core/meson.build
index d121bc0e1f..843ff67efb 100644
--- a/libnm-core/meson.build
+++ b/libnm-core/meson.build
@@ -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(
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index 2ed85526df..bda7f89d14 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -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 */);
/*****************************************************************************/
diff --git a/libnm-core/nm-errors.c b/libnm-core/nm-errors.c
index 106d2051f0..95a12c0717 100644
--- a/libnm-core/nm-errors.c
+++ b/libnm-core/nm-errors.c
@@ -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);
diff --git a/libnm-core/nm-setting-ethtool.c b/libnm-core/nm-setting-ethtool.c
index f1d6a8786c..7d3f4d96f9 100644
--- a/libnm-core/nm-setting-ethtool.c
+++ b/libnm-core/nm-setting-ethtool.c
@@ -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++;
}
diff --git a/libnm-core/nm-setting-ethtool.h b/libnm-core/nm-setting-ethtool.h
index 29b12569ac..d2310b408e 100644
--- a/libnm-core/nm-setting-ethtool.h
+++ b/libnm-core/nm-setting-ethtool.h
@@ -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);
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 6384e2e9a1..ab5de92a46 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -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);
}
/**
diff --git a/libnm-core/tests/meson.build b/libnm-core/tests/meson.build
index 8773baf7ad..0f6a4f5022 100644
--- a/libnm-core/tests/meson.build
+++ b/libnm-core/tests/meson.build
@@ -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,
)
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 4b44472e2f..00f6febbbb 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -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);
diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c
index 1ab2b7931c..b17ba15d51 100644
--- a/libnm-core/tests/test-setting.c
+++ b/libnm-core/tests/test-setting.c
@@ -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"
diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h
index b0b4cf3b8b..f9cc856555 100644
--- a/libnm/NetworkManager.h
+++ b/libnm/NetworkManager.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"
diff --git a/libnm/meson.build b/libnm/meson.build
index e4179c3033..27f51df684 100644
--- a/libnm/meson.build
+++ b/libnm/meson.build
@@ -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',
diff --git a/libnm/nm-ethtool-utils.h b/libnm/nm-ethtool-utils.h
new file mode 100644
index 0000000000..e8df3da242
--- /dev/null
+++ b/libnm/nm-ethtool-utils.h
@@ -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__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cee590c0cf..b3d33487bd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -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
diff --git a/shared/README.md b/shared/README.md
new file mode 100644
index 0000000000..ed950fce39
--- /dev/null
+++ b/shared/README.md
@@ -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.
diff --git a/shared/meson.build b/shared/meson.build
index 42fccae7da..58c29b7c76 100644
--- a/shared/meson.build
+++ b/shared/meson.build
@@ -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
diff --git a/libnm-core/nm-libnm-core-intern/nm-ethtool-utils.h b/shared/nm-base/nm-base.h
index 7afffe1b31..1db21aebc1 100644
--- a/libnm-core/nm-libnm-core-intern/nm-ethtool-utils.h
+++ b/shared/nm-base/nm-base.h
@@ -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__ */
diff --git a/libnm-core/nm-libnm-core-intern/nm-ethtool-utils.c b/shared/nm-base/nm-ethtool-base.c
index d02cfca111..9934aa06c1 100644
--- a/libnm-core/nm-libnm-core-intern/nm-ethtool-utils.c
+++ b/shared/nm-base/nm-ethtool-base.c
@@ -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"
/*****************************************************************************/
diff --git a/shared/nm-base/nm-ethtool-base.h b/shared/nm-base/nm-ethtool-base.h
new file mode 100644
index 0000000000..be90ce756e
--- /dev/null
+++ b/shared/nm-base/nm-ethtool-base.h
@@ -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__ */
diff --git a/shared/nm-base/nm-ethtool-utils-base.h b/shared/nm-base/nm-ethtool-utils-base.h
new file mode 120000
index 0000000000..ee2598578b
--- /dev/null
+++ b/shared/nm-base/nm-ethtool-utils-base.h
@@ -0,0 +1 @@
+../../libnm/nm-ethtool-utils.h \ No newline at end of file
diff --git a/shared/nm-default.h b/shared/nm-default.h
index 91ab085be8..f2cb024441 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.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
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c
index 5bab4bd2f2..f42b53c394 100644
--- a/shared/nm-glib-aux/nm-shared-utils.c
+++ b/shared/nm-glib-aux/nm-shared-utils.c
@@ -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)
{
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index fe61459f5f..8f0d50c9f5 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -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,
diff --git a/src/nm-logging.c b/shared/nm-log-core/nm-logging.c
index a646bb574f..495d5aca3c 100644
--- a/src/nm-logging.c
+++ b/shared/nm-log-core/nm-logging.c
@@ -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;
diff --git a/src/nm-logging.h b/shared/nm-log-core/nm-logging.h
index d3143d3973..d3143d3973 100644
--- a/src/nm-logging.h
+++ b/shared/nm-log-core/nm-logging.h
diff --git a/src/platform/nm-netlink.c b/shared/nm-platform/nm-netlink.c
index f9ebd1b623..f9ebd1b623 100644
--- a/src/platform/nm-netlink.c
+++ b/shared/nm-platform/nm-netlink.c
diff --git a/src/platform/nm-netlink.h b/shared/nm-platform/nm-netlink.h
index 8de42531d3..8de42531d3 100644
--- a/src/platform/nm-netlink.h
+++ b/shared/nm-platform/nm-netlink.h
diff --git a/src/platform/nm-platform-utils.c b/shared/nm-platform/nm-platform-utils.c
index f0dfc074a7..59e4a24491 100644
--- a/src/platform/nm-platform-utils.c
+++ b/shared/nm-platform/nm-platform-utils.c
@@ -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,
diff --git a/src/platform/nm-platform-utils.h b/shared/nm-platform/nm-platform-utils.h
index 4e778f0768..d74723eb9f 100644
--- a/src/platform/nm-platform-utils.h
+++ b/shared/nm-platform/nm-platform-utils.h
@@ -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);
diff --git a/shared/nm-platform/nmp-base.h b/shared/nm-platform/nmp-base.h
new file mode 100644
index 0000000000..210c26d6bb
--- /dev/null
+++ b/shared/nm-platform/nmp-base.h
@@ -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__ */
diff --git a/src/platform/nmp-netns.c b/shared/nm-platform/nmp-netns.c
index 69bb39cd82..01aefde66a 100644
--- a/src/platform/nmp-netns.c
+++ b/shared/nm-platform/nmp-netns.c
@@ -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! */
diff --git a/src/platform/nmp-netns.h b/shared/nm-platform/nmp-netns.h
index 2ba29e169e..b18bd03e76 100644
--- a/src/platform/nmp-netns.h
+++ b/shared/nm-platform/nmp-netns.h
@@ -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);
diff --git a/shared/nm-platform/tests/meson.build b/shared/nm-platform/tests/meson.build
new file mode 100644
index 0000000000..8d2b9c0f6e
--- /dev/null
+++ b/shared/nm-platform/tests/meson.build
@@ -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,
+)
diff --git a/shared/nm-platform/tests/test-nm-platform.c b/shared/nm-platform/tests/test-nm-platform.c
new file mode 100644
index 0000000000..0386a3a546
--- /dev/null
+++ b/shared/nm-platform/tests/test-nm-platform.c
@@ -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();
+}
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 37245b1c9d..f67baead46 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -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);
}
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 355f1047a2..8316107123 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -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
diff --git a/src/devices/wifi/nm-iwd-manager.c b/src/devices/wifi/nm-iwd-manager.c
index 0725e5ba68..5ded8e15a6 100644
--- a/src/devices/wifi/nm-iwd-manager.c
+++ b/src/devices/wifi/nm-iwd-manager.c
@@ -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"
diff --git a/src/meson.build b/src/meson.build
index 1d5f7b443c..8c0c141c29 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -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 = [
diff --git a/src/ndisc/nm-lndp-ndisc.c b/src/ndisc/nm-lndp-ndisc.c
index 2117190584..1d8becbfec 100644
--- a/src/ndisc/nm-lndp-ndisc.c
+++ b/src/ndisc/nm-lndp-ndisc.c
@@ -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"
diff --git a/src/ndisc/nm-ndisc.c b/src/ndisc/nm-ndisc.c
index c9e221136f..44035ff909 100644
--- a/src/ndisc/nm-ndisc.c
+++ b/src/ndisc/nm-ndisc.c
@@ -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"
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
index 7b62968fb5..660f6f4317 100644
--- a/src/nm-core-utils.c
+++ b/src/nm-core-utils.c
@@ -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.
diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
index c90daaa683..f4fe5f673c 100644
--- a/src/nm-core-utils.h
+++ b/src/nm-core-utils.h
@@ -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);
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 8fc30adb8b..42483cf756 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -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"
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index b881871c5a..8014549f4d 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -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"
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
index 0be98e5fe6..eeb69946a4 100644
--- a/src/nm-ip6-config.c
+++ b/src/nm-ip6-config.c
@@ -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"
diff --git a/src/nm-l3-config-data.c b/src/nm-l3-config-data.c
index daff7312db..0f689d409b 100644
--- a/src/nm-l3-config-data.c
+++ b/src/nm-l3-config-data.c
@@ -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"
diff --git a/src/nm-netns.c b/src/nm-netns.c
index bc4e9f619d..9f62643686 100644
--- a/src/nm-netns.c
+++ b/src/nm-netns.c
@@ -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"
/*****************************************************************************/
diff --git a/src/nm-netns.h b/src/nm-netns.h
index 36a34e29d4..aab3b52019 100644
--- a/src/nm-netns.h
+++ b/src/nm-netns.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))
diff --git a/src/nm-types.h b/src/nm-types.h
index 533099b577..ab2314594d 100644
--- a/src/nm-types.h
+++ b/src/nm-types.h
@@ -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 {
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 21f1e92465..fbd3e3fbc7 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -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"
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 74b2d5a962..3d992704eb 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -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"),
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 1feb1cd42d..6411abbacc 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -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);
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index c61ee16401..d400c5680a 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -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"
@@ -976,12 +979,6 @@ typedef struct {
} 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),
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_HAS_PRIVATE_KEY = (1LL << 1),
@@ -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);
diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c
index 16edbd1216..9520013ad7 100644
--- a/src/platform/nmp-object.c
+++ b/src/platform/nmp-object.c
@@ -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"
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c
index 4e08b282b0..529100b9f2 100644
--- a/src/platform/tests/test-common.c
+++ b/src/platform/tests/test-common.c
@@ -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();
diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c
index 66cb20ea64..895b89a09b 100644
--- a/src/platform/tests/test-link.c
+++ b/src/platform/tests/test-link.c
@@ -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;
diff --git a/src/platform/tests/test-platform-general.c b/src/platform/tests/test-platform-general.c
index ee99348077..00671cfba0 100644
--- a/src/platform/tests/test-platform-general.c
+++ b/src/platform/tests/test-platform-general.c
@@ -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"
diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c
index f814d8c78b..0aa94ecd2d 100644
--- a/src/platform/tests/test-route.c
+++ b/src/platform/tests/test-route.c
@@ -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"
diff --git a/src/platform/tests/test-tc.c b/src/platform/tests/test-tc.c
index 1920dfa4af..c005b069f0 100644
--- a/src/platform/tests/test-tc.c
+++ b/src/platform/tests/test-tc.c
@@ -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 *
diff --git a/src/platform/wifi/nm-wifi-utils-nl80211.c b/src/platform/wifi/nm-wifi-utils-nl80211.c
index a1c8ba6c93..aae6af1ec8 100644
--- a/src/platform/wifi/nm-wifi-utils-nl80211.c
+++ b/src/platform/wifi/nm-wifi-utils-nl80211.c
@@ -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"
diff --git a/src/platform/wifi/nm-wifi-utils-nl80211.h b/src/platform/wifi/nm-wifi-utils-nl80211.h
index 1633a9ce4b..37c32ed78e 100644
--- a/src/platform/wifi/nm-wifi-utils-nl80211.h
+++ b/src/platform/wifi/nm-wifi-utils-nl80211.h
@@ -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) \
diff --git a/src/platform/wifi/nm-wifi-utils-wext.c b/src/platform/wifi/nm-wifi-utils-wext.c
index 070b21092b..2b070b5abe 100644
--- a/src/platform/wifi/nm-wifi-utils-wext.c
+++ b/src/platform/wifi/nm-wifi-utils-wext.c
@@ -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;
diff --git a/src/platform/wifi/nm-wifi-utils.c b/src/platform/wifi/nm-wifi-utils.c
index a9d5f2484c..66d6a05a75 100644
--- a/src/platform/wifi/nm-wifi-utils.c
+++ b/src/platform/wifi/nm-wifi-utils.c
@@ -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)
diff --git a/src/platform/wifi/nm-wifi-utils.h b/src/platform/wifi/nm-wifi-utils.h
index 09e07a21c3..a252e43e54 100644
--- a/src/platform/wifi/nm-wifi-utils.h
+++ b/src/platform/wifi/nm-wifi-utils.h
@@ -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;
diff --git a/src/platform/wpan/nm-wpan-utils.c b/src/platform/wpan/nm-wpan-utils.c
index 79c72b92da..96897ae04d 100644
--- a/src/platform/wpan/nm-wpan-utils.c
+++ b/src/platform/wpan/nm-wpan-utils.c
@@ -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, ...) \
diff --git a/src/platform/wpan/nm-wpan-utils.h b/src/platform/wpan/nm-wpan-utils.h
index 6d170dd9ea..940c2c9daa 100644
--- a/src/platform/wpan/nm-wpan-utils.h
+++ b/src/platform/wpan/nm-wpan-utils.h
@@ -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;
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index 8e0bf1d68d..bce47efc8e 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -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"
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
index 0f0568118a..36ec922514 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.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"
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index a5f844e64c..a268c58c58 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -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"
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index 5b6923e4de..71f2d3e8c9 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -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"
diff --git a/src/systemd/meson.build b/src/systemd/meson.build
index 4dbbe13099..4f3a63eda4 100644
--- a/src/systemd/meson.build
+++ b/src/systemd/meson.build
@@ -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,
+)
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 7d6d0b0a2b..1d3f596382 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -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()],
)
diff --git a/src/tests/test-core.c b/src/tests/test-core.c
index 002723464e..87136dc3f1 100644
--- a/src/tests/test-core.c
+++ b/src/tests/test-core.c
@@ -105,6 +105,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)
{
struct in6_addr a = *nmtst_inet6_from_string(a1);
@@ -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);