about summary refs log tree commit diff
path: root/src/ppp/nm-pppd-plugin.c
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2018-08-24 11:00:09 +0200
committerSebastien Bacher <seb128@ubuntu.com>2018-08-24 11:06:47 +0200
commitb7db94545968c37886b7111d8c85f62eb063fbb4 (patch)
tree7c2aedd497b1fdcb26bf9d49f98cc63a530baf2e /src/ppp/nm-pppd-plugin.c
parent9d5cdc3adde9e7e57bf5a0e754e563b6a9e8e513 (diff)
parentcaf1db9d6fbc056cc6c76a24574890f6c7895f3d (diff)
Import Debian changes 1.12.2-0ubuntu3
network-manager (1.12.2-0ubuntu3) cosmic; urgency=medium

  * debian/rules:
    - use --with-libnm-glib, the default reversed since that's a legacy
      library but we still need it for unity-control-center

network-manager (1.12.2-0ubuntu2) cosmic; urgency=medium

  * debian/patches/git-newglib-test.patch:
    - backport upstream commit to fix the tests with the new glib 

network-manager (1.12.2-0ubuntu1) cosmic; urgency=medium

  * New upstream version
  * d/p/libnm-register-empty-NMClient-and-NetworkManager-when-loa.patch,
    d/p/e91f1a7d2a6b8400b6b331d5b72287dcb5164a39.patch,
    d/p/git_thunderbolt_connect.patch:
    - removed, those changes are in the new version
  * Backport Debian changes
  * Update symbols file for libnm0
  * Enable iwd support
  * Drop version requirements when oldstable ships a newer version
  * Drop dh_strip override, the dbgsym migration is done
  * Rebase patches
  * Make sure the example server.conf is actually installed
  * Update install path for plugins, it now includes a version number
  * Drop libnl3 build dependency.
    Upstream has copied the code directly from libnl3 for the few functions it
    needs with a few small modifications.
  * Drop libiw build dependency.
    Hasn't been needed for a long time and was simply a left over from older
    releases.
  * Bump Standards-Version to 4.1.5
  * Fix compile error due to NM_AVAILABLE_IN_1_12_2 macro (Closes: #905372)
Diffstat (limited to 'src/ppp/nm-pppd-plugin.c')
-rw-r--r--src/ppp/nm-pppd-plugin.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/ppp/nm-pppd-plugin.c b/src/ppp/nm-pppd-plugin.c
index 0ac8f907..989f7433 100644
--- a/src/ppp/nm-pppd-plugin.c
+++ b/src/ppp/nm-pppd-plugin.c
@@ -28,6 +28,7 @@
 #include <pppd/ipcp.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <net/if.h>
 #include <arpa/inet.h>
 #include <dlfcn.h>
 
@@ -36,7 +37,9 @@
 #include <pppd/ipv6cp.h>
 
 #include "nm-default.h"
+
 #include "nm-dbus-interface.h"
+
 #include "nm-pppd-plugin.h"
 #include "nm-ppp-status.h"
 
@@ -50,7 +53,9 @@ static void
 nm_phasechange (void *data, int arg)
 {
 	NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN;
+	char new_name[IF_NAMESIZE];
 	char *ppp_phase;
+	int index;
 
 	g_return_if_fail (G_IS_DBUS_PROXY (proxy));
 
@@ -126,6 +131,25 @@ nm_phasechange (void *data, int arg)
 		                   NULL,
 		                   NULL, NULL);
 	}
+
+	if (ppp_status == PHASE_RUNNING) {
+		index = if_nametoindex (ifname);
+		/* Make a sync call to ensure that when the call
+		 * terminates the interface already has its final
+		 * name. */
+		g_dbus_proxy_call_sync (proxy,
+		                        "SetIfindex",
+		                        g_variant_new ("(i)", index),
+		                        G_DBUS_CALL_FLAGS_NONE,
+		                        25000,
+		                        NULL, NULL);
+		/* Update the name in pppd if NM changed it */
+		if (   if_indextoname (index, new_name)
+		    && !nm_streq0 (ifname, new_name)) {
+			g_message ("nm-ppp-plugin: interface name changed from '%s' to '%s'", ifname, new_name);
+			strncpy (ifname, new_name, IF_NAMESIZE);
+		}
+	}
 }
 
 static void
@@ -148,6 +172,9 @@ nm_ip_up (void *data, int arg)
 
 	g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
 
+	/* Keep sending the interface name to be backwards compatible
+	 * with older versions of NM during a package upgrade, where
+	 * NM is not restarted and the pppd plugin was not loaded. */
 	g_variant_builder_add (&builder, "{sv}",
 	                       NM_PPP_IP4_CONFIG_INTERFACE,
 	                       g_variant_new_string (ifname));
@@ -242,6 +269,9 @@ nm_ip6_up (void *data, int arg)
 	g_message ("nm-ppp-plugin: (%s): ip6-up event", __func__);
 
 	g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
+	/* Keep sending the interface name to be backwards compatible
+	 * with older versions of NM during a package upgrade, where
+	 * NM is not restarted and the pppd plugin was not loaded. */
 	g_variant_builder_add (&builder, "{sv}",
 	                       NM_PPP_IP6_CONFIG_INTERFACE,
 	                       g_variant_new_string (ifname));
@@ -361,8 +391,6 @@ plugin_init (void)
 	GDBusConnection *bus;
 	GError *err = NULL;
 
-	nm_g_type_init ();
-
 	g_message ("nm-ppp-plugin: (%s): initializing", __func__);
 
 	bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err);