-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgmtd: Revert changes related to local validation. #11166
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,9 @@ static int nb_node_new_cb(const struct lysc_node *snode, void *arg) | |
{ | ||
struct nb_node *nb_node; | ||
struct lysc_node *sparent, *sparent_list; | ||
struct frr_yang_module_info *module; | ||
|
||
module = (struct frr_yang_module_info *)arg; | ||
nb_node = XCALLOC(MTYPE_NB_NODE, sizeof(*nb_node)); | ||
yang_snode_get_path(snode, YANG_PATH_DATA, nb_node->xpath, | ||
sizeof(nb_node->xpath)); | ||
|
@@ -141,6 +143,9 @@ 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); | ||
|
||
return YANG_ITER_CONTINUE; | ||
} | ||
|
||
|
@@ -243,6 +248,9 @@ 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)) | ||
return error; | ||
|
||
error += nb_node_validate_cb(nb_node, NB_OP_CREATE, | ||
!!nb_node->cbs.create, false); | ||
error += nb_node_validate_cb(nb_node, NB_OP_MODIFY, | ||
|
@@ -1213,6 +1221,8 @@ 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)); | ||
|
||
nb_log_config_callback(event, NB_OP_CREATE, dnode); | ||
|
||
args.context = context; | ||
|
@@ -1262,6 +1272,8 @@ 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)); | ||
|
||
nb_log_config_callback(event, NB_OP_MODIFY, dnode); | ||
|
||
args.context = context; | ||
|
@@ -1311,6 +1323,8 @@ 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)); | ||
|
||
nb_log_config_callback(event, NB_OP_DESTROY, dnode); | ||
|
||
args.context = context; | ||
|
@@ -1354,6 +1368,8 @@ 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)); | ||
|
||
nb_log_config_callback(event, NB_OP_MOVE, dnode); | ||
|
||
args.context = context; | ||
|
@@ -1397,6 +1413,9 @@ 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)) | ||
return 0; | ||
|
||
nb_log_config_callback(NB_EV_VALIDATE, NB_OP_PRE_VALIDATE, dnode); | ||
|
||
args.dnode = dnode; | ||
|
@@ -1428,6 +1447,9 @@ 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)) | ||
return; | ||
|
||
nb_log_config_callback(NB_EV_APPLY, NB_OP_APPLY_FINISH, dnode); | ||
|
||
args.context = context; | ||
|
@@ -1443,6 +1465,9 @@ 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)) | ||
return NULL; | ||
|
||
DEBUGD(&nb_dbg_cbs_state, | ||
"northbound callback (get_elem): xpath [%s] list_entry [%p]", | ||
xpath, list_entry); | ||
|
@@ -1458,6 +1483,9 @@ 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)) | ||
return NULL; | ||
|
||
DEBUGD(&nb_dbg_cbs_state, | ||
"northbound callback (get_next): node [%s] parent_list_entry [%p] list_entry [%p]", | ||
nb_node->xpath, parent_list_entry, list_entry); | ||
|
@@ -1472,6 +1500,9 @@ 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)) | ||
return 0; | ||
|
||
DEBUGD(&nb_dbg_cbs_state, | ||
"northbound callback (get_keys): node [%s] list_entry [%p]", | ||
nb_node->xpath, list_entry); | ||
|
@@ -1487,6 +1518,9 @@ 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)) | ||
return NULL; | ||
|
||
DEBUGD(&nb_dbg_cbs_state, | ||
"northbound callback (lookup_entry): node [%s] parent_list_entry [%p]", | ||
nb_node->xpath, parent_list_entry); | ||
|
@@ -1502,6 +1536,9 @@ 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)) | ||
return 0; | ||
|
||
DEBUGD(&nb_dbg_cbs_rpc, "northbound RPC: %s", xpath); | ||
|
||
args.xpath = xpath; | ||
|
@@ -1528,6 +1565,9 @@ 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)) | ||
return NB_OK; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check here is done prior to calling However, I don't know why this code is even being invoked in the first place for a module with no callbacks -- as mentioned in an earlier comment. This comment applies to the other top level checks (pre_validate, apply_finish etc..) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nb_init() which is invoked by frr_init calls nb_validate_callbacks() for all FRR daemons. These changes tries to avoid that for YANG modules that are marked with 'ignore_cbs'. |
||
|
||
if (event == NB_EV_VALIDATE) | ||
resource = NULL; | ||
else | ||
|
@@ -1925,7 +1965,7 @@ static int nb_oper_data_iter_list(const struct nb_node *nb_node, | |
/* Iterate over all list entries. */ | ||
do { | ||
const struct lysc_node_leaf *skey; | ||
struct yang_list_keys list_keys; | ||
struct yang_list_keys list_keys = {}; | ||
char xpath[XPATH_MAXLEN * 2]; | ||
int ret; | ||
|
||
|
@@ -2585,6 +2625,10 @@ const char *nb_client_name(enum nb_client client) | |
|
||
static void nb_load_callbacks(const struct frr_yang_module_info *module) | ||
{ | ||
|
||
if (module->ignore_cbs) | ||
return; | ||
|
||
for (size_t i = 0; module->nodes[i].xpath; i++) { | ||
struct nb_node *nb_node; | ||
uint32_t priority; | ||
|
@@ -2658,7 +2702,8 @@ void nb_init(struct thread_master *tm, | |
|
||
/* Initialize the compiled nodes with northbound data */ | ||
for (size_t i = 0; i < nmodules; i++) { | ||
yang_snodes_iterate(loaded[i]->info, nb_node_new_cb, 0, NULL); | ||
yang_snodes_iterate(loaded[i]->info, nb_node_new_cb, 0, | ||
(void *)modules[i]); | ||
nb_load_callbacks(modules[i]); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these nodes even created in the first place if the module supports no callbacks? If they serve no purpose this code should be changed to not create the nb_nodes and all the rest of the state etc that goes along with them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for the Mgmtd deamon where we need the nb_nodes to populate config data trees and the corresponding schema. This is useful for yang schema-based validations and for fetching the equivalent of "show running config".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Libyang2 has constructed it's own tree for validation and the output of "show running config". In fact the nb_node's hang off a "priv" pointer in the corresponding libyang2 schema node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@choppsv1 Most of the code (including the API needed to do yang-validation) in lib/northbound,c needs a nb_node as parameter. Hence it is going to be lot difficult to avoid creating the nb_nodes on MGMTd. Hence added this new flag on the nb_nodes and then used it to avoid calling callbacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to revist this later. We should be able to do validation w/o requiring a bunch of dummy nodes.