mlxsw: spectrum_router: Support RIF without device

Spectrum-2 underlay RIF is merely an auxiliary RIF that points to the
virtual router used for encapsulated packets lookup. It exists only when
its overlay RIF exists but may be shared with other overlay RIFs.
Hence it is undesired to mark any device as related to it.

Therefore allow usage of NULL device when allocating RIF.

Signed-off-by: Nir Dotan <nird@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Nir Dotan 2019-01-20 06:50:49 +00:00 committed by David S. Miller
parent 33c04afe4d
commit 73b8f493c8
2 changed files with 8 additions and 6 deletions

View File

@ -220,7 +220,7 @@ mlxsw_sp_dpipe_table_erif_entries_dump(void *priv, bool counters_enabled,
for (; i < rif_count; i++) { for (; i < rif_count; i++) {
struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i); struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i);
if (!rif) if (!rif || !mlxsw_sp_rif_dev(rif))
continue; continue;
err = mlxsw_sp_erif_entry_get(mlxsw_sp, &entry, rif, err = mlxsw_sp_erif_entry_get(mlxsw_sp, &entry, rif,
counters_enabled); counters_enabled);

View File

@ -80,7 +80,7 @@ struct mlxsw_sp_router {
struct mlxsw_sp_rif { struct mlxsw_sp_rif {
struct list_head nexthop_list; struct list_head nexthop_list;
struct list_head neigh_list; struct list_head neigh_list;
struct net_device *dev; struct net_device *dev; /* NULL for underlay RIF */
struct mlxsw_sp_fid *fid; struct mlxsw_sp_fid *fid;
unsigned char addr[ETH_ALEN]; unsigned char addr[ETH_ALEN];
int mtu; int mtu;
@ -6224,10 +6224,12 @@ static struct mlxsw_sp_rif *mlxsw_sp_rif_alloc(size_t rif_size, u16 rif_index,
INIT_LIST_HEAD(&rif->nexthop_list); INIT_LIST_HEAD(&rif->nexthop_list);
INIT_LIST_HEAD(&rif->neigh_list); INIT_LIST_HEAD(&rif->neigh_list);
ether_addr_copy(rif->addr, l3_dev->dev_addr); if (l3_dev) {
rif->mtu = l3_dev->mtu; ether_addr_copy(rif->addr, l3_dev->dev_addr);
rif->mtu = l3_dev->mtu;
rif->dev = l3_dev;
}
rif->vr_id = vr_id; rif->vr_id = vr_id;
rif->dev = l3_dev;
rif->rif_index = rif_index; rif->rif_index = rif_index;
return rif; return rif;
@ -6758,7 +6760,7 @@ static int mlxsw_sp_router_port_check_rif_addr(struct mlxsw_sp *mlxsw_sp,
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) { for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) {
rif = mlxsw_sp->router->rifs[i]; rif = mlxsw_sp->router->rifs[i];
if (rif && rif->dev != dev && if (rif && rif->dev && rif->dev != dev &&
!ether_addr_equal_masked(rif->dev->dev_addr, dev_addr, !ether_addr_equal_masked(rif->dev->dev_addr, dev_addr,
mlxsw_sp->mac_mask)) { mlxsw_sp->mac_mask)) {
NL_SET_ERR_MSG_MOD(extack, "All router interface MAC addresses must have the same prefix"); NL_SET_ERR_MSG_MOD(extack, "All router interface MAC addresses must have the same prefix");