邢庆杰
2018-Jan-06 09:25 UTC
[Bridge] [PATCH 3.2 01/06] "bridge should send gratuitous ARP to notify peer while a bond, which is a port of this bridge, changes."
We create bond0 and add eth0ð1 as slaves. Eth0 is active. Then we add bond0 into br0 as a bridge port. Br0 has ip address. When eth0 is down, after bond0's failover eth1 become active. At this moment, we need br0 send a gratuitous ARP to notify peer to update ARP table. Signed-off-by: Xing.Qingjie <xqjcool at gmail.com> --- net/bridge/br_notify.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c index a76b621..90cf123 100644 --- a/net/bridge/br_notify.c +++ b/net/bridge/br_notify.c @@ -34,6 +34,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v struct net_device *dev = ptr; struct net_bridge_port *p; struct net_bridge *br; + struct in_device *in_dev; bool changed_addr; int err; @@ -102,6 +103,17 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v case NETDEV_PRE_TYPE_CHANGE: /* Forbid underlaying device to change its type. */ return NOTIFY_BAD; + + case NETDEV_NOTIFY_PEERS: + /* Send gratuitous arp while bond,a port of bridge, changes */ + if (dev->priv_flags & IFF_BONDING && dev->flags & IFF_MASTER) { + in_dev = __in_dev_get_rtnl(br->dev); + + ASSERT_RTNL(); + if (in_dev) + inetdev_send_gratuitous_arp(br->dev, in_dev); + } + break; } /* Events that may cause spanning tree to refresh */ -- 1.7.1 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linuxfoundation.org/pipermail/bridge/attachments/20180106/537e67bb/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-bridge-should-send-gratuitous-ARP-to-notify-peer-whi.patch Type: application/octet-stream Size: 1677 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/bridge/attachments/20180106/537e67bb/attachment.obj>
Stephen Hemminger
2018-Jan-06 14:33 UTC
[Bridge] [PATCH 3.2 01/06] "bridge should send gratuitous ARP to notify peer while a bond, which is a port of this bridge, changes."
On Sat, 6 Jan 2018 17:25:20 +0800 ??? <xqjcool at gmail.com> wrote:> We create bond0 and add eth0ð1 as slaves. Eth0 is active. Then we add > bond0 > into br0 as a bridge port. Br0 has ip address. When eth0 is down, after > bond0's > failover eth1 become active. At this moment, we need br0 send a gratuitous > ARP > to notify peer to update ARP table. > > Signed-off-by: Xing.Qingjie <xqjcool at gmail.com> > --- > net/bridge/br_notify.c | 12 ++++++++++++ > 1 files changed, 12 insertions(+), 0 deletions(-) > diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c > index a76b621..90cf123 100644 > --- a/net/bridge/br_notify.c > +++ b/net/bridge/br_notify.c > @@ -34,6 +34,7 @@ static int br_device_event(struct notifier_block *unused, > unsigned long event, v > struct net_device *dev = ptr; > struct net_bridge_port *p; > struct net_bridge *br; > + struct in_device *in_dev; > bool changed_addr; > int err; > @@ -102,6 +103,17 @@ static int br_device_event(struct notifier_block > *unused, unsigned long event, v > case NETDEV_PRE_TYPE_CHANGE: > /* Forbid underlaying device to change its type. */ > return NOTIFY_BAD; > + > + case NETDEV_NOTIFY_PEERS: > + /* Send gratuitous arp while bond,a port of bridge, changes > */ > + if (dev->priv_flags & IFF_BONDING && dev->flags & > IFF_MASTER) { > + in_dev = __in_dev_get_rtnl(br->dev); > + > + ASSERT_RTNL(); > + if (in_dev) > + inetdev_send_gratuitous_arp(br->dev, > in_dev); > + } > + break; > } > /* Events that may cause spanning tree to refresh */ > -- > 1.7.1Thanks for your patch. There is no reason a bridge has to have an IP address. This should be done in bonding device, doing it here is error prone. Plus there are many more layered devices than bonding. The patch also has many formatting issues. Your mail client mangles patches. Conditional expressions with & and && should have parenthesis.