mlxsw: spectrum_router: Use mlxsw_sp_ul_rif_get() to get main VRF LB RIF

The current function, mlxsw_sp_router_ul_rif_get(), is a wrapper around the
function mentioned in the subject. As such it forms an external interface
of the router code.

In future patches we will want to maintain connection between RIFs and the
CRIFs (introduced in the next patch) that back them. That will not hold
for the VRF-based loopback netdevices, so the whole CRIF business can be
kept hidden from the rest of mlxsw.

But for the main VRF loopback RIF we do want to keep the RIF-CRIF
connection, because that RIF is used for blackhole next hops, and the next
hop code can be kept simpler for assuming rif->crif is valid.

Hence, instead, call mlxsw_sp_ul_rif_get() to create the main VRF loopback
RIF. This being an internal function will take the CRIF argument anyway.
Furthermore, the function does not lock, which is not necessary at this
point in code yet.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Link: https://lore.kernel.org/r/7a39a011a02a84164cd7f5da7985ec5b2ae01ba5.1687438411.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Petr Machata 2023-06-22 15:33:03 +02:00 committed by Jakub Kicinski
parent ebbd17ce29
commit f3c85eed1a

View File

@ -10564,19 +10564,20 @@ static void __mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp)
static int mlxsw_sp_lb_rif_init(struct mlxsw_sp *mlxsw_sp,
struct netlink_ext_ack *extack)
{
u16 lb_rif_index;
struct mlxsw_sp_rif *lb_rif;
int err;
/* Create a generic loopback RIF associated with the main table
* (default VRF). Any table can be used, but the main table exists
* anyway, so we do not waste resources.
*/
err = mlxsw_sp_router_ul_rif_get(mlxsw_sp, RT_TABLE_MAIN,
&lb_rif_index);
if (err)
lb_rif = mlxsw_sp_ul_rif_get(mlxsw_sp, RT_TABLE_MAIN, extack);
if (IS_ERR(lb_rif)) {
err = PTR_ERR(lb_rif);
return err;
}
mlxsw_sp->router->lb_rif_index = lb_rif_index;
mlxsw_sp->router->lb_rif_index = lb_rif->rif_index;
return 0;
}