netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] Fix support for macvlan devices on top bonding
@ 2014-06-04 20:23 Vlad Yasevich
  2014-06-04 20:23 ` [PATCH net-next 1/3] bonding: Turn on IFF_UNICAST_FLT on bond devices Vlad Yasevich
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Vlad Yasevich @ 2014-06-04 20:23 UTC (permalink / raw)
  To: netdev; +Cc: j.vosburgh, vfalico, andy, kaber, Vlad Yasevich

Currently, macvlan devices do not work well over bond interfaces.
Everything works well, untill a failover is triggered in the bond
device and then macvlan becomes unreachble untill arp entries
are flushed.   This series adds needed functionality to
handle correct notifications and update switches with mac addresses
assigned to macvlans.

The first patch simply addes IFF_UNICAST_FLT flag to bonds since they
already correctly manage the unicast filter list of the slaves, so
we might as well prevent the bond from needlessly going into promiscuous
mode.

The second patch adds notifier handler to macvlan to trigger correct
ARP notifications.

The third patch adds handling for TLB and RLB modes that use special
ETH_P_LOOPBACK type packets to teach switch about mac addresses.
It also allow ARPs for the macvlan mac addresses to be handled by
RLB mode.

Vlad Yasevich (3):
  bonding: Turn on IFF_UNICAST_FLT on bond devices
  macvlan: Support bonding events
  bonding: Support macvlans on top of tlb/rlb mode bonds

 drivers/net/bonding/bond_alb.c  | 21 ++++++++++++++++++---
 drivers/net/bonding/bond_main.c |  8 ++++----
 drivers/net/bonding/bonding.h   | 24 ++++++++++++++++++++++++
 drivers/net/macvlan.c           |  7 +++++++
 4 files changed, 53 insertions(+), 7 deletions(-)

-- 
1.9.0

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

* [PATCH net-next 1/3] bonding: Turn on IFF_UNICAST_FLT on bond devices
  2014-06-04 20:23 [PATCH net-next 0/3] Fix support for macvlan devices on top bonding Vlad Yasevich
@ 2014-06-04 20:23 ` Vlad Yasevich
  2014-06-04 20:23 ` [PATCH net-next 2/3] macvlan: Support bonding events Vlad Yasevich
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Vlad Yasevich @ 2014-06-04 20:23 UTC (permalink / raw)
  To: netdev; +Cc: j.vosburgh, vfalico, andy, kaber, Vlad Yasevich

Bonding devices manage the unicast filters of the underlying
interfaces, but do not turn on IFF_UNICAST_FLT flag.  Thus
anytime a unicast address is added to the bond, the bond is
places in promiscuous mode.

Turn on IFF_UNICAST_FLT on the bond device so that the bond does
not go into promiscuous mode needlesly.  If an underlying device
does not support unicast filtering, that device will automaticall
enter promiscuous mode already.

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
 drivers/net/bonding/bond_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 59a12c61..a89bf18 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3945,7 +3945,7 @@ void bond_setup(struct net_device *bond_dev)
 	/* Initialize the device options */
 	bond_dev->tx_queue_len = 0;
 	bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
-	bond_dev->priv_flags |= IFF_BONDING;
+	bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT;
 	bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
 
 	/* At first, we block adding VLANs. That's the only way to
-- 
1.9.0

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

* [PATCH net-next 2/3] macvlan: Support bonding events
  2014-06-04 20:23 [PATCH net-next 0/3] Fix support for macvlan devices on top bonding Vlad Yasevich
  2014-06-04 20:23 ` [PATCH net-next 1/3] bonding: Turn on IFF_UNICAST_FLT on bond devices Vlad Yasevich
