Merge branch 'rs485fix' of git://www.jni.nu/cris
[sfrench/cifs-2.6.git] / drivers / net / bonding / bond_sysfs.c
index f9a034361a8ef1263904cef001a28cccbc05b27a..c311aed9bd022c2870b33fdc8c88a953d6cceb93 100644 (file)
@@ -313,19 +313,26 @@ static ssize_t bonding_store_mode(struct device *d,
                       bond->dev->name, (int)strlen(buf) - 1, buf);
                ret = -EINVAL;
                goto out;
-       } else {
-               if (bond->params.mode == BOND_MODE_8023AD)
-                       bond_unset_master_3ad_flags(bond);
+       }
+       if ((new_value == BOND_MODE_ALB ||
+            new_value == BOND_MODE_TLB) &&
+           bond->params.arp_interval) {
+               pr_err("%s: %s mode is incompatible with arp monitoring.\n",
+                      bond->dev->name, bond_mode_tbl[new_value].modename);
+               ret = -EINVAL;
+               goto out;
+       }
+       if (bond->params.mode == BOND_MODE_8023AD)
+               bond_unset_master_3ad_flags(bond);
 
-               if (bond->params.mode == BOND_MODE_ALB)
-                       bond_unset_master_alb_flags(bond);
+       if (bond->params.mode == BOND_MODE_ALB)
+               bond_unset_master_alb_flags(bond);
 
-               bond->params.mode = new_value;
-               bond_set_mode_ops(bond, bond->params.mode);
-               pr_info("%s: setting mode to %s (%d).\n",
-                       bond->dev->name, bond_mode_tbl[new_value].modename,
-                      new_value);
-       }
+       bond->params.mode = new_value;
+       bond_set_mode_ops(bond, bond->params.mode);
+       pr_info("%s: setting mode to %s (%d).\n",
+               bond->dev->name, bond_mode_tbl[new_value].modename,
+               new_value);
 out:
        return ret;
 }
@@ -510,7 +517,13 @@ static ssize_t bonding_store_arp_interval(struct device *d,
                ret = -EINVAL;
                goto out;
        }
-
+       if (bond->params.mode == BOND_MODE_ALB ||
+           bond->params.mode == BOND_MODE_TLB) {
+               pr_info("%s: ARP monitoring cannot be used with ALB/TLB. Only MII monitoring is supported on %s.\n",
+                       bond->dev->name, bond->dev->name);
+               ret = -EINVAL;
+               goto out;
+       }
        pr_info("%s: Setting ARP monitoring interval to %d.\n",
                bond->dev->name, new_value);
        bond->params.arp_interval = new_value;
@@ -1427,8 +1440,8 @@ static ssize_t bonding_show_queue_id(struct device *d,
 
        read_lock(&bond->lock);
        bond_for_each_slave(bond, slave, i) {
-               if (res > (PAGE_SIZE - 6)) {
-                       /* not enough space for another interface name */
+               if (res > (PAGE_SIZE - IFNAMSIZ - 6)) {
+                       /* not enough space for another interface_name:queue_id pair */
                        if ((PAGE_SIZE - res) > 10)
                                res = PAGE_SIZE - 10;
                        res += sprintf(buf + res, "++more++ ");