summary refs log tree commit diff
path: root/src/core/ppp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ppp')
-rw-r--r--src/core/ppp/meson.build18
-rw-r--r--src/core/ppp/nm-ppp-manager-call.c47
-rw-r--r--src/core/ppp/nm-ppp-manager.c13
-rw-r--r--src/core/ppp/nm-pppd-plugin.c20
4 files changed, 61 insertions, 37 deletions
diff --git a/src/core/ppp/meson.build b/src/core/ppp/meson.build
index 607b4718..9ee46113 100644
--- a/src/core/ppp/meson.build
+++ b/src/core/ppp/meson.build
@@ -4,9 +4,20 @@ nm_pppd_plugin = shared_module(
   'nm-pppd-plugin',
   name_prefix: '',
   sources: 'nm-pppd-plugin.c',
-  dependencies: libnm_core_nm_default_dep,
-  c_args: [
-    '-DG_LOG_DOMAIN="nm-pppd-plugin"',
+  include_directories: [
+    src_inc,
+    top_inc,
+  ],
+  dependencies: [
+    libnm_core_public_dep,
+    glib_dep,
+  ],
+  link_with: [
+    libnm_core_impl,
+    libnm_log_null,
+    libnm_glib_aux,
+    libnm_std_aux,
+    libc_siphash,
   ],
   install: true,
   install_dir: pppd_plugin_dir,
@@ -20,7 +31,6 @@ core_plugins += shared_module(
     'nm-ppp-manager.c',
   ],
   dependencies: core_plugin_dep,
-  c_args: daemon_c_flags,
   link_args: '-Wl,--version-script,@0@'.format(linker_script),
   link_depends: linker_script,
   install: true,
diff --git a/src/core/ppp/nm-ppp-manager-call.c b/src/core/ppp/nm-ppp-manager-call.c
index f791e8b0..5e84f596 100644
--- a/src/core/ppp/nm-ppp-manager-call.c
+++ b/src/core/ppp/nm-ppp-manager-call.c
@@ -18,17 +18,21 @@
 
 /*****************************************************************************/
 
-static NMPPPOps *ppp_ops = NULL;
+static const NMPPPOps *_ppp_ops = NULL;
+
+#define ppp_ops_get() ((const NMPPPOps *) g_atomic_pointer_get(&_ppp_ops))
 
 NMPPPManager *
 nm_ppp_manager_create(const char *iface, GError **error)
 {
-    NMPPPManager *ret;
-    GModule *     plugin;
-    GError *      error_local = NULL;
-    NMPPPOps *    ops;
-    struct stat   st;
-
+    NMPPPManager *  ret;
+    GModule *       plugin;
+    GError *        error_local = NULL;
+    struct stat     st;
+    const NMPPPOps *ppp_ops;
+
+again:
+    ppp_ops = ppp_ops_get();
     if (G_UNLIKELY(!ppp_ops)) {
         if (stat(PPP_PLUGIN_PATH, &st) != 0) {
             g_set_error_literal(error,
@@ -58,7 +62,7 @@ nm_ppp_manager_create(const char *iface, GError **error)
             return NULL;
         }
 
-        if (!g_module_symbol(plugin, "ppp_ops", (gpointer) &ops)) {
+        if (!g_module_symbol(plugin, "ppp_ops", (gpointer *) &ppp_ops)) {
             g_set_error(error,
                         NM_MANAGER_ERROR,
                         NM_MANAGER_ERROR_MISSING_PLUGIN,
@@ -67,18 +71,21 @@ nm_ppp_manager_create(const char *iface, GError **error)
             return NULL;
         }
 
+        nm_assert(ppp_ops);
+        nm_assert(ppp_ops->create);
+        nm_assert(ppp_ops->start);
+        nm_assert(ppp_ops->stop);
+        nm_assert(ppp_ops->stop_cancel);
+
+        if (!g_atomic_pointer_compare_and_exchange(&_ppp_ops, NULL, ppp_ops)) {
+            g_module_close(plugin);
+            goto again;
+        }
+
         /* after loading glib types from the plugin, we cannot unload the library anymore.
          * Make it resident. */
         g_module_make_resident(plugin);
 
-        nm_assert(ops);
-        nm_assert(ops->create);
-        nm_assert(ops->start);
-        nm_assert(ops->stop);
-        nm_assert(ops->stop_cancel);
-
-        ppp_ops = ops;
-
         nm_log_info(LOGD_CORE | LOGD_PPP, "loaded PPP plugin " PPP_PLUGIN_PATH);
     }
 
@@ -94,6 +101,8 @@ nm_ppp_manager_set_route_parameters(NMPPPManager *self,
                                     guint32       ip6_route_table,
                                     guint32       ip6_route_metric)
 {
+    const NMPPPOps *ppp_ops = ppp_ops_get();
+
     g_return_if_fail(ppp_ops);
 
     ppp_ops->set_route_parameters(self,
@@ -111,6 +120,8 @@ nm_ppp_manager_start(NMPPPManager *self,
                      guint         baud_override,
                      GError **     err)
 {
+    const NMPPPOps *ppp_ops = ppp_ops_get();
+
     g_return_val_if_fail(ppp_ops, FALSE);
 
     return ppp_ops->start(self, req, ppp_name, timeout_secs, baud_override, err);
@@ -122,6 +133,8 @@ nm_ppp_manager_stop(NMPPPManager *           self,
                     NMPPPManagerStopCallback callback,
                     gpointer                 user_data)
 {
+    const NMPPPOps *ppp_ops = ppp_ops_get();
+
     g_return_val_if_fail(ppp_ops, NULL);
 
     return ppp_ops->stop(self, cancellable, callback, user_data);
@@ -130,6 +143,8 @@ nm_ppp_manager_stop(NMPPPManager *           self,
 void
 nm_ppp_manager_stop_cancel(NMPPPManagerStopHandle *handle)
 {
+    const NMPPPOps *ppp_ops = ppp_ops_get();
+
     g_return_if_fail(ppp_ops);
     g_return_if_fail(handle);
 
diff --git a/src/core/ppp/nm-ppp-manager.c b/src/core/ppp/nm-ppp-manager.c
index 396a49ae..fefc5d61 100644
--- a/src/core/ppp/nm-ppp-manager.c
+++ b/src/core/ppp/nm-ppp-manager.c
@@ -28,8 +28,9 @@
 #include <linux/rtnetlink.h>
 
 #include "NetworkManagerUtils.h"
-#include "platform/nm-platform.h"
-#include "nm-core-internal.h"
+#include "libnm-platform/nm-platform.h"
+#include "libnm-platform/nm-platform-utils.h"
+#include "libnm-core-intern/nm-core-internal.h"
 #include "nm-act-request.h"
 #include "nm-ip4-config.h"
 #include "nm-ip6-config.h"
@@ -998,7 +999,7 @@ _ppp_manager_start(NMPPPManager *self,
 
     /* Make sure /dev/ppp exists (bgo #533064) */
     if (stat("/dev/ppp", &st) || !S_ISCHR(st.st_mode))
-        nm_utils_modprobe(NULL, FALSE, "ppp_generic", NULL);
+        nmp_utils_modprobe(NULL, FALSE, "ppp_generic", NULL);
 
     connection = nm_act_request_get_applied_connection(req);
     g_return_val_if_fail(connection, FALSE);
@@ -1445,11 +1446,11 @@ nm_ppp_manager_class_init(NMPPPManagerClass *manager_class)
                                   NULL,
                                   G_TYPE_NONE,
                                   2,
-                                  G_TYPE_UINT /*guint32 in_bytes*/,
-                                  G_TYPE_UINT /*guint32 out_bytes*/);
+                                  G_TYPE_UINT,  /* guint32 in_bytes */
+                                  G_TYPE_UINT); /* guint32 out_bytes */
 }
 
-NMPPPOps ppp_ops = {
+const NMPPPOps ppp_ops = {
     .create               = _ppp_manager_new,
     .set_route_parameters = _ppp_manager_set_route_parameters,
     .start                = _ppp_manager_start,
diff --git a/src/core/ppp/nm-pppd-plugin.c b/src/core/ppp/nm-pppd-plugin.c
index c9016dac..5ffa7d17 100644
--- a/src/core/ppp/nm-pppd-plugin.c
+++ b/src/core/ppp/nm-pppd-plugin.c
@@ -20,7 +20,7 @@
 #include <pppd/eui64.h>
 #include <pppd/ipv6cp.h>
 
-#include "nm-glib-aux/nm-default-glib.h"
+#include "libnm-glib-aux/nm-default-glib.h"
 
 #include "nm-dbus-interface.h"
 
@@ -226,11 +226,10 @@ nm_ip_up(void *data, int arg)
         if (opts.dnsaddr[1])
             dns[len++] = opts.dnsaddr[1];
 
-        g_variant_builder_add(
-            &builder,
-            "{sv}",
-            NM_PPP_IP4_CONFIG_DNS,
-            g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, dns, len, sizeof(guint32)));
+        g_variant_builder_add(&builder,
+                              "{sv}",
+                              NM_PPP_IP4_CONFIG_DNS,
+                              nm_g_variant_new_au(dns, len));
     }
 
     if (opts.winsaddr[0] || opts.winsaddr[1]) {
@@ -242,11 +241,10 @@ nm_ip_up(void *data, int arg)
         if (opts.winsaddr[1])
             wins[len++] = opts.winsaddr[1];
 
-        g_variant_builder_add(
-            &builder,
-            "{sv}",
-            NM_PPP_IP4_CONFIG_WINS,
-            g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, wins, len, sizeof(guint32)));
+        g_variant_builder_add(&builder,
+                              "{sv}",
+                              NM_PPP_IP4_CONFIG_WINS,
+                              nm_g_variant_new_au(wins, len));
     }
 
     g_message("nm-ppp-plugin: sending IPv4 config to NetworkManager...");