From de39f67d723253c7ac6d2021f2236eb8afab475b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 14 Jun 2023 14:14:31 +0200 Subject: [PATCH 1/3] ppp: detect the ppp version in the configure script Previously, the ppp version was only detected (and used) at one place, in "nm-pppd-compat.c", after including the ppp headers. That was nice and easy. However, with that way, we could only detect it after including ppp headers, and given the ugliness of ppp headers, we only want to include them in "nm-pppd-compat.c" (and nowhere else). In particular, 'nm-pppd-compat.c" uses symbols from the ppp daemon, it thus can only be linked into a ppp plugin, not in NetworkManager core itself. But at some places we will need to know the ppp version, outside of the ppp plugin and "nm-pppd-compat.c". Additionally, detect it at configure time and place it in "config.h". There is a static assert that we are in agreement with the two ways of detection. (cherry picked from commit 3e66c0bde1472489dfafe53f25fbe252d5a4bcad) (cherry picked from commit 65756dca7f865be16f4c1d29b0782e270dd83c8e) --- config.h.meson | 3 +++ configure.ac | 3 +++ meson.build | 3 +++ src/core/ppp/nm-pppd-compat.c | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/config.h.meson b/config.h.meson index 7337165082..bda542035b 100644 --- a/config.h.meson +++ b/config.h.meson @@ -239,6 +239,9 @@ /* Define to path of pppd binary */ #mesondefine PPPD_PATH +/* The detected ppp API version */ +#mesondefine NM_PPP_VERSION_2_5_OR_NEWER + /* Define if you have iwd support */ #mesondefine WITH_IWD diff --git a/configure.ac b/configure.ac index 8757257fae..445cd6fb02 100644 --- a/configure.ac +++ b/configure.ac @@ -754,10 +754,12 @@ fi AC_SUBST(DBUS_SYS_DIR) # pppd +NM_PPP_VERSION_2_5_OR_NEWER=0 PPPD_VERSION=2.4.9 PKG_CHECK_EXISTS([pppd], [ PPPD_VERSION=`$PKG_CONFIG --modversion pppd` PPPD_CFLAGS=`$PKG_CONFIG --cflags pppd` + NM_PPP_VERSION_2_5_OR_NEWER=1 ]) AC_ARG_ENABLE(ppp, @@ -783,6 +785,7 @@ else PPPD_PLUGIN_DIR="${libdir}/pppd/$PPPD_VERSION" fi AC_SUBST(PPPD_PLUGIN_DIR) +AC_DEFINE_UNQUOTED(NM_PPP_VERSION_2_5_OR_NEWER, $NM_PPP_VERSION_2_5_OR_NEWER, [The detected ppp API version]) AC_ARG_WITH(pppd, AS_HELP_STRING([--with-pppd=/path/to/pppd], [path to pppd binary])) if test "x${with_pppd}" = x; then diff --git a/meson.build b/meson.build index a8ec64be69..64350e1cfe 100644 --- a/meson.build +++ b/meson.build @@ -560,10 +560,12 @@ config_h.set10('WITH_FIREWALLD_ZONE', enable_firewalld_zone) # pppd enable_ppp = get_option('ppp') +NM_PPP_VERSION_2_5_OR_NEWER = 0 if enable_ppp pppd_dep = dependency('pppd', required: false) if (pppd_dep.found()) pppd_version = pppd_dep.version() + NM_PPP_VERSION_2_5_OR_NEWER = 1 else assert(cc.has_header('pppd/pppd.h'), 'couldn\'t find pppd.h. pppd development headers are required') pppd_version = '2.4.9' @@ -584,6 +586,7 @@ if enable_ppp endif endif config_h.set10('WITH_PPP', enable_ppp) +config_h.set10('NM_PPP_VERSION_2_5_OR_NEWER', NM_PPP_VERSION_2_5_OR_NEWER) # ModemManager1 with libmm-glib enable_modem_manager = get_option('modem_manager') diff --git a/src/core/ppp/nm-pppd-compat.c b/src/core/ppp/nm-pppd-compat.c index fd67eb3493..f7940c5501 100644 --- a/src/core/ppp/nm-pppd-compat.c +++ b/src/core/ppp/nm-pppd-compat.c @@ -75,6 +75,10 @@ _NM_PRAGMA_WARNING_REENABLE; /*****************************************************************************/ +G_STATIC_ASSERT(PPP_VERSION_2_5_OR_NEWER == NM_PPP_VERSION_2_5_OR_NEWER); + +/*****************************************************************************/ + G_STATIC_ASSERT((gint64) NM_PPP_STATUS_DEAD == PHASE_DEAD); G_STATIC_ASSERT((gint64) NM_PPP_STATUS_INITIALIZE == PHASE_INITIALIZE); G_STATIC_ASSERT((gint64) NM_PPP_STATUS_SERIALCONN == PHASE_SERIALCONN); From 21f96f7357840dbdacb7abb077fd7e773755aef3 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Jun 2023 08:51:54 +0200 Subject: [PATCH 2/3] ppp: fix plugin name for "rp-pppoe.so" with ppp 2.5 Between ppp 2.4.8 and 2.4.9, "rp-pppoe.so" was renamed to "pppoe.so" (and a symlink created). Between 2.4.9 and 2.5.0, the symlink was dropped. See-also: https://github.com/ppp-project/ppp/commit/b2c36e6c0e1655aea9b1b0a03a8160f42a26c884 I guess, NetworkManager always meant to use ppp's "(rp-)pppoe.so" plugin, and never the library from the rp-pppoe project. If a user actually wants to use the plugin from rp-pppoe project, then this is going to break. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1312 Fixes: afe80171b24d ('ppp: move ppp code to "nm-pppd-compat.c"') (cherry picked from commit 84e21d8bbcbe14b3325fde51a91d0e16c803612f) (cherry picked from commit 1c736a44b4f1653da73774e09879597df1613f60) --- src/core/ppp/nm-ppp-manager.c | 4 ++-- src/core/ppp/nm-ppp-status.h | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/ppp/nm-ppp-manager.c b/src/core/ppp/nm-ppp-manager.c index e5fcb6aa2b..c58513f85c 100644 --- a/src/core/ppp/nm-ppp-manager.c +++ b/src/core/ppp/nm-ppp-manager.c @@ -842,7 +842,7 @@ create_pppd_cmd_line(NMPPPManager *self, const char *pppoe_service; nm_strv_ptrarray_add_string_dup(cmd, "plugin"); - nm_strv_ptrarray_add_string_dup(cmd, "rp-pppoe.so"); + nm_strv_ptrarray_add_string_dup(cmd, NM_PPPOE_PLUGIN_NAME); nm_strv_ptrarray_add_string_concat(cmd, "nic-", priv->parent_iface); @@ -871,7 +871,7 @@ create_pppd_cmd_line(NMPPPManager *self, } else if (!strcmp(protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE)) { nm_strv_ptrarray_add_string_dup(cmd, "plugin"); - nm_strv_ptrarray_add_string_dup(cmd, "rp-pppoe.so"); + nm_strv_ptrarray_add_string_dup(cmd, NM_PPPOE_PLUGIN_NAME); nm_strv_ptrarray_add_string_dup(cmd, priv->parent_iface); } diff --git a/src/core/ppp/nm-ppp-status.h b/src/core/ppp/nm-ppp-status.h index 57b48fe922..a2576e9cc0 100644 --- a/src/core/ppp/nm-ppp-status.h +++ b/src/core/ppp/nm-ppp-status.h @@ -29,4 +29,10 @@ typedef enum { NM_PPP_STATUS_INTERN_DEAD, } NMPPPStatus; +/*****************************************************************************/ + +/* The plugin name "(rp-)pppoe.so" depends on the ppp version. */ + +#define NM_PPPOE_PLUGIN_NAME (NM_PPP_VERSION_2_5_OR_NEWER ? "pppoe.so" : "rp-pppoe.so") + #endif /* __NM_PPP_STATUS_H__ */ From 5b421193fe7dfcfded6936a9c49497efb6c3dc4c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 14 Jun 2023 14:53:31 +0200 Subject: [PATCH 3/3] ppp/autotools: add missing check for symbols of libnm-ppp-plugin (cherry picked from commit 0a7145a061b26a6be0162500e3dde0940aeb2dda) (cherry picked from commit 8083bf1c7dfcd07208b94c4d21c88640ad338bce) --- Makefile.am | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.am b/Makefile.am index 16586af4d1..0c0265588b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3227,6 +3227,12 @@ src_core_ppp_libnm_ppp_plugin_la_LIBADD = \ $(src_core_ppp_libnm_ppp_plugin_la_OBJECTS): $(src_libnm_core_public_mkenums_h) +check-local-ppp-plugin: src/core/NetworkManager src/core/ppp/libnm-ppp-plugin.la + $(srcdir)/tools/check-exports.sh $(builddir)/src/core/ppp/.libs/libnm-ppp-plugin.so "$(srcdir)/src/core/ppp/nm-ppp-plugin.ver" + $(call check_so_symbols,$(builddir)/src/core/ppp/.libs/libnm-ppp-plugin.so) + +check_local += check-local-ppp-plugin + endif EXTRA_DIST += \