diff options
author | Jay Vosburgh <fubar@us.ibm.com> | 2006-09-23 00:54:53 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-09-25 20:08:09 -0400 |
commit | f5b2b966f032f22d3a289045a5afd4afa09f09c6 (patch) | |
tree | cb3c505d8f444438bed09353788f6c96150f68ad /drivers/net/bonding/bond_sysfs.c | |
parent | 70298705bb29fb7982b85089adf17cd37b94baa7 (diff) |
[PATCH] bonding: Validate probe replies in ARP monitor
Add logic to check ARP request / reply packets used for ARP
monitor link integrity checking.
The current method simply examines the slave device to see if it
has sent and received traffic; this can be fooled by extraneous traffic.
For example, if multiple hosts running bonding are behind a common
switch, the probe traffic from the multiple instances of bonding will
update the tx/rx times on each other's slave devices.
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 15b6a29bb4d4..ced9ed8f995a 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -51,6 +51,7 @@ extern struct bond_params bonding_defaults; | |||
51 | extern struct bond_parm_tbl bond_mode_tbl[]; | 51 | extern struct bond_parm_tbl bond_mode_tbl[]; |
52 | extern struct bond_parm_tbl bond_lacp_tbl[]; | 52 | extern struct bond_parm_tbl bond_lacp_tbl[]; |
53 | extern struct bond_parm_tbl xmit_hashtype_tbl[]; | 53 | extern struct bond_parm_tbl xmit_hashtype_tbl[]; |
54 | extern struct bond_parm_tbl arp_validate_tbl[]; | ||
54 | 55 | ||
55 | static int expected_refcount = -1; | 56 | static int expected_refcount = -1; |
56 | static struct class *netdev_class; | 57 | static struct class *netdev_class; |
@@ -503,6 +504,53 @@ out: | |||
503 | static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); | 504 | static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); |
504 | 505 | ||
505 | /* | 506 | /* |
507 | * Show and set arp_validate. | ||
508 | */ | ||
509 | static ssize_t bonding_show_arp_validate(struct class_device *cd, char *buf) | ||
510 | { | ||
511 | struct bonding *bond = to_bond(cd); | ||
512 | |||
513 | return sprintf(buf, "%s %d\n", | ||
514 | arp_validate_tbl[bond->params.arp_validate].modename, | ||
515 | bond->params.arp_validate) + 1; | ||
516 | } | ||
517 | |||
518 | static ssize_t bonding_store_arp_validate(struct class_device *cd, const char *buf, size_t count) | ||
519 | { | ||
520 | int new_value; | ||
521 | struct bonding *bond = to_bond(cd); | ||
522 | |||
523 | new_value = bond_parse_parm((char *)buf, arp_validate_tbl); | ||
524 | if (new_value < 0) { | ||
525 | printk(KERN_ERR DRV_NAME | ||
526 | ": %s: Ignoring invalid arp_validate value %s\n", | ||
527 | bond->dev->name, buf); | ||
528 | return -EINVAL; | ||
529 | } | ||
530 | if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { | ||
531 | printk(KERN_ERR DRV_NAME | ||
532 | ": %s: arp_validate only supported in active-backup mode.\n", | ||
533 | bond->dev->name); | ||
534 | return -EINVAL; | ||
535 | } | ||
536 | printk(KERN_INFO DRV_NAME ": %s: setting arp_validate to %s (%d).\n", | ||
537 | bond->dev->name, arp_validate_tbl[new_value].modename, | ||
538 | new_value); | ||
539 | |||
540 | if (!bond->params.arp_validate && new_value) { | ||
541 | bond_register_arp(bond); | ||
542 | } else if (bond->params.arp_validate && !new_value) { | ||
543 | bond_unregister_arp(bond); | ||
544 | } | ||
545 | |||
546 | bond->params.arp_validate = new_value; | ||
547 | |||
548 | return count; | ||
549 | } | ||
550 | |||
551 | static CLASS_DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate); | ||
552 | |||
553 | /* | ||
506 | * Show and set the arp timer interval. There are two tricky bits | 554 | * Show and set the arp timer interval. There are two tricky bits |
507 | * here. First, if ARP monitoring is activated, then we must disable | 555 | * here. First, if ARP monitoring is activated, then we must disable |
508 | * MII monitoring. Second, if the ARP timer isn't running, we must | 556 | * MII monitoring. Second, if the ARP timer isn't running, we must |
@@ -914,6 +962,11 @@ static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, si | |||
914 | "ARP monitoring. Disabling ARP monitoring...\n", | 962 | "ARP monitoring. Disabling ARP monitoring...\n", |
915 | bond->dev->name); | 963 | bond->dev->name); |
916 | bond->params.arp_interval = 0; | 964 | bond->params.arp_interval = 0; |
965 | if (bond->params.arp_validate) { | ||
966 | bond_unregister_arp(bond); | ||
967 | bond->params.arp_validate = | ||
968 | BOND_ARP_VALIDATE_NONE; | ||
969 | } | ||
917 | /* Kill ARP timer, else it brings bond's link down */ | 970 | /* Kill ARP timer, else it brings bond's link down */ |
918 | if (bond->mii_timer.function) { | 971 | if (bond->mii_timer.function) { |
919 | printk(KERN_INFO DRV_NAME | 972 | printk(KERN_INFO DRV_NAME |
@@ -1273,6 +1326,7 @@ static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, N | |||
1273 | static struct attribute *per_bond_attrs[] = { | 1326 | static struct attribute *per_bond_attrs[] = { |
1274 | &class_device_attr_slaves.attr, | 1327 | &class_device_attr_slaves.attr, |
1275 | &class_device_attr_mode.attr, | 1328 | &class_device_attr_mode.attr, |
1329 | &class_device_attr_arp_validate.attr, | ||
1276 | &class_device_attr_arp_interval.attr, | 1330 | &class_device_attr_arp_interval.attr, |
1277 | &class_device_attr_arp_ip_target.attr, | 1331 | &class_device_attr_arp_ip_target.attr, |
1278 | &class_device_attr_downdelay.attr, | 1332 | &class_device_attr_downdelay.attr, |