Commit 7eacd03810960823393521063734fc8188446bca

Authored by Neil Horman
Committed by David S. Miller
1 parent d2bb3905ab

bonding: Make alb learning packet interval configurable

running bonding in ALB mode requires that learning packets be sent periodically,
so that the switch knows where to send responding traffic.  However, depending
on switch configuration, there may not be any need to send traffic at the
default rate of 3 packets per second, which represents little more than wasted
data.  Allow the ALB learning packet interval to be made configurable via sysfs

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Acked-by: Veaceslav Falico <vfalico@redhat.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 6 changed files with 53 additions and 5 deletions Side-by-side Diff

Documentation/networking/bonding.txt
... ... @@ -1362,6 +1362,12 @@
1362 1362 To remove an ARP target:
1363 1363 # echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
1364 1364  
  1365 +To configure the interval between learning packet transmits:
  1366 +# echo 12 > /sys/class/net/bond0/bonding/lp_interval
  1367 + NOTE: the lp_inteval is the number of seconds between instances where
  1368 +the bonding driver sends learning packets to each slaves peer switch. The
  1369 +default interval is 1 second.
  1370 +
1365 1371 Example Configuration
1366 1372 ---------------------
1367 1373 We begin with the same example that is shown in section 3.3,
drivers/net/bonding/bond_alb.c
... ... @@ -1472,7 +1472,7 @@
1472 1472 bond_info->lp_counter++;
1473 1473  
1474 1474 /* send learning packets */
1475   - if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
  1475 + if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
1476 1476 /* change of curr_active_slave involves swapping of mac addresses.
1477 1477 * in order to avoid this swapping from happening while
1478 1478 * sending the learning packets, the curr_slave_lock must be held for
drivers/net/bonding/bond_alb.h
... ... @@ -36,14 +36,15 @@
36 36 * Used for division - never set
37 37 * to zero !!!
38 38 */
39   -#define BOND_ALB_LP_INTERVAL 1 /* In seconds, periodic send of
40   - * learning packets to the switch
41   - */
  39 +#define BOND_ALB_DEFAULT_LP_INTERVAL 1
  40 +#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval) /* In seconds, periodic send of
  41 + * learning packets to the switch
  42 + */
42 43  
43 44 #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
44 45 * ALB_TIMER_TICKS_PER_SEC)
45 46  
46   -#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
  47 +#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
47 48 * ALB_TIMER_TICKS_PER_SEC)
48 49  
49 50 #define TLB_HASH_TABLE_SIZE 256 /* The size of the clients hash table.
drivers/net/bonding/bond_main.c
... ... @@ -4416,6 +4416,7 @@
4416 4416 params->all_slaves_active = all_slaves_active;
4417 4417 params->resend_igmp = resend_igmp;
4418 4418 params->min_links = min_links;
  4419 + params->lp_interval = BOND_ALB_DEFAULT_LP_INTERVAL;
4419 4420  
4420 4421 if (primary) {
4421 4422 strncpy(params->primary, primary, IFNAMSIZ);
drivers/net/bonding/bond_sysfs.c
... ... @@ -1699,6 +1699,44 @@
1699 1699 static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
1700 1700 bonding_show_resend_igmp, bonding_store_resend_igmp);
1701 1701  
  1702 +
  1703 +static ssize_t bonding_show_lp_interval(struct device *d,
  1704 + struct device_attribute *attr,
  1705 + char *buf)
  1706 +{
  1707 + struct bonding *bond = to_bond(d);
  1708 + return sprintf(buf, "%d\n", bond->params.lp_interval);
  1709 +}
  1710 +
  1711 +static ssize_t bonding_store_lp_interval(struct device *d,
  1712 + struct device_attribute *attr,
  1713 + const char *buf, size_t count)
  1714 +{
  1715 + struct bonding *bond = to_bond(d);
  1716 + int new_value, ret = count;
  1717 +
  1718 + if (sscanf(buf, "%d", &new_value) != 1) {
  1719 + pr_err("%s: no lp interval value specified.\n",
  1720 + bond->dev->name);
  1721 + ret = -EINVAL;
  1722 + goto out;
  1723 + }
  1724 +
  1725 + if (new_value <= 0) {
  1726 + pr_err ("%s: lp_interval must be between 1 and %d\n",
  1727 + bond->dev->name, INT_MAX);
  1728 + ret = -EINVAL;
  1729 + goto out;
  1730 + }
  1731 +
  1732 + bond->params.lp_interval = new_value;
  1733 +out:
  1734 + return ret;
  1735 +}
  1736 +
  1737 +static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
  1738 + bonding_show_lp_interval, bonding_store_lp_interval);
  1739 +
1702 1740 static struct attribute *per_bond_attrs[] = {
1703 1741 &dev_attr_slaves.attr,
1704 1742 &dev_attr_mode.attr,
... ... @@ -1729,6 +1767,7 @@
1729 1767 &dev_attr_all_slaves_active.attr,
1730 1768 &dev_attr_resend_igmp.attr,
1731 1769 &dev_attr_min_links.attr,
  1770 + &dev_attr_lp_interval.attr,
1732 1771 NULL,
1733 1772 };
1734 1773  
drivers/net/bonding/bonding.h
... ... @@ -176,6 +176,7 @@
176 176 int tx_queues;
177 177 int all_slaves_active;
178 178 int resend_igmp;
  179 + int lp_interval;
179 180 };
180 181  
181 182 struct bond_parm_tbl {