Skip to content

Commit

Permalink
lib, mgmtd: rename ignore_cbs to ignore_cfg_cbs
Browse files Browse the repository at this point in the history
Setting this variable to true makes NB ignore only configuration-related
callbacks. CLI-related callbacks are still loaded and executed, so
rename the variable to make it clearer.

Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Jan 11, 2024
1 parent 86cbd58 commit 3472197
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion doc/developer/mgmtd-dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ An here is the addition to the modules array in ``mgmtd/mgmt_main.c``:
...
#ifdef HAVE_STATICD
&(struct frr_yang_module_info){.name = "frr-staticd",
.ignore_cbs = true},
.ignore_cfg_cbs = true},
#endif
}
Expand Down
34 changes: 17 additions & 17 deletions lib/northbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ static int nb_node_new_cb(const struct lysc_node *snode, void *arg)
assert(snode->priv == NULL);
((struct lysc_node *)snode)->priv = nb_node;

if (module && module->ignore_cbs)
SET_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS);
if (module && module->ignore_cfg_cbs)
SET_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS);

return YANG_ITER_CONTINUE;
}
Expand Down Expand Up @@ -250,7 +250,7 @@ static unsigned int nb_node_validate_cbs(const struct nb_node *nb_node)
{
unsigned int error = 0;

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return error;

error += nb_node_validate_cb(nb_node, NB_OP_CREATE,
Expand Down Expand Up @@ -1171,7 +1171,7 @@ static int nb_callback_create(struct nb_context *context,
bool unexpected_error = false;
int ret;

assert(!CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS));
assert(!CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS));

nb_log_config_callback(event, NB_OP_CREATE, dnode);

Expand Down Expand Up @@ -1222,7 +1222,7 @@ static int nb_callback_modify(struct nb_context *context,
bool unexpected_error = false;
int ret;

assert(!CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS));
assert(!CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS));

nb_log_config_callback(event, NB_OP_MODIFY, dnode);

Expand Down Expand Up @@ -1273,7 +1273,7 @@ static int nb_callback_destroy(struct nb_context *context,
bool unexpected_error = false;
int ret;

assert(!CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS));
assert(!CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS));

nb_log_config_callback(event, NB_OP_DESTROY, dnode);

Expand Down Expand Up @@ -1318,7 +1318,7 @@ static int nb_callback_move(struct nb_context *context,
bool unexpected_error = false;
int ret;

assert(!CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS));
assert(!CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS));

nb_log_config_callback(event, NB_OP_MOVE, dnode);

Expand Down Expand Up @@ -1363,7 +1363,7 @@ static int nb_callback_pre_validate(struct nb_context *context,
bool unexpected_error = false;
int ret;

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return 0;

nb_log_config_callback(NB_EV_VALIDATE, NB_OP_PRE_VALIDATE, dnode);
Expand Down Expand Up @@ -1397,7 +1397,7 @@ static void nb_callback_apply_finish(struct nb_context *context,
{
struct nb_cb_apply_finish_args args = {};

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return;

nb_log_config_callback(NB_EV_APPLY, NB_OP_APPLY_FINISH, dnode);
Expand All @@ -1415,7 +1415,7 @@ struct yang_data *nb_callback_get_elem(const struct nb_node *nb_node,
{
struct nb_cb_get_elem_args args = {};

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return NULL;

DEBUGD(&nb_dbg_cbs_state,
Expand All @@ -1433,7 +1433,7 @@ const void *nb_callback_get_next(const struct nb_node *nb_node,
{
struct nb_cb_get_next_args args = {};

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return NULL;

DEBUGD(&nb_dbg_cbs_state,
Expand All @@ -1450,7 +1450,7 @@ int nb_callback_get_keys(const struct nb_node *nb_node, const void *list_entry,
{
struct nb_cb_get_keys_args args = {};

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return 0;

DEBUGD(&nb_dbg_cbs_state,
Expand All @@ -1468,7 +1468,7 @@ const void *nb_callback_lookup_entry(const struct nb_node *nb_node,
{
struct nb_cb_lookup_entry_args args = {};

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return NULL;

DEBUGD(&nb_dbg_cbs_state,
Expand All @@ -1487,7 +1487,7 @@ const void *nb_callback_lookup_node_entry(struct lyd_node *node,
struct nb_cb_lookup_entry_args args = {};
const struct nb_node *nb_node = node->schema->priv;

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return NULL;

if (yang_get_node_keys(node, &keys)) {
Expand All @@ -1512,7 +1512,7 @@ const void *nb_callback_lookup_next(const struct nb_node *nb_node,
{
struct nb_cb_lookup_entry_args args = {};

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return NULL;

DEBUGD(&nb_dbg_cbs_state,
Expand All @@ -1530,7 +1530,7 @@ int nb_callback_rpc(const struct nb_node *nb_node, const char *xpath,
{
struct nb_cb_rpc_args args = {};

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return 0;

DEBUGD(&nb_dbg_cbs_rpc, "northbound RPC: %s", xpath);
Expand Down Expand Up @@ -1559,7 +1559,7 @@ static int nb_callback_configuration(struct nb_context *context,
union nb_resource *resource;
int ret = NB_ERR;

if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CBS))
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_IGNORE_CFG_CBS))
return NB_OK;

if (event == NB_EV_VALIDATE)
Expand Down
11 changes: 6 additions & 5 deletions lib/northbound.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ struct nb_node {
#define F_NB_NODE_CONFIG_ONLY 0x01
/* The YANG list doesn't contain key leafs. */
#define F_NB_NODE_KEYLESS_LIST 0x02
/* Ignore callbacks for this node */
#define F_NB_NODE_IGNORE_CBS 0x04
/* Ignore config callbacks for this node */
#define F_NB_NODE_IGNORE_CFG_CBS 0x04

/*
* HACK: old gcc versions (< 5.x) have a bug that prevents C99 flexible arrays
Expand All @@ -628,10 +628,11 @@ struct frr_yang_module_info {
const char *name;

/*
* Ignore callbacks for this module. Set this to true to
* load module without any callbacks.
* Ignore configuration callbacks for this module. Set this to true to
* load module with only CLI-related callbacks. This is useful for
* modules loaded in mgmtd.
*/
bool ignore_cbs;
bool ignore_cfg_cbs;

/* Northbound callbacks. */
const struct {
Expand Down
6 changes: 3 additions & 3 deletions mgmtd/mgmt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,19 @@ extern const struct frr_yang_module_info frr_staticd_info;
*/
const struct frr_yang_module_info zebra_info = {
.name = "frr-zebra",
.ignore_cbs = true,
.ignore_cfg_cbs = true,
.nodes = { { .xpath = NULL } },
};

const struct frr_yang_module_info affinity_map_info = {
.name = "frr-affinity-map",
.ignore_cbs = true,
.ignore_cfg_cbs = true,
.nodes = { { .xpath = NULL } },
};

const struct frr_yang_module_info zebra_route_map_info = {
.name = "frr-zebra-route-map",
.ignore_cbs = true,
.ignore_cfg_cbs = true,
.nodes = { { .xpath = NULL } },
};

Expand Down
2 changes: 1 addition & 1 deletion staticd/static_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ static int static_path_list_cli_cmp(const struct lyd_node *dnode1,

const struct frr_yang_module_info frr_staticd_info = {
.name = "frr-staticd",
.ignore_cbs = true,
.ignore_cfg_cbs = true,
.nodes = {
{
.xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd",
Expand Down

0 comments on commit 3472197

Please sign in to comment.