Nexthops that need to be programmed with a trap action might not have a
valid router interface (RIF) associated with them. Therefore, use the
loopback RIF created during initialization to program them to the
device.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
 {
        struct mlxsw_sp_neigh_entry *neigh_entry = nh->neigh_entry;
        char ratr_pl[MLXSW_REG_RATR_LEN];
+       u16 rif_index;
 
+       rif_index = nh->rif ? nh->rif->rif_index :
+                             mlxsw_sp->router->lb_rif_index;
        mlxsw_reg_ratr_pack(ratr_pl, MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY,
                            true, MLXSW_REG_RATR_TYPE_ETHERNET,
-                           adj_index, nh->rif->rif_index);
+                           adj_index, rif_index);
        if (nh->action == MLXSW_SP_NEXTHOP_ACTION_DISCARD)
                mlxsw_reg_ratr_trap_action_set(ratr_pl,
                                               MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS);