lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 2 Jan 2008 16:20:48 -0500
From:	"Jari Takkala" <Jari.Takkala@...com>
To:	<netdev@...r.kernel.org>
Subject: [PATCH 2.6.23.12] net/bonding: option to specify initial bond interface number

Allow the user to specify an initial interface number when loading the bonding driver. This is useful when loading multiple instances of the bonding driver and you want to control the interface number assignment. For example, if the user wishes to create a bond5 interface they can type 'modprobe -o bond5 bonding ifnum=5'. It also works with the max_bonds option.

Signed-off-by: Jari Takkala <jari.takkala@...com>
---
diff -ruN linux-2.6.23.12.orig/drivers/net/bonding/bond_main.c linux-2.6.23.12/drivers/net/bonding/bond_main.c
--- linux-2.6.23.12.orig/drivers/net/bonding/bond_main.c	2007-12-18 16:55:57.000000000 -0500
+++ linux-2.6.23.12/drivers/net/bonding/bond_main.c	2008-01-02 14:49:37.000000000 -0500
@@ -85,6 +85,7 @@
 #define BOND_LINK_MON_INTERV	0
 #define BOND_LINK_ARP_INTERV	0
 
+static int ifnum	= BOND_DEFAULT_IFNUM;
 static int max_bonds	= BOND_DEFAULT_MAX_BONDS;
 static int miimon	= BOND_LINK_MON_INTERV;
 static int updelay	= 0;
@@ -99,6 +100,8 @@
 static char *arp_validate = NULL;
 struct bond_params bonding_defaults;
 
+module_param(ifnum, int, 0);
+MODULE_PARM_DESC(ifnum, "Initial interface number to assign");
 module_param(max_bonds, int, 0);
 MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
 module_param(miimon, int, 0);
@@ -4388,6 +4391,14 @@
 		}
 	}
 
+	if (ifnum < 0 || ifnum > INT_MAX) {
+		printk(KERN_WARNING DRV_NAME
+		       ": Warning: ifnum (%d) not in range %d-%d, so it "
+		       "was reset to BOND_DEFAULT_IFNUM (%d)\n",
+		       ifnum, 0, INT_MAX, BOND_DEFAULT_IFNUM);
+		ifnum = BOND_DEFAULT_IFNUM;
+	}
+
 	if (max_bonds < 1 || max_bonds > INT_MAX) {
 		printk(KERN_WARNING DRV_NAME
 		       ": Warning: max_bonds (%d) not in range %d-%d, so it "
@@ -4703,6 +4714,7 @@
 {
 	int i;
 	int res;
+	char ifname[16];
 
 	printk(KERN_INFO "%s", version);
 
@@ -4715,7 +4727,13 @@
 	bond_create_proc_dir();
 #endif
 	for (i = 0; i < max_bonds; i++) {
-		res = bond_create(NULL, &bonding_defaults, NULL);
+		if (ifnum != BOND_DEFAULT_IFNUM) {
+			ifnum = ifnum + i;
+			snprintf(ifname, sizeof(ifname) - 1, "bond%d", ifnum);
+			res = bond_create(ifname, &bonding_defaults, NULL);
+		} else {
+			res = bond_create(NULL, &bonding_defaults, NULL);
+		}
 		if (res)
 			goto err;
 	}
diff -ruN linux-2.6.23.12.orig/include/linux/if_bonding.h linux-2.6.23.12/include/linux/if_bonding.h
--- linux-2.6.23.12.orig/include/linux/if_bonding.h	2007-12-18 16:55:57.000000000 -0500
+++ linux-2.6.23.12/include/linux/if_bonding.h	2008-01-02 13:30:18.000000000 -0500
@@ -81,6 +81,7 @@
 #define BOND_STATE_ACTIVE       0   /* link is active */
 #define BOND_STATE_BACKUP       1   /* link is backup */
 
+#define BOND_DEFAULT_IFNUM	0   /* Default interface number */
 #define BOND_DEFAULT_MAX_BONDS  1   /* Default maximum number of devices to support */
 
 /* hashing types */

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