All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] bonding: emit event when bonding changes MAC
@ 2012-03-28  5:18 Weiping Pan
  2012-03-29 17:19 ` Jay Vosburgh
  0 siblings, 1 reply; 3+ messages in thread
From: Weiping Pan @ 2012-03-28  5:18 UTC (permalink / raw)
  To: netdev; +Cc: fubar, andy, lwang, linux-kernel, Weiping Pan

When a bonding device is configured with fail_over_mac=active,
we expect to see the MAC address of the new active slave as the source MAC
address after failover. But we see that the source MAC address is the MAC
address of previous active slave.

Emit NETDEV_CHANGEADDR event when bonding changes its MAC address, in order
to let arp_netdev_event flush neighbour cache and route cache.

How to reproduce this bug ?

                       -----------hostB----------------
hostA ----- switch ---|-- eth0--bond0(192.168.100.2/24)|
(192.168.100.1/24  \--|-- eth1-/                       |
                       --------------------------------

1 on hostB,
modprobe bonding mode=1 miimon=500 fail_over_mac=active downdelay=1000
num_grat_arp=1
ifconfig bond0 192.168.100.2/24 up
ifenslave bond0 eth0
ifenslave bond0 eth1

then eth0 is the active slave, and MAC of bond0 is MAC of eth0.

2 on hostA, ping 192.168.100.2

3 on hostB,
tcpdump -i bond0 -p icmp -XXX
you will see bond0 uses MAC of eth0 as source MAC in icmp reply.

4 on hostB,
ifconfig eth0 down
tcpdump -i bond0 -p icmp -XXX (just keep it running in step 3)
you will see first bond0 uses MAC of eth1 as source MAC in icmp
reply, then it will use MAC of eth0 as source MAC.

Signed-off-by: Weiping Pan <wpan@redhat.com>
---
 drivers/net/bonding/bond_main.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b920d82..a20b585 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -892,9 +892,15 @@ static void bond_do_fail_over_mac(struct bonding *bond,
 
 	switch (bond->params.fail_over_mac) {
 	case BOND_FOM_ACTIVE:
-		if (new_active)
+		if (new_active) {
 			memcpy(bond->dev->dev_addr,  new_active->dev->dev_addr,
 			       new_active->dev->addr_len);
+			write_unlock_bh(&bond->curr_slave_lock);
+			read_unlock(&bond->lock);
+			call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev);
+			read_lock(&bond->lock);
+			write_lock_bh(&bond->curr_slave_lock);
+		}
 		break;
 	case BOND_FOM_FOLLOW:
 		/*
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bonding: emit event when bonding changes MAC
  2012-03-28  5:18 [PATCH net] bonding: emit event when bonding changes MAC Weiping Pan
@ 2012-03-29 17:19 ` Jay Vosburgh
  2012-03-29 22:12   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Jay Vosburgh @ 2012-03-29 17:19 UTC (permalink / raw)
  To: Weiping Pan; +Cc: netdev, andy, lwang, linux-kernel

Weiping Pan <wpan@redhat.com> wrote:

