netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration
@ 2018-07-10  7:02 Ido Schimmel
  2018-07-10  7:02 ` [PATCH net-next 1/3] team: Publish team_port_get_rcu() Ido Schimmel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-07-10  7:02 UTC (permalink / raw)
  To: netdev; +Cc: davem, petrm, jiri, mlxsw, Ido Schimmel

Petr says:

When offloading mirror-to-gretap, mlxsw needs to preroute the path that
the encapsulated packet will take. That path may include a LAG device
above a front panel port. So far, mlxsw resolved the path to the first
up front panel slave of the LAG interface, but that only reflects
administrative state of the port. It neglects to consider whether the
port actually has a carrier, and what the LACP state is. This patch set
aims to address these problems.

Patch #1 publishes team_port_get_rcu().

Then in patch #2, a new function is introduced,
mlxsw_sp_port_dev_check(). That returns, for a given netdevice that is a
slave of a LAG device, whether that device is "txable", i.e. whether the
LAG master would send traffic through it. Since there's no good place to
put LAG-wide helpers, introduce a new header include/net/lag.h.

Finally in patch #3, fix the slave selection logic to take into
consideration whether a given slave has a carrier and whether it is
txable.

Petr Machata (3):
  team: Publish team_port_get_rcu()
  net: Add lag.h, net_lag_port_dev_txable()
  mlxsw: spectrum_span: Change LAG lower selection

 drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c |  5 ++++-
 drivers/net/team/team.c                             |  5 -----
 include/linux/if_team.h                             | 18 ++++++++++++++++++
 include/net/bonding.h                               | 13 +++++++++++++
 include/net/lag.h                                   | 17 +++++++++++++++++
 5 files changed, 52 insertions(+), 6 deletions(-)
 create mode 100644 include/net/lag.h

-- 
2.14.4

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

* [PATCH net-next 1/3] team: Publish team_port_get_rcu()
  2018-07-10  7:02 [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration Ido Schimmel
@ 2018-07-10  7:02 ` Ido Schimmel
  2018-07-10  7:02 ` [PATCH net-next 2/3] net: Add lag.h, net_lag_port_dev_txable() Ido Schimmel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-07-10  7:02 UTC (permalink / raw)
  To: netdev; +Cc: davem, petrm, jiri, mlxsw, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

A follow-up patch adds a new entry point, team_port_dev_txable(). Making
it an ordinary exported function would mean that any module that may
need the service in one of the supported configurations also
unconditionally needs to pull in the team module, whether or not the
user actually intends to create team interfaces.

To prevent that, team_port_dev_txable() is defined in if_team.h, and
therefore all dependencies of that function also need to be
publicly-visible.

Therefore move team_port_get_rcu() from team.c to if_team.h.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/team/team.c | 5 -----
 include/linux/if_team.h | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index b070959737ff..c46191183fb1 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -41,11 +41,6 @@
 
 #define team_port_exists(dev) (dev->priv_flags & IFF_TEAM_PORT)
 
-static struct team_port *team_port_get_rcu(const struct net_device *dev)
-{
-	return rcu_dereference(dev->rx_handler_data);
-}
-
 static struct team_port *team_port_get_rtnl(const struct net_device *dev)
 {
 	struct team_port *port = rtnl_dereference(dev->rx_handler_data);
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index d95cae09dea0..0d07c6655cce 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -74,6 +74,11 @@ struct team_port {
 	long mode_priv[0];
 };
 
+static inline struct team_port *team_port_get_rcu(const struct net_device *dev)
+{
+	return rcu_dereference(dev->rx_handler_data);
+}
+
 static inline bool team_port_enabled(struct team_port *port)
 {
 	return port->index != -1;
-- 
2.14.4

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

* [PATCH net-next 2/3] net: Add lag.h, net_lag_port_dev_txable()
  2018-07-10  7:02 [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration Ido Schimmel
  2018-07-10  7:02 ` [PATCH net-next 1/3] team: Publish team_port_get_rcu() Ido Schimmel
