Skip to contentSkip to conversation

bonding: do not save non-existent device to bond primary in check params

PATCH In review Ding Tianhong 2 participants 2 messages Jan 9, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/4 bonding: do not save non-existent device to bond primary in check params

When install the bonding, the primay will be use to distinguish the primary slave for ab, alb and tlb mode, but it is meanless to save a no existed device, so add check for it.

---
 drivers/net/bonding/bond_main.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/net/bonding/bond_main.c +13 -7
index de646e2..651c5fd 100644
@@ -4246,13 +4246,19 @@ static int bond_check_params(struct bond_params *params)
 		pr_debug("Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details.\n");
 	}
 
-	if (primary && !USES_PRIMARY(bond_mode)) {
-		/* currently, using a primary only makes sense
-		 * in active backup, TLB or ALB modes
-		 */
-		pr_warning("Warning: %s primary device specified but has no effect in %s mode\n",
-			   primary, bond_mode_name(bond_mode));
-		primary = NULL;
+	if (primary) {
+		if (!__dev_get_by_name(&init_net, primary)) {
+			pr_warn("Warning: %s primary device is not exist\n",
+				primary);
+			primary = NULL;
+		} else if (!USES_PRIMARY(bond_mode)) {
+			/* currently, using a primary only makes sense
+			 * in active backup, TLB or ALB modes
+			 */
+			pr_warn("Warning: %s primary device specified but has no effect in %s mode\n",
+				primary, bond_mode_name(bond_mode));
+			primary = NULL;
+		}
 	}
 
 	if (primary && primary_reselect) {
Signature · 1 line
1.8.0
#1 lore raw
Quoted 3 lines · Ding Tianhong

When install the bonding, the primay will be use to distinguish the primary slave for ab, alb and tlb mode, but it is meanless to save a no existed device, so add check for it.

Same remark as for the sysfs patch - we can have arbitrary name of the interface in the paramter.

Quoted 41 lines

---
drivers/net/bonding/bond_main.c | 20 +++++++++++++-------

1 file changed, 13 insertions(+), 7 deletions(-)
drivers/net/bonding/bond_main.c +13 -7
index de646e2..651c5fd 100644
@@ -4246,13 +4246,19 @@ static int bond_check_params(struct bond_params *params)
 		pr_debug("Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details.\n");
 	}
 
-	if (primary && !USES_PRIMARY(bond_mode)) {
-		/* currently, using a primary only makes sense
-		 * in active backup, TLB or ALB modes
-		 */
-		pr_warning("Warning: %s primary device specified but has no effect in %s mode\n",
-			   primary, bond_mode_name(bond_mode));
-		primary = NULL;
+	if (primary) {
+		if (!__dev_get_by_name(&init_net, primary)) {
+			pr_warn("Warning: %s primary device is not exist\n",
+				primary);
+			primary = NULL;
+		} else if (!USES_PRIMARY(bond_mode)) {
+			/* currently, using a primary only makes sense
+			 * in active backup, TLB or ALB modes
+			 */
+			pr_warn("Warning: %s primary device specified but has no effect in %s mode\n",
+				primary, bond_mode_name(bond_mode));
+			primary = NULL;
+		}
 	}
 
 	if (primary && primary_reselect) {
Signature · 1 line
1.8.0