]> git.proxmox.com Git - mirror_frr.git/commit - lib/northbound_cli.c
lib, ripd: rework API for converted CLI commands
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 26 Nov 2018 17:30:14 +0000 (15:30 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 26 Nov 2018 17:57:23 +0000 (15:57 -0200)
commita6233bfcb3b0678d24221e77cabea5c3ff859eda
treeb573f9054dd01c848f21c52d4bbd90a7606d9e9f
parentbb5b9c10c14ee9b9578f9e0b363784aa815c548d
lib, ripd: rework API for converted CLI commands

When editing the candidate configuration, the northbound must ensure
that either all changes made by a command are accepted or none are.
This is done to prevent inconsistent states where only parts of a
command are applied in the event any error happens.

The previous API for converted commands, the nb_cli_cfg_change()
function, required callers to pass an array containing all changes
that needed to be applied in the candidate configuration. The
problem with this API is that it was very inconvenient for complex
commands, which change different configuration options depending
on several factors.  This required users to manipulate the array
of configuration changes using low-level primitives, making it
complicated to implement some commands.

To solve this problem, introduce a new API based on the two following
functions:
- nb_cli_enqueue_change()
- nb_cli_apply_changes()

The first function is used to enqueue configuration changes, one
at time. Then the nb_cli_apply_changes() function is used to apply
all the enqueued configuration changes.

To implement this, a static-sized array was allocated in the "vty"
structure, along with a counter of enqueued changes. This eliminates
the need to declare an array of configuration changes in every
converted CLI command, simplifying things quite considerably.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/command.c
lib/if.c
lib/northbound_cli.c
lib/northbound_cli.h
lib/vty.h
ripd/rip_cli.c