All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] mlxsw: Small routing improvements
@ 2019-04-21  7:18 Ido Schimmel
  2019-04-21  7:18 ` [PATCH net-next 1/2] mlxsw: spectrum: Use a stable ECMP/LAG seed Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ido Schimmel @ 2019-04-21  7:18 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jiri Pirko, mlxsw, dsahern, Ido Schimmel

Patch #1 switches the driver to use a unique and stable ECMP/LAG seed.
This allows for consistent behavior across reboots and avoids hash
polarization at the same time.

Patch #2 relaxes the FIB rule validation in the driver to allow the
installation of rules that direct locally generated traffic (iif=lo).
This does not result in a discrepancy between both data paths because
packets received by the device would never match such rules.

Ido Schimmel (2):
  mlxsw: spectrum: Use a stable ECMP/LAG seed
  mlxsw: spectrum_router: Relax FIB rule validation

 drivers/net/ethernet/mellanox/mlxsw/spectrum.c        | 4 ++--
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.20.1


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

* [PATCH net-next 1/2] mlxsw: spectrum: Use a stable ECMP/LAG seed
  2019-04-21  7:18 [PATCH net-next 0/2] mlxsw: Small routing improvements Ido Schimmel
@ 2019-04-21  7:18 ` Ido Schimmel
  2019-04-21  7:18 ` [PATCH net-next 2/2] mlxsw: spectrum_router: Relax FIB rule validation Ido Schimmel
  2019-04-21 17:32 ` [PATCH net-next 0/2] mlxsw: Small routing improvements David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2019-04-21  7:18 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jiri Pirko, mlxsw, dsahern, Ido Schimmel

In order to get a consistent behavior of traffic flows across reboots /
module unload, we need to use the same ECMP/LAG seed.

Calculate the seed by hashing the base MAC of the device. This results
in a seed that is both unique (to avoid polarization) and consistent.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c        | 4 ++--
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index fc325f1213fb..a1c2b117a2b3 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -21,7 +21,7 @@
 #include <linux/dcbnl.h>
 #include <linux/inetdevice.h>
 #include <linux/netlink.h>
-#include <linux/random.h>
+#include <linux/jhash.h>
 #include <net/switchdev.h>
 #include <net/pkt_cls.h>
 #include <net/tc_act/tc_mirred.h>
@@ -4227,7 +4227,7 @@ static int mlxsw_sp_lag_init(struct mlxsw_sp *mlxsw_sp)
 	u32 seed;
 	int err;
 
-	get_random_bytes(&seed, sizeof(seed));
+	seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), 0);
 	mlxsw_reg_slcr_pack(slcr_pl, MLXSW_REG_SLCR_LAG_HASH_SMAC |
 				     MLXSW_REG_SLCR_LAG_HASH_DMAC |
 				     MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 64498c9f55ab..6c73400b1508 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -13,9 +13,9 @@
 #include <linux/socket.h>
 #include <linux/route.h>
 #include <linux/gcd.h>
-#include <linux/random.h>
 #include <linux/if_macvlan.h>
 #include <linux/refcount.h>
+#include <linux/jhash.h>
 #include <net/netevent.h>
 #include <net/neighbour.h>
 #include <net/arp.h>
@@ -7831,7 +7831,7 @@ static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp)
 	char recr2_pl[MLXSW_REG_RECR2_LEN];
 	u32 seed;
 
-	get_random_bytes(&seed, sizeof(seed));
+	seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), 0);
 	mlxsw_reg_recr2_pack(recr2_pl, seed);
 	mlxsw_sp_mp4_hash_init(recr2_pl);
 	mlxsw_sp_mp6_hash_init(recr2_pl);
-- 
2.20.1


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

* [PATCH net-next 2/2] mlxsw: spectrum_router: Relax FIB rule validation
  2019-04-21  7:18 [PATCH net-next 0/2] mlxsw: Small routing improvements Ido Schimmel
  2019-04-21  7:18 ` [PATCH net-next 1/2] mlxsw: spectrum: Use a stable ECMP/LAG seed Ido Schimmel
@ 2019-04-21  7:18 ` Ido Schimmel
  2019-04-21 17:32 ` [PATCH net-next 0/2] mlxsw: Small routing improvements David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2019-04-21  7:18 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jiri Pirko, mlxsw, dsahern, Ido Schimmel

Currently, mlxsw does not support policy-based routing (PBR) and
therefore forbids the installation of non-default FIB rules except for
the l3mdev rule which is used for VRFs.

Relax the check to allow the installation of FIB rules that would never
match packets received by the device. Specifically, if the iif is that
of the loopback netdev. This is useful for users that need to redirect
locally generated packets based on FIB rules.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Tested-by: Alexander Petrovskiy <alexpe@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 6c73400b1508..8f31c2ddc538 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -6050,6 +6050,10 @@ static int mlxsw_sp_router_fib_rule_event(unsigned long event,
 	fr_info = container_of(info, struct fib_rule_notifier_info, info);
 	rule = fr_info->rule;
 
+	/* Rule only affects locally generated traffic */
+	if (rule->iifindex == info->net->loopback_dev->ifindex)
+		return 0;
+
 	switch (info->family) {
 	case AF_INET:
 		if (!fib4_rule_default(rule) && !rule->l3mdev)
-- 
2.20.1


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

* Re: [PATCH net-next 0/2] mlxsw: Small routing improvements
  2019-04-21  7:18 [PATCH net-next 0/2] mlxsw: Small routing improvements Ido Schimmel
  2019-04-21  7:18 ` [PATCH net-next 1/2] mlxsw: spectrum: Use a stable ECMP/LAG seed Ido Schimmel
  2019-04-21  7:18 ` [PATCH net-next 2/2] mlxsw: spectrum_router: Relax FIB rule validation Ido Schimmel
@ 2019-04-21 17:32 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-04-21 17:32 UTC (permalink / raw)
  To: idosch; +Cc: netdev, jiri, mlxsw, dsahern

From: Ido Schimmel <idosch@mellanox.com>
Date: Sun, 21 Apr 2019 07:18:33 +0000

> Patch #1 switches the driver to use a unique and stable ECMP/LAG seed.
> This allows for consistent behavior across reboots and avoids hash
> polarization at the same time.
> 
> Patch #2 relaxes the FIB rule validation in the driver to allow the
> installation of rules that direct locally generated traffic (iif=lo).
> This does not result in a discrepancy between both data paths because
> packets received by the device would never match such rules.

Series applied, thanks.

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

end of thread, other threads:[~2019-04-21 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-21  7:18 [PATCH net-next 0/2] mlxsw: Small routing improvements Ido Schimmel
2019-04-21  7:18 ` [PATCH net-next 1/2] mlxsw: spectrum: Use a stable ECMP/LAG seed Ido Schimmel
2019-04-21  7:18 ` [PATCH net-next 2/2] mlxsw: spectrum_router: Relax FIB rule validation Ido Schimmel
2019-04-21 17:32 ` [PATCH net-next 0/2] mlxsw: Small routing improvements 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.