diff options
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 160 |
1 files changed, 116 insertions, 44 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 3bdb47382521..18cf4787874c 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -36,22 +36,13 @@ | |||
36 | #include <linux/rtnetlink.h> | 36 | #include <linux/rtnetlink.h> |
37 | #include <net/net_namespace.h> | 37 | #include <net/net_namespace.h> |
38 | 38 | ||
39 | /* #define BONDING_DEBUG 1 */ | ||
40 | #include "bonding.h" | 39 | #include "bonding.h" |
40 | |||
41 | #define to_dev(obj) container_of(obj,struct device,kobj) | 41 | #define to_dev(obj) container_of(obj,struct device,kobj) |
42 | #define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv)) | 42 | #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd)))) |
43 | 43 | ||
44 | /*---------------------------- Declarations -------------------------------*/ | 44 | /*---------------------------- Declarations -------------------------------*/ |
45 | 45 | ||
46 | |||
47 | extern struct list_head bond_dev_list; | ||
48 | extern struct bond_params bonding_defaults; | ||
49 | extern struct bond_parm_tbl bond_mode_tbl[]; | ||
50 | extern struct bond_parm_tbl bond_lacp_tbl[]; | ||
51 | extern struct bond_parm_tbl xmit_hashtype_tbl[]; | ||
52 | extern struct bond_parm_tbl arp_validate_tbl[]; | ||
53 | extern struct bond_parm_tbl fail_over_mac_tbl[]; | ||
54 | |||
55 | static int expected_refcount = -1; | 46 | static int expected_refcount = -1; |
56 | /*--------------------------- Data Structures -----------------------------*/ | 47 | /*--------------------------- Data Structures -----------------------------*/ |
57 | 48 | ||
@@ -316,18 +307,12 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
316 | 307 | ||
317 | /* Set the slave's MTU to match the bond */ | 308 | /* Set the slave's MTU to match the bond */ |
318 | original_mtu = dev->mtu; | 309 | original_mtu = dev->mtu; |
319 | if (dev->mtu != bond->dev->mtu) { | 310 | res = dev_set_mtu(dev, bond->dev->mtu); |
320 | if (dev->change_mtu) { | 311 | if (res) { |
321 | res = dev->change_mtu(dev, | 312 | ret = res; |
322 | bond->dev->mtu); | 313 | goto out; |
323 | if (res) { | ||
324 | ret = res; | ||
325 | goto out; | ||
326 | } | ||
327 | } else { | ||
328 | dev->mtu = bond->dev->mtu; | ||
329 | } | ||
330 | } | 314 | } |
315 | |||
331 | res = bond_enslave(bond->dev, dev); | 316 | res = bond_enslave(bond->dev, dev); |
332 | bond_for_each_slave(bond, slave, i) | 317 | bond_for_each_slave(bond, slave, i) |
333 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) | 318 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) |
@@ -356,11 +341,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
356 | goto out; | 341 | goto out; |
357 | } | 342 | } |
358 | /* set the slave MTU to the default */ | 343 | /* set the slave MTU to the default */ |
359 | if (dev->change_mtu) { | 344 | dev_set_mtu(dev, original_mtu); |
360 | dev->change_mtu(dev, original_mtu); | ||
361 | } else { | ||
362 | dev->mtu = original_mtu; | ||
363 | } | ||
364 | } | 345 | } |
365 | else { | 346 | else { |
366 | printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n", | 347 | printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n", |
@@ -620,6 +601,8 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
620 | ": %s: Setting ARP monitoring interval to %d.\n", | 601 | ": %s: Setting ARP monitoring interval to %d.\n", |
621 | bond->dev->name, new_value); | 602 | bond->dev->name, new_value); |
622 | bond->params.arp_interval = new_value; | 603 | bond->params.arp_interval = new_value; |
604 | if (bond->params.arp_interval) | ||
605 | bond->dev->priv_flags |= IFF_MASTER_ARPMON; | ||
623 | if (bond->params.miimon) { | 606 | if (bond->params.miimon) { |
624 | printk(KERN_INFO DRV_NAME | 607 | printk(KERN_INFO DRV_NAME |
625 | ": %s: ARP monitoring cannot be used with MII monitoring. " | 608 | ": %s: ARP monitoring cannot be used with MII monitoring. " |
@@ -672,8 +655,8 @@ static ssize_t bonding_show_arp_targets(struct device *d, | |||
672 | 655 | ||
673 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { | 656 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { |
674 | if (bond->params.arp_targets[i]) | 657 | if (bond->params.arp_targets[i]) |
675 | res += sprintf(buf + res, "%u.%u.%u.%u ", | 658 | res += sprintf(buf + res, "%pI4 ", |
676 | NIPQUAD(bond->params.arp_targets[i])); | 659 | &bond->params.arp_targets[i]); |
677 | } | 660 | } |
678 | if (res) | 661 | if (res) |
679 | buf[res-1] = '\n'; /* eat the leftover space */ | 662 | buf[res-1] = '\n'; /* eat the leftover space */ |
@@ -695,8 +678,8 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
695 | if (buf[0] == '+') { | 678 | if (buf[0] == '+') { |
696 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { | 679 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { |
697 | printk(KERN_ERR DRV_NAME | 680 | printk(KERN_ERR DRV_NAME |
698 | ": %s: invalid ARP target %u.%u.%u.%u specified for addition\n", | 681 | ": %s: invalid ARP target %pI4 specified for addition\n", |
699 | bond->dev->name, NIPQUAD(newtarget)); | 682 | bond->dev->name, &newtarget); |
700 | ret = -EINVAL; | 683 | ret = -EINVAL; |
701 | goto out; | 684 | goto out; |
702 | } | 685 | } |
@@ -704,8 +687,8 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
704 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { | 687 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { |
705 | if (targets[i] == newtarget) { /* duplicate */ | 688 | if (targets[i] == newtarget) { /* duplicate */ |
706 | printk(KERN_ERR DRV_NAME | 689 | printk(KERN_ERR DRV_NAME |
707 | ": %s: ARP target %u.%u.%u.%u is already present\n", | 690 | ": %s: ARP target %pI4 is already present\n", |
708 | bond->dev->name, NIPQUAD(newtarget)); | 691 | bond->dev->name, &newtarget); |
709 | if (done) | 692 | if (done) |
710 | targets[i] = 0; | 693 | targets[i] = 0; |
711 | ret = -EINVAL; | 694 | ret = -EINVAL; |
@@ -713,8 +696,8 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
713 | } | 696 | } |
714 | if (targets[i] == 0 && !done) { | 697 | if (targets[i] == 0 && !done) { |
715 | printk(KERN_INFO DRV_NAME | 698 | printk(KERN_INFO DRV_NAME |
716 | ": %s: adding ARP target %d.%d.%d.%d.\n", | 699 | ": %s: adding ARP target %pI4.\n", |
717 | bond->dev->name, NIPQUAD(newtarget)); | 700 | bond->dev->name, &newtarget); |
718 | done = 1; | 701 | done = 1; |
719 | targets[i] = newtarget; | 702 | targets[i] = newtarget; |
720 | } | 703 | } |
@@ -731,8 +714,8 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
731 | else if (buf[0] == '-') { | 714 | else if (buf[0] == '-') { |
732 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { | 715 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { |
733 | printk(KERN_ERR DRV_NAME | 716 | printk(KERN_ERR DRV_NAME |
734 | ": %s: invalid ARP target %d.%d.%d.%d specified for removal\n", | 717 | ": %s: invalid ARP target %pI4 specified for removal\n", |
735 | bond->dev->name, NIPQUAD(newtarget)); | 718 | bond->dev->name, &newtarget); |
736 | ret = -EINVAL; | 719 | ret = -EINVAL; |
737 | goto out; | 720 | goto out; |
738 | } | 721 | } |
@@ -740,16 +723,16 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
740 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { | 723 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { |
741 | if (targets[i] == newtarget) { | 724 | if (targets[i] == newtarget) { |
742 | printk(KERN_INFO DRV_NAME | 725 | printk(KERN_INFO DRV_NAME |
743 | ": %s: removing ARP target %d.%d.%d.%d.\n", | 726 | ": %s: removing ARP target %pI4.\n", |
744 | bond->dev->name, NIPQUAD(newtarget)); | 727 | bond->dev->name, &newtarget); |
745 | targets[i] = 0; | 728 | targets[i] = 0; |
746 | done = 1; | 729 | done = 1; |
747 | } | 730 | } |
748 | } | 731 | } |
749 | if (!done) { | 732 | if (!done) { |
750 | printk(KERN_INFO DRV_NAME | 733 | printk(KERN_INFO DRV_NAME |
751 | ": %s: unable to remove nonexistent ARP target %d.%d.%d.%d.\n", | 734 | ": %s: unable to remove nonexistent ARP target %pI4.\n", |
752 | bond->dev->name, NIPQUAD(newtarget)); | 735 | bond->dev->name, &newtarget); |
753 | ret = -EINVAL; | 736 | ret = -EINVAL; |
754 | goto out; | 737 | goto out; |
755 | } | 738 | } |
@@ -942,6 +925,53 @@ out: | |||
942 | } | 925 | } |
943 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); | 926 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); |
944 | 927 | ||
928 | static ssize_t bonding_show_ad_select(struct device *d, | ||
929 | struct device_attribute *attr, | ||
930 | char *buf) | ||
931 | { | ||
932 | struct bonding *bond = to_bond(d); | ||
933 | |||
934 | return sprintf(buf, "%s %d\n", | ||
935 | ad_select_tbl[bond->params.ad_select].modename, | ||
936 | bond->params.ad_select); | ||
937 | } | ||
938 | |||
939 | |||
940 | static ssize_t bonding_store_ad_select(struct device *d, | ||
941 | struct device_attribute *attr, | ||
942 | const char *buf, size_t count) | ||
943 | { | ||
944 | int new_value, ret = count; | ||
945 | struct bonding *bond = to_bond(d); | ||
946 | |||
947 | if (bond->dev->flags & IFF_UP) { | ||
948 | printk(KERN_ERR DRV_NAME | ||
949 | ": %s: Unable to update ad_select because interface " | ||
950 | "is up.\n", bond->dev->name); | ||
951 | ret = -EPERM; | ||
952 | goto out; | ||
953 | } | ||
954 | |||
955 | new_value = bond_parse_parm(buf, ad_select_tbl); | ||
956 | |||
957 | if (new_value != -1) { | ||
958 | bond->params.ad_select = new_value; | ||
959 | printk(KERN_INFO DRV_NAME | ||
960 | ": %s: Setting ad_select to %s (%d).\n", | ||
961 | bond->dev->name, ad_select_tbl[new_value].modename, | ||
962 | new_value); | ||
963 | } else { | ||
964 | printk(KERN_ERR DRV_NAME | ||
965 | ": %s: Ignoring invalid ad_select value %.*s.\n", | ||
966 | bond->dev->name, (int)strlen(buf) - 1, buf); | ||
967 | ret = -EINVAL; | ||
968 | } | ||
969 | out: | ||
970 | return ret; | ||
971 | } | ||
972 | |||
973 | static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, bonding_show_ad_select, bonding_store_ad_select); | ||
974 | |||
945 | /* | 975 | /* |
946 | * Show and set the number of grat ARP to send after a failover event. | 976 | * Show and set the number of grat ARP to send after a failover event. |
947 | */ | 977 | */ |
@@ -981,6 +1011,47 @@ out: | |||
981 | return ret; | 1011 | return ret; |
982 | } | 1012 | } |
983 | static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, bonding_show_n_grat_arp, bonding_store_n_grat_arp); | 1013 | static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, bonding_show_n_grat_arp, bonding_store_n_grat_arp); |
1014 | |||
1015 | /* | ||
1016 | * Show and set the number of unsolicted NA's to send after a failover event. | ||
1017 | */ | ||
1018 | static ssize_t bonding_show_n_unsol_na(struct device *d, | ||
1019 | struct device_attribute *attr, | ||
1020 | char *buf) | ||
1021 | { | ||
1022 | struct bonding *bond = to_bond(d); | ||
1023 | |||
1024 | return sprintf(buf, "%d\n", bond->params.num_unsol_na); | ||
1025 | } | ||
1026 | |||
1027 | static ssize_t bonding_store_n_unsol_na(struct device *d, | ||
1028 | struct device_attribute *attr, | ||
1029 | const char *buf, size_t count) | ||
1030 | { | ||
1031 | int new_value, ret = count; | ||
1032 | struct bonding *bond = to_bond(d); | ||
1033 | |||
1034 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
1035 | printk(KERN_ERR DRV_NAME | ||
1036 | ": %s: no num_unsol_na value specified.\n", | ||
1037 | bond->dev->name); | ||
1038 | ret = -EINVAL; | ||
1039 | goto out; | ||
1040 | } | ||
1041 | if (new_value < 0 || new_value > 255) { | ||
1042 | printk(KERN_ERR DRV_NAME | ||
1043 | ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n", | ||
1044 | bond->dev->name, new_value); | ||
1045 | ret = -EINVAL; | ||
1046 | goto out; | ||
1047 | } else { | ||
1048 | bond->params.num_unsol_na = new_value; | ||
1049 | } | ||
1050 | out: | ||
1051 | return ret; | ||
1052 | } | ||
1053 | static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, bonding_show_n_unsol_na, bonding_store_n_unsol_na); | ||
1054 | |||
984 | /* | 1055 | /* |
985 | * Show and set the MII monitor interval. There are two tricky bits | 1056 | * Show and set the MII monitor interval. There are two tricky bits |
986 | * here. First, if MII monitoring is activated, then we must disable | 1057 | * here. First, if MII monitoring is activated, then we must disable |
@@ -1039,6 +1110,7 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
1039 | "ARP monitoring. Disabling ARP monitoring...\n", | 1110 | "ARP monitoring. Disabling ARP monitoring...\n", |
1040 | bond->dev->name); | 1111 | bond->dev->name); |
1041 | bond->params.arp_interval = 0; | 1112 | bond->params.arp_interval = 0; |
1113 | bond->dev->priv_flags &= ~IFF_MASTER_ARPMON; | ||
1042 | if (bond->params.arp_validate) { | 1114 | if (bond->params.arp_validate) { |
1043 | bond_unregister_arp(bond); | 1115 | bond_unregister_arp(bond); |
1044 | bond->params.arp_validate = | 1116 | bond->params.arp_validate = |
@@ -1391,13 +1463,11 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d, | |||
1391 | { | 1463 | { |
1392 | int count = 0; | 1464 | int count = 0; |
1393 | struct bonding *bond = to_bond(d); | 1465 | struct bonding *bond = to_bond(d); |
1394 | DECLARE_MAC_BUF(mac); | ||
1395 | 1466 | ||
1396 | if (bond->params.mode == BOND_MODE_8023AD) { | 1467 | if (bond->params.mode == BOND_MODE_8023AD) { |
1397 | struct ad_info ad_info; | 1468 | struct ad_info ad_info; |
1398 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { | 1469 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { |
1399 | count = sprintf(buf,"%s\n", | 1470 | count = sprintf(buf, "%pM\n", ad_info.partner_system); |
1400 | print_mac(mac, ad_info.partner_system)); | ||
1401 | } | 1471 | } |
1402 | } | 1472 | } |
1403 | 1473 | ||
@@ -1417,8 +1487,10 @@ static struct attribute *per_bond_attrs[] = { | |||
1417 | &dev_attr_downdelay.attr, | 1487 | &dev_attr_downdelay.attr, |
1418 | &dev_attr_updelay.attr, | 1488 | &dev_attr_updelay.attr, |
1419 | &dev_attr_lacp_rate.attr, | 1489 | &dev_attr_lacp_rate.attr, |
1490 | &dev_attr_ad_select.attr, | ||
1420 | &dev_attr_xmit_hash_policy.attr, | 1491 | &dev_attr_xmit_hash_policy.attr, |
1421 | &dev_attr_num_grat_arp.attr, | 1492 | &dev_attr_num_grat_arp.attr, |
1493 | &dev_attr_num_unsol_na.attr, | ||
1422 | &dev_attr_miimon.attr, | 1494 | &dev_attr_miimon.attr, |
1423 | &dev_attr_primary.attr, | 1495 | &dev_attr_primary.attr, |
1424 | &dev_attr_use_carrier.attr, | 1496 | &dev_attr_use_carrier.attr, |