aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r--drivers/net/bonding/bond_sysfs.c126
1 files changed, 109 insertions, 17 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 3bdb47382521..aaf2927b5c38 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -48,6 +48,7 @@ extern struct list_head bond_dev_list;
48extern struct bond_params bonding_defaults; 48extern struct bond_params bonding_defaults;
49extern struct bond_parm_tbl bond_mode_tbl[]; 49extern struct bond_parm_tbl bond_mode_tbl[];
50extern struct bond_parm_tbl bond_lacp_tbl[]; 50extern struct bond_parm_tbl bond_lacp_tbl[];
51extern struct bond_parm_tbl ad_select_tbl[];
51extern struct bond_parm_tbl xmit_hashtype_tbl[]; 52extern struct bond_parm_tbl xmit_hashtype_tbl[];
52extern struct bond_parm_tbl arp_validate_tbl[]; 53extern struct bond_parm_tbl arp_validate_tbl[];
53extern struct bond_parm_tbl fail_over_mac_tbl[]; 54extern struct bond_parm_tbl fail_over_mac_tbl[];
@@ -620,6 +621,8 @@ static ssize_t bonding_store_arp_interval(struct device *d,
620 ": %s: Setting ARP monitoring interval to %d.\n", 621 ": %s: Setting ARP monitoring interval to %d.\n",
621 bond->dev->name, new_value); 622 bond->dev->name, new_value);
622 bond->params.arp_interval = new_value; 623 bond->params.arp_interval = new_value;
624 if (bond->params.arp_interval)
625 bond->dev->priv_flags |= IFF_MASTER_ARPMON;
623 if (bond->params.miimon) { 626 if (bond->params.miimon) {
624 printk(KERN_INFO DRV_NAME 627 printk(KERN_INFO DRV_NAME
625 ": %s: ARP monitoring cannot be used with MII monitoring. " 628 ": %s: ARP monitoring cannot be used with MII monitoring. "
@@ -672,8 +675,8 @@ static ssize_t bonding_show_arp_targets(struct device *d,
672 675
673 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { 676 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) {
674 if (bond->params.arp_targets[i]) 677 if (bond->params.arp_targets[i])
675 res += sprintf(buf + res, "%u.%u.%u.%u ", 678 res += sprintf(buf + res, "%pI4 ",
676 NIPQUAD(bond->params.arp_targets[i])); 679 &bond->params.arp_targets[i]);
677 } 680 }
678 if (res) 681 if (res)
679 buf[res-1] = '\n'; /* eat the leftover space */ 682 buf[res-1] = '\n'; /* eat the leftover space */
@@ -695,8 +698,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
695 if (buf[0] == '+') { 698 if (buf[0] == '+') {
696 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { 699 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
697 printk(KERN_ERR DRV_NAME 700 printk(KERN_ERR DRV_NAME
698 ": %s: invalid ARP target %u.%u.%u.%u specified for addition\n", 701 ": %s: invalid ARP target %pI4 specified for addition\n",
699 bond->dev->name, NIPQUAD(newtarget)); 702 bond->dev->name, &newtarget);
700 ret = -EINVAL; 703 ret = -EINVAL;
701 goto out; 704 goto out;
702 } 705 }
@@ -704,8 +707,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
704 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { 707 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
705 if (targets[i] == newtarget) { /* duplicate */ 708 if (targets[i] == newtarget) { /* duplicate */
706 printk(KERN_ERR DRV_NAME 709 printk(KERN_ERR DRV_NAME
707 ": %s: ARP target %u.%u.%u.%u is already present\n", 710 ": %s: ARP target %pI4 is already present\n",
708 bond->dev->name, NIPQUAD(newtarget)); 711 bond->dev->name, &newtarget);
709 if (done) 712 if (done)
710 targets[i] = 0; 713 targets[i] = 0;
711 ret = -EINVAL; 714 ret = -EINVAL;
@@ -713,8 +716,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
713 } 716 }
714 if (targets[i] == 0 && !done) { 717 if (targets[i] == 0 && !done) {
715 printk(KERN_INFO DRV_NAME 718 printk(KERN_INFO DRV_NAME
716 ": %s: adding ARP target %d.%d.%d.%d.\n", 719 ": %s: adding ARP target %pI4.\n",
717 bond->dev->name, NIPQUAD(newtarget)); 720 bond->dev->name, &newtarget);
718 done = 1; 721 done = 1;
719 targets[i] = newtarget; 722 targets[i] = newtarget;
720 } 723 }
@@ -731,8 +734,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
731 else if (buf[0] == '-') { 734 else if (buf[0] == '-') {
732 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { 735 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
733 printk(KERN_ERR DRV_NAME 736 printk(KERN_ERR DRV_NAME
734 ": %s: invalid ARP target %d.%d.%d.%d specified for removal\n", 737 ": %s: invalid ARP target %pI4 specified for removal\n",
735 bond->dev->name, NIPQUAD(newtarget)); 738 bond->dev->name, &newtarget);
736 ret = -EINVAL; 739 ret = -EINVAL;
737 goto out; 740 goto out;
738 } 741 }
@@ -740,16 +743,16 @@ static ssize_t bonding_store_arp_targets(struct device *d,
740 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { 743 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
741 if (targets[i] == newtarget) { 744 if (targets[i] == newtarget) {
742 printk(KERN_INFO DRV_NAME 745 printk(KERN_INFO DRV_NAME
743 ": %s: removing ARP target %d.%d.%d.%d.\n", 746 ": %s: removing ARP target %pI4.\n",
744 bond->dev->name, NIPQUAD(newtarget)); 747 bond->dev->name, &newtarget);
745 targets[i] = 0; 748 targets[i] = 0;
746 done = 1; 749 done = 1;
747 } 750 }
748 } 751 }
749 if (!done) { 752 if (!done) {
750 printk(KERN_INFO DRV_NAME 753 printk(KERN_INFO DRV_NAME
751 ": %s: unable to remove nonexistent ARP target %d.%d.%d.%d.\n", 754 ": %s: unable to remove nonexistent ARP target %pI4.\n",
752 bond->dev->name, NIPQUAD(newtarget)); 755 bond->dev->name, &newtarget);
753 ret = -EINVAL; 756 ret = -EINVAL;
754 goto out; 757 goto out;
755 } 758 }
@@ -942,6 +945,53 @@ out:
942} 945}
943static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); 946static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp);
944 947
948static ssize_t bonding_show_ad_select(struct device *d,
949 struct device_attribute *attr,
950 char *buf)
951{
952 struct bonding *bond = to_bond(d);
953
954 return sprintf(buf, "%s %d\n",
955 ad_select_tbl[bond->params.ad_select].modename,
956 bond->params.ad_select);
957}
958
959
960static ssize_t bonding_store_ad_select(struct device *d,
961 struct device_attribute *attr,
962 const char *buf, size_t count)
963{
964 int new_value, ret = count;
965 struct bonding *bond = to_bond(d);
966
967 if (bond->dev->flags & IFF_UP) {
968 printk(KERN_ERR DRV_NAME
969 ": %s: Unable to update ad_select because interface "
970 "is up.\n", bond->dev->name);
971 ret = -EPERM;
972 goto out;
973 }
974
975 new_value = bond_parse_parm(buf, ad_select_tbl);
976
977 if (new_value != -1) {
978 bond->params.ad_select = new_value;
979 printk(KERN_INFO DRV_NAME
980 ": %s: Setting ad_select to %s (%d).\n",
981 bond->dev->name, ad_select_tbl[new_value].modename,
982 new_value);
983 } else {
984 printk(KERN_ERR DRV_NAME
985 ": %s: Ignoring invalid ad_select value %.*s.\n",
986 bond->dev->name, (int)strlen(buf) - 1, buf);
987 ret = -EINVAL;
988 }
989out:
990 return ret;
991}
992
993static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, bonding_show_ad_select, bonding_store_ad_select);
994
945/* 995/*
946 * Show and set the number of grat ARP to send after a failover event. 996 * Show and set the number of grat ARP to send after a failover event.
947 */ 997 */
@@ -981,6 +1031,47 @@ out:
981 return ret; 1031 return ret;
982} 1032}
983static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, bonding_show_n_grat_arp, bonding_store_n_grat_arp); 1033static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, bonding_show_n_grat_arp, bonding_store_n_grat_arp);
1034
1035/*
1036 * Show and set the number of unsolicted NA's to send after a failover event.
1037 */
1038static ssize_t bonding_show_n_unsol_na(struct device *d,
1039 struct device_attribute *attr,
1040 char *buf)
1041{
1042 struct bonding *bond = to_bond(d);
1043
1044 return sprintf(buf, "%d\n", bond->params.num_unsol_na);
1045}
1046
1047static ssize_t bonding_store_n_unsol_na(struct device *d,
1048 struct device_attribute *attr,
1049 const char *buf, size_t count)
1050{
1051 int new_value, ret = count;
1052 struct bonding *bond = to_bond(d);
1053
1054 if (sscanf(buf, "%d", &new_value) != 1) {
1055 printk(KERN_ERR DRV_NAME
1056 ": %s: no num_unsol_na value specified.\n",
1057 bond->dev->name);
1058 ret = -EINVAL;
1059 goto out;
1060 }
1061 if (new_value < 0 || new_value > 255) {
1062 printk(KERN_ERR DRV_NAME
1063 ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
1064 bond->dev->name, new_value);
1065 ret = -EINVAL;
1066 goto out;
1067 } else {
1068 bond->params.num_unsol_na = new_value;
1069 }
1070out:
1071 return ret;
1072}
1073static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, bonding_show_n_unsol_na, bonding_store_n_unsol_na);
1074
984/* 1075/*
985 * Show and set the MII monitor interval. There are two tricky bits 1076 * Show and set the MII monitor interval. There are two tricky bits
986 * here. First, if MII monitoring is activated, then we must disable 1077 * here. First, if MII monitoring is activated, then we must disable
@@ -1039,6 +1130,7 @@ static ssize_t bonding_store_miimon(struct device *d,
1039 "ARP monitoring. Disabling ARP monitoring...\n", 1130 "ARP monitoring. Disabling ARP monitoring...\n",
1040 bond->dev->name); 1131 bond->dev->name);
1041 bond->params.arp_interval = 0; 1132 bond->params.arp_interval = 0;
1133 bond->dev->priv_flags &= ~IFF_MASTER_ARPMON;
1042 if (bond->params.arp_validate) { 1134 if (bond->params.arp_validate) {
1043 bond_unregister_arp(bond); 1135 bond_unregister_arp(bond);
1044 bond->params.arp_validate = 1136 bond->params.arp_validate =
@@ -1391,13 +1483,11 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
1391{ 1483{
1392 int count = 0; 1484 int count = 0;
1393 struct bonding *bond = to_bond(d); 1485 struct bonding *bond = to_bond(d);
1394 DECLARE_MAC_BUF(mac);
1395 1486
1396 if (bond->params.mode == BOND_MODE_8023AD) { 1487 if (bond->params.mode == BOND_MODE_8023AD) {
1397 struct ad_info ad_info; 1488 struct ad_info ad_info;
1398 if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { 1489 if (!bond_3ad_get_active_agg_info(bond, &ad_info)) {
1399 count = sprintf(buf,"%s\n", 1490 count = sprintf(buf, "%pM\n", ad_info.partner_system);
1400 print_mac(mac, ad_info.partner_system));
1401 } 1491 }
1402 } 1492 }
1403 1493
@@ -1417,8 +1507,10 @@ static struct attribute *per_bond_attrs[] = {
1417 &dev_attr_downdelay.attr, 1507 &dev_attr_downdelay.attr,
1418 &dev_attr_updelay.attr, 1508 &dev_attr_updelay.attr,
1419 &dev_attr_lacp_rate.attr, 1509 &dev_attr_lacp_rate.attr,
1510 &dev_attr_ad_select.attr,
1420 &dev_attr_xmit_hash_policy.attr, 1511 &dev_attr_xmit_hash_policy.attr,
1421 &dev_attr_num_grat_arp.attr, 1512 &dev_attr_num_grat_arp.attr,
1513 &dev_attr_num_unsol_na.attr,
1422 &dev_attr_miimon.attr, 1514 &dev_attr_miimon.attr,
1423 &dev_attr_primary.attr, 1515 &dev_attr_primary.attr,
1424 &dev_attr_use_carrier.attr, 1516 &dev_attr_use_carrier.attr,