summary refs log tree commit diff
path: root/src/core/devices/nm-device-ppp.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2022-01-13 22:30:39 +0100
committerMichael Biebl <biebl@debian.org>2022-01-13 22:30:39 +0100
commit88c227d90a6b7b388c5c85d72802a0ca8f05ed5c (patch)
tree71f32df6617802270e8a78574bd8e1637dc532f4 /src/core/devices/nm-device-ppp.c
parente74c568b07b50b97873fb4ee1d776dedefbd54d6 (diff)
New upstream version 1.34.0 upstream/1.34.0
Diffstat (limited to 'src/core/devices/nm-device-ppp.c')
-rw-r--r--src/core/devices/nm-device-ppp.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/core/devices/nm-device-ppp.c b/src/core/devices/nm-device-ppp.c
index 8df245bb..04051bec 100644
--- a/src/core/devices/nm-device-ppp.c
+++ b/src/core/devices/nm-device-ppp.c
@@ -93,28 +93,35 @@ ppp_ifindex_set(NMPPPManager *ppp_manager, int ifindex, const char *iface, gpoin
 }
 
 static void
-ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data)
+_ppp_ip4_config_handle(NMDevicePpp *self)
 {
-    NMDevice *          device = NM_DEVICE(user_data);
-    NMDevicePpp *       self   = NM_DEVICE_PPP(device);
+    NMDevice *          device = NM_DEVICE(self);
     NMDevicePppPrivate *priv   = NM_DEVICE_PPP_GET_PRIVATE(self);
 
-    _LOGT(LOGD_DEVICE | LOGD_PPP, "received IPv4 config from pppd");
+    if (!priv->ip4_config)
+        return;
 
-    if (nm_device_get_state(device) == NM_DEVICE_STATE_IP_CONFIG) {
-        if (nm_device_activate_ip4_state_in_conf(device)) {
-            nm_device_activate_schedule_ip_config_result(device,
-                                                         AF_INET,
-                                                         NM_IP_CONFIG_CAST(config));
-            return;
-        }
-    } else {
-        if (priv->ip4_config)
-            g_object_unref(priv->ip4_config);
-        priv->ip4_config = g_object_ref(config);
+    if (nm_device_get_state(device) == NM_DEVICE_STATE_IP_CONFIG
+        && nm_device_activate_ip4_state_in_conf(device)) {
+        nm_device_activate_schedule_ip_config_result(
+            device,
+            AF_INET,
+            NM_IP_CONFIG_CAST(g_steal_pointer(&priv->ip4_config)));
+        return;
     }
 }
 
+static void
+ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data)
+{
+    NMDevicePpp *       self = NM_DEVICE_PPP(user_data);
+    NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self);
+
+    _LOGT(LOGD_DEVICE | LOGD_PPP, "received IPv4 config from pppd");
+    nm_g_object_ref_set(&priv->ip4_config, config);
+    _ppp_ip4_config_handle(self);
+}
+
 static gboolean
 check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error)
 {
@@ -193,6 +200,15 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason)
     return NM_ACT_STAGE_RETURN_POSTPONE;
 }
 
+static gboolean
+_schedule_ip_config_result(gpointer user_data)
+{
+    gs_unref_object NMDevicePpp *self = user_data;
+
+    _ppp_ip4_config_handle(self);
+    return G_SOURCE_REMOVE;
+}
+
 static NMActStageReturn
 act_stage3_ip_config_start(NMDevice *           device,
                            int                  addr_family,
@@ -203,13 +219,8 @@ act_stage3_ip_config_start(NMDevice *           device,
         NMDevicePpp *       self = NM_DEVICE_PPP(device);
         NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self);
 
-        if (priv->ip4_config) {
-            if (out_config)
-                *out_config = g_steal_pointer(&priv->ip4_config);
-            else
-                g_clear_object(&priv->ip4_config);
-            return NM_ACT_STAGE_RETURN_SUCCESS;
-        }
+        if (priv->ip4_config)
+            nm_g_idle_add(_schedule_ip_config_result, g_object_ref(self));
 
         /* Wait IPCP termination */
         return NM_ACT_STAGE_RETURN_POSTPONE;
@@ -256,6 +267,8 @@ deactivate(NMDevice *device)
         nm_ppp_manager_stop(priv->ppp_manager, NULL, NULL, NULL);
         g_clear_object(&priv->ppp_manager);
     }
+
+    g_clear_object(&priv->ip4_config);
 }
 
 static void