mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 12:30:10 +01:00
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.
This commit is contained in:
parent
a7afa9ead7
commit
74bf32ff9a
1 changed files with 10 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue