Commit a313da88 authored by Pavel Šimerda's avatar Pavel Šimerda
Browse files

platform: suppress kernel's automatic creation of bond0 (rh #953466)

Which it does whenever the 'bonding' module gets loaded no matter
what name the user wants to give the new bond interface.

Ported nm-system fix from commit 7cc95d89, using system() to avoid
dependency on NM libs.

Automatic test included. You have to run 'rmmod bonding' before testing
to ensure that the module is not already inserted. Second run without
rmmod always succeeds.
parent 1929471d
......@@ -829,6 +829,18 @@ build_rtnl_link (int ifindex, const char *name, NMLinkType type)
static gboolean
link_add (NMPlatform *platform, const char *name, NMLinkType type)
{
if (type == NM_LINK_TYPE_BOND) {
/* When the kernel loads the bond module, either via explicit modprobe
* or automatically in response to creating a bond master, it will also
* create a 'bond0' interface. Since the bond we're about to create may
* or may not be named 'bond0' prevent potential confusion about a bond
* that the user didn't want by telling the bonding module not to create
* bond0 automatically.
*/
if (!g_file_test ("/sys/class/net/bonding_masters", G_FILE_TEST_EXISTS))
system ("modprobe bonding max_bonds=0");
}
return add_object (platform, build_rtnl_link (0, name, type));
}
......
......@@ -107,7 +107,18 @@ virtual_add (NMLinkType link_type, const char *name, SignalData *link_added, Sig
case NM_LINK_TYPE_BRIDGE:
return nm_platform_bridge_add (name);
case NM_LINK_TYPE_BOND:
return nm_platform_bond_add (name);
{
gboolean bond0_exists = nm_platform_link_exists ("bond0");
gboolean result = nm_platform_bond_add (name);
NMPlatformError error = nm_platform_get_error ();
/* Check that bond0 is *not* automatically created. */
if (!bond0_exists)
g_assert (!nm_platform_link_exists ("bond0"));
nm_platform_set_error (error);
return result;
}
case NM_LINK_TYPE_TEAM:
return nm_platform_team_add (name);
default:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment