summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-07-03 17:01:43 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2017-08-05 08:03:16 +0200
commit74bf32ff9a672008017c23696c0eb7e9e02e6198 (patch)
tree4c88c3850717c43d3be3c5083904e915ce322de3
parenta7afa9ead7e8ca53d269ee69284056889f072281 (diff)
downloadNetworkManager-74bf32ff9a672008017c23696c0eb7e9e02e6198.tar.gz
core: ppp: use a different unit for each activation
We can't tell pppd to create an interface with a given name, so we use the name generated by kernel and rename the interface afterwards. A race condition can happen during the rename: NM receives the interface name from pppd, but in the meantime the interface could be deleted and another one with that name could appear. In this case we would rename the wrong interface. Using a changing unit index, we ensure that interfaces created by NM don't race with each others. There is still the chance to race with externally-created interfaces, but I guess this is not easily solvable since the pppd plugin does not expose the ifindex. When the specified unit is already in use, the kernel selects another one.
-rw-r--r--src/ppp/nm-ppp-manager.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c
index fec7ce375f..06703366f3 100644
--- a/src/ppp/nm-ppp-manager.c
+++ b/src/ppp/nm-ppp-manager.c
@@ -678,6 +678,7 @@ create_pppd_cmd_line (NMPPPManager *self,
const char *pppd_binary = NULL;
NMCmdLine *cmd;
gboolean ppp_debug;
+ static int unit;
g_return_val_if_fail (setting != NULL, NULL);
@@ -842,6 +843,15 @@ create_pppd_cmd_line (NMPPPManager *self,
nm_cmd_line_add_string (cmd, "plugin");
nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN);
+ if (pppoe && nm_setting_pppoe_get_parent (pppoe)) {
+ /* The PPP interface is going to be renamed, so pass a
+ * different unit each time so that activations don't
+ * race with each others. */
+ nm_cmd_line_add_string (cmd, "unit");
+ nm_cmd_line_add_int (cmd, unit);
+ unit = unit < G_MAXINT ? unit + 1 : 0;
+ }
+
return cmd;
}