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-08 17:03:53 +0100
commitb5117691f1502da20f4585d0c8f641a74d54aa5b (patch)
tree185192d51888549295db25751d0c3d640b607210
parentbf7b4cbab0fbb228e9ae629b4e1ba9fd34d2d816 (diff)
downloadNetworkManager-bg/bgo1515829.tar.gz
ppp: update interface name in the plugin after NM changes itbg/bgo1515829
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 eabb3afb79..b0210595e3 100644
--- a/src/ppp/nm-pppd-plugin.c
+++ b/src/ppp/nm-pppd-plugin.c
@@ -52,6 +52,8 @@ nm_phasechange (void *data, int arg)
{
NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN;
char *ppp_phase;
+ int index;
+ char new_name[IF_NAMESIZE];
g_return_if_fail (G_IS_DBUS_PROXY (proxy));
@@ -129,12 +131,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);
+ }
}
}