diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/grammar_sandbox_main.c | 2 | ||||
| -rw-r--r-- | lib/libfrr.c | 2 | ||||
| -rw-r--r-- | lib/northbound.c | 8 | ||||
| -rw-r--r-- | lib/northbound.h | 5 | ||||
| -rw-r--r-- | lib/yang.c | 3 | ||||
| -rw-r--r-- | lib/zclient.c | 31 | ||||
| -rw-r--r-- | lib/zclient.h | 5 |
7 files changed, 51 insertions, 5 deletions
diff --git a/lib/grammar_sandbox_main.c b/lib/grammar_sandbox_main.c index fbb97d2dd5..2066e4c96d 100644 --- a/lib/grammar_sandbox_main.c +++ b/lib/grammar_sandbox_main.c @@ -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); diff --git a/lib/libfrr.c b/lib/libfrr.c index 2597eb61e2..500a02aacd 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -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", diff --git a/lib/northbound.c b/lib/northbound.c index 29e843a84e..18500a8bd2 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -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, diff --git a/lib/northbound.h b/lib/northbound.h index fa5ac5616c..7b481273cb 100644 --- a/lib/northbound.h +++ b/lib/northbound.h @@ -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 diff --git a/lib/yang.c b/lib/yang.c index 6ab9492d52..9bfdcb858c 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -84,6 +84,9 @@ static const char *yang_module_imp_clb(const char *mod_name, static const char *const frr_native_modules[] = { "frr-interface", "frr-vrf", + "frr-routing", + "frr-route-map", + "frr-nexthop", "frr-ripd", "frr-ripngd", "frr-isisd", diff --git a/lib/zclient.c b/lib/zclient.c index 808aa18bbe..6b5f3e349a 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -871,6 +871,37 @@ static int zapi_nexthop_cmp_no_labels(const struct zapi_nexthop *next1, break; } + if (next1->srte_color < next2->srte_color) + return -1; + if (next1->srte_color > next2->srte_color) + return 1; + + if (CHECK_FLAG(next1->flags, NEXTHOP_FLAG_HAS_BACKUP) || + CHECK_FLAG(next2->flags, NEXTHOP_FLAG_HAS_BACKUP)) { + + if (!CHECK_FLAG(next1->flags, NEXTHOP_FLAG_HAS_BACKUP) && + CHECK_FLAG(next2->flags, NEXTHOP_FLAG_HAS_BACKUP)) + return -1; + + if (CHECK_FLAG(next1->flags, NEXTHOP_FLAG_HAS_BACKUP) && + !CHECK_FLAG(next2->flags, NEXTHOP_FLAG_HAS_BACKUP)) + return 1; + + if (next1->backup_num > 0 || next2->backup_num > 0) { + + if (next1->backup_num < next2->backup_num) + return -1; + + if (next1->backup_num > next2->backup_num) + return 1; + + ret = memcmp(next1->backup_idx, + next2->backup_idx, next1->backup_num); + if (ret != 0) + return ret; + } + } + return 0; } diff --git a/lib/zclient.h b/lib/zclient.h index dab384d5ec..c6a67790a1 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -391,6 +391,11 @@ struct zmsghdr { } __attribute__((packed)); #define ZAPI_HEADER_CMD_LOCATION offsetof(struct zmsghdr, command) +/* + * ZAPI nexthop. Note that these are sorted when associated with ZAPI routes, + * and that sorting must be aligned with the sorting of nexthops in + * lib/nexthop.c. Any new fields must be accounted for in zapi_nexthop_cmp(). + */ struct zapi_nexthop { enum nexthop_types_t type; vrf_id_t vrf_id; |
