summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-01-08 17:03:53 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2018-01-10 15:36:29 +0100
commit398f9105b49e1c44389462533a53b5a11cc94eca (patch)
treec6f493a9861fddff4454d2a5de3d94846cf0dc84
parent41ef5853e687891438de584d5f44eb7fbaa9ac8a (diff)
downloadNetworkManager-398f9105b49e1c44389462533a53b5a11cc94eca.tar.gz
ppp: update interface name in the plugin after NM changes it
When NM knows of the ifindex/name of the new PPP interface (through the SetIfindex() call), it renames it. This can race with the pppd daemon, which issues ioctl() using the interface name cached in the global 'ifname' variable: ... NetworkManager[27213]: <debug> [1515427406.0036] ppp-manager: set-ifindex 71 pppd[27801]: sent [CCP ConfRej id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>] NetworkManager[27213]: <debug> [1515427406.0036] platform: link: setting 'ppp5' (71) name dsl-ppp pppd[27801]: sent [IPCP ConfAck id=0x2 <addr 3.1.1.1>] pppd[27801]: ioctl(SIOCSIFADDR): No such device (line 2473) pppd[27801]: Interface configuration failed pppd[27801]: Couldn't get PPP statistics: No such device ... Fortunately the variable is exposed to plugins and so we can turn the SetIfindex() D-Bus call into a synchronous one and then update the value of the 'ifname' global variable with the new interface name assigned by NM.
-rw-r--r--src/ppp/nm-pppd-plugin.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ppp/nm-pppd-plugin.c b/src/ppp/nm-pppd-plugin.c
index 8c9646a46c..c5496e6622 100644
--- a/src/ppp/nm-pppd-plugin.c
+++ b/src/ppp/nm-pppd-plugin.c
@@ -53,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));
@@ -131,12 +133,22 @@ nm_phasechange (void *data, int arg)
}
if (ppp_status == PHASE_RUNNING) {
- g_dbus_proxy_call (proxy,
- "SetIfindex",
- g_variant_new ("(i)", if_nametoindex (ifname)),
- G_DBUS_CALL_FLAGS_NONE, -1,
- NULL,
- NULL, NULL);
+ 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);
+ }
}
}