diff options
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 324 |
1 files changed, 175 insertions, 149 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 72357597fa1b..ecb20208f67c 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /* | 1 | /* |
3 | * Copyright(c) 2004-2005 Intel Corporation. All rights reserved. | 2 | * Copyright(c) 2004-2005 Intel Corporation. All rights reserved. |
4 | * | 3 | * |
@@ -38,7 +37,7 @@ | |||
38 | 37 | ||
39 | #include "bonding.h" | 38 | #include "bonding.h" |
40 | 39 | ||
41 | #define to_dev(obj) container_of(obj,struct device,kobj) | 40 | #define to_dev(obj) container_of(obj, struct device, kobj) |
42 | #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd)))) | 41 | #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd)))) |
43 | 42 | ||
44 | /*---------------------------- Declarations -------------------------------*/ | 43 | /*---------------------------- Declarations -------------------------------*/ |
@@ -83,7 +82,8 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf) | |||
83 | * | 82 | * |
84 | */ | 83 | */ |
85 | 84 | ||
86 | static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t count) | 85 | static ssize_t bonding_store_bonds(struct class *cls, |
86 | const char *buffer, size_t count) | ||
87 | { | 87 | { |
88 | char command[IFNAMSIZ + 1] = {0, }; | 88 | char command[IFNAMSIZ + 1] = {0, }; |
89 | char *ifname; | 89 | char *ifname; |
@@ -97,11 +97,11 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t | |||
97 | goto err_no_cmd; | 97 | goto err_no_cmd; |
98 | 98 | ||
99 | if (command[0] == '+') { | 99 | if (command[0] == '+') { |
100 | printk(KERN_INFO DRV_NAME | 100 | pr_info(DRV_NAME |
101 | ": %s is being created...\n", ifname); | 101 | ": %s is being created...\n", ifname); |
102 | rv = bond_create(ifname); | 102 | rv = bond_create(ifname); |
103 | if (rv) { | 103 | if (rv) { |
104 | printk(KERN_INFO DRV_NAME ": Bond creation failed.\n"); | 104 | pr_info(DRV_NAME ": Bond creation failed.\n"); |
105 | res = rv; | 105 | res = rv; |
106 | } | 106 | } |
107 | goto out; | 107 | goto out; |
@@ -118,28 +118,28 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t | |||
118 | */ | 118 | */ |
119 | if (atomic_read(&bond->dev->dev.kobj.kref.refcount) | 119 | if (atomic_read(&bond->dev->dev.kobj.kref.refcount) |
120 | > expected_refcount){ | 120 | > expected_refcount){ |
121 | printk(KERN_INFO DRV_NAME | 121 | pr_info(DRV_NAME |
122 | ": Unable remove bond %s due to open references.\n", | 122 | ": Unable remove bond %s due to open references.\n", |
123 | ifname); | 123 | ifname); |
124 | res = -EPERM; | 124 | res = -EPERM; |
125 | goto out_unlock; | 125 | goto out_unlock; |
126 | } | 126 | } |
127 | printk(KERN_INFO DRV_NAME | 127 | pr_info(DRV_NAME |
128 | ": %s is being deleted...\n", | 128 | ": %s is being deleted...\n", |
129 | bond->dev->name); | 129 | bond->dev->name); |
130 | unregister_netdevice(bond->dev); | 130 | unregister_netdevice(bond->dev); |
131 | goto out_unlock; | 131 | goto out_unlock; |
132 | } | 132 | } |
133 | 133 | ||
134 | printk(KERN_ERR DRV_NAME | 134 | pr_err(DRV_NAME |
135 | ": unable to delete non-existent bond %s\n", ifname); | 135 | ": unable to delete non-existent bond %s\n", ifname); |
136 | res = -ENODEV; | 136 | res = -ENODEV; |
137 | goto out_unlock; | 137 | goto out_unlock; |
138 | } | 138 | } |
139 | 139 | ||
140 | err_no_cmd: | 140 | err_no_cmd: |
141 | printk(KERN_ERR DRV_NAME | 141 | pr_err(DRV_NAME ": no command found in bonding_masters." |
142 | ": no command found in bonding_masters. Use +ifname or -ifname.\n"); | 142 | " Use +ifname or -ifname.\n"); |
143 | return -EPERM; | 143 | return -EPERM; |
144 | 144 | ||
145 | out_unlock: | 145 | out_unlock: |
@@ -155,7 +155,8 @@ out: | |||
155 | static CLASS_ATTR(bonding_masters, S_IWUSR | S_IRUGO, | 155 | static CLASS_ATTR(bonding_masters, S_IWUSR | S_IRUGO, |
156 | bonding_show_bonds, bonding_store_bonds); | 156 | bonding_show_bonds, bonding_store_bonds); |
157 | 157 | ||
158 | int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave) | 158 | int bond_create_slave_symlinks(struct net_device *master, |
159 | struct net_device *slave) | ||
159 | { | 160 | { |
160 | char linkname[IFNAMSIZ+7]; | 161 | char linkname[IFNAMSIZ+7]; |
161 | int ret = 0; | 162 | int ret = 0; |
@@ -166,19 +167,20 @@ int bond_create_slave_symlinks(struct net_device *master, struct net_device *sla | |||
166 | if (ret) | 167 | if (ret) |
167 | return ret; | 168 | return ret; |
168 | /* next, create a link from the master to the slave */ | 169 | /* next, create a link from the master to the slave */ |
169 | sprintf(linkname,"slave_%s",slave->name); | 170 | sprintf(linkname, "slave_%s", slave->name); |
170 | ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj), | 171 | ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj), |
171 | linkname); | 172 | linkname); |
172 | return ret; | 173 | return ret; |
173 | 174 | ||
174 | } | 175 | } |
175 | 176 | ||
176 | void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave) | 177 | void bond_destroy_slave_symlinks(struct net_device *master, |
178 | struct net_device *slave) | ||
177 | { | 179 | { |
178 | char linkname[IFNAMSIZ+7]; | 180 | char linkname[IFNAMSIZ+7]; |
179 | 181 | ||
180 | sysfs_remove_link(&(slave->dev.kobj), "master"); | 182 | sysfs_remove_link(&(slave->dev.kobj), "master"); |
181 | sprintf(linkname,"slave_%s",slave->name); | 183 | sprintf(linkname, "slave_%s", slave->name); |
182 | sysfs_remove_link(&(master->dev.kobj), linkname); | 184 | sysfs_remove_link(&(master->dev.kobj), linkname); |
183 | } | 185 | } |
184 | 186 | ||
@@ -252,7 +254,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
252 | read_lock(&bond->lock); | 254 | read_lock(&bond->lock); |
253 | bond_for_each_slave(bond, slave, i) | 255 | bond_for_each_slave(bond, slave, i) |
254 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { | 256 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { |
255 | printk(KERN_ERR DRV_NAME | 257 | pr_err(DRV_NAME |
256 | ": %s: Interface %s is already enslaved!\n", | 258 | ": %s: Interface %s is already enslaved!\n", |
257 | bond->dev->name, ifname); | 259 | bond->dev->name, ifname); |
258 | ret = -EPERM; | 260 | ret = -EPERM; |
@@ -261,21 +263,20 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
261 | } | 263 | } |
262 | 264 | ||
263 | read_unlock(&bond->lock); | 265 | read_unlock(&bond->lock); |
264 | printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", | 266 | pr_info(DRV_NAME ": %s: Adding slave %s.\n", |
265 | bond->dev->name, ifname); | 267 | bond->dev->name, ifname); |
266 | dev = dev_get_by_name(&init_net, ifname); | 268 | dev = dev_get_by_name(&init_net, ifname); |
267 | if (!dev) { | 269 | if (!dev) { |
268 | printk(KERN_INFO DRV_NAME | 270 | pr_info(DRV_NAME |
269 | ": %s: Interface %s does not exist!\n", | 271 | ": %s: Interface %s does not exist!\n", |
270 | bond->dev->name, ifname); | 272 | bond->dev->name, ifname); |
271 | ret = -EPERM; | 273 | ret = -EPERM; |
272 | goto out; | 274 | goto out; |
273 | } | 275 | } else |
274 | else | ||
275 | dev_put(dev); | 276 | dev_put(dev); |
276 | 277 | ||
277 | if (dev->flags & IFF_UP) { | 278 | if (dev->flags & IFF_UP) { |
278 | printk(KERN_ERR DRV_NAME | 279 | pr_err(DRV_NAME |
279 | ": %s: Error: Unable to enslave %s " | 280 | ": %s: Error: Unable to enslave %s " |
280 | "because it is already up.\n", | 281 | "because it is already up.\n", |
281 | bond->dev->name, dev->name); | 282 | bond->dev->name, dev->name); |
@@ -302,9 +303,9 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
302 | bond_for_each_slave(bond, slave, i) | 303 | bond_for_each_slave(bond, slave, i) |
303 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) | 304 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) |
304 | slave->original_mtu = original_mtu; | 305 | slave->original_mtu = original_mtu; |
305 | if (res) { | 306 | if (res) |
306 | ret = res; | 307 | ret = res; |
307 | } | 308 | |
308 | goto out; | 309 | goto out; |
309 | } | 310 | } |
310 | 311 | ||
@@ -318,7 +319,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
318 | break; | 319 | break; |
319 | } | 320 | } |
320 | if (dev) { | 321 | if (dev) { |
321 | printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", | 322 | pr_info(DRV_NAME ": %s: Removing slave %s\n", |
322 | bond->dev->name, dev->name); | 323 | bond->dev->name, dev->name); |
323 | res = bond_release(bond->dev, dev); | 324 | res = bond_release(bond->dev, dev); |
324 | if (res) { | 325 | if (res) { |
@@ -327,9 +328,9 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
327 | } | 328 | } |
328 | /* set the slave MTU to the default */ | 329 | /* set the slave MTU to the default */ |
329 | dev_set_mtu(dev, original_mtu); | 330 | dev_set_mtu(dev, original_mtu); |
330 | } | 331 | } else { |
331 | else { | 332 | pr_err(DRV_NAME ": unable to remove non-existent" |
332 | printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n", | 333 | " slave %s for bond %s.\n", |
333 | ifname, bond->dev->name); | 334 | ifname, bond->dev->name); |
334 | ret = -ENODEV; | 335 | ret = -ENODEV; |
335 | } | 336 | } |
@@ -337,7 +338,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
337 | } | 338 | } |
338 | 339 | ||
339 | err_no_cmd: | 340 | err_no_cmd: |
340 | printk(KERN_ERR DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); | 341 | pr_err(DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); |
341 | ret = -EPERM; | 342 | ret = -EPERM; |
342 | 343 | ||
343 | out: | 344 | out: |
@@ -345,7 +346,8 @@ out: | |||
345 | return ret; | 346 | return ret; |
346 | } | 347 | } |
347 | 348 | ||
348 | static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves); | 349 | static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, |
350 | bonding_store_slaves); | ||
349 | 351 | ||
350 | /* | 352 | /* |
351 | * Show and set the bonding mode. The bond interface must be down to | 353 | * Show and set the bonding mode. The bond interface must be down to |
@@ -369,16 +371,15 @@ static ssize_t bonding_store_mode(struct device *d, | |||
369 | struct bonding *bond = to_bond(d); | 371 | struct bonding *bond = to_bond(d); |
370 | 372 | ||
371 | if (bond->dev->flags & IFF_UP) { | 373 | if (bond->dev->flags & IFF_UP) { |
372 | printk(KERN_ERR DRV_NAME | 374 | pr_err(DRV_NAME ": unable to update mode of %s" |
373 | ": unable to update mode of %s because interface is up.\n", | 375 | " because interface is up.\n", bond->dev->name); |
374 | bond->dev->name); | ||
375 | ret = -EPERM; | 376 | ret = -EPERM; |
376 | goto out; | 377 | goto out; |
377 | } | 378 | } |
378 | 379 | ||
379 | new_value = bond_parse_parm(buf, bond_mode_tbl); | 380 | new_value = bond_parse_parm(buf, bond_mode_tbl); |
380 | if (new_value < 0) { | 381 | if (new_value < 0) { |
381 | printk(KERN_ERR DRV_NAME | 382 | pr_err(DRV_NAME |
382 | ": %s: Ignoring invalid mode value %.*s.\n", | 383 | ": %s: Ignoring invalid mode value %.*s.\n", |
383 | bond->dev->name, | 384 | bond->dev->name, |
384 | (int)strlen(buf) - 1, buf); | 385 | (int)strlen(buf) - 1, buf); |
@@ -393,17 +394,19 @@ static ssize_t bonding_store_mode(struct device *d, | |||
393 | 394 | ||
394 | bond->params.mode = new_value; | 395 | bond->params.mode = new_value; |
395 | bond_set_mode_ops(bond, bond->params.mode); | 396 | bond_set_mode_ops(bond, bond->params.mode); |
396 | printk(KERN_INFO DRV_NAME ": %s: setting mode to %s (%d).\n", | 397 | pr_info(DRV_NAME ": %s: setting mode to %s (%d).\n", |
397 | bond->dev->name, bond_mode_tbl[new_value].modename, new_value); | 398 | bond->dev->name, bond_mode_tbl[new_value].modename, |
399 | new_value); | ||
398 | } | 400 | } |
399 | out: | 401 | out: |
400 | return ret; | 402 | return ret; |
401 | } | 403 | } |
402 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode); | 404 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, |
405 | bonding_show_mode, bonding_store_mode); | ||
403 | 406 | ||
404 | /* | 407 | /* |
405 | * Show and set the bonding transmit hash method. The bond interface must be down to | 408 | * Show and set the bonding transmit hash method. |
406 | * change the xmit hash policy. | 409 | * The bond interface must be down to change the xmit hash policy. |
407 | */ | 410 | */ |
408 | static ssize_t bonding_show_xmit_hash(struct device *d, | 411 | static ssize_t bonding_show_xmit_hash(struct device *d, |
409 | struct device_attribute *attr, | 412 | struct device_attribute *attr, |
@@ -424,7 +427,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
424 | struct bonding *bond = to_bond(d); | 427 | struct bonding *bond = to_bond(d); |
425 | 428 | ||
426 | if (bond->dev->flags & IFF_UP) { | 429 | if (bond->dev->flags & IFF_UP) { |
427 | printk(KERN_ERR DRV_NAME | 430 | pr_err(DRV_NAME |
428 | "%s: Interface is up. Unable to update xmit policy.\n", | 431 | "%s: Interface is up. Unable to update xmit policy.\n", |
429 | bond->dev->name); | 432 | bond->dev->name); |
430 | ret = -EPERM; | 433 | ret = -EPERM; |
@@ -433,7 +436,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
433 | 436 | ||
434 | new_value = bond_parse_parm(buf, xmit_hashtype_tbl); | 437 | new_value = bond_parse_parm(buf, xmit_hashtype_tbl); |
435 | if (new_value < 0) { | 438 | if (new_value < 0) { |
436 | printk(KERN_ERR DRV_NAME | 439 | pr_err(DRV_NAME |
437 | ": %s: Ignoring invalid xmit hash policy value %.*s.\n", | 440 | ": %s: Ignoring invalid xmit hash policy value %.*s.\n", |
438 | bond->dev->name, | 441 | bond->dev->name, |
439 | (int)strlen(buf) - 1, buf); | 442 | (int)strlen(buf) - 1, buf); |
@@ -442,13 +445,15 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
442 | } else { | 445 | } else { |
443 | bond->params.xmit_policy = new_value; | 446 | bond->params.xmit_policy = new_value; |
444 | bond_set_mode_ops(bond, bond->params.mode); | 447 | bond_set_mode_ops(bond, bond->params.mode); |
445 | printk(KERN_INFO DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", | 448 | pr_info(DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", |
446 | bond->dev->name, xmit_hashtype_tbl[new_value].modename, new_value); | 449 | bond->dev->name, |
450 | xmit_hashtype_tbl[new_value].modename, new_value); | ||
447 | } | 451 | } |
448 | out: | 452 | out: |
449 | return ret; | 453 | return ret; |
450 | } | 454 | } |
451 | static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); | 455 | static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, |
456 | bonding_show_xmit_hash, bonding_store_xmit_hash); | ||
452 | 457 | ||
453 | /* | 458 | /* |
454 | * Show and set arp_validate. | 459 | * Show and set arp_validate. |
@@ -473,39 +478,41 @@ static ssize_t bonding_store_arp_validate(struct device *d, | |||
473 | 478 | ||
474 | new_value = bond_parse_parm(buf, arp_validate_tbl); | 479 | new_value = bond_parse_parm(buf, arp_validate_tbl); |
475 | if (new_value < 0) { | 480 | if (new_value < 0) { |
476 | printk(KERN_ERR DRV_NAME | 481 | pr_err(DRV_NAME |
477 | ": %s: Ignoring invalid arp_validate value %s\n", | 482 | ": %s: Ignoring invalid arp_validate value %s\n", |
478 | bond->dev->name, buf); | 483 | bond->dev->name, buf); |
479 | return -EINVAL; | 484 | return -EINVAL; |
480 | } | 485 | } |
481 | if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { | 486 | if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { |
482 | printk(KERN_ERR DRV_NAME | 487 | pr_err(DRV_NAME |
483 | ": %s: arp_validate only supported in active-backup mode.\n", | 488 | ": %s: arp_validate only supported in active-backup mode.\n", |
484 | bond->dev->name); | 489 | bond->dev->name); |
485 | return -EINVAL; | 490 | return -EINVAL; |
486 | } | 491 | } |
487 | printk(KERN_INFO DRV_NAME ": %s: setting arp_validate to %s (%d).\n", | 492 | pr_info(DRV_NAME ": %s: setting arp_validate to %s (%d).\n", |
488 | bond->dev->name, arp_validate_tbl[new_value].modename, | 493 | bond->dev->name, arp_validate_tbl[new_value].modename, |
489 | new_value); | 494 | new_value); |
490 | 495 | ||
491 | if (!bond->params.arp_validate && new_value) { | 496 | if (!bond->params.arp_validate && new_value) |
492 | bond_register_arp(bond); | 497 | bond_register_arp(bond); |
493 | } else if (bond->params.arp_validate && !new_value) { | 498 | else if (bond->params.arp_validate && !new_value) |
494 | bond_unregister_arp(bond); | 499 | bond_unregister_arp(bond); |
495 | } | ||
496 | 500 | ||
497 | bond->params.arp_validate = new_value; | 501 | bond->params.arp_validate = new_value; |
498 | 502 | ||
499 | return count; | 503 | return count; |
500 | } | 504 | } |
501 | 505 | ||
502 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate); | 506 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, |
507 | bonding_store_arp_validate); | ||
503 | 508 | ||
504 | /* | 509 | /* |
505 | * Show and store fail_over_mac. User only allowed to change the | 510 | * Show and store fail_over_mac. User only allowed to change the |
506 | * value when there are no slaves. | 511 | * value when there are no slaves. |
507 | */ | 512 | */ |
508 | static ssize_t bonding_show_fail_over_mac(struct device *d, struct device_attribute *attr, char *buf) | 513 | static ssize_t bonding_show_fail_over_mac(struct device *d, |
514 | struct device_attribute *attr, | ||
515 | char *buf) | ||
509 | { | 516 | { |
510 | struct bonding *bond = to_bond(d); | 517 | struct bonding *bond = to_bond(d); |
511 | 518 | ||
@@ -514,13 +521,15 @@ static ssize_t bonding_show_fail_over_mac(struct device *d, struct device_attrib | |||
514 | bond->params.fail_over_mac); | 521 | bond->params.fail_over_mac); |
515 | } | 522 | } |
516 | 523 | ||
517 | static ssize_t bonding_store_fail_over_mac(struct device *d, struct device_attribute *attr, const char *buf, size_t count) | 524 | static ssize_t bonding_store_fail_over_mac(struct device *d, |
525 | struct device_attribute *attr, | ||
526 | const char *buf, size_t count) | ||
518 | { | 527 | { |
519 | int new_value; | 528 | int new_value; |
520 | struct bonding *bond = to_bond(d); | 529 | struct bonding *bond = to_bond(d); |
521 | 530 | ||
522 | if (bond->slave_cnt != 0) { | 531 | if (bond->slave_cnt != 0) { |
523 | printk(KERN_ERR DRV_NAME | 532 | pr_err(DRV_NAME |
524 | ": %s: Can't alter fail_over_mac with slaves in bond.\n", | 533 | ": %s: Can't alter fail_over_mac with slaves in bond.\n", |
525 | bond->dev->name); | 534 | bond->dev->name); |
526 | return -EPERM; | 535 | return -EPERM; |
@@ -528,21 +537,22 @@ static ssize_t bonding_store_fail_over_mac(struct device *d, struct device_attri | |||
528 | 537 | ||
529 | new_value = bond_parse_parm(buf, fail_over_mac_tbl); | 538 | new_value = bond_parse_parm(buf, fail_over_mac_tbl); |
530 | if (new_value < 0) { | 539 | if (new_value < 0) { |
531 | printk(KERN_ERR DRV_NAME | 540 | pr_err(DRV_NAME |
532 | ": %s: Ignoring invalid fail_over_mac value %s.\n", | 541 | ": %s: Ignoring invalid fail_over_mac value %s.\n", |
533 | bond->dev->name, buf); | 542 | bond->dev->name, buf); |
534 | return -EINVAL; | 543 | return -EINVAL; |
535 | } | 544 | } |
536 | 545 | ||
537 | bond->params.fail_over_mac = new_value; | 546 | bond->params.fail_over_mac = new_value; |
538 | printk(KERN_INFO DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n", | 547 | pr_info(DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n", |
539 | bond->dev->name, fail_over_mac_tbl[new_value].modename, | 548 | bond->dev->name, fail_over_mac_tbl[new_value].modename, |
540 | new_value); | 549 | new_value); |
541 | 550 | ||
542 | return count; | 551 | return count; |
543 | } | 552 | } |
544 | 553 | ||
545 | static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, bonding_show_fail_over_mac, bonding_store_fail_over_mac); | 554 | static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, |
555 | bonding_show_fail_over_mac, bonding_store_fail_over_mac); | ||
546 | 556 | ||
547 | /* | 557 | /* |
548 | * Show and set the arp timer interval. There are two tricky bits | 558 | * Show and set the arp timer interval. There are two tricky bits |
@@ -567,28 +577,28 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
567 | struct bonding *bond = to_bond(d); | 577 | struct bonding *bond = to_bond(d); |
568 | 578 | ||
569 | if (sscanf(buf, "%d", &new_value) != 1) { | 579 | if (sscanf(buf, "%d", &new_value) != 1) { |
570 | printk(KERN_ERR DRV_NAME | 580 | pr_err(DRV_NAME |
571 | ": %s: no arp_interval value specified.\n", | 581 | ": %s: no arp_interval value specified.\n", |
572 | bond->dev->name); | 582 | bond->dev->name); |
573 | ret = -EINVAL; | 583 | ret = -EINVAL; |
574 | goto out; | 584 | goto out; |
575 | } | 585 | } |
576 | if (new_value < 0) { | 586 | if (new_value < 0) { |
577 | printk(KERN_ERR DRV_NAME | 587 | pr_err(DRV_NAME |
578 | ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", | 588 | ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", |
579 | bond->dev->name, new_value, INT_MAX); | 589 | bond->dev->name, new_value, INT_MAX); |
580 | ret = -EINVAL; | 590 | ret = -EINVAL; |
581 | goto out; | 591 | goto out; |
582 | } | 592 | } |
583 | 593 | ||
584 | printk(KERN_INFO DRV_NAME | 594 | pr_info(DRV_NAME |
585 | ": %s: Setting ARP monitoring interval to %d.\n", | 595 | ": %s: Setting ARP monitoring interval to %d.\n", |
586 | bond->dev->name, new_value); | 596 | bond->dev->name, new_value); |
587 | bond->params.arp_interval = new_value; | 597 | bond->params.arp_interval = new_value; |
588 | if (bond->params.arp_interval) | 598 | if (bond->params.arp_interval) |
589 | bond->dev->priv_flags |= IFF_MASTER_ARPMON; | 599 | bond->dev->priv_flags |= IFF_MASTER_ARPMON; |
590 | if (bond->params.miimon) { | 600 | if (bond->params.miimon) { |
591 | printk(KERN_INFO DRV_NAME | 601 | pr_info(DRV_NAME |
592 | ": %s: ARP monitoring cannot be used with MII monitoring. " | 602 | ": %s: ARP monitoring cannot be used with MII monitoring. " |
593 | "%s Disabling MII monitoring.\n", | 603 | "%s Disabling MII monitoring.\n", |
594 | bond->dev->name, bond->dev->name); | 604 | bond->dev->name, bond->dev->name); |
@@ -599,7 +609,7 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
599 | } | 609 | } |
600 | } | 610 | } |
601 | if (!bond->params.arp_targets[0]) { | 611 | if (!bond->params.arp_targets[0]) { |
602 | printk(KERN_INFO DRV_NAME | 612 | pr_info(DRV_NAME |
603 | ": %s: ARP monitoring has been set up, " | 613 | ": %s: ARP monitoring has been set up, " |
604 | "but no ARP targets have been specified.\n", | 614 | "but no ARP targets have been specified.\n", |
605 | bond->dev->name); | 615 | bond->dev->name); |
@@ -625,7 +635,8 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
625 | out: | 635 | out: |
626 | return ret; | 636 | return ret; |
627 | } | 637 | } |
628 | static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval); | 638 | static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR, |
639 | bonding_show_arp_interval, bonding_store_arp_interval); | ||
629 | 640 | ||
630 | /* | 641 | /* |
631 | * Show and set the arp targets. | 642 | * Show and set the arp targets. |
@@ -661,7 +672,7 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
661 | /* look for adds */ | 672 | /* look for adds */ |
662 | if (buf[0] == '+') { | 673 | if (buf[0] == '+') { |
663 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { | 674 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { |
664 | printk(KERN_ERR DRV_NAME | 675 | pr_err(DRV_NAME |
665 | ": %s: invalid ARP target %pI4 specified for addition\n", | 676 | ": %s: invalid ARP target %pI4 specified for addition\n", |
666 | bond->dev->name, &newtarget); | 677 | bond->dev->name, &newtarget); |
667 | ret = -EINVAL; | 678 | ret = -EINVAL; |
@@ -670,14 +681,14 @@ 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 */ | 681 | /* 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++) { | 682 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { |
672 | if (targets[i] == newtarget) { /* duplicate */ | 683 | if (targets[i] == newtarget) { /* duplicate */ |
673 | printk(KERN_ERR DRV_NAME | 684 | pr_err(DRV_NAME |
674 | ": %s: ARP target %pI4 is already present\n", | 685 | ": %s: ARP target %pI4 is already present\n", |
675 | bond->dev->name, &newtarget); | 686 | bond->dev->name, &newtarget); |
676 | ret = -EINVAL; | 687 | ret = -EINVAL; |
677 | goto out; | 688 | goto out; |
678 | } | 689 | } |
679 | if (targets[i] == 0) { | 690 | if (targets[i] == 0) { |
680 | printk(KERN_INFO DRV_NAME | 691 | pr_info(DRV_NAME |
681 | ": %s: adding ARP target %pI4.\n", | 692 | ": %s: adding ARP target %pI4.\n", |
682 | bond->dev->name, &newtarget); | 693 | bond->dev->name, &newtarget); |
683 | done = 1; | 694 | done = 1; |
@@ -685,17 +696,16 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
685 | } | 696 | } |
686 | } | 697 | } |
687 | if (!done) { | 698 | if (!done) { |
688 | printk(KERN_ERR DRV_NAME | 699 | pr_err(DRV_NAME |
689 | ": %s: ARP target table is full!\n", | 700 | ": %s: ARP target table is full!\n", |
690 | bond->dev->name); | 701 | bond->dev->name); |
691 | ret = -EINVAL; | 702 | ret = -EINVAL; |
692 | goto out; | 703 | goto out; |
693 | } | 704 | } |
694 | 705 | ||
695 | } | 706 | } else if (buf[0] == '-') { |
696 | else if (buf[0] == '-') { | ||
697 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { | 707 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { |
698 | printk(KERN_ERR DRV_NAME | 708 | pr_err(DRV_NAME |
699 | ": %s: invalid ARP target %pI4 specified for removal\n", | 709 | ": %s: invalid ARP target %pI4 specified for removal\n", |
700 | bond->dev->name, &newtarget); | 710 | bond->dev->name, &newtarget); |
701 | ret = -EINVAL; | 711 | ret = -EINVAL; |
@@ -705,7 +715,7 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
705 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { | 715 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { |
706 | if (targets[i] == newtarget) { | 716 | if (targets[i] == newtarget) { |
707 | int j; | 717 | int j; |
708 | printk(KERN_INFO DRV_NAME | 718 | pr_info(DRV_NAME |
709 | ": %s: removing ARP target %pI4.\n", | 719 | ": %s: removing ARP target %pI4.\n", |
710 | bond->dev->name, &newtarget); | 720 | bond->dev->name, &newtarget); |
711 | for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++) | 721 | for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++) |
@@ -716,15 +726,15 @@ static ssize_t bonding_store_arp_targets(struct device *d, | |||
716 | } | 726 | } |
717 | } | 727 | } |
718 | if (!done) { | 728 | if (!done) { |
719 | printk(KERN_INFO DRV_NAME | 729 | pr_info(DRV_NAME |
720 | ": %s: unable to remove nonexistent ARP target %pI4.\n", | 730 | ": %s: unable to remove nonexistent ARP target %pI4.\n", |
721 | bond->dev->name, &newtarget); | 731 | bond->dev->name, &newtarget); |
722 | ret = -EINVAL; | 732 | ret = -EINVAL; |
723 | goto out; | 733 | goto out; |
724 | } | 734 | } |
725 | } | 735 | } else { |
726 | else { | 736 | pr_err(DRV_NAME ": no command found in arp_ip_targets file" |
727 | printk(KERN_ERR DRV_NAME ": no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n", | 737 | " for bond %s. Use +<addr> or -<addr>.\n", |
728 | bond->dev->name); | 738 | bond->dev->name); |
729 | ret = -EPERM; | 739 | ret = -EPERM; |
730 | goto out; | 740 | goto out; |
@@ -757,7 +767,7 @@ static ssize_t bonding_store_downdelay(struct device *d, | |||
757 | struct bonding *bond = to_bond(d); | 767 | struct bonding *bond = to_bond(d); |
758 | 768 | ||
759 | if (!(bond->params.miimon)) { | 769 | if (!(bond->params.miimon)) { |
760 | printk(KERN_ERR DRV_NAME | 770 | pr_err(DRV_NAME |
761 | ": %s: Unable to set down delay as MII monitoring is disabled\n", | 771 | ": %s: Unable to set down delay as MII monitoring is disabled\n", |
762 | bond->dev->name); | 772 | bond->dev->name); |
763 | ret = -EPERM; | 773 | ret = -EPERM; |
@@ -765,14 +775,14 @@ static ssize_t bonding_store_downdelay(struct device *d, | |||
765 | } | 775 | } |
766 | 776 | ||
767 | if (sscanf(buf, "%d", &new_value) != 1) { | 777 | if (sscanf(buf, "%d", &new_value) != 1) { |
768 | printk(KERN_ERR DRV_NAME | 778 | pr_err(DRV_NAME |
769 | ": %s: no down delay value specified.\n", | 779 | ": %s: no down delay value specified.\n", |
770 | bond->dev->name); | 780 | bond->dev->name); |
771 | ret = -EINVAL; | 781 | ret = -EINVAL; |
772 | goto out; | 782 | goto out; |
773 | } | 783 | } |
774 | if (new_value < 0) { | 784 | if (new_value < 0) { |
775 | printk(KERN_ERR DRV_NAME | 785 | pr_err(DRV_NAME |
776 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", | 786 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", |
777 | bond->dev->name, new_value, 1, INT_MAX); | 787 | bond->dev->name, new_value, 1, INT_MAX); |
778 | ret = -EINVAL; | 788 | ret = -EINVAL; |
@@ -787,15 +797,17 @@ static ssize_t bonding_store_downdelay(struct device *d, | |||
787 | bond->params.miimon); | 797 | bond->params.miimon); |
788 | } | 798 | } |
789 | bond->params.downdelay = new_value / bond->params.miimon; | 799 | bond->params.downdelay = new_value / bond->params.miimon; |
790 | printk(KERN_INFO DRV_NAME ": %s: Setting down delay to %d.\n", | 800 | pr_info(DRV_NAME ": %s: Setting down delay to %d.\n", |
791 | bond->dev->name, bond->params.downdelay * bond->params.miimon); | 801 | bond->dev->name, |
802 | bond->params.downdelay * bond->params.miimon); | ||
792 | 803 | ||
793 | } | 804 | } |
794 | 805 | ||
795 | out: | 806 | out: |
796 | return ret; | 807 | return ret; |
797 | } | 808 | } |
798 | static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay); | 809 | static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR, |
810 | bonding_show_downdelay, bonding_store_downdelay); | ||
799 | 811 | ||
800 | static ssize_t bonding_show_updelay(struct device *d, | 812 | static ssize_t bonding_show_updelay(struct device *d, |
801 | struct device_attribute *attr, | 813 | struct device_attribute *attr, |
@@ -815,7 +827,7 @@ static ssize_t bonding_store_updelay(struct device *d, | |||
815 | struct bonding *bond = to_bond(d); | 827 | struct bonding *bond = to_bond(d); |
816 | 828 | ||
817 | if (!(bond->params.miimon)) { | 829 | if (!(bond->params.miimon)) { |
818 | printk(KERN_ERR DRV_NAME | 830 | pr_err(DRV_NAME |
819 | ": %s: Unable to set up delay as MII monitoring is disabled\n", | 831 | ": %s: Unable to set up delay as MII monitoring is disabled\n", |
820 | bond->dev->name); | 832 | bond->dev->name); |
821 | ret = -EPERM; | 833 | ret = -EPERM; |
@@ -823,14 +835,14 @@ static ssize_t bonding_store_updelay(struct device *d, | |||
823 | } | 835 | } |
824 | 836 | ||
825 | if (sscanf(buf, "%d", &new_value) != 1) { | 837 | if (sscanf(buf, "%d", &new_value) != 1) { |
826 | printk(KERN_ERR DRV_NAME | 838 | pr_err(DRV_NAME |
827 | ": %s: no up delay value specified.\n", | 839 | ": %s: no up delay value specified.\n", |
828 | bond->dev->name); | 840 | bond->dev->name); |
829 | ret = -EINVAL; | 841 | ret = -EINVAL; |
830 | goto out; | 842 | goto out; |
831 | } | 843 | } |
832 | if (new_value < 0) { | 844 | if (new_value < 0) { |
833 | printk(KERN_ERR DRV_NAME | 845 | pr_err(DRV_NAME |
834 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", | 846 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", |
835 | bond->dev->name, new_value, 1, INT_MAX); | 847 | bond->dev->name, new_value, 1, INT_MAX); |
836 | ret = -EINVAL; | 848 | ret = -EINVAL; |
@@ -845,7 +857,7 @@ static ssize_t bonding_store_updelay(struct device *d, | |||
845 | bond->params.miimon); | 857 | bond->params.miimon); |
846 | } | 858 | } |
847 | bond->params.updelay = new_value / bond->params.miimon; | 859 | bond->params.updelay = new_value / bond->params.miimon; |
848 | printk(KERN_INFO DRV_NAME ": %s: Setting up delay to %d.\n", | 860 | pr_info(DRV_NAME ": %s: Setting up delay to %d.\n", |
849 | bond->dev->name, bond->params.updelay * bond->params.miimon); | 861 | bond->dev->name, bond->params.updelay * bond->params.miimon); |
850 | 862 | ||
851 | } | 863 | } |
@@ -853,7 +865,8 @@ static ssize_t bonding_store_updelay(struct device *d, | |||
853 | out: | 865 | out: |
854 | return ret; | 866 | return ret; |
855 | } | 867 | } |
856 | static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay); | 868 | static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR, |
869 | bonding_show_updelay, bonding_store_updelay); | ||
857 | 870 | ||
858 | /* | 871 | /* |
859 | * Show and set the LACP interval. Interface must be down, and the mode | 872 | * Show and set the LACP interval. Interface must be down, and the mode |
@@ -878,7 +891,7 @@ static ssize_t bonding_store_lacp(struct device *d, | |||
878 | struct bonding *bond = to_bond(d); | 891 | struct bonding *bond = to_bond(d); |
879 | 892 | ||
880 | if (bond->dev->flags & IFF_UP) { | 893 | if (bond->dev->flags & IFF_UP) { |
881 | printk(KERN_ERR DRV_NAME | 894 | pr_err(DRV_NAME |
882 | ": %s: Unable to update LACP rate because interface is up.\n", | 895 | ": %s: Unable to update LACP rate because interface is up.\n", |
883 | bond->dev->name); | 896 | bond->dev->name); |
884 | ret = -EPERM; | 897 | ret = -EPERM; |
@@ -886,7 +899,7 @@ static ssize_t bonding_store_lacp(struct device *d, | |||
886 | } | 899 | } |
887 | 900 | ||
888 | if (bond->params.mode != BOND_MODE_8023AD) { | 901 | if (bond->params.mode != BOND_MODE_8023AD) { |
889 | printk(KERN_ERR DRV_NAME | 902 | pr_err(DRV_NAME |
890 | ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", | 903 | ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", |
891 | bond->dev->name); | 904 | bond->dev->name); |
892 | ret = -EPERM; | 905 | ret = -EPERM; |
@@ -897,19 +910,20 @@ static ssize_t bonding_store_lacp(struct device *d, | |||
897 | 910 | ||
898 | if ((new_value == 1) || (new_value == 0)) { | 911 | if ((new_value == 1) || (new_value == 0)) { |
899 | bond->params.lacp_fast = new_value; | 912 | bond->params.lacp_fast = new_value; |
900 | printk(KERN_INFO DRV_NAME | 913 | pr_info(DRV_NAME ": %s: Setting LACP rate to %s (%d).\n", |
901 | ": %s: Setting LACP rate to %s (%d).\n", | 914 | bond->dev->name, bond_lacp_tbl[new_value].modename, |
902 | bond->dev->name, bond_lacp_tbl[new_value].modename, new_value); | 915 | new_value); |
903 | } else { | 916 | } else { |
904 | printk(KERN_ERR DRV_NAME | 917 | pr_err(DRV_NAME |
905 | ": %s: Ignoring invalid LACP rate value %.*s.\n", | 918 | ": %s: Ignoring invalid LACP rate value %.*s.\n", |
906 | bond->dev->name, (int)strlen(buf) - 1, buf); | 919 | bond->dev->name, (int)strlen(buf) - 1, buf); |
907 | ret = -EINVAL; | 920 | ret = -EINVAL; |
908 | } | 921 | } |
909 | out: | 922 | out: |
910 | return ret; | 923 | return ret; |
911 | } | 924 | } |
912 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); | 925 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, |
926 | bonding_show_lacp, bonding_store_lacp); | ||
913 | 927 | ||
914 | static ssize_t bonding_show_ad_select(struct device *d, | 928 | static ssize_t bonding_show_ad_select(struct device *d, |
915 | struct device_attribute *attr, | 929 | struct device_attribute *attr, |
@@ -931,7 +945,7 @@ static ssize_t bonding_store_ad_select(struct device *d, | |||
931 | struct bonding *bond = to_bond(d); | 945 | struct bonding *bond = to_bond(d); |
932 | 946 | ||
933 | if (bond->dev->flags & IFF_UP) { | 947 | if (bond->dev->flags & IFF_UP) { |
934 | printk(KERN_ERR DRV_NAME | 948 | pr_err(DRV_NAME |
935 | ": %s: Unable to update ad_select because interface " | 949 | ": %s: Unable to update ad_select because interface " |
936 | "is up.\n", bond->dev->name); | 950 | "is up.\n", bond->dev->name); |
937 | ret = -EPERM; | 951 | ret = -EPERM; |
@@ -942,12 +956,12 @@ static ssize_t bonding_store_ad_select(struct device *d, | |||
942 | 956 | ||
943 | if (new_value != -1) { | 957 | if (new_value != -1) { |
944 | bond->params.ad_select = new_value; | 958 | bond->params.ad_select = new_value; |
945 | printk(KERN_INFO DRV_NAME | 959 | pr_info(DRV_NAME |
946 | ": %s: Setting ad_select to %s (%d).\n", | 960 | ": %s: Setting ad_select to %s (%d).\n", |
947 | bond->dev->name, ad_select_tbl[new_value].modename, | 961 | bond->dev->name, ad_select_tbl[new_value].modename, |
948 | new_value); | 962 | new_value); |
949 | } else { | 963 | } else { |
950 | printk(KERN_ERR DRV_NAME | 964 | pr_err(DRV_NAME |
951 | ": %s: Ignoring invalid ad_select value %.*s.\n", | 965 | ": %s: Ignoring invalid ad_select value %.*s.\n", |
952 | bond->dev->name, (int)strlen(buf) - 1, buf); | 966 | bond->dev->name, (int)strlen(buf) - 1, buf); |
953 | ret = -EINVAL; | 967 | ret = -EINVAL; |
@@ -955,8 +969,8 @@ static ssize_t bonding_store_ad_select(struct device *d, | |||
955 | out: | 969 | out: |
956 | return ret; | 970 | return ret; |
957 | } | 971 | } |
958 | 972 | static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, | |
959 | static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, bonding_show_ad_select, bonding_store_ad_select); | 973 | bonding_show_ad_select, bonding_store_ad_select); |
960 | 974 | ||
961 | /* | 975 | /* |
962 | * 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. |
@@ -978,14 +992,14 @@ static ssize_t bonding_store_n_grat_arp(struct device *d, | |||
978 | struct bonding *bond = to_bond(d); | 992 | struct bonding *bond = to_bond(d); |
979 | 993 | ||
980 | if (sscanf(buf, "%d", &new_value) != 1) { | 994 | if (sscanf(buf, "%d", &new_value) != 1) { |
981 | printk(KERN_ERR DRV_NAME | 995 | pr_err(DRV_NAME |
982 | ": %s: no num_grat_arp value specified.\n", | 996 | ": %s: no num_grat_arp value specified.\n", |
983 | bond->dev->name); | 997 | bond->dev->name); |
984 | ret = -EINVAL; | 998 | ret = -EINVAL; |
985 | goto out; | 999 | goto out; |
986 | } | 1000 | } |
987 | if (new_value < 0 || new_value > 255) { | 1001 | if (new_value < 0 || new_value > 255) { |
988 | printk(KERN_ERR DRV_NAME | 1002 | pr_err(DRV_NAME |
989 | ": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n", | 1003 | ": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n", |
990 | bond->dev->name, new_value); | 1004 | bond->dev->name, new_value); |
991 | ret = -EINVAL; | 1005 | ret = -EINVAL; |
@@ -996,10 +1010,11 @@ static ssize_t bonding_store_n_grat_arp(struct device *d, | |||
996 | out: | 1010 | out: |
997 | return ret; | 1011 | return ret; |
998 | } | 1012 | } |
999 | 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, |
1014 | bonding_show_n_grat_arp, bonding_store_n_grat_arp); | ||
1000 | 1015 | ||
1001 | /* | 1016 | /* |
1002 | * Show and set the number of unsolicted NA's to send after a failover event. | 1017 | * Show and set the number of unsolicited NA's to send after a failover event. |
1003 | */ | 1018 | */ |
1004 | static ssize_t bonding_show_n_unsol_na(struct device *d, | 1019 | static ssize_t bonding_show_n_unsol_na(struct device *d, |
1005 | struct device_attribute *attr, | 1020 | struct device_attribute *attr, |
@@ -1018,25 +1033,26 @@ static ssize_t bonding_store_n_unsol_na(struct device *d, | |||
1018 | struct bonding *bond = to_bond(d); | 1033 | struct bonding *bond = to_bond(d); |
1019 | 1034 | ||
1020 | if (sscanf(buf, "%d", &new_value) != 1) { | 1035 | if (sscanf(buf, "%d", &new_value) != 1) { |
1021 | printk(KERN_ERR DRV_NAME | 1036 | pr_err(DRV_NAME |
1022 | ": %s: no num_unsol_na value specified.\n", | 1037 | ": %s: no num_unsol_na value specified.\n", |
1023 | bond->dev->name); | 1038 | bond->dev->name); |
1024 | ret = -EINVAL; | 1039 | ret = -EINVAL; |
1025 | goto out; | 1040 | goto out; |
1026 | } | 1041 | } |
1042 | |||
1027 | if (new_value < 0 || new_value > 255) { | 1043 | if (new_value < 0 || new_value > 255) { |
1028 | printk(KERN_ERR DRV_NAME | 1044 | pr_err(DRV_NAME |
1029 | ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n", | 1045 | ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n", |
1030 | bond->dev->name, new_value); | 1046 | bond->dev->name, new_value); |
1031 | ret = -EINVAL; | 1047 | ret = -EINVAL; |
1032 | goto out; | 1048 | goto out; |
1033 | } else { | 1049 | } else |
1034 | bond->params.num_unsol_na = new_value; | 1050 | bond->params.num_unsol_na = new_value; |
1035 | } | ||
1036 | out: | 1051 | out: |
1037 | return ret; | 1052 | return ret; |
1038 | } | 1053 | } |
1039 | static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, bonding_show_n_unsol_na, bonding_store_n_unsol_na); | 1054 | static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, |
1055 | bonding_show_n_unsol_na, bonding_store_n_unsol_na); | ||
1040 | 1056 | ||
1041 | /* | 1057 | /* |
1042 | * Show and set the MII monitor interval. There are two tricky bits | 1058 | * Show and set the MII monitor interval. There are two tricky bits |
@@ -1061,37 +1077,37 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
1061 | struct bonding *bond = to_bond(d); | 1077 | struct bonding *bond = to_bond(d); |
1062 | 1078 | ||
1063 | if (sscanf(buf, "%d", &new_value) != 1) { | 1079 | if (sscanf(buf, "%d", &new_value) != 1) { |
1064 | printk(KERN_ERR DRV_NAME | 1080 | pr_err(DRV_NAME |
1065 | ": %s: no miimon value specified.\n", | 1081 | ": %s: no miimon value specified.\n", |
1066 | bond->dev->name); | 1082 | bond->dev->name); |
1067 | ret = -EINVAL; | 1083 | ret = -EINVAL; |
1068 | goto out; | 1084 | goto out; |
1069 | } | 1085 | } |
1070 | if (new_value < 0) { | 1086 | if (new_value < 0) { |
1071 | printk(KERN_ERR DRV_NAME | 1087 | pr_err(DRV_NAME |
1072 | ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n", | 1088 | ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n", |
1073 | bond->dev->name, new_value, 1, INT_MAX); | 1089 | bond->dev->name, new_value, 1, INT_MAX); |
1074 | ret = -EINVAL; | 1090 | ret = -EINVAL; |
1075 | goto out; | 1091 | goto out; |
1076 | } else { | 1092 | } else { |
1077 | printk(KERN_INFO DRV_NAME | 1093 | pr_info(DRV_NAME |
1078 | ": %s: Setting MII monitoring interval to %d.\n", | 1094 | ": %s: Setting MII monitoring interval to %d.\n", |
1079 | bond->dev->name, new_value); | 1095 | bond->dev->name, new_value); |
1080 | bond->params.miimon = new_value; | 1096 | bond->params.miimon = new_value; |
1081 | if(bond->params.updelay) | 1097 | if (bond->params.updelay) |
1082 | printk(KERN_INFO DRV_NAME | 1098 | pr_info(DRV_NAME |
1083 | ": %s: Note: Updating updelay (to %d) " | 1099 | ": %s: Note: Updating updelay (to %d) " |
1084 | "since it is a multiple of the miimon value.\n", | 1100 | "since it is a multiple of the miimon value.\n", |
1085 | bond->dev->name, | 1101 | bond->dev->name, |
1086 | bond->params.updelay * bond->params.miimon); | 1102 | bond->params.updelay * bond->params.miimon); |
1087 | if(bond->params.downdelay) | 1103 | if (bond->params.downdelay) |
1088 | printk(KERN_INFO DRV_NAME | 1104 | pr_info(DRV_NAME |
1089 | ": %s: Note: Updating downdelay (to %d) " | 1105 | ": %s: Note: Updating downdelay (to %d) " |
1090 | "since it is a multiple of the miimon value.\n", | 1106 | "since it is a multiple of the miimon value.\n", |
1091 | bond->dev->name, | 1107 | bond->dev->name, |
1092 | bond->params.downdelay * bond->params.miimon); | 1108 | bond->params.downdelay * bond->params.miimon); |
1093 | if (bond->params.arp_interval) { | 1109 | if (bond->params.arp_interval) { |
1094 | printk(KERN_INFO DRV_NAME | 1110 | pr_info(DRV_NAME |
1095 | ": %s: MII monitoring cannot be used with " | 1111 | ": %s: MII monitoring cannot be used with " |
1096 | "ARP monitoring. Disabling ARP monitoring...\n", | 1112 | "ARP monitoring. Disabling ARP monitoring...\n", |
1097 | bond->dev->name); | 1113 | bond->dev->name); |
@@ -1125,7 +1141,8 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
1125 | out: | 1141 | out: |
1126 | return ret; | 1142 | return ret; |
1127 | } | 1143 | } |
1128 | static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon); | 1144 | static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, |
1145 | bonding_show_miimon, bonding_store_miimon); | ||
1129 | 1146 | ||
1130 | /* | 1147 | /* |
1131 | * Show and set the primary slave. The store function is much | 1148 | * Show and set the primary slave. The store function is much |
@@ -1161,7 +1178,7 @@ static ssize_t bonding_store_primary(struct device *d, | |||
1161 | write_lock_bh(&bond->curr_slave_lock); | 1178 | write_lock_bh(&bond->curr_slave_lock); |
1162 | 1179 | ||
1163 | if (!USES_PRIMARY(bond->params.mode)) { | 1180 | if (!USES_PRIMARY(bond->params.mode)) { |
1164 | printk(KERN_INFO DRV_NAME | 1181 | pr_info(DRV_NAME |
1165 | ": %s: Unable to set primary slave; %s is in mode %d\n", | 1182 | ": %s: Unable to set primary slave; %s is in mode %d\n", |
1166 | bond->dev->name, bond->dev->name, bond->params.mode); | 1183 | bond->dev->name, bond->dev->name, bond->params.mode); |
1167 | } else { | 1184 | } else { |
@@ -1169,7 +1186,7 @@ static ssize_t bonding_store_primary(struct device *d, | |||
1169 | if (strnicmp | 1186 | if (strnicmp |
1170 | (slave->dev->name, buf, | 1187 | (slave->dev->name, buf, |
1171 | strlen(slave->dev->name)) == 0) { | 1188 | strlen(slave->dev->name)) == 0) { |
1172 | printk(KERN_INFO DRV_NAME | 1189 | pr_info(DRV_NAME |
1173 | ": %s: Setting %s as primary slave.\n", | 1190 | ": %s: Setting %s as primary slave.\n", |
1174 | bond->dev->name, slave->dev->name); | 1191 | bond->dev->name, slave->dev->name); |
1175 | bond->primary_slave = slave; | 1192 | bond->primary_slave = slave; |
@@ -1181,13 +1198,13 @@ static ssize_t bonding_store_primary(struct device *d, | |||
1181 | /* if we got here, then we didn't match the name of any slave */ | 1198 | /* if we got here, then we didn't match the name of any slave */ |
1182 | 1199 | ||
1183 | if (strlen(buf) == 0 || buf[0] == '\n') { | 1200 | if (strlen(buf) == 0 || buf[0] == '\n') { |
1184 | printk(KERN_INFO DRV_NAME | 1201 | pr_info(DRV_NAME |
1185 | ": %s: Setting primary slave to None.\n", | 1202 | ": %s: Setting primary slave to None.\n", |
1186 | bond->dev->name); | 1203 | bond->dev->name); |
1187 | bond->primary_slave = NULL; | 1204 | bond->primary_slave = NULL; |
1188 | bond_select_active_slave(bond); | 1205 | bond_select_active_slave(bond); |
1189 | } else { | 1206 | } else { |
1190 | printk(KERN_INFO DRV_NAME | 1207 | pr_info(DRV_NAME |
1191 | ": %s: Unable to set %.*s as primary slave as it is not a slave.\n", | 1208 | ": %s: Unable to set %.*s as primary slave as it is not a slave.\n", |
1192 | bond->dev->name, (int)strlen(buf) - 1, buf); | 1209 | bond->dev->name, (int)strlen(buf) - 1, buf); |
1193 | } | 1210 | } |
@@ -1199,7 +1216,8 @@ out: | |||
1199 | 1216 | ||
1200 | return count; | 1217 | return count; |
1201 | } | 1218 | } |
1202 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); | 1219 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, |
1220 | bonding_show_primary, bonding_store_primary); | ||
1203 | 1221 | ||
1204 | /* | 1222 | /* |
1205 | * Show and set the use_carrier flag. | 1223 | * Show and set the use_carrier flag. |
@@ -1222,7 +1240,7 @@ static ssize_t bonding_store_carrier(struct device *d, | |||
1222 | 1240 | ||
1223 | 1241 | ||
1224 | if (sscanf(buf, "%d", &new_value) != 1) { | 1242 | if (sscanf(buf, "%d", &new_value) != 1) { |
1225 | printk(KERN_ERR DRV_NAME | 1243 | pr_err(DRV_NAME |
1226 | ": %s: no use_carrier value specified.\n", | 1244 | ": %s: no use_carrier value specified.\n", |
1227 | bond->dev->name); | 1245 | bond->dev->name); |
1228 | ret = -EINVAL; | 1246 | ret = -EINVAL; |
@@ -1230,17 +1248,18 @@ static ssize_t bonding_store_carrier(struct device *d, | |||
1230 | } | 1248 | } |
1231 | if ((new_value == 0) || (new_value == 1)) { | 1249 | if ((new_value == 0) || (new_value == 1)) { |
1232 | bond->params.use_carrier = new_value; | 1250 | bond->params.use_carrier = new_value; |
1233 | printk(KERN_INFO DRV_NAME ": %s: Setting use_carrier to %d.\n", | 1251 | pr_info(DRV_NAME ": %s: Setting use_carrier to %d.\n", |
1234 | bond->dev->name, new_value); | 1252 | bond->dev->name, new_value); |
1235 | } else { | 1253 | } else { |
1236 | printk(KERN_INFO DRV_NAME | 1254 | pr_info(DRV_NAME |
1237 | ": %s: Ignoring invalid use_carrier value %d.\n", | 1255 | ": %s: Ignoring invalid use_carrier value %d.\n", |
1238 | bond->dev->name, new_value); | 1256 | bond->dev->name, new_value); |
1239 | } | 1257 | } |
1240 | out: | 1258 | out: |
1241 | return count; | 1259 | return count; |
1242 | } | 1260 | } |
1243 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier); | 1261 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, |
1262 | bonding_show_carrier, bonding_store_carrier); | ||
1244 | 1263 | ||
1245 | 1264 | ||
1246 | /* | 1265 | /* |
@@ -1269,8 +1288,8 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1269 | { | 1288 | { |
1270 | int i; | 1289 | int i; |
1271 | struct slave *slave; | 1290 | struct slave *slave; |
1272 | struct slave *old_active = NULL; | 1291 | struct slave *old_active = NULL; |
1273 | struct slave *new_active = NULL; | 1292 | struct slave *new_active = NULL; |
1274 | struct bonding *bond = to_bond(d); | 1293 | struct bonding *bond = to_bond(d); |
1275 | 1294 | ||
1276 | if (!rtnl_trylock()) | 1295 | if (!rtnl_trylock()) |
@@ -1278,11 +1297,11 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1278 | read_lock(&bond->lock); | 1297 | read_lock(&bond->lock); |
1279 | write_lock_bh(&bond->curr_slave_lock); | 1298 | write_lock_bh(&bond->curr_slave_lock); |
1280 | 1299 | ||
1281 | if (!USES_PRIMARY(bond->params.mode)) { | 1300 | if (!USES_PRIMARY(bond->params.mode)) |
1282 | printk(KERN_INFO DRV_NAME | 1301 | pr_info(DRV_NAME ": %s: Unable to change active slave;" |
1283 | ": %s: Unable to change active slave; %s is in mode %d\n", | 1302 | " %s is in mode %d\n", |
1284 | bond->dev->name, bond->dev->name, bond->params.mode); | 1303 | bond->dev->name, bond->dev->name, bond->params.mode); |
1285 | } else { | 1304 | else { |
1286 | bond_for_each_slave(bond, slave, i) { | 1305 | bond_for_each_slave(bond, slave, i) { |
1287 | if (strnicmp | 1306 | if (strnicmp |
1288 | (slave->dev->name, buf, | 1307 | (slave->dev->name, buf, |
@@ -1321,18 +1340,18 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1321 | /* if we got here, then we didn't match the name of any slave */ | 1340 | /* if we got here, then we didn't match the name of any slave */ |
1322 | 1341 | ||
1323 | if (strlen(buf) == 0 || buf[0] == '\n') { | 1342 | if (strlen(buf) == 0 || buf[0] == '\n') { |
1324 | printk(KERN_INFO DRV_NAME | 1343 | pr_info(DRV_NAME |
1325 | ": %s: Setting active slave to None.\n", | 1344 | ": %s: Setting active slave to None.\n", |
1326 | bond->dev->name); | 1345 | bond->dev->name); |
1327 | bond->primary_slave = NULL; | 1346 | bond->primary_slave = NULL; |
1328 | bond_select_active_slave(bond); | 1347 | bond_select_active_slave(bond); |
1329 | } else { | 1348 | } else { |
1330 | printk(KERN_INFO DRV_NAME | 1349 | pr_info(DRV_NAME ": %s: Unable to set %.*s" |
1331 | ": %s: Unable to set %.*s as active slave as it is not a slave.\n", | 1350 | " as active slave as it is not a slave.\n", |
1332 | bond->dev->name, (int)strlen(buf) - 1, buf); | 1351 | bond->dev->name, (int)strlen(buf) - 1, buf); |
1333 | } | 1352 | } |
1334 | } | 1353 | } |
1335 | out: | 1354 | out: |
1336 | write_unlock_bh(&bond->curr_slave_lock); | 1355 | write_unlock_bh(&bond->curr_slave_lock); |
1337 | read_unlock(&bond->lock); | 1356 | read_unlock(&bond->lock); |
1338 | rtnl_unlock(); | 1357 | rtnl_unlock(); |
@@ -1340,7 +1359,8 @@ out: | |||
1340 | return count; | 1359 | return count; |
1341 | 1360 | ||
1342 | } | 1361 | } |
1343 | static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave); | 1362 | static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, |
1363 | bonding_show_active_slave, bonding_store_active_slave); | ||
1344 | 1364 | ||
1345 | 1365 | ||
1346 | /* | 1366 | /* |
@@ -1357,7 +1377,7 @@ static ssize_t bonding_show_mii_status(struct device *d, | |||
1357 | curr = bond->curr_active_slave; | 1377 | curr = bond->curr_active_slave; |
1358 | read_unlock(&bond->curr_slave_lock); | 1378 | read_unlock(&bond->curr_slave_lock); |
1359 | 1379 | ||
1360 | return sprintf(buf, "%s\n", (curr) ? "up" : "down"); | 1380 | return sprintf(buf, "%s\n", curr ? "up" : "down"); |
1361 | } | 1381 | } |
1362 | static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); | 1382 | static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); |
1363 | 1383 | ||
@@ -1374,7 +1394,9 @@ static ssize_t bonding_show_ad_aggregator(struct device *d, | |||
1374 | 1394 | ||
1375 | if (bond->params.mode == BOND_MODE_8023AD) { | 1395 | if (bond->params.mode == BOND_MODE_8023AD) { |
1376 | struct ad_info ad_info; | 1396 | struct ad_info ad_info; |
1377 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.aggregator_id); | 1397 | count = sprintf(buf, "%d\n", |
1398 | (bond_3ad_get_active_agg_info(bond, &ad_info)) | ||
1399 | ? 0 : ad_info.aggregator_id); | ||
1378 | } | 1400 | } |
1379 | 1401 | ||
1380 | return count; | 1402 | return count; |
@@ -1394,7 +1416,9 @@ static ssize_t bonding_show_ad_num_ports(struct device *d, | |||
1394 | 1416 | ||
1395 | if (bond->params.mode == BOND_MODE_8023AD) { | 1417 | if (bond->params.mode == BOND_MODE_8023AD) { |
1396 | struct ad_info ad_info; | 1418 | struct ad_info ad_info; |
1397 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0: ad_info.ports); | 1419 | count = sprintf(buf, "%d\n", |
1420 | (bond_3ad_get_active_agg_info(bond, &ad_info)) | ||
1421 | ? 0 : ad_info.ports); | ||
1398 | } | 1422 | } |
1399 | 1423 | ||
1400 | return count; | 1424 | return count; |
@@ -1414,7 +1438,9 @@ static ssize_t bonding_show_ad_actor_key(struct device *d, | |||
1414 | 1438 | ||
1415 | if (bond->params.mode == BOND_MODE_8023AD) { | 1439 | if (bond->params.mode == BOND_MODE_8023AD) { |
1416 | struct ad_info ad_info; | 1440 | struct ad_info ad_info; |
1417 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.actor_key); | 1441 | count = sprintf(buf, "%d\n", |
1442 | (bond_3ad_get_active_agg_info(bond, &ad_info)) | ||
1443 | ? 0 : ad_info.actor_key); | ||
1418 | } | 1444 | } |
1419 | 1445 | ||
1420 | return count; | 1446 | return count; |
@@ -1434,7 +1460,9 @@ static ssize_t bonding_show_ad_partner_key(struct device *d, | |||
1434 | 1460 | ||
1435 | if (bond->params.mode == BOND_MODE_8023AD) { | 1461 | if (bond->params.mode == BOND_MODE_8023AD) { |
1436 | struct ad_info ad_info; | 1462 | struct ad_info ad_info; |
1437 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.partner_key); | 1463 | count = sprintf(buf, "%d\n", |
1464 | (bond_3ad_get_active_agg_info(bond, &ad_info)) | ||
1465 | ? 0 : ad_info.partner_key); | ||
1438 | } | 1466 | } |
1439 | 1467 | ||
1440 | return count; | 1468 | return count; |
@@ -1454,9 +1482,8 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d, | |||
1454 | 1482 | ||
1455 | if (bond->params.mode == BOND_MODE_8023AD) { | 1483 | if (bond->params.mode == BOND_MODE_8023AD) { |
1456 | struct ad_info ad_info; | 1484 | struct ad_info ad_info; |
1457 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { | 1485 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) |
1458 | count = sprintf(buf, "%pM\n", ad_info.partner_system); | 1486 | count = sprintf(buf, "%pM\n", ad_info.partner_system); |
1459 | } | ||
1460 | } | 1487 | } |
1461 | 1488 | ||
1462 | return count; | 1489 | return count; |
@@ -1549,9 +1576,8 @@ int bond_create_sysfs_entry(struct bonding *bond) | |||
1549 | int err; | 1576 | int err; |
1550 | 1577 | ||
1551 | err = sysfs_create_group(&(dev->dev.kobj), &bonding_group); | 1578 | err = sysfs_create_group(&(dev->dev.kobj), &bonding_group); |
1552 | if (err) { | 1579 | if (err) |
1553 | printk(KERN_EMERG "eek! didn't create group!\n"); | 1580 | printk(KERN_EMERG "eek! didn't create group!\n"); |
1554 | } | ||
1555 | 1581 | ||
1556 | if (expected_refcount < 1) | 1582 | if (expected_refcount < 1) |
1557 | expected_refcount = atomic_read(&bond->dev->dev.kobj.kref.refcount); | 1583 | expected_refcount = atomic_read(&bond->dev->dev.kobj.kref.refcount); |