diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/bonding/bond_sysfs.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 418 |
1 files changed, 195 insertions, 223 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 8762a27a2a18..b8bec086daa1 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -19,6 +19,9 @@ | |||
19 | * file called LICENSE. | 19 | * file called LICENSE. |
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | |||
23 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
24 | |||
22 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
23 | #include <linux/module.h> | 26 | #include <linux/module.h> |
24 | #include <linux/device.h> | 27 | #include <linux/device.h> |
@@ -36,6 +39,8 @@ | |||
36 | #include <linux/rtnetlink.h> | 39 | #include <linux/rtnetlink.h> |
37 | #include <linux/etherdevice.h> | 40 | #include <linux/etherdevice.h> |
38 | #include <net/net_namespace.h> | 41 | #include <net/net_namespace.h> |
42 | #include <net/netns/generic.h> | ||
43 | #include <linux/nsproxy.h> | ||
39 | 44 | ||
40 | #include "bonding.h" | 45 | #include "bonding.h" |
41 | 46 | ||
@@ -46,14 +51,18 @@ | |||
46 | * "show" function for the bond_masters attribute. | 51 | * "show" function for the bond_masters attribute. |
47 | * The class parameter is ignored. | 52 | * The class parameter is ignored. |
48 | */ | 53 | */ |
49 | static ssize_t bonding_show_bonds(struct class *cls, char *buf) | 54 | static ssize_t bonding_show_bonds(struct class *cls, |
55 | struct class_attribute *attr, | ||
56 | char *buf) | ||
50 | { | 57 | { |
58 | struct net *net = current->nsproxy->net_ns; | ||
59 | struct bond_net *bn = net_generic(net, bond_net_id); | ||
51 | int res = 0; | 60 | int res = 0; |
52 | struct bonding *bond; | 61 | struct bonding *bond; |
53 | 62 | ||
54 | rtnl_lock(); | 63 | rtnl_lock(); |
55 | 64 | ||
56 | list_for_each_entry(bond, &bond_dev_list, bond_list) { | 65 | list_for_each_entry(bond, &bn->dev_list, bond_list) { |
57 | if (res > (PAGE_SIZE - IFNAMSIZ)) { | 66 | if (res > (PAGE_SIZE - IFNAMSIZ)) { |
58 | /* not enough space for another interface name */ | 67 | /* not enough space for another interface name */ |
59 | if ((PAGE_SIZE - res) > 10) | 68 | if ((PAGE_SIZE - res) > 10) |
@@ -70,11 +79,12 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf) | |||
70 | return res; | 79 | return res; |
71 | } | 80 | } |
72 | 81 | ||
73 | static struct net_device *bond_get_by_name(const char *ifname) | 82 | static struct net_device *bond_get_by_name(struct net *net, const char *ifname) |
74 | { | 83 | { |
84 | struct bond_net *bn = net_generic(net, bond_net_id); | ||
75 | struct bonding *bond; | 85 | struct bonding *bond; |
76 | 86 | ||
77 | list_for_each_entry(bond, &bond_dev_list, bond_list) { | 87 | list_for_each_entry(bond, &bn->dev_list, bond_list) { |
78 | if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0) | 88 | if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0) |
79 | return bond->dev; | 89 | return bond->dev; |
80 | } | 90 | } |
@@ -90,8 +100,10 @@ static struct net_device *bond_get_by_name(const char *ifname) | |||
90 | */ | 100 | */ |
91 | 101 | ||
92 | static ssize_t bonding_store_bonds(struct class *cls, | 102 | static ssize_t bonding_store_bonds(struct class *cls, |
103 | struct class_attribute *attr, | ||
93 | const char *buffer, size_t count) | 104 | const char *buffer, size_t count) |
94 | { | 105 | { |
106 | struct net *net = current->nsproxy->net_ns; | ||
95 | char command[IFNAMSIZ + 1] = {0, }; | 107 | char command[IFNAMSIZ + 1] = {0, }; |
96 | char *ifname; | 108 | char *ifname; |
97 | int rv, res = count; | 109 | int rv, res = count; |
@@ -103,25 +115,22 @@ static ssize_t bonding_store_bonds(struct class *cls, | |||
103 | goto err_no_cmd; | 115 | goto err_no_cmd; |
104 | 116 | ||
105 | if (command[0] == '+') { | 117 | if (command[0] == '+') { |
106 | pr_info(DRV_NAME | 118 | pr_info("%s is being created...\n", ifname); |
107 | ": %s is being created...\n", ifname); | 119 | rv = bond_create(net, ifname); |
108 | rv = bond_create(ifname); | ||
109 | if (rv) { | 120 | if (rv) { |
110 | pr_info(DRV_NAME ": Bond creation failed.\n"); | 121 | pr_info("Bond creation failed.\n"); |
111 | res = rv; | 122 | res = rv; |
112 | } | 123 | } |
113 | } else if (command[0] == '-') { | 124 | } else if (command[0] == '-') { |
114 | struct net_device *bond_dev; | 125 | struct net_device *bond_dev; |
115 | 126 | ||
116 | rtnl_lock(); | 127 | rtnl_lock(); |
117 | bond_dev = bond_get_by_name(ifname); | 128 | bond_dev = bond_get_by_name(net, ifname); |
118 | if (bond_dev) { | 129 | if (bond_dev) { |
119 | pr_info(DRV_NAME ": %s is being deleted...\n", | 130 | pr_info("%s is being deleted...\n", ifname); |
120 | ifname); | ||
121 | unregister_netdevice(bond_dev); | 131 | unregister_netdevice(bond_dev); |
122 | } else { | 132 | } else { |
123 | pr_err(DRV_NAME ": unable to delete non-existent %s\n", | 133 | pr_err("unable to delete non-existent %s\n", ifname); |
124 | ifname); | ||
125 | res = -ENODEV; | 134 | res = -ENODEV; |
126 | } | 135 | } |
127 | rtnl_unlock(); | 136 | rtnl_unlock(); |
@@ -134,8 +143,7 @@ static ssize_t bonding_store_bonds(struct class *cls, | |||
134 | return res; | 143 | return res; |
135 | 144 | ||
136 | err_no_cmd: | 145 | err_no_cmd: |
137 | pr_err(DRV_NAME ": no command found in bonding_masters." | 146 | pr_err("no command found in bonding_masters. Use +ifname or -ifname.\n"); |
138 | " Use +ifname or -ifname.\n"); | ||
139 | return -EPERM; | 147 | return -EPERM; |
140 | } | 148 | } |
141 | 149 | ||
@@ -219,8 +227,8 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
219 | 227 | ||
220 | /* Quick sanity check -- is the bond interface up? */ | 228 | /* Quick sanity check -- is the bond interface up? */ |
221 | if (!(bond->dev->flags & IFF_UP)) { | 229 | if (!(bond->dev->flags & IFF_UP)) { |
222 | pr_warning(DRV_NAME ": %s: doing slave updates when " | 230 | pr_warning("%s: doing slave updates when interface is down.\n", |
223 | "interface is down.\n", bond->dev->name); | 231 | bond->dev->name); |
224 | } | 232 | } |
225 | 233 | ||
226 | /* Note: We can't hold bond->lock here, as bond_create grabs it. */ | 234 | /* Note: We can't hold bond->lock here, as bond_create grabs it. */ |
@@ -239,20 +247,16 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
239 | /* Got a slave name in ifname. Is it already in the list? */ | 247 | /* Got a slave name in ifname. Is it already in the list? */ |
240 | found = 0; | 248 | found = 0; |
241 | 249 | ||
242 | /* FIXME: get netns from sysfs object */ | 250 | dev = __dev_get_by_name(dev_net(bond->dev), ifname); |
243 | dev = __dev_get_by_name(&init_net, ifname); | ||
244 | if (!dev) { | 251 | if (!dev) { |
245 | pr_info(DRV_NAME | 252 | pr_info("%s: Interface %s does not exist!\n", |
246 | ": %s: Interface %s does not exist!\n", | 253 | bond->dev->name, ifname); |
247 | bond->dev->name, ifname); | ||
248 | ret = -ENODEV; | 254 | ret = -ENODEV; |
249 | goto out; | 255 | goto out; |
250 | } | 256 | } |
251 | 257 | ||
252 | if (dev->flags & IFF_UP) { | 258 | if (dev->flags & IFF_UP) { |
253 | pr_err(DRV_NAME | 259 | pr_err("%s: Error: Unable to enslave %s because it is already up.\n", |
254 | ": %s: Error: Unable to enslave %s " | ||
255 | "because it is already up.\n", | ||
256 | bond->dev->name, dev->name); | 260 | bond->dev->name, dev->name); |
257 | ret = -EPERM; | 261 | ret = -EPERM; |
258 | goto out; | 262 | goto out; |
@@ -261,8 +265,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
261 | read_lock(&bond->lock); | 265 | read_lock(&bond->lock); |
262 | bond_for_each_slave(bond, slave, i) | 266 | bond_for_each_slave(bond, slave, i) |
263 | if (slave->dev == dev) { | 267 | if (slave->dev == dev) { |
264 | pr_err(DRV_NAME | 268 | pr_err("%s: Interface %s is already enslaved!\n", |
265 | ": %s: Interface %s is already enslaved!\n", | ||
266 | bond->dev->name, ifname); | 269 | bond->dev->name, ifname); |
267 | ret = -EPERM; | 270 | ret = -EPERM; |
268 | read_unlock(&bond->lock); | 271 | read_unlock(&bond->lock); |
@@ -270,8 +273,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
270 | } | 273 | } |
271 | read_unlock(&bond->lock); | 274 | read_unlock(&bond->lock); |
272 | 275 | ||
273 | pr_info(DRV_NAME ": %s: Adding slave %s.\n", | 276 | pr_info("%s: Adding slave %s.\n", bond->dev->name, ifname); |
274 | bond->dev->name, ifname); | ||
275 | 277 | ||
276 | /* If this is the first slave, then we need to set | 278 | /* If this is the first slave, then we need to set |
277 | the master's hardware address to be the same as the | 279 | the master's hardware address to be the same as the |
@@ -308,7 +310,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
308 | break; | 310 | break; |
309 | } | 311 | } |
310 | if (dev) { | 312 | if (dev) { |
311 | pr_info(DRV_NAME ": %s: Removing slave %s\n", | 313 | pr_info("%s: Removing slave %s\n", |
312 | bond->dev->name, dev->name); | 314 | bond->dev->name, dev->name); |
313 | res = bond_release(bond->dev, dev); | 315 | res = bond_release(bond->dev, dev); |
314 | if (res) { | 316 | if (res) { |
@@ -318,16 +320,16 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
318 | /* set the slave MTU to the default */ | 320 | /* set the slave MTU to the default */ |
319 | dev_set_mtu(dev, original_mtu); | 321 | dev_set_mtu(dev, original_mtu); |
320 | } else { | 322 | } else { |
321 | pr_err(DRV_NAME ": unable to remove non-existent" | 323 | pr_err("unable to remove non-existent slave %s for bond %s.\n", |
322 | " slave %s for bond %s.\n", | 324 | ifname, bond->dev->name); |
323 | ifname, bond->dev->name); | ||
324 | ret = -ENODEV; | 325 | ret = -ENODEV; |
325 | } | 326 | } |
326 | goto out; | 327 | goto out; |
327 | } | 328 | } |
328 | 329 | ||
329 | err_no_cmd: | 330 | err_no_cmd: |
330 | pr_err(DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); | 331 | pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n", |
332 | bond->dev->name); | ||
331 | ret = -EPERM; | 333 | ret = -EPERM; |
332 | 334 | ||
333 | out: | 335 | out: |
@@ -360,18 +362,16 @@ static ssize_t bonding_store_mode(struct device *d, | |||
360 | struct bonding *bond = to_bond(d); | 362 | struct bonding *bond = to_bond(d); |
361 | 363 | ||
362 | if (bond->dev->flags & IFF_UP) { | 364 | if (bond->dev->flags & IFF_UP) { |
363 | pr_err(DRV_NAME ": unable to update mode of %s" | 365 | pr_err("unable to update mode of %s because interface is up.\n", |
364 | " because interface is up.\n", bond->dev->name); | 366 | bond->dev->name); |
365 | ret = -EPERM; | 367 | ret = -EPERM; |
366 | goto out; | 368 | goto out; |
367 | } | 369 | } |
368 | 370 | ||
369 | new_value = bond_parse_parm(buf, bond_mode_tbl); | 371 | new_value = bond_parse_parm(buf, bond_mode_tbl); |
370 | if (new_value < 0) { | 372 | if (new_value < 0) { |
371 | pr_err(DRV_NAME | 373 | pr_err("%s: Ignoring invalid mode value %.*s.\n", |
372 | ": %s: Ignoring invalid mode value %.*s.\n", | 374 | bond->dev->name, (int)strlen(buf) - 1, buf); |
373 | bond->dev->name, | ||
374 | (int)strlen(buf) - 1, buf); | ||
375 | ret = -EINVAL; | 375 | ret = -EINVAL; |
376 | goto out; | 376 | goto out; |
377 | } else { | 377 | } else { |
@@ -383,8 +383,8 @@ static ssize_t bonding_store_mode(struct device *d, | |||
383 | 383 | ||
384 | bond->params.mode = new_value; | 384 | bond->params.mode = new_value; |
385 | bond_set_mode_ops(bond, bond->params.mode); | 385 | bond_set_mode_ops(bond, bond->params.mode); |
386 | pr_info(DRV_NAME ": %s: setting mode to %s (%d).\n", | 386 | pr_info("%s: setting mode to %s (%d).\n", |
387 | bond->dev->name, bond_mode_tbl[new_value].modename, | 387 | bond->dev->name, bond_mode_tbl[new_value].modename, |
388 | new_value); | 388 | new_value); |
389 | } | 389 | } |
390 | out: | 390 | out: |
@@ -416,8 +416,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
416 | struct bonding *bond = to_bond(d); | 416 | struct bonding *bond = to_bond(d); |
417 | 417 | ||
418 | if (bond->dev->flags & IFF_UP) { | 418 | if (bond->dev->flags & IFF_UP) { |
419 | pr_err(DRV_NAME | 419 | pr_err("%s: Interface is up. Unable to update xmit policy.\n", |
420 | "%s: Interface is up. Unable to update xmit policy.\n", | ||
421 | bond->dev->name); | 420 | bond->dev->name); |
422 | ret = -EPERM; | 421 | ret = -EPERM; |
423 | goto out; | 422 | goto out; |
@@ -425,8 +424,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
425 | 424 | ||
426 | new_value = bond_parse_parm(buf, xmit_hashtype_tbl); | 425 | new_value = bond_parse_parm(buf, xmit_hashtype_tbl); |
427 | if (new_value < 0) { | 426 | if (new_value < 0) { |
428 | pr_err(DRV_NAME | 427 | pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n", |
429 | ": %s: Ignoring invalid xmit hash policy value %.*s.\n", | ||
430 | bond->dev->name, | 428 | bond->dev->name, |
431 | (int)strlen(buf) - 1, buf); | 429 | (int)strlen(buf) - 1, buf); |
432 | ret = -EINVAL; | 430 | ret = -EINVAL; |
@@ -434,7 +432,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
434 | } else { | 432 | } else { |
435 | bond->params.xmit_policy = new_value; | 433 | bond->params.xmit_policy = new_value; |
436 | bond_set_mode_ops(bond, bond->params.mode); | 434 | bond_set_mode_ops(bond, bond->params.mode); |
437 | pr_info(DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", | 435 | pr_info("%s: setting xmit hash policy to %s (%d).\n", |
438 | bond->dev->name, | 436 | bond->dev->name, |
439 | xmit_hashtype_tbl[new_value].modename, new_value); | 437 | xmit_hashtype_tbl[new_value].modename, new_value); |
440 | } | 438 | } |
@@ -467,20 +465,18 @@ static ssize_t bonding_store_arp_validate(struct device *d, | |||
467 | 465 | ||
468 | new_value = bond_parse_parm(buf, arp_validate_tbl); | 466 | new_value = bond_parse_parm(buf, arp_validate_tbl); |
469 | if (new_value < 0) { | 467 | if (new_value < 0) { |
470 | pr_err(DRV_NAME | 468 | pr_err("%s: Ignoring invalid arp_validate value %s\n", |
471 | ": %s: Ignoring invalid arp_validate value %s\n", | ||
472 | bond->dev->name, buf); | 469 | bond->dev->name, buf); |
473 | return -EINVAL; | 470 | return -EINVAL; |
474 | } | 471 | } |
475 | if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { | 472 | if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { |
476 | pr_err(DRV_NAME | 473 | pr_err("%s: arp_validate only supported in active-backup mode.\n", |
477 | ": %s: arp_validate only supported in active-backup mode.\n", | ||
478 | bond->dev->name); | 474 | bond->dev->name); |
479 | return -EINVAL; | 475 | return -EINVAL; |
480 | } | 476 | } |
481 | pr_info(DRV_NAME ": %s: setting arp_validate to %s (%d).\n", | 477 | pr_info("%s: setting arp_validate to %s (%d).\n", |
482 | bond->dev->name, arp_validate_tbl[new_value].modename, | 478 | bond->dev->name, arp_validate_tbl[new_value].modename, |
483 | new_value); | 479 | new_value); |
484 | 480 | ||
485 | if (!bond->params.arp_validate && new_value) | 481 | if (!bond->params.arp_validate && new_value) |
486 | bond_register_arp(bond); | 482 | bond_register_arp(bond); |
@@ -518,24 +514,22 @@ static ssize_t bonding_store_fail_over_mac(struct device *d, | |||
518 | struct bonding *bond = to_bond(d); | 514 | struct bonding *bond = to_bond(d); |
519 | 515 | ||
520 | if (bond->slave_cnt != 0) { | 516 | if (bond->slave_cnt != 0) { |
521 | pr_err(DRV_NAME | 517 | pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n", |
522 | ": %s: Can't alter fail_over_mac with slaves in bond.\n", | ||
523 | bond->dev->name); | 518 | bond->dev->name); |
524 | return -EPERM; | 519 | return -EPERM; |
525 | } | 520 | } |
526 | 521 | ||
527 | new_value = bond_parse_parm(buf, fail_over_mac_tbl); | 522 | new_value = bond_parse_parm(buf, fail_over_mac_tbl); |
528 | if (new_value < 0) { | 523 | if (new_value < 0) { |
529 | pr_err(DRV_NAME | 524 | pr_err("%s: Ignoring invalid fail_over_mac value %s.\n", |
530 | ": %s: Ignoring invalid fail_over_mac value %s.\n", | ||
531 | bond->dev->name, buf); | 525 | bond->dev->name, buf); |
532 | return -EINVAL; | 526 | return -EINVAL; |
533 | } | 527 | } |
534 | 528 | ||
535 | bond->params.fail_over_mac = new_value; | 529 | bond->params.fail_over_mac = new_value; |
536 | pr_info(DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n", | 530 | pr_info("%s: Setting fail_over_mac to %s (%d).\n", |
537 | bond->dev->name, fail_over_mac_tbl[new_value].modename, | 531 | bond->dev->name, fail_over_mac_tbl[new_value].modename, |
538 | new_value); | 532 | new_value); |
539 | 533 | ||
540 | return count; | 534 | return count; |
541 | } | 535 | } |
@@ -566,31 +560,26 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
566 | struct bonding *bond = to_bond(d); | 560 | struct bonding *bond = to_bond(d); |
567 | 561 | ||
568 | if (sscanf(buf, "%d", &new_value) != 1) { | 562 | if (sscanf(buf, "%d", &new_value) != 1) { |
569 | pr_err(DRV_NAME | 563 | pr_err("%s: no arp_interval value specified.\n", |
570 | ": %s: no arp_interval value specified.\n", | ||
571 | bond->dev->name); | 564 | bond->dev->name); |
572 | ret = -EINVAL; | 565 | ret = -EINVAL; |
573 | goto out; | 566 | goto out; |
574 | } | 567 | } |
575 | if (new_value < 0) { | 568 | if (new_value < 0) { |
576 | pr_err(DRV_NAME | 569 | pr_err("%s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", |
577 | ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", | ||
578 | bond->dev->name, new_value, INT_MAX); | 570 | bond->dev->name, new_value, INT_MAX); |
579 | ret = -EINVAL; | 571 | ret = -EINVAL; |
580 | goto out; | 572 | goto out; |
581 | } | 573 | } |
582 | 574 | ||
583 | pr_info(DRV_NAME | 575 | pr_info("%s: Setting ARP monitoring interval to %d.\n", |
584 | ": %s: Setting ARP monitoring interval to %d.\n", | 576 | bond->dev->name, new_value); |
585 | bond->dev->name, new_value); | ||
586 | bond->params.arp_interval = new_value; | 577 | bond->params.arp_interval = new_value; |
587 | if (bond->params.arp_interval) | 578 | if (bond->params.arp_interval) |
588 | bond->dev->priv_flags |= IFF_MASTER_ARPMON; | 579 | bond->dev->priv_flags |= IFF_MASTER_ARPMON; |
589 | if (bond->params.miimon) { | 580 | if (bond->params.miimon) { |
590 | pr_info(DRV_NAME | 581 | pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", |
591 | ": %s: ARP monitoring cannot be used with MII monitoring. " | 582 | bond->dev->name, bond->dev->name); |
592 | "%s Disabling MII monitoring.\n", | ||
593 | bond->dev->name, bond->dev->name); | ||
594 | bond->params.miimon = 0; | 583 | bond->params.miimon = 0; |
595 | if (delayed_work_pending(&bond->mii_work)) { | 584 | if (delayed_work_pending(&bond->mii_work)) { |
596 | cancel_delayed_work(&bond->mii_work); | 585 | cancel_delayed_work(&bond->mii_work); |
@@ -598,10 +587,8 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
598 | } | 587 | } |
599 | } | 588 | } |
600 | if (!bond->params.arp_targets[0]) { | 589 | if (!bond->params.arp_targets[0]) { |
601 | pr_info(DRV_NAME | 590 | pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n", |
602 | ": %s: ARP monitoring has been set up, " | 591 | bond->dev->name); |
603 | "but no ARP targets have been specified.\n", | ||
604 | bond->dev->name); | ||
605 | } | 592 | } |
606 | if (bond->dev->flags & IFF_UP) { | 593 | if (bond->dev->flags & IFF_UP) { |
607 | /* If the interface is up, we may need to fire off | 594 | /* If the interface is up, we may need to fire off |
@@ -661,8 +648,7 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
661 | /* look for adds */ | 648 | /* look for adds */ |
662 | if (buf[0] == '+') { | 649 | if (buf[0] == '+') { |
663 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { | 650 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { |
664 | pr_err(DRV_NAME | 651 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", |
665 | ": %s: invalid ARP target %pI4 specified for addition\n", | ||
666 | bond->dev->name, &newtarget); | 652 | bond->dev->name, &newtarget); |
667 | ret = -EINVAL; | 653 | ret = -EINVAL; |
668 | goto out; | 654 | goto out; |
@@ -670,23 +656,20 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
670 | /* look for an empty slot to put the target in, and check for dupes */ | 656 | /* look for an empty slot to put the target in, and check for dupes */ |
671 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { | 657 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { |
672 | if (targets[i] == newtarget) { /* duplicate */ | 658 | if (targets[i] == newtarget) { /* duplicate */ |
673 | pr_err(DRV_NAME | 659 | pr_err("%s: ARP target %pI4 is already present\n", |
674 | ": %s: ARP target %pI4 is already present\n", | ||
675 | bond->dev->name, &newtarget); | 660 | bond->dev->name, &newtarget); |
676 | ret = -EINVAL; | 661 | ret = -EINVAL; |
677 | goto out; | 662 | goto out; |
678 | } | 663 | } |
679 | if (targets[i] == 0) { | 664 | if (targets[i] == 0) { |
680 | pr_info(DRV_NAME | 665 | pr_info("%s: adding ARP target %pI4.\n", |
681 | ": %s: adding ARP target %pI4.\n", | 666 | bond->dev->name, &newtarget); |
682 | bond->dev->name, &newtarget); | ||
683 | done = 1; | 667 | done = 1; |
684 | targets[i] = newtarget; | 668 | targets[i] = newtarget; |
685 | } | 669 | } |
686 | } | 670 | } |
687 | if (!done) { | 671 | if (!done) { |
688 | pr_err(DRV_NAME | 672 | pr_err("%s: ARP target table is full!\n", |
689 | ": %s: ARP target table is full!\n", | ||
690 | bond->dev->name); | 673 | bond->dev->name); |
691 | ret = -EINVAL; | 674 | ret = -EINVAL; |
692 | goto out; | 675 | goto out; |
@@ -694,8 +677,7 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
694 | 677 | ||
695 | } else if (buf[0] == '-') { | 678 | } else if (buf[0] == '-') { |
696 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { | 679 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { |
697 | pr_err(DRV_NAME | 680 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", |
698 | ": %s: invalid ARP target %pI4 specified for removal\n", | ||
699 | bond->dev->name, &newtarget); | 681 | bond->dev->name, &newtarget); |
700 | ret = -EINVAL; | 682 | ret = -EINVAL; |
701 | goto out; | 683 | goto out; |
@@ -704,9 +686,8 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
704 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { | 686 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { |
705 | if (targets[i] == newtarget) { | 687 | if (targets[i] == newtarget) { |
706 | int j; | 688 | int j; |
707 | pr_info(DRV_NAME | 689 | pr_info("%s: removing ARP target %pI4.\n", |
708 | ": %s: removing ARP target %pI4.\n", | 690 | bond->dev->name, &newtarget); |
709 | bond->dev->name, &newtarget); | ||
710 | for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++) | 691 | for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++) |
711 | targets[j] = targets[j+1]; | 692 | targets[j] = targets[j+1]; |
712 | 693 | ||
@@ -715,16 +696,14 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
715 | } | 696 | } |
716 | } | 697 | } |
717 | if (!done) { | 698 | if (!done) { |
718 | pr_info(DRV_NAME | 699 | pr_info("%s: unable to remove nonexistent ARP target %pI4.\n", |
719 | ": %s: unable to remove nonexistent ARP target %pI4.\n", | 700 | bond->dev->name, &newtarget); |
720 | bond->dev->name, &newtarget); | ||
721 | ret = -EINVAL; | 701 | ret = -EINVAL; |
722 | goto out; | 702 | goto out; |
723 | } | 703 | } |
724 | } else { | 704 | } else { |
725 | pr_err(DRV_NAME ": no command found in arp_ip_targets file" | 705 | pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n", |
726 | " for bond %s. Use +<addr> or -<addr>.\n", | 706 | bond->dev->name); |
727 | bond->dev->name); | ||
728 | ret = -EPERM; | 707 | ret = -EPERM; |
729 | goto out; | 708 | goto out; |
730 | } | 709 | } |
@@ -756,41 +735,34 @@ static ssize_t bonding_store_downdelay(struct device *d, | |||
756 | struct bonding *bond = to_bond(d); | 735 | struct bonding *bond = to_bond(d); |
757 | 736 | ||
758 | if (!(bond->params.miimon)) { | 737 | if (!(bond->params.miimon)) { |
759 | pr_err(DRV_NAME | 738 | pr_err("%s: Unable to set down delay as MII monitoring is disabled\n", |
760 | ": %s: Unable to set down delay as MII monitoring is disabled\n", | ||
761 | bond->dev->name); | 739 | bond->dev->name); |
762 | ret = -EPERM; | 740 | ret = -EPERM; |
763 | goto out; | 741 | goto out; |
764 | } | 742 | } |
765 | 743 | ||
766 | if (sscanf(buf, "%d", &new_value) != 1) { | 744 | if (sscanf(buf, "%d", &new_value) != 1) { |
767 | pr_err(DRV_NAME | 745 | pr_err("%s: no down delay value specified.\n", bond->dev->name); |
768 | ": %s: no down delay value specified.\n", | ||
769 | bond->dev->name); | ||
770 | ret = -EINVAL; | 746 | ret = -EINVAL; |
771 | goto out; | 747 | goto out; |
772 | } | 748 | } |
773 | if (new_value < 0) { | 749 | if (new_value < 0) { |
774 | pr_err(DRV_NAME | 750 | pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n", |
775 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", | ||
776 | bond->dev->name, new_value, 1, INT_MAX); | 751 | bond->dev->name, new_value, 1, INT_MAX); |
777 | ret = -EINVAL; | 752 | ret = -EINVAL; |
778 | goto out; | 753 | goto out; |
779 | } else { | 754 | } else { |
780 | if ((new_value % bond->params.miimon) != 0) { | 755 | if ((new_value % bond->params.miimon) != 0) { |
781 | pr_warning(DRV_NAME | 756 | pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n", |
782 | ": %s: Warning: down delay (%d) is not a " | ||
783 | "multiple of miimon (%d), delay rounded " | ||
784 | "to %d ms\n", | ||
785 | bond->dev->name, new_value, | 757 | bond->dev->name, new_value, |
786 | bond->params.miimon, | 758 | bond->params.miimon, |
787 | (new_value / bond->params.miimon) * | 759 | (new_value / bond->params.miimon) * |
788 | bond->params.miimon); | 760 | bond->params.miimon); |
789 | } | 761 | } |
790 | bond->params.downdelay = new_value / bond->params.miimon; | 762 | bond->params.downdelay = new_value / bond->params.miimon; |
791 | pr_info(DRV_NAME ": %s: Setting down delay to %d.\n", | 763 | pr_info("%s: Setting down delay to %d.\n", |
792 | bond->dev->name, | 764 | bond->dev->name, |
793 | bond->params.downdelay * bond->params.miimon); | 765 | bond->params.downdelay * bond->params.miimon); |
794 | 766 | ||
795 | } | 767 | } |
796 | 768 | ||
@@ -818,41 +790,35 @@ static ssize_t bonding_store_updelay(struct device *d, | |||
818 | struct bonding *bond = to_bond(d); | 790 | struct bonding *bond = to_bond(d); |
819 | 791 | ||
820 | if (!(bond->params.miimon)) { | 792 | if (!(bond->params.miimon)) { |
821 | pr_err(DRV_NAME | 793 | pr_err("%s: Unable to set up delay as MII monitoring is disabled\n", |
822 | ": %s: Unable to set up delay as MII monitoring is disabled\n", | ||
823 | bond->dev->name); | 794 | bond->dev->name); |
824 | ret = -EPERM; | 795 | ret = -EPERM; |
825 | goto out; | 796 | goto out; |
826 | } | 797 | } |
827 | 798 | ||
828 | if (sscanf(buf, "%d", &new_value) != 1) { | 799 | if (sscanf(buf, "%d", &new_value) != 1) { |
829 | pr_err(DRV_NAME | 800 | pr_err("%s: no up delay value specified.\n", |
830 | ": %s: no up delay value specified.\n", | ||
831 | bond->dev->name); | 801 | bond->dev->name); |
832 | ret = -EINVAL; | 802 | ret = -EINVAL; |
833 | goto out; | 803 | goto out; |
834 | } | 804 | } |
835 | if (new_value < 0) { | 805 | if (new_value < 0) { |
836 | pr_err(DRV_NAME | 806 | pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n", |
837 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", | ||
838 | bond->dev->name, new_value, 1, INT_MAX); | 807 | bond->dev->name, new_value, 1, INT_MAX); |
839 | ret = -EINVAL; | 808 | ret = -EINVAL; |
840 | goto out; | 809 | goto out; |
841 | } else { | 810 | } else { |
842 | if ((new_value % bond->params.miimon) != 0) { | 811 | if ((new_value % bond->params.miimon) != 0) { |
843 | pr_warning(DRV_NAME | 812 | pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n", |
844 | ": %s: Warning: up delay (%d) is not a " | ||
845 | "multiple of miimon (%d), updelay rounded " | ||
846 | "to %d ms\n", | ||
847 | bond->dev->name, new_value, | 813 | bond->dev->name, new_value, |
848 | bond->params.miimon, | 814 | bond->params.miimon, |
849 | (new_value / bond->params.miimon) * | 815 | (new_value / bond->params.miimon) * |
850 | bond->params.miimon); | 816 | bond->params.miimon); |
851 | } | 817 | } |
852 | bond->params.updelay = new_value / bond->params.miimon; | 818 | bond->params.updelay = new_value / bond->params.miimon; |
853 | pr_info(DRV_NAME ": %s: Setting up delay to %d.\n", | 819 | pr_info("%s: Setting up delay to %d.\n", |
854 | bond->dev->name, bond->params.updelay * bond->params.miimon); | 820 | bond->dev->name, |
855 | 821 | bond->params.updelay * bond->params.miimon); | |
856 | } | 822 | } |
857 | 823 | ||
858 | out: | 824 | out: |
@@ -884,16 +850,14 @@ static ssize_t bonding_store_lacp(struct device *d, | |||
884 | struct bonding *bond = to_bond(d); | 850 | struct bonding *bond = to_bond(d); |
885 | 851 | ||
886 | if (bond->dev->flags & IFF_UP) { | 852 | if (bond->dev->flags & IFF_UP) { |
887 | pr_err(DRV_NAME | 853 | pr_err("%s: Unable to update LACP rate because interface is up.\n", |
888 | ": %s: Unable to update LACP rate because interface is up.\n", | ||
889 | bond->dev->name); | 854 | bond->dev->name); |
890 | ret = -EPERM; | 855 | ret = -EPERM; |
891 | goto out; | 856 | goto out; |
892 | } | 857 | } |
893 | 858 | ||
894 | if (bond->params.mode != BOND_MODE_8023AD) { | 859 | if (bond->params.mode != BOND_MODE_8023AD) { |
895 | pr_err(DRV_NAME | 860 | pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", |
896 | ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", | ||
897 | bond->dev->name); | 861 | bond->dev->name); |
898 | ret = -EPERM; | 862 | ret = -EPERM; |
899 | goto out; | 863 | goto out; |
@@ -903,12 +867,11 @@ static ssize_t bonding_store_lacp(struct device *d, | |||
903 | 867 | ||
904 | if ((new_value == 1) || (new_value == 0)) { | 868 | if ((new_value == 1) || (new_value == 0)) { |
905 | bond->params.lacp_fast = new_value; | 869 | bond->params.lacp_fast = new_value; |
906 | pr_info(DRV_NAME ": %s: Setting LACP rate to %s (%d).\n", | 870 | pr_info("%s: Setting LACP rate to %s (%d).\n", |
907 | bond->dev->name, bond_lacp_tbl[new_value].modename, | 871 | bond->dev->name, bond_lacp_tbl[new_value].modename, |
908 | new_value); | 872 | new_value); |
909 | } else { | 873 | } else { |
910 | pr_err(DRV_NAME | 874 | pr_err("%s: Ignoring invalid LACP rate value %.*s.\n", |
911 | ": %s: Ignoring invalid LACP rate value %.*s.\n", | ||
912 | bond->dev->name, (int)strlen(buf) - 1, buf); | 875 | bond->dev->name, (int)strlen(buf) - 1, buf); |
913 | ret = -EINVAL; | 876 | ret = -EINVAL; |
914 | } | 877 | } |
@@ -938,9 +901,8 @@ static ssize_t bonding_store_ad_select(struct device *d, | |||
938 | struct bonding *bond = to_bond(d); | 901 | struct bonding *bond = to_bond(d); |
939 | 902 | ||
940 | if (bond->dev->flags & IFF_UP) { | 903 | if (bond->dev->flags & IFF_UP) { |
941 | pr_err(DRV_NAME | 904 | pr_err("%s: Unable to update ad_select because interface is up.\n", |
942 | ": %s: Unable to update ad_select because interface " | 905 | bond->dev->name); |
943 | "is up.\n", bond->dev->name); | ||
944 | ret = -EPERM; | 906 | ret = -EPERM; |
945 | goto out; | 907 | goto out; |
946 | } | 908 | } |
@@ -949,13 +911,11 @@ static ssize_t bonding_store_ad_select(struct device *d, | |||
949 | 911 | ||
950 | if (new_value != -1) { | 912 | if (new_value != -1) { |
951 | bond->params.ad_select = new_value; | 913 | bond->params.ad_select = new_value; |
952 | pr_info(DRV_NAME | 914 | pr_info("%s: Setting ad_select to %s (%d).\n", |
953 | ": %s: Setting ad_select to %s (%d).\n", | 915 | bond->dev->name, ad_select_tbl[new_value].modename, |
954 | bond->dev->name, ad_select_tbl[new_value].modename, | 916 | new_value); |
955 | new_value); | ||
956 | } else { | 917 | } else { |
957 | pr_err(DRV_NAME | 918 | pr_err("%s: Ignoring invalid ad_select value %.*s.\n", |
958 | ": %s: Ignoring invalid ad_select value %.*s.\n", | ||
959 | bond->dev->name, (int)strlen(buf) - 1, buf); | 919 | bond->dev->name, (int)strlen(buf) - 1, buf); |
960 | ret = -EINVAL; | 920 | ret = -EINVAL; |
961 | } | 921 | } |
@@ -985,15 +945,13 @@ static ssize_t bonding_store_n_grat_arp(struct device *d, | |||
985 | struct bonding *bond = to_bond(d); | 945 | struct bonding *bond = to_bond(d); |
986 | 946 | ||
987 | if (sscanf(buf, "%d", &new_value) != 1) { | 947 | if (sscanf(buf, "%d", &new_value) != 1) { |
988 | pr_err(DRV_NAME | 948 | pr_err("%s: no num_grat_arp value specified.\n", |
989 | ": %s: no num_grat_arp value specified.\n", | ||
990 | bond->dev->name); | 949 | bond->dev->name); |
991 | ret = -EINVAL; | 950 | ret = -EINVAL; |
992 | goto out; | 951 | goto out; |
993 | } | 952 | } |
994 | if (new_value < 0 || new_value > 255) { | 953 | if (new_value < 0 || new_value > 255) { |
995 | pr_err(DRV_NAME | 954 | pr_err("%s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n", |
996 | ": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n", | ||
997 | bond->dev->name, new_value); | 955 | bond->dev->name, new_value); |
998 | ret = -EINVAL; | 956 | ret = -EINVAL; |
999 | goto out; | 957 | goto out; |
@@ -1026,16 +984,14 @@ static ssize_t bonding_store_n_unsol_na(struct device *d, | |||
1026 | struct bonding *bond = to_bond(d); | 984 | struct bonding *bond = to_bond(d); |
1027 | 985 | ||
1028 | if (sscanf(buf, "%d", &new_value) != 1) { | 986 | if (sscanf(buf, "%d", &new_value) != 1) { |
1029 | pr_err(DRV_NAME | 987 | pr_err("%s: no num_unsol_na value specified.\n", |
1030 | ": %s: no num_unsol_na value specified.\n", | ||
1031 | bond->dev->name); | 988 | bond->dev->name); |
1032 | ret = -EINVAL; | 989 | ret = -EINVAL; |
1033 | goto out; | 990 | goto out; |
1034 | } | 991 | } |
1035 | 992 | ||
1036 | if (new_value < 0 || new_value > 255) { | 993 | if (new_value < 0 || new_value > 255) { |
1037 | pr_err(DRV_NAME | 994 | pr_err("%s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n", |
1038 | ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n", | ||
1039 | bond->dev->name, new_value); | 995 | bond->dev->name, new_value); |
1040 | ret = -EINVAL; | 996 | ret = -EINVAL; |
1041 | goto out; | 997 | goto out; |
@@ -1070,40 +1026,31 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
1070 | struct bonding *bond = to_bond(d); | 1026 | struct bonding *bond = to_bond(d); |
1071 | 1027 | ||
1072 | if (sscanf(buf, "%d", &new_value) != 1) { | 1028 | if (sscanf(buf, "%d", &new_value) != 1) { |
1073 | pr_err(DRV_NAME | 1029 | pr_err("%s: no miimon value specified.\n", |
1074 | ": %s: no miimon value specified.\n", | ||
1075 | bond->dev->name); | 1030 | bond->dev->name); |
1076 | ret = -EINVAL; | 1031 | ret = -EINVAL; |
1077 | goto out; | 1032 | goto out; |
1078 | } | 1033 | } |
1079 | if (new_value < 0) { | 1034 | if (new_value < 0) { |
1080 | pr_err(DRV_NAME | 1035 | pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n", |
1081 | ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n", | ||
1082 | bond->dev->name, new_value, 1, INT_MAX); | 1036 | bond->dev->name, new_value, 1, INT_MAX); |
1083 | ret = -EINVAL; | 1037 | ret = -EINVAL; |
1084 | goto out; | 1038 | goto out; |
1085 | } else { | 1039 | } else { |
1086 | pr_info(DRV_NAME | 1040 | pr_info("%s: Setting MII monitoring interval to %d.\n", |
1087 | ": %s: Setting MII monitoring interval to %d.\n", | 1041 | bond->dev->name, new_value); |
1088 | bond->dev->name, new_value); | ||
1089 | bond->params.miimon = new_value; | 1042 | bond->params.miimon = new_value; |
1090 | if (bond->params.updelay) | 1043 | if (bond->params.updelay) |
1091 | pr_info(DRV_NAME | 1044 | pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n", |
1092 | ": %s: Note: Updating updelay (to %d) " | 1045 | bond->dev->name, |
1093 | "since it is a multiple of the miimon value.\n", | 1046 | bond->params.updelay * bond->params.miimon); |
1094 | bond->dev->name, | ||
1095 | bond->params.updelay * bond->params.miimon); | ||
1096 | if (bond->params.downdelay) | 1047 | if (bond->params.downdelay) |
1097 | pr_info(DRV_NAME | 1048 | pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n", |
1098 | ": %s: Note: Updating downdelay (to %d) " | 1049 | bond->dev->name, |
1099 | "since it is a multiple of the miimon value.\n", | 1050 | bond->params.downdelay * bond->params.miimon); |
1100 | bond->dev->name, | ||
1101 | bond->params.downdelay * bond->params.miimon); | ||
1102 | if (bond->params.arp_interval) { | 1051 | if (bond->params.arp_interval) { |
1103 | pr_info(DRV_NAME | 1052 | pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n", |
1104 | ": %s: MII monitoring cannot be used with " | 1053 | bond->dev->name); |
1105 | "ARP monitoring. Disabling ARP monitoring...\n", | ||
1106 | bond->dev->name); | ||
1107 | bond->params.arp_interval = 0; | 1054 | bond->params.arp_interval = 0; |
1108 | bond->dev->priv_flags &= ~IFF_MASTER_ARPMON; | 1055 | bond->dev->priv_flags &= ~IFF_MASTER_ARPMON; |
1109 | if (bond->params.arp_validate) { | 1056 | if (bond->params.arp_validate) { |
@@ -1171,17 +1118,15 @@ static ssize_t bonding_store_primary(struct device *d, | |||
1171 | write_lock_bh(&bond->curr_slave_lock); | 1118 | write_lock_bh(&bond->curr_slave_lock); |
1172 | 1119 | ||
1173 | if (!USES_PRIMARY(bond->params.mode)) { | 1120 | if (!USES_PRIMARY(bond->params.mode)) { |
1174 | pr_info(DRV_NAME | 1121 | pr_info("%s: Unable to set primary slave; %s is in mode %d\n", |
1175 | ": %s: Unable to set primary slave; %s is in mode %d\n", | 1122 | bond->dev->name, bond->dev->name, bond->params.mode); |
1176 | bond->dev->name, bond->dev->name, bond->params.mode); | ||
1177 | } else { | 1123 | } else { |
1178 | bond_for_each_slave(bond, slave, i) { | 1124 | bond_for_each_slave(bond, slave, i) { |
1179 | if (strnicmp | 1125 | if (strnicmp |
1180 | (slave->dev->name, buf, | 1126 | (slave->dev->name, buf, |
1181 | strlen(slave->dev->name)) == 0) { | 1127 | strlen(slave->dev->name)) == 0) { |
1182 | pr_info(DRV_NAME | 1128 | pr_info("%s: Setting %s as primary slave.\n", |
1183 | ": %s: Setting %s as primary slave.\n", | 1129 | bond->dev->name, slave->dev->name); |
1184 | bond->dev->name, slave->dev->name); | ||
1185 | bond->primary_slave = slave; | 1130 | bond->primary_slave = slave; |
1186 | strcpy(bond->params.primary, slave->dev->name); | 1131 | strcpy(bond->params.primary, slave->dev->name); |
1187 | bond_select_active_slave(bond); | 1132 | bond_select_active_slave(bond); |
@@ -1192,15 +1137,13 @@ static ssize_t bonding_store_primary(struct device *d, | |||
1192 | /* if we got here, then we didn't match the name of any slave */ | 1137 | /* if we got here, then we didn't match the name of any slave */ |
1193 | 1138 | ||
1194 | if (strlen(buf) == 0 || buf[0] == '\n') { | 1139 | if (strlen(buf) == 0 || buf[0] == '\n') { |
1195 | pr_info(DRV_NAME | 1140 | pr_info("%s: Setting primary slave to None.\n", |
1196 | ": %s: Setting primary slave to None.\n", | 1141 | bond->dev->name); |
1197 | bond->dev->name); | ||
1198 | bond->primary_slave = NULL; | 1142 | bond->primary_slave = NULL; |
1199 | bond_select_active_slave(bond); | 1143 | bond_select_active_slave(bond); |
1200 | } else { | 1144 | } else { |
1201 | pr_info(DRV_NAME | 1145 | pr_info("%s: Unable to set %.*s as primary slave as it is not a slave.\n", |
1202 | ": %s: Unable to set %.*s as primary slave as it is not a slave.\n", | 1146 | bond->dev->name, (int)strlen(buf) - 1, buf); |
1203 | bond->dev->name, (int)strlen(buf) - 1, buf); | ||
1204 | } | 1147 | } |
1205 | } | 1148 | } |
1206 | out: | 1149 | out: |
@@ -1214,6 +1157,57 @@ static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, | |||
1214 | bonding_show_primary, bonding_store_primary); | 1157 | bonding_show_primary, bonding_store_primary); |
1215 | 1158 | ||
1216 | /* | 1159 | /* |
1160 | * Show and set the primary_reselect flag. | ||
1161 | */ | ||
1162 | static ssize_t bonding_show_primary_reselect(struct device *d, | ||
1163 | struct device_attribute *attr, | ||
1164 | char *buf) | ||
1165 | { | ||
1166 | struct bonding *bond = to_bond(d); | ||
1167 | |||
1168 | return sprintf(buf, "%s %d\n", | ||
1169 | pri_reselect_tbl[bond->params.primary_reselect].modename, | ||
1170 | bond->params.primary_reselect); | ||
1171 | } | ||
1172 | |||
1173 | static ssize_t bonding_store_primary_reselect(struct device *d, | ||
1174 | struct device_attribute *attr, | ||
1175 | const char *buf, size_t count) | ||
1176 | { | ||
1177 | int new_value, ret = count; | ||
1178 | struct bonding *bond = to_bond(d); | ||
1179 | |||
1180 | if (!rtnl_trylock()) | ||
1181 | return restart_syscall(); | ||
1182 | |||
1183 | new_value = bond_parse_parm(buf, pri_reselect_tbl); | ||
1184 | if (new_value < 0) { | ||
1185 | pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n", | ||
1186 | bond->dev->name, | ||
1187 | (int) strlen(buf) - 1, buf); | ||
1188 | ret = -EINVAL; | ||
1189 | goto out; | ||
1190 | } | ||
1191 | |||
1192 | bond->params.primary_reselect = new_value; | ||
1193 | pr_info("%s: setting primary_reselect to %s (%d).\n", | ||
1194 | bond->dev->name, pri_reselect_tbl[new_value].modename, | ||
1195 | new_value); | ||
1196 | |||
1197 | read_lock(&bond->lock); | ||
1198 | write_lock_bh(&bond->curr_slave_lock); | ||
1199 | bond_select_active_slave(bond); | ||
1200 | write_unlock_bh(&bond->curr_slave_lock); | ||
1201 | read_unlock(&bond->lock); | ||
1202 | out: | ||
1203 | rtnl_unlock(); | ||
1204 | return ret; | ||
1205 | } | ||
1206 | static DEVICE_ATTR(primary_reselect, S_IRUGO | S_IWUSR, | ||
1207 | bonding_show_primary_reselect, | ||
1208 | bonding_store_primary_reselect); | ||
1209 | |||
1210 | /* | ||
1217 | * Show and set the use_carrier flag. | 1211 | * Show and set the use_carrier flag. |
1218 | */ | 1212 | */ |
1219 | static ssize_t bonding_show_carrier(struct device *d, | 1213 | static ssize_t bonding_show_carrier(struct device *d, |
@@ -1234,20 +1228,18 @@ static ssize_t bonding_store_carrier(struct device *d, | |||
1234 | 1228 | ||
1235 | 1229 | ||
1236 | if (sscanf(buf, "%d", &new_value) != 1) { | 1230 | if (sscanf(buf, "%d", &new_value) != 1) { |
1237 | pr_err(DRV_NAME | 1231 | pr_err("%s: no use_carrier value specified.\n", |
1238 | ": %s: no use_carrier value specified.\n", | ||
1239 | bond->dev->name); | 1232 | bond->dev->name); |
1240 | ret = -EINVAL; | 1233 | ret = -EINVAL; |
1241 | goto out; | 1234 | goto out; |
1242 | } | 1235 | } |
1243 | if ((new_value == 0) || (new_value == 1)) { | 1236 | if ((new_value == 0) || (new_value == 1)) { |
1244 | bond->params.use_carrier = new_value; | 1237 | bond->params.use_carrier = new_value; |
1245 | pr_info(DRV_NAME ": %s: Setting use_carrier to %d.\n", | 1238 | pr_info("%s: Setting use_carrier to %d.\n", |
1246 | bond->dev->name, new_value); | 1239 | bond->dev->name, new_value); |
1247 | } else { | 1240 | } else { |
1248 | pr_info(DRV_NAME | 1241 | pr_info("%s: Ignoring invalid use_carrier value %d.\n", |
1249 | ": %s: Ignoring invalid use_carrier value %d.\n", | 1242 | bond->dev->name, new_value); |
1250 | bond->dev->name, new_value); | ||
1251 | } | 1243 | } |
1252 | out: | 1244 | out: |
1253 | return count; | 1245 | return count; |
@@ -1292,8 +1284,7 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1292 | write_lock_bh(&bond->curr_slave_lock); | 1284 | write_lock_bh(&bond->curr_slave_lock); |
1293 | 1285 | ||
1294 | if (!USES_PRIMARY(bond->params.mode)) | 1286 | if (!USES_PRIMARY(bond->params.mode)) |
1295 | pr_info(DRV_NAME ": %s: Unable to change active slave;" | 1287 | pr_info("%s: Unable to change active slave; %s is in mode %d\n", |
1296 | " %s is in mode %d\n", | ||
1297 | bond->dev->name, bond->dev->name, bond->params.mode); | 1288 | bond->dev->name, bond->dev->name, bond->params.mode); |
1298 | else { | 1289 | else { |
1299 | bond_for_each_slave(bond, slave, i) { | 1290 | bond_for_each_slave(bond, slave, i) { |
@@ -1304,9 +1295,9 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1304 | new_active = slave; | 1295 | new_active = slave; |
1305 | if (new_active == old_active) { | 1296 | if (new_active == old_active) { |
1306 | /* do nothing */ | 1297 | /* do nothing */ |
1307 | pr_info(DRV_NAME | 1298 | pr_info("%s: %s is already the current active slave.\n", |
1308 | ": %s: %s is already the current active slave.\n", | 1299 | bond->dev->name, |
1309 | bond->dev->name, slave->dev->name); | 1300 | slave->dev->name); |
1310 | goto out; | 1301 | goto out; |
1311 | } | 1302 | } |
1312 | else { | 1303 | else { |
@@ -1314,16 +1305,15 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1314 | (old_active) && | 1305 | (old_active) && |
1315 | (new_active->link == BOND_LINK_UP) && | 1306 | (new_active->link == BOND_LINK_UP) && |
1316 | IS_UP(new_active->dev)) { | 1307 | IS_UP(new_active->dev)) { |
1317 | pr_info(DRV_NAME | 1308 | pr_info("%s: Setting %s as active slave.\n", |
1318 | ": %s: Setting %s as active slave.\n", | 1309 | bond->dev->name, |
1319 | bond->dev->name, slave->dev->name); | 1310 | slave->dev->name); |
1320 | bond_change_active_slave(bond, new_active); | 1311 | bond_change_active_slave(bond, new_active); |
1321 | } | 1312 | } |
1322 | else { | 1313 | else { |
1323 | pr_info(DRV_NAME | 1314 | pr_info("%s: Could not set %s as active slave; either %s is down or the link is down.\n", |
1324 | ": %s: Could not set %s as active slave; " | 1315 | bond->dev->name, |
1325 | "either %s is down or the link is down.\n", | 1316 | slave->dev->name, |
1326 | bond->dev->name, slave->dev->name, | ||
1327 | slave->dev->name); | 1317 | slave->dev->name); |
1328 | } | 1318 | } |
1329 | goto out; | 1319 | goto out; |
@@ -1334,14 +1324,12 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1334 | /* if we got here, then we didn't match the name of any slave */ | 1324 | /* if we got here, then we didn't match the name of any slave */ |
1335 | 1325 | ||
1336 | if (strlen(buf) == 0 || buf[0] == '\n') { | 1326 | if (strlen(buf) == 0 || buf[0] == '\n') { |
1337 | pr_info(DRV_NAME | 1327 | pr_info("%s: Setting active slave to None.\n", |
1338 | ": %s: Setting active slave to None.\n", | ||
1339 | bond->dev->name); | 1328 | bond->dev->name); |
1340 | bond->primary_slave = NULL; | 1329 | bond->primary_slave = NULL; |
1341 | bond_select_active_slave(bond); | 1330 | bond_select_active_slave(bond); |
1342 | } else { | 1331 | } else { |
1343 | pr_info(DRV_NAME ": %s: Unable to set %.*s" | 1332 | pr_info("%s: Unable to set %.*s as active slave as it is not a slave.\n", |
1344 | " as active slave as it is not a slave.\n", | ||
1345 | bond->dev->name, (int)strlen(buf) - 1, buf); | 1333 | bond->dev->name, (int)strlen(buf) - 1, buf); |
1346 | } | 1334 | } |
1347 | } | 1335 | } |
@@ -1502,6 +1490,7 @@ static struct attribute *per_bond_attrs[] = { | |||
1502 | &dev_attr_num_unsol_na.attr, | 1490 | &dev_attr_num_unsol_na.attr, |
1503 | &dev_attr_miimon.attr, | 1491 | &dev_attr_miimon.attr, |
1504 | &dev_attr_primary.attr, | 1492 | &dev_attr_primary.attr, |
1493 | &dev_attr_primary_reselect.attr, | ||
1505 | &dev_attr_use_carrier.attr, | 1494 | &dev_attr_use_carrier.attr, |
1506 | &dev_attr_active_slave.attr, | 1495 | &dev_attr_active_slave.attr, |
1507 | &dev_attr_mii_status.attr, | 1496 | &dev_attr_mii_status.attr, |
@@ -1542,8 +1531,7 @@ int bond_create_sysfs(void) | |||
1542 | /* Is someone being kinky and naming a device bonding_master? */ | 1531 | /* Is someone being kinky and naming a device bonding_master? */ |
1543 | if (__dev_get_by_name(&init_net, | 1532 | if (__dev_get_by_name(&init_net, |
1544 | class_attr_bonding_masters.attr.name)) | 1533 | class_attr_bonding_masters.attr.name)) |
1545 | pr_err("network device named %s already " | 1534 | pr_err("network device named %s already exists in sysfs", |
1546 | "exists in sysfs", | ||
1547 | class_attr_bonding_masters.attr.name); | 1535 | class_attr_bonding_masters.attr.name); |
1548 | ret = 0; | 1536 | ret = 0; |
1549 | } | 1537 | } |
@@ -1564,24 +1552,8 @@ void bond_destroy_sysfs(void) | |||
1564 | * Initialize sysfs for each bond. This sets up and registers | 1552 | * Initialize sysfs for each bond. This sets up and registers |
1565 | * the 'bondctl' directory for each individual bond under /sys/class/net. | 1553 | * the 'bondctl' directory for each individual bond under /sys/class/net. |
1566 | */ | 1554 | */ |
1567 | int bond_create_sysfs_entry(struct bonding *bond) | 1555 | void bond_prepare_sysfs_group(struct bonding *bond) |
1568 | { | ||
1569 | struct net_device *dev = bond->dev; | ||
1570 | int err; | ||
1571 | |||
1572 | err = sysfs_create_group(&(dev->dev.kobj), &bonding_group); | ||
1573 | if (err) | ||
1574 | pr_emerg("eek! didn't create group!\n"); | ||
1575 | |||
1576 | return err; | ||
1577 | } | ||
1578 | /* | ||
1579 | * Remove sysfs entries for each bond. | ||
1580 | */ | ||
1581 | void bond_destroy_sysfs_entry(struct bonding *bond) | ||
1582 | { | 1556 | { |
1583 | struct net_device *dev = bond->dev; | 1557 | bond->dev->sysfs_groups[0] = &bonding_group; |
1584 | |||
1585 | sysfs_remove_group(&(dev->dev.kobj), &bonding_group); | ||
1586 | } | 1558 | } |
1587 | 1559 | ||