Commit 57837885 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_router: Associate RIFs with correct VR

When a router interface (RIF) is created due to a netdev being enslaved
to a VRF master, then it should be associated with the appropriate
virtual router (VR) and not the default one.

If netdev is a VRF slave, lookup the VR based on the VRF's table ID.
Otherwise default to the MAIN table.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fdeea7be
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <net/arp.h> #include <net/arp.h>
#include <net/ip_fib.h> #include <net/ip_fib.h>
#include <net/fib_rules.h> #include <net/fib_rules.h>
#include <net/l3mdev.h>
#include "spectrum.h" #include "spectrum.h"
#include "core.h" #include "core.h"
...@@ -2762,6 +2763,7 @@ mlxsw_sp_vport_rif_sp_create(struct mlxsw_sp_port *mlxsw_sp_vport, ...@@ -2762,6 +2763,7 @@ mlxsw_sp_vport_rif_sp_create(struct mlxsw_sp_port *mlxsw_sp_vport,
struct net_device *l3_dev) struct net_device *l3_dev)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_vport->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = mlxsw_sp_vport->mlxsw_sp;
u32 tb_id = l3mdev_fib_table(l3_dev);
struct mlxsw_sp_vr *vr; struct mlxsw_sp_vr *vr;
struct mlxsw_sp_fid *f; struct mlxsw_sp_fid *f;
struct mlxsw_sp_rif *r; struct mlxsw_sp_rif *r;
...@@ -2772,7 +2774,7 @@ mlxsw_sp_vport_rif_sp_create(struct mlxsw_sp_port *mlxsw_sp_vport, ...@@ -2772,7 +2774,7 @@ mlxsw_sp_vport_rif_sp_create(struct mlxsw_sp_port *mlxsw_sp_vport,
if (rif == MLXSW_SP_INVALID_RIF) if (rif == MLXSW_SP_INVALID_RIF)
return ERR_PTR(-ERANGE); return ERR_PTR(-ERANGE);
vr = mlxsw_sp_vr_get(mlxsw_sp, RT_TABLE_MAIN); vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN);
if (IS_ERR(vr)) if (IS_ERR(vr))
return ERR_CAST(vr); return ERR_CAST(vr);
...@@ -3010,6 +3012,7 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp, ...@@ -3010,6 +3012,7 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp,
struct net_device *l3_dev, struct net_device *l3_dev,
struct mlxsw_sp_fid *f) struct mlxsw_sp_fid *f)
{ {
u32 tb_id = l3mdev_fib_table(l3_dev);
struct mlxsw_sp_vr *vr; struct mlxsw_sp_vr *vr;
struct mlxsw_sp_rif *r; struct mlxsw_sp_rif *r;
u16 rif; u16 rif;
...@@ -3019,7 +3022,7 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp, ...@@ -3019,7 +3022,7 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp,
if (rif == MLXSW_SP_INVALID_RIF) if (rif == MLXSW_SP_INVALID_RIF)
return -ERANGE; return -ERANGE;
vr = mlxsw_sp_vr_get(mlxsw_sp, RT_TABLE_MAIN); vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN);
if (IS_ERR(vr)) if (IS_ERR(vr))
return PTR_ERR(vr); return PTR_ERR(vr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment