diff options
author | Christian Hopps <chopps@labn.net> | 2023-02-24 02:23:51 +0100 |
---|---|---|
committer | Christian Hopps <chopps@labn.net> | 2023-02-24 02:59:17 +0100 |
commit | 41ef7327e3ebf9f0293c6046190aceb9d44f8414 (patch) | |
tree | 76bac8831c49014cdb6edf1698a4b6851623c490 /lib/northbound_cli.c | |
parent | Merge pull request #12876 from opensourcerouting/fix/align_show_bgp_with_conf... (diff) | |
download | frr-41ef7327e3ebf9f0293c6046190aceb9d44f8414.tar.xz frr-41ef7327e3ebf9f0293c6046190aceb9d44f8414.zip |
lib: fix init. use of nb_context to be by value not by reference
Pass context argument by value on initialization to be clear that the
value is used/saved but not a pointer to the value. Previously the
northbound code was incorrectly holding a pointer to stack allocated
context structs.
However, the structure definition also had some musings (ifdef'd out
code) and a comment that might be taken to imply that user data could
follow the structure and thus be maintained by the code; it won't; so it
can't; so get rid of the disabled misleading code/text from the
structure definition.
The common use case worked b/c the transaction which cached the pointer
was created and freed inside a single function
call (`nb_condidate_commit`) that executed below the stack allocation.
All other use cases (grpc, confd, sysrepo, and -- coming soon -- mgmtd)
were bugs.
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/northbound_cli.c')
-rw-r--r-- | lib/northbound_cli.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index 0dfa66b37..fa5884fb7 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -46,7 +46,7 @@ static int nb_cli_classic_commit(struct vty *vty) context.client = NB_CLIENT_CLI; context.user = vty; - ret = nb_candidate_commit(&context, vty->candidate_config, true, NULL, + ret = nb_candidate_commit(context, vty->candidate_config, true, NULL, NULL, errmsg, sizeof(errmsg)); switch (ret) { case NB_OK: @@ -313,7 +313,7 @@ int nb_cli_confirmed_commit_rollback(struct vty *vty) context.client = NB_CLIENT_CLI; context.user = vty; ret = nb_candidate_commit( - &context, vty->confirmed_commit_rollback, true, + context, vty->confirmed_commit_rollback, true, "Rollback to previous configuration - confirmed commit has timed out", &transaction_id, errmsg, sizeof(errmsg)); if (ret == NB_OK) { @@ -394,9 +394,8 @@ static int nb_cli_commit(struct vty *vty, bool force, context.client = NB_CLIENT_CLI; context.user = vty; - ret = nb_candidate_commit(&context, vty->candidate_config, true, - comment, &transaction_id, errmsg, - sizeof(errmsg)); + ret = nb_candidate_commit(context, vty->candidate_config, true, comment, + &transaction_id, errmsg, sizeof(errmsg)); /* Map northbound return code to CLI return code. */ switch (ret) { @@ -1717,7 +1716,7 @@ static int nb_cli_rollback_configuration(struct vty *vty, context.client = NB_CLIENT_CLI; context.user = vty; - ret = nb_candidate_commit(&context, candidate, true, comment, NULL, + ret = nb_candidate_commit(context, candidate, true, comment, NULL, errmsg, sizeof(errmsg)); nb_config_free(candidate); switch (ret) { |