@ 2014-06-04 20:23 ` Vlad Yasevich
  2014-06-04 20:23 ` [PATCH net-next 3/3] bonding: Support macvlans on top of tlb/rlb mode bonds Vlad Yasevich
  2014-06-04 22:14 ` [PATCH net-next 0/3] Fix support for macvlan devices on top bonding David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Vlad Yasevich @ 2014-06-04 20:23 UTC (permalink / raw)
  To: netdev; +Cc: j.vosburgh, vfalico, andy, kaber, Vlad Yasevich

Bonding and team drivers generate specific events during failover
that trigger switch updates.  When a macvlan device is configured
on top of bonding, we want switches to learn about the macvlan
devices as well.   This patch adds a handler to macvlan driver to
propagate these events to all macvlan devices.  We let the generic
inetdev event handler do the work.

This allows macvlan to operated correctly over active-backup
mode bond.

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
 drivers/net/macvlan.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index eee9106..453d55a 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1209,6 +1209,13 @@ static int macvlan_device_event(struct notifier_block *unused,
 	case NETDEV_PRE_TYPE_CHANGE:
 		/* Forbid underlaying device to change its type. */
 		return NOTIFY_BAD;
+
+	case NETDEV_NOTIFY_PEERS:
+	case NETDEV_BONDING_FAILOVER:
+	case NETDEV_RESEND_IGMP:
+		/* Propagate to all vlans */
+		list_for_each_entry(vlan, &port->vlans, list)
+			call_netdevice_notifiers(event, vlan->dev);
 	}
 	return NOTIFY_DONE;
 }
-- 
1.9.0

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

* [PATCH net-next 3/3] bonding: Support macvlans on top of tlb/rlb mode bonds
  2014-06-04 20:23 [PATCH net-next 0/3] Fix support for macvlan devices on top bonding Vlad Yasevich
  2014-06-04 20:23 ` [PATCH net-next 1/3] bonding: Turn on IFF_UNICAST_FLT on bond devices Vlad Yasevich
  2014-06-04 20:23 ` [PATCH net-next 2/3] macvlan: Support bonding events Vlad Yasevich
@ 2014-06-04 20:23 ` Vlad Yasevich
  2014-06-04 22:14 ` [PATCH net-next 0/3] Fix support for macvlan devices on top bonding David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Vlad Yasevich @ 2014-06-04 20:23 UTC (permalink / raw)
  To: netdev; +Cc: j.vosburgh, vfalico, andy, kaber, Vlad Yasevich

To make TLB mode work, the patch allows learning packets
to be sent using mac addresses assigned to macvlan devices,
also taking into an account vlans that may be between the
bond and macvlan device.

To make RLB work, all we have to do is accept ARP packets
for addresses added to the bond dev->uc list.  Since RLB
mode will take care to update the peers directly with
correct mac addresses, learning packets for these addresses
do not have be send to switch.

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
 drivers/net/bonding/bond_alb.c  | 21 ++++++++++++++++++---
 drivers/net/bonding/bond_main.c |  6 +++---
 drivers/net/bonding/bonding.h   | 24 ++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 7bbbf1c..8da636f 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -755,7 +755,7 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
 	/* Don't modify or load balance ARPs that do not originate locally
 	 * (e.g.,arrive via a bridge).
 	 */
-	if (!bond_slave_has_mac_rcu(bond, arp->mac_src))
+	if (!bond_slave_has_mac_rx(bond, arp->mac_src))
 		return NULL;
 
 	if (arp->op_code == htons(ARPOP_REPLY)) {
@@ -1039,11 +1039,14 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
 	struct bonding *bond = bond_get_bond_by_slave(slave);
 	struct net_device *upper;
 	struct list_head *iter;
+	struct bond_vlan_tag tags[BOND_MAX_VLAN_ENCAP];
 
 	/* send untagged */
 	alb_send_lp_vid(slave, mac_addr, 0, 0);
 
-	/* loop through vlans and send one packet for each */
+	/* loop through all devices and see if we need to send a packet
+	 * for that device.
+	 */
 	rcu_read_lock();
 	netdev_for_each_all_upper_dev_rcu(bond->dev, upper, iter) {
 		if (is_vlan_dev(upper) && vlan_get_encap_level(upper) == 0) {
@@ -1059,6 +1062,16 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
 						vlan_dev_vlan_id(upper));
 			}
 		}
+
+		/* If this is a macvlan device, then only send updates
+		 * when strict_match is turned off.
+		 */
+		if (netif_is_macvlan(upper) && !strict_match) {
+			memset(tags, 0, sizeof(tags));
+			bond_verify_device_path(bond->dev, upper, tags);
+			alb_send_lp_vid(slave, upper->dev_addr,
+					tags[0].vlan_proto, tags[0].vlan_id);
+		}
 	}
 	rcu_read_unlock();
 }
@@ -1560,8 +1573,10 @@ void bond_alb_monitor(struct work_struct *work)
 			/* If updating current_active, use all currently
 			 * user mac addreses (!strict_match).  Otherwise, only
 			 * use mac of the slave device.
+			 * In RLB mode, we always use strict matches.
 			 */
-			strict_match = (slave != bond->curr_active_slave);
+			strict_match = (slave != bond->curr_active_slave ||
+					bond_info->rlb_enabled);
 			alb_send_learning_packets(slave, slave->dev->dev_addr,
 						  strict_match);
 		}
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a89bf18..04f35f9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2206,9 +2206,9 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op,
  * When the path is validated, collect any vlan information in the
  * path.
  */
-static bool bond_verify_device_path(struct net_device *start_dev,
-				    struct net_device *end_dev,
-				    struct bond_vlan_tag *tags)
+bool bond_verify_device_path(struct net_device *start_dev,
+			     struct net_device *end_dev,
+			     struct bond_vlan_tag *tags)
 {
 	struct net_device *upper;
 	struct list_head  *iter;
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index ea64aa2..0b4d9cd 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -516,6 +516,9 @@ void bond_netlink_fini(void);
 struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
 struct net_device *bond_option_active_slave_get(struct bonding *bond);
 const char *bond_slave_link_status(s8 link);
+bool bond_verify_device_path(struct net_device *start_dev,
+			     struct net_device *end_dev,
+			     struct bond_vlan_tag *tags);
 
 #ifdef CONFIG_PROC_FS
 void bond_create_proc_entry(struct bonding *bond);
@@ -567,6 +570,27 @@ static inline struct slave *bond_slave_has_mac_rcu(struct bonding *bond,
 	return NULL;
 }
 
+/* Caller must hold rcu_read_lock() for read */
+static inline bool bond_slave_has_mac_rx(struct bonding *bond, const u8 *mac)
+{
+	struct list_head *iter;
+	struct slave *tmp;
+	struct netdev_hw_addr *ha;
+
+	bond_for_each_slave_rcu(bond, tmp, iter)
+		if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr))
+			return true;
+
+	if (netdev_uc_empty(bond->dev))
+		return false;
+
+	netdev_for_each_uc_addr(ha, bond->dev)
+		if (ether_addr_equal_64bits(mac, ha->addr))
+			return true;
+
+	return false;
+}
+
 /* Check if the ip is present in arp ip list, or first free slot if ip == 0
  * Returns -1 if not found, index if found
  */
-- 
1.9.0

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

* Re: [PATCH net-next 0/3] Fix support for macvlan devices on top bonding
  2014-06-04 20:23 [PATCH net-next 0/3] Fix support for macvlan devices on top bonding Vlad Yasevich
                   ` (2 preceding siblings ...)
  2014-06-04 20:23 ` [PATCH net-next 3/3] bonding: Support macvlans on top of tlb/rlb mode bonds Vlad Yasevich
@ 2014-06-04 22:14 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2014-06-04 22:14 UTC (permalink / raw)
  To: vyasevic; +Cc: netdev, j.vosburgh, vfalico, andy, kaber

From: Vlad Yasevich <vyasevic@redhat.com>
Date: Wed,  4 Jun 2014 16:23:35 -0400

> Currently, macvlan devices do not work well over bond interfaces.
> Everything works well, untill a failover is triggered in the bond
> device and then macvlan becomes unreachble untill arp entries
> are flushed.   This series adds needed functionality to
> handle correct notifications and update switches with mac addresses
> assigned to macvlans.
> 
> The first patch simply addes IFF_UNICAST_FLT flag to bonds since they
> already correctly manage the unicast filter list of the slaves, so
> we might as well prevent the bond from needlessly going into promiscuous
> mode.
> 
> The second patch adds notifier handler to macvlan to trigger correct
> ARP notifications.
> 
> The third patch adds handling for TLB and RLB modes that use special
> ETH_P_LOOPBACK type packets to teach switch about mac addresses.
> It also allow ARPs for the macvlan mac addresses to be handled by
> RLB mode.

Series applied, thanks Vlad.

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

end of thread, other threads:[~2014-06-04 22:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-04 20:23 [PATCH net-next 0/3] Fix support for macvlan devices on top bonding Vlad Yasevich
2014-06-04 20:23 ` [PATCH net-next 1/3] bonding: Turn on IFF_UNICAST_FLT on bond devices Vlad Yasevich
2014-06-04 20:23 ` [PATCH net-next 2/3] macvlan: Support bonding events Vlad Yasevich
2014-06-04 20:23 ` [PATCH net-next 3/3] bonding: Support macvlans on top of tlb/rlb mode bonds Vlad Yasevich
2014-06-04 22:14 ` [PATCH net-next 0/3] Fix support for macvlan devices on top bonding David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).