>When a bonding device is configured with fail_over_mac=active,
>we expect to see the MAC address of the new active slave as the source MAC
>address after failover. But we see that the source MAC address is the MAC
>address of previous active slave.
>
>Emit NETDEV_CHANGEADDR event when bonding changes its MAC address, in order
>to let arp_netdev_event flush neighbour cache and route cache.
>
>How to reproduce this bug ?
>
>                       -----------hostB----------------
>hostA ----- switch ---|-- eth0--bond0(192.168.100.2/24)|
>(192.168.100.1/24  \--|-- eth1-/                       |
>                       --------------------------------
>
>1 on hostB,
>modprobe bonding mode=1 miimon=500 fail_over_mac=active downdelay=1000
>num_grat_arp=1
>ifconfig bond0 192.168.100.2/24 up
>ifenslave bond0 eth0
>ifenslave bond0 eth1
>
>then eth0 is the active slave, and MAC of bond0 is MAC of eth0.
>
>2 on hostA, ping 192.168.100.2
>
>3 on hostB,
>tcpdump -i bond0 -p icmp -XXX
>you will see bond0 uses MAC of eth0 as source MAC in icmp reply.
>
>4 on hostB,
>ifconfig eth0 down
>tcpdump -i bond0 -p icmp -XXX (just keep it running in step 3)
>you will see first bond0 uses MAC of eth1 as source MAC in icmp
>reply, then it will use MAC of eth0 as source MAC.
>
>Signed-off-by: Weiping Pan <wpan@redhat.com>

Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>


>---
> drivers/net/bonding/bond_main.c |    8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index b920d82..a20b585 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -892,9 +892,15 @@ static void bond_do_fail_over_mac(struct bonding *bond,
>
> 	switch (bond->params.fail_over_mac) {
> 	case BOND_FOM_ACTIVE:
>-		if (new_active)
>+		if (new_active) {
> 			memcpy(bond->dev->dev_addr,  new_active->dev->dev_addr,
> 			       new_active->dev->addr_len);
>+			write_unlock_bh(&bond->curr_slave_lock);
>+			read_unlock(&bond->lock);
>+			call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev);
>+			read_lock(&bond->lock);
>+			write_lock_bh(&bond->curr_slave_lock);
>+		}
> 		break;
> 	case BOND_FOM_FOLLOW:
> 		/*
>-- 
>1.7.4
>
>--
>To unsubscribe from this list: send the line "unsubscribe netdev" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bonding: emit event when bonding changes MAC
  2012-03-29 17:19 ` Jay Vosburgh
@ 2012-03-29 22:12   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2012-03-29 22:12 UTC (permalink / raw)
  To: fubar; +Cc: wpan, netdev, andy, lwang, linux-kernel

From: Jay Vosburgh <fubar@us.ibm.com>
Date: Thu, 29 Mar 2012 10:19:44 -0700

> Weiping Pan <wpan@redhat.com> wrote:
> 
>>When a bonding device is configured with fail_over_mac=active,
>>we expect to see the MAC address of the new active slave as the source MAC
>>address after failover. But we see that the source MAC address is the MAC
>>address of previous active slave.
>>
>>Emit NETDEV_CHANGEADDR event when bonding changes its MAC address, in order
>>to let arp_netdev_event flush neighbour cache and route cache.
>>
>>How to reproduce this bug ?
>>
>>                       -----------hostB----------------
>>hostA ----- switch ---|-- eth0--bond0(192.168.100.2/24)|
>>(192.168.100.1/24  \--|-- eth1-/                       |
>>                       --------------------------------
>>
>>1 on hostB,
>>modprobe bonding mode=1 miimon=500 fail_over_mac=active downdelay=1000
>>num_grat_arp=1
>>ifconfig bond0 192.168.100.2/24 up
>>ifenslave bond0 eth0
>>ifenslave bond0 eth1
>>
>>then eth0 is the active slave, and MAC of bond0 is MAC of eth0.
>>
>>2 on hostA, ping 192.168.100.2
>>
>>3 on hostB,
>>tcpdump -i bond0 -p icmp -XXX
>>you will see bond0 uses MAC of eth0 as source MAC in icmp reply.
>>
>>4 on hostB,
>>ifconfig eth0 down
>>tcpdump -i bond0 -p icmp -XXX (just keep it running in step 3)
>>you will see first bond0 uses MAC of eth1 as source MAC in icmp
>>reply, then it will use MAC of eth0 as source MAC.
>>
>>Signed-off-by: Weiping Pan <wpan@redhat.com>
> 
> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>

Applied, thanks everyone.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-29 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-28  5:18 [PATCH net] bonding: emit event when bonding changes MAC Weiping Pan
2012-03-29 17:19 ` Jay Vosburgh
2012-03-29 22:12   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.