]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mlxsw: spectrum_router: Support RIF without device
authorNir Dotan <nird@mellanox.com>
Sun, 20 Jan 2019 06:50:49 +0000 (06:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 20 Jan 2019 19:12:57 +0000 (11:12 -0800)
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>
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 41e607a14846db0a791f721c15c2171caf736881..49933818c6f5996489742ed06324c952b150dda0 100644 (file)
@@ -220,7 +220,7 @@ start_again:
        for (; i < rif_count; i++) {
                struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i);
 
-               if (!rif)
+               if (!rif || !mlxsw_sp_rif_dev(rif))
                        continue;
                err = mlxsw_sp_erif_entry_get(mlxsw_sp, &entry, rif,
                                              counters_enabled);
index 2cfbba810527497be616cd0bdb802fa8178485b7..4316afc2c043343e07661beb80fb62b9a1286f94 100644 (file)
@@ -80,7 +80,7 @@ struct mlxsw_sp_router {
 struct mlxsw_sp_rif {
        struct list_head nexthop_list;
        struct list_head neigh_list;
-       struct net_device *dev;
+       struct net_device *dev; /* NULL for underlay RIF */
        struct mlxsw_sp_fid *fid;
        unsigned char addr[ETH_ALEN];
        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->neigh_list);
-       ether_addr_copy(rif->addr, l3_dev->dev_addr);
-       rif->mtu = l3_dev->mtu;
+       if (l3_dev) {
+               ether_addr_copy(rif->addr, l3_dev->dev_addr);
+               rif->mtu = l3_dev->mtu;
+               rif->dev = l3_dev;
+       }
        rif->vr_id = vr_id;
-       rif->dev = l3_dev;
        rif->rif_index = rif_index;
 
        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++) {
                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,
                                             mlxsw_sp->mac_mask)) {
                        NL_SET_ERR_MSG_MOD(extack, "All router interface MAC addresses must have the same prefix");