]> Pileus Git - ~andy/linux/commitdiff
bonding: fix double dev_add_pack
authorJay Vosburgh <fubar@us.ibm.com>
Thu, 1 Mar 2007 01:03:20 +0000 (17:03 -0800)
committerJeff Garzik <jeff@garzik.org>
Tue, 6 Mar 2007 11:08:11 +0000 (06:08 -0500)
Bonding can erroneously register the same packet_type to receive
ARPs (for use by ARP validation): once at device open time, and once via
sysfs.  Since sysfs can change the validate setting (and thus register
or unregister) at any time, a flag is needed to synchronize with device
open in order to avoid double registrations, and the simplest place is
within the packet_type structure itself.  Double unregister is not an
issue.

Bug reported by Ulrich Oelmann <ulrich.oelmann@web.de>.

Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/bonding/bond_main.c

index ea73ebff438712214251997fdf3138541fe236bf..68afcb5d7257b4fd90ec9cde9c8747e8cff52a8e 100644 (file)
@@ -3423,6 +3423,9 @@ void bond_register_arp(struct bonding *bond)
 {
        struct packet_type *pt = &bond->arp_mon_pt;
 
+       if (pt->type)
+               return;
+
        pt->type = htons(ETH_P_ARP);
        pt->dev = NULL; /*bond->dev;XXX*/
        pt->func = bond_arp_rcv;
@@ -3431,7 +3434,10 @@ void bond_register_arp(struct bonding *bond)
 
 void bond_unregister_arp(struct bonding *bond)
 {
-       dev_remove_pack(&bond->arp_mon_pt);
+       struct packet_type *pt = &bond->arp_mon_pt;
+
+       dev_remove_pack(pt);
+       pt->type = 0;
 }
 
 /*---------------------------- Hashing Policies -----------------------------*/