Subject: [PATCH][BONDING] Allow setting max_bonds to zero

From: Phil Oester <[email-masked]>
Date: Fri, 29 Feb 2008 10:52:57 -0800

commit fc78750341ab174a16f865625b24377670e92e50
Author: Phil Oester <[email-masked]>
Date:   Fri Feb 29 13:43:34 2008 -0500

    If the bonding driver is compiled into the kernel, it will create a
    "bond0" device by default.  The patch below allows max_bonds to be
    set to 0 to prevent any devices from being created.
    
    Phil
    
    Signed-off-by: Phil Oester <[email-masked]>

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 64597d8..2bef4b4 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4624,11 +4624,11 @@ static int bond_check_params(struct bond_params *params)
 		}
 	}
 
-	if (max_bonds < 1 || max_bonds > INT_MAX) {
+	if (max_bonds > INT_MAX) {
 		printk(KERN_WARNING DRV_NAME
-		       ": Warning: max_bonds (%d) not in range %d-%d, so it "
+		       ": Warning: max_bonds (%d) not in range 0-%d, so it "
 		       "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n",
-		       max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS);
+		       max_bonds, INT_MAX, BOND_DEFAULT_MAX_BONDS);
 		max_bonds = BOND_DEFAULT_MAX_BONDS;
 	}
 
@@ -4982,9 +4982,11 @@ static int __init bonding_init(void)
 			goto err;
 	}
 
-	res = bond_create_sysfs();
-	if (res)
-		goto err;
+	if (max_bonds > 0) {
+		res = bond_create_sysfs();
+		if (res)
+			goto err;
+	}
 
 	register_netdevice_notifier(&bond_netdev_notifier);
 	register_inetaddr_notifier(&bond_inetaddr_notifier);