@ 2018-07-10  7:02 ` Ido Schimmel
  2018-07-10  7:02 ` [PATCH net-next 3/3] mlxsw: spectrum_span: Change LAG lower selection Ido Schimmel
  2018-07-12  6:10 ` [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-07-10  7:02 UTC (permalink / raw)
  To: netdev; +Cc: davem, petrm, jiri, mlxsw, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

LAG devices (team or bond) recognize for each one of their slave devices
whether LAG traffic is going to be sent through that device. Bond calls
such devices "active", team calls them "txable". When this state
changes, a NETDEV_CHANGELOWERSTATE notification is distributed, together
with a netdev_notifier_changelowerstate_info structure that for LAG
devices includes a tx_enabled flag that refers to the new state. The
notification thus makes it possible to react to the changes in txability
in drivers.

However there's no way to query txability from the outside on demand.
That is problematic namely for mlxsw, which when resolving ERSPAN packet
path, may encounter a LAG device, and needs to determine which of the
slaves it should choose.

To that end, introduce a new function, net_lag_port_dev_txable(), which
determines whether a given slave device is "active" or
"txable" (depending on the flavor of the LAG device). That function then
dispatches to per-LAG-flavor helpers, bond_is_active_slave_dev() resp.
team_port_dev_txable().

Because there currently is no good place where net_lag_port_dev_txable()
should be added, introduce a new header file, lag.h, which should from
now on hold any logic common to both team and bond. (But keep
netif_is_lag_master() together with the rest of netif_is_*_master()
functions).

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 include/linux/if_team.h | 13 +++++++++++++
 include/net/bonding.h   | 13 +++++++++++++
 include/net/lag.h       | 17 +++++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 include/net/lag.h

diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index 0d07c6655cce..ac42da56f7a2 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -89,6 +89,19 @@ static inline bool team_port_txable(struct team_port *port)
 	return port->linkup && team_port_enabled(port);
 }
 
+static inline bool team_port_dev_txable(const struct net_device *port_dev)
+{
+	struct team_port *port;
+	bool txable;
+
+	rcu_read_lock();
+	port = team_port_get_rcu(port_dev);
+	txable = port ? team_port_txable(port) : false;
+	rcu_read_unlock();
+
+	return txable;
+}
+
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static inline void team_netpoll_send_skb(struct team_port *port,
 					 struct sk_buff *skb)
diff --git a/include/net/bonding.h b/include/net/bonding.h
index 808f1d167349..a2d058170ea3 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -411,6 +411,19 @@ static inline bool bond_slave_can_tx(struct slave *slave)
 	       bond_is_active_slave(slave);
 }
 
+static inline bool bond_is_active_slave_dev(const struct net_device *slave_dev)
+{
+	struct slave *slave;
+	bool active;
+
+	rcu_read_lock();
+	slave = bond_slave_get_rcu(slave_dev);
+	active = bond_is_active_slave(slave);
+	rcu_read_unlock();
+
+	return active;
+}
+
 static inline void bond_hw_addr_copy(u8 *dst, const u8 *src, unsigned int len)
 {
 	if (len == ETH_ALEN) {
diff --git a/include/net/lag.h b/include/net/lag.h
new file mode 100644
index 000000000000..95b880e6fdde
--- /dev/null
+++ b/include/net/lag.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_IF_LAG_H
+#define _LINUX_IF_LAG_H
+
+#include <linux/netdevice.h>
+#include <linux/if_team.h>
+#include <net/bonding.h>
+
+static inline bool net_lag_port_dev_txable(const struct net_device *port_dev)
+{
+	if (netif_is_team_port(port_dev))
+		return team_port_dev_txable(port_dev);
+	else
+		return bond_is_active_slave_dev(port_dev);
+}
+
+#endif /* _LINUX_IF_LAG_H */
-- 
2.14.4

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

* [PATCH net-next 3/3] mlxsw: spectrum_span: Change LAG lower selection
  2018-07-10  7:02 [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration Ido Schimmel
  2018-07-10  7:02 ` [PATCH net-next 1/3] team: Publish team_port_get_rcu() Ido Schimmel
  2018-07-10  7:02 ` [PATCH net-next 2/3] net: Add lag.h, net_lag_port_dev_txable() Ido Schimmel
@ 2018-07-10  7:02 ` Ido Schimmel
  2018-07-12  6:10 ` [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-07-10  7:02 UTC (permalink / raw)
  To: netdev; +Cc: davem, petrm, jiri, mlxsw, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

When offloading mirror-to-gretap, mlxsw needs to preroute the path that
the encapsulated packet will take. That path may include a LAG device
above a front panel port. So far, mlxsw resolved the path to the first
up front panel slave of the LAG interface, but that only reflects
administrative state of the port. It neglects to consider whether the
port actually has a carrier, and what the LACP state is.

So instead of checking upness of the device, check carrier state and
txability.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
index 3d187d88cc7c..e42d640cddab 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
@@ -36,6 +36,7 @@
 #include <linux/list.h>
 #include <net/arp.h>
 #include <net/gre.h>
+#include <net/lag.h>
 #include <net/ndisc.h>
 #include <net/ip6_tunnel.h>
 
@@ -254,7 +255,9 @@ mlxsw_sp_span_entry_lag(struct net_device *lag_dev)
 	struct list_head *iter;
 
 	netdev_for_each_lower_dev(lag_dev, dev, iter)
-		if ((dev->flags & IFF_UP) && mlxsw_sp_port_dev_check(dev))
+		if (netif_carrier_ok(dev) &&
+		    net_lag_port_dev_txable(dev) &&
+		    mlxsw_sp_port_dev_check(dev))
 			return dev;
 
 	return NULL;
-- 
2.14.4

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

* Re: [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration
  2018-07-10  7:02 [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration Ido Schimmel
                   ` (2 preceding siblings ...)
  2018-07-10  7:02 ` [PATCH net-next 3/3] mlxsw: spectrum_span: Change LAG lower selection Ido Schimmel
@ 2018-07-12  6:10 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-07-12  6:10 UTC (permalink / raw)
  To: idosch; +Cc: netdev, petrm, jiri, mlxsw

From: Ido Schimmel <idosch@mellanox.com>
Date: Tue, 10 Jul 2018 10:02:56 +0300

> Petr says:
> 
> When offloading mirror-to-gretap, mlxsw needs to preroute the path that
> the encapsulated packet will take. That path may include a LAG device
> above a front panel port. So far, mlxsw resolved the path to the first
> up front panel slave of the LAG interface, but that only reflects
> administrative state of the port. It neglects to consider whether the
> port actually has a carrier, and what the LACP state is. This patch set
> aims to address these problems.
> 
> Patch #1 publishes team_port_get_rcu().
> 
> Then in patch #2, a new function is introduced,
> mlxsw_sp_port_dev_check(). That returns, for a given netdevice that is a
> slave of a LAG device, whether that device is "txable", i.e. whether the
> LAG master would send traffic through it. Since there's no good place to
> put LAG-wide helpers, introduce a new header include/net/lag.h.
> 
> Finally in patch #3, fix the slave selection logic to take into
> consideration whether a given slave has a carrier and whether it is
> txable.

Series applied, thank you.

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

end of thread, other threads:[~2018-07-12  6:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-10  7:02 [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration Ido Schimmel
2018-07-10  7:02 ` [PATCH net-next 1/3] team: Publish team_port_get_rcu() Ido Schimmel
2018-07-10  7:02 ` [PATCH net-next 2/3] net: Add lag.h, net_lag_port_dev_txable() Ido Schimmel
2018-07-10  7:02 ` [PATCH net-next 3/3] mlxsw: spectrum_span: Change LAG lower selection Ido Schimmel
2018-07-12  6:10 ` [PATCH net-next 0/3] mlxsw: ERSPAN: Take LACP state into consideration 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).