mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 11:30:55 +00:00
*: record transaction based on control flag
In case of config rollback is enabled, record northbound transaction based on a control flag. The actual frr daemons would set the flag to true via nb_init from frr_init. This will allow test daemon to bypass recording transacation to db. Signed-off-by: Chirag Shah <chirag@nvidia.com>
This commit is contained in:
parent
6a7fb29c19
commit
390a886277
@ -55,7 +55,7 @@ int main(int argc, char **argv)
|
||||
vty_init(master, true);
|
||||
lib_cmd_init();
|
||||
yang_init(true);
|
||||
nb_init(master, NULL, 0);
|
||||
nb_init(master, NULL, 0, false);
|
||||
|
||||
vty_stdio(vty_do_exit);
|
||||
|
||||
|
@ -719,7 +719,7 @@ struct thread_master *frr_init(void)
|
||||
|
||||
debug_init_cli();
|
||||
|
||||
nb_init(master, di->yang_modules, di->n_yang_modules);
|
||||
nb_init(master, di->yang_modules, di->n_yang_modules, true);
|
||||
if (nb_db_init() != NB_OK)
|
||||
flog_warn(EC_LIB_NB_DATABASE,
|
||||
"%s: failed to initialize northbound database",
|
||||
|
@ -57,6 +57,8 @@ static struct {
|
||||
const void *owner_user;
|
||||
} running_config_mgmt_lock;
|
||||
|
||||
/* Knob to record config transaction */
|
||||
static bool nb_db_enabled;
|
||||
/*
|
||||
* Global lock used to prevent multiple configuration transactions from
|
||||
* happening concurrently.
|
||||
@ -732,7 +734,7 @@ void nb_candidate_commit_apply(struct nb_transaction *transaction,
|
||||
nb_config_replace(running_config, transaction->config, true);
|
||||
|
||||
/* Record transaction. */
|
||||
if (save_transaction
|
||||
if (save_transaction && nb_db_enabled
|
||||
&& nb_db_transaction_save(transaction, transaction_id) != NB_OK)
|
||||
flog_warn(EC_LIB_NB_TRANSACTION_RECORD_FAILED,
|
||||
"%s: failed to record transaction", __func__);
|
||||
@ -2216,7 +2218,7 @@ static void nb_load_callbacks(const struct frr_yang_module_info *module)
|
||||
|
||||
void nb_init(struct thread_master *tm,
|
||||
const struct frr_yang_module_info *const modules[],
|
||||
size_t nmodules)
|
||||
size_t nmodules, bool db_enabled)
|
||||
{
|
||||
unsigned int errors = 0;
|
||||
|
||||
@ -2241,6 +2243,8 @@ void nb_init(struct thread_master *tm,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
nb_db_enabled = db_enabled;
|
||||
|
||||
/* Create an empty running configuration. */
|
||||
running_config = nb_config_new(NULL);
|
||||
running_config_entries = hash_create(running_config_entry_key_make,
|
||||
|
@ -1239,10 +1239,13 @@ extern const char *nb_client_name(enum nb_client client);
|
||||
*
|
||||
* nmodules
|
||||
* Size of the modules array.
|
||||
*
|
||||
* db_enabled
|
||||
* Set this to record the transactions in the transaction log.
|
||||
*/
|
||||
extern void nb_init(struct thread_master *tm,
|
||||
const struct frr_yang_module_info *const modules[],
|
||||
size_t nmodules);
|
||||
size_t nmodules, bool db_enabled);
|
||||
|
||||
/*
|
||||
* Finish the northbound layer gracefully. Should be called only when the daemon
|
||||
|
@ -1387,7 +1387,7 @@ static void bgp_startup(void)
|
||||
|
||||
master = thread_master_create(NULL);
|
||||
yang_init(true);
|
||||
nb_init(master, NULL, 0);
|
||||
nb_init(master, NULL, 0, false);
|
||||
bgp_master_init(master, BGP_SOCKET_SNDBUF_SIZE);
|
||||
bgp_option_set(BGP_OPT_NO_LISTEN);
|
||||
vrf_init(NULL, NULL, NULL, NULL, NULL);
|
||||
|
@ -156,7 +156,7 @@ int main(int argc, char **argv)
|
||||
vty_init(master, false);
|
||||
lib_cmd_init();
|
||||
yang_init(true);
|
||||
nb_init(master, NULL, 0);
|
||||
nb_init(master, NULL, 0, false);
|
||||
|
||||
/* OSPF vty inits. */
|
||||
test_vty_init();
|
||||
|
@ -80,7 +80,7 @@ int main(int argc, char **argv)
|
||||
vty_init(master, false);
|
||||
lib_cmd_init();
|
||||
yang_init(true);
|
||||
nb_init(master, NULL, 0);
|
||||
nb_init(master, NULL, 0, false);
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
|
@ -209,7 +209,7 @@ static void test_init(void)
|
||||
|
||||
cmd_init(1);
|
||||
yang_init(true);
|
||||
nb_init(master, NULL, 0);
|
||||
nb_init(master, NULL, 0, false);
|
||||
|
||||
install_node(&bgp_node);
|
||||
install_node(&rip_node);
|
||||
|
@ -400,7 +400,7 @@ int main(int argc, char **argv)
|
||||
vty_init(master, false);
|
||||
lib_cmd_init();
|
||||
yang_init(true);
|
||||
nb_init(master, modules, array_size(modules));
|
||||
nb_init(master, modules, array_size(modules), false);
|
||||
|
||||
/* Create artificial data. */
|
||||
create_data(num_vrfs, num_interfaces, num_routes);
|
||||
|
Loading…
Reference in New Issue
Block a user