PERF: Added a recurse parameter to xml_yang_minmax_recurse() to avoid "double recursion"
C-API: `candidate_commit()`: validate_level (added in 6.1) marked obsolete
This commit is contained in:
parent
2db5961169
commit
55422f4187
9 changed files with 30 additions and 29 deletions
|
|
@ -42,6 +42,9 @@
|
||||||
## 6.2.0
|
## 6.2.0
|
||||||
Expected: April 2023
|
Expected: April 2023
|
||||||
|
|
||||||
|
* C-API
|
||||||
|
* `candidate_commit()`: validate_level (added in 6.1) marked obsolete
|
||||||
|
|
||||||
## 6.1.0
|
## 6.1.0
|
||||||
19 Feb 2023
|
19 Feb 2023
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,7 @@ from_client_edit_config(clicon_handle h,
|
||||||
}
|
}
|
||||||
/* Limited validation of incoming payload
|
/* Limited validation of incoming payload
|
||||||
*/
|
*/
|
||||||
if ((ret = xml_yang_minmax_recurse(xc, &xret)) < 0)
|
if ((ret = xml_yang_minmax_recurse(xc, 1, &xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* xmldb_put (difflist handling) requires list keys */
|
/* xmldb_put (difflist handling) requires list keys */
|
||||||
if (ret==1 && (ret = xml_yang_validate_list_key_only(xc, &xret)) < 0)
|
if (ret==1 && (ret = xml_yang_validate_list_key_only(xc, &xret)) < 0)
|
||||||
|
|
@ -567,7 +567,7 @@ from_client_edit_config(clicon_handle h,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((ret = candidate_commit(h, NULL, "candidate", myid, VL_FULL, cbret)) < 0){ /* Assume validation fail, nofatal */
|
if ((ret = candidate_commit(h, NULL, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
|
||||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||||
goto done;
|
goto done;
|
||||||
xmldb_copy(h, "running", "candidate");
|
xmldb_copy(h, "running", "candidate");
|
||||||
|
|
|
||||||
|
|
@ -465,7 +465,6 @@ startup_commit(clicon_handle h,
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] db The (candidate) database. The wanted backend state
|
* @param[in] db The (candidate) database. The wanted backend state
|
||||||
* @param[in] td Transaction data
|
* @param[in] td Transaction data
|
||||||
* @param[in] vlev Validation level (0: full validation)
|
|
||||||
* @param[out] xret Error XML tree, if retval is 0. Free with xml_free after use
|
* @param[out] xret Error XML tree, if retval is 0. Free with xml_free after use
|
||||||
* @retval 1 Validation OK
|
* @retval 1 Validation OK
|
||||||
* @retval 0 Validation failed (with xret set)
|
* @retval 0 Validation failed (with xret set)
|
||||||
|
|
@ -478,7 +477,6 @@ static int
|
||||||
validate_common(clicon_handle h,
|
validate_common(clicon_handle h,
|
||||||
char *db,
|
char *db,
|
||||||
transaction_data_t *td,
|
transaction_data_t *td,
|
||||||
validate_level vlev,
|
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -546,18 +544,16 @@ validate_common(clicon_handle h,
|
||||||
if (plugin_transaction_begin_all(h, td) < 0)
|
if (plugin_transaction_begin_all(h, td) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (vlev == VL_FULL){
|
/* 5. Make generic validation on all new or changed data.
|
||||||
/* 5. Make generic validation on all new or changed data.
|
Note this is only call that uses 3-values */
|
||||||
Note this is only call that uses 3-values */
|
if ((ret = generic_validate(h, yspec, td, xret)) < 0)
|
||||||
if ((ret = generic_validate(h, yspec, td, xret)) < 0)
|
goto done;
|
||||||
goto done;
|
if (ret == 0)
|
||||||
if (ret == 0)
|
goto fail;
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* 6. Call plugin transaction validate callbacks */
|
/* 6. Call plugin transaction validate callbacks */
|
||||||
if (plugin_transaction_validate_all(h, td) < 0)
|
if (plugin_transaction_validate_all(h, td) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
/* 7. Call plugin transaction complete callbacks */
|
/* 7. Call plugin transaction complete callbacks */
|
||||||
if (plugin_transaction_complete_all(h, td) < 0)
|
if (plugin_transaction_complete_all(h, td) < 0)
|
||||||
|
|
@ -598,7 +594,7 @@ candidate_validate(clicon_handle h,
|
||||||
if ((td = transaction_new()) == NULL)
|
if ((td = transaction_new()) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* Common steps (with commit) */
|
/* Common steps (with commit) */
|
||||||
if ((ret = validate_common(h, db, td, VL_FULL, &xret)) < 0){
|
if ((ret = validate_common(h, db, td, &xret)) < 0){
|
||||||
/* A little complex due to several sources of validation fails or errors.
|
/* A little complex due to several sources of validation fails or errors.
|
||||||
* (1) xerr is set -> translate to cbret; (2) cbret set use that; otherwise
|
* (1) xerr is set -> translate to cbret; (2) cbret set use that; otherwise
|
||||||
* use clicon_err.
|
* use clicon_err.
|
||||||
|
|
@ -652,7 +648,7 @@ candidate_validate(clicon_handle h,
|
||||||
* @param[in] xe Request: <rpc><xn></rpc> (or NULL)
|
* @param[in] xe Request: <rpc><xn></rpc> (or NULL)
|
||||||
* @param[in] db A candidate database, not necessarily "candidate"
|
* @param[in] db A candidate database, not necessarily "candidate"
|
||||||
* @param[in] myid Client id of triggering incoming message (or 0)
|
* @param[in] myid Client id of triggering incoming message (or 0)
|
||||||
* @param[in] vlev Validation level (0: full validation)
|
* @param[in] vlev Validation level (0: full validation) // obsolete
|
||||||
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. (if retval = 0)
|
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. (if retval = 0)
|
||||||
* @retval 1 Validation OK
|
* @retval 1 Validation OK
|
||||||
* @retval 0 Validation failed (with cbret set)
|
* @retval 0 Validation failed (with cbret set)
|
||||||
|
|
@ -663,7 +659,7 @@ candidate_commit(clicon_handle h,
|
||||||
cxobj *xe,
|
cxobj *xe,
|
||||||
char *db,
|
char *db,
|
||||||
uint32_t myid,
|
uint32_t myid,
|
||||||
validate_level vlev,
|
validate_level vlev, // obsolete
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -679,7 +675,7 @@ candidate_commit(clicon_handle h,
|
||||||
/* Common steps (with validate). Load candidate and running and compute diffs
|
/* Common steps (with validate). Load candidate and running and compute diffs
|
||||||
* Note this is only call that uses 3-values
|
* Note this is only call that uses 3-values
|
||||||
*/
|
*/
|
||||||
if ((ret = validate_common(h, db, td, vlev, &xret)) < 0)
|
if ((ret = validate_common(h, db, td, &xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* If the confirmed-commit feature is enabled, execute phase 2:
|
/* If the confirmed-commit feature is enabled, execute phase 2:
|
||||||
|
|
@ -824,7 +820,7 @@ from_client_commit(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
if ((ret = candidate_commit(h, xe, "candidate", myid, VL_FULL, cbret)) < 0){ /* Assume validation fail, nofatal */
|
if ((ret = candidate_commit(h, xe, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
|
||||||
clicon_debug(1, "Commit candidate failed");
|
clicon_debug(1, "Commit candidate failed");
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||||
|
|
@ -1091,7 +1087,7 @@ load_failsafe(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
if (xmldb_db_reset(h, "running") < 0)
|
if (xmldb_db_reset(h, "running") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
ret = candidate_commit(h, NULL, db, 0, VL_FULL, cbret);
|
ret = candidate_commit(h, NULL, db, 0, 0, cbret);
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
if (xmldb_copy(h, "tmp", "running") < 0)
|
if (xmldb_copy(h, "tmp", "running") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -653,7 +653,7 @@ do_rollback(clicon_handle h,
|
||||||
confirmed_commit_persist_id_set(h, NULL);
|
confirmed_commit_persist_id_set(h, NULL);
|
||||||
}
|
}
|
||||||
confirmed_commit_state_set(h, ROLLBACK);
|
confirmed_commit_state_set(h, ROLLBACK);
|
||||||
if (candidate_commit(h, NULL, "rollback", 0, VL_FULL, cbret) < 0) { /* Assume validation fail, nofatal */
|
if (candidate_commit(h, NULL, "rollback", 0, 0, cbret) < 0) { /* Assume validation fail, nofatal */
|
||||||
/* theoretically, this should never error, since the rollback database was previously active and therefore
|
/* theoretically, this should never error, since the rollback database was previously active and therefore
|
||||||
* had itself been previously and successfully committed.
|
* had itself been previously and successfully committed.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ top_srcdir = @top_srcdir@
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
bindir = @bindir@
|
bindir = @bindir@
|
||||||
includedir = @includedir@
|
includedir = @includedir@
|
||||||
datarootdir = @datarootdir@
|
|
||||||
sysconfdir = @sysconfdir@
|
sysconfdir = @sysconfdir@
|
||||||
datarootdir = @datarootdir@
|
datarootdir = @datarootdir@
|
||||||
localstatedir = @localstatedir@
|
localstatedir = @localstatedir@
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,6 @@
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
int xml_yang_minmax_recurse(cxobj *xt, cxobj **xret);
|
int xml_yang_minmax_recurse(cxobj *xt, int recurse, cxobj **xret);
|
||||||
|
|
||||||
#endif /* _CLIXON_VALIDATE_MINMAX_H_ */
|
#endif /* _CLIXON_VALIDATE_MINMAX_H_ */
|
||||||
|
|
|
||||||
|
|
@ -1359,7 +1359,7 @@ xml_yang_validate_all(clicon_handle h,
|
||||||
/* Check unique and min-max after choice test for example*/
|
/* Check unique and min-max after choice test for example*/
|
||||||
if (yang_config(yt) != 0){
|
if (yang_config(yt) != 0){
|
||||||
/* Checks if next level contains any unique list constraints */
|
/* Checks if next level contains any unique list constraints */
|
||||||
if ((ret = xml_yang_minmax_recurse(xt, xret)) < 0)
|
if ((ret = xml_yang_minmax_recurse(xt, 1, xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -1396,7 +1396,7 @@ xml_yang_validate_all_top(clicon_handle h,
|
||||||
if ((ret = xml_yang_validate_all(h, x, xret)) < 1)
|
if ((ret = xml_yang_validate_all(h, x, xret)) < 1)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if ((ret = xml_yang_minmax_recurse(xt, xret)) < 1)
|
if ((ret = xml_yang_minmax_recurse(xt, 0, xret)) < 1)
|
||||||
return ret;
|
return ret;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -633,6 +633,8 @@ xml_yang_minmax_gap_analysis(cxobj *xt,
|
||||||
* 7 null nolist neq gap analysis; nopresence-check;
|
* 7 null nolist neq gap analysis; nopresence-check;
|
||||||
* 8 list nolist neq gap analysis; yprev: check-minmax; nopresence-check;
|
* 8 list nolist neq gap analysis; yprev: check-minmax; nopresence-check;
|
||||||
* @param[in] xt XML parent (may have lists w unique constraints as child)
|
* @param[in] xt XML parent (may have lists w unique constraints as child)
|
||||||
|
* @param[in] recurse Set if called in a recursive loop (will recurse anyway),
|
||||||
|
* otherwise non-presence containers will be traversed
|
||||||
* @param[out] xret Error XML tree. Free with xml_free after use
|
* @param[out] xret Error XML tree. Free with xml_free after use
|
||||||
* @retval 1 Validation OK
|
* @retval 1 Validation OK
|
||||||
* @retval 0 Validation failed (xret set)
|
* @retval 0 Validation failed (xret set)
|
||||||
|
|
@ -643,6 +645,7 @@ xml_yang_minmax_gap_analysis(cxobj *xt,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml_yang_minmax_recurse(cxobj *xt,
|
xml_yang_minmax_recurse(cxobj *xt,
|
||||||
|
int recurse,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -709,11 +712,11 @@ xml_yang_minmax_recurse(cxobj *xt,
|
||||||
}
|
}
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (keyw == Y_CONTAINER &&
|
if (recurse && keyw == Y_CONTAINER &&
|
||||||
yang_find(y, Y_PRESENCE, NULL) == NULL){
|
yang_find(y, Y_PRESENCE, NULL) == NULL){
|
||||||
yang_stmt *yc = NULL;
|
yang_stmt *yc = NULL;
|
||||||
while ((yc = yn_each(y, yc)) != NULL) {
|
while ((yc = yn_each(y, yc)) != NULL) {
|
||||||
if ((ret = xml_yang_minmax_recurse(x, xret)) < 0)
|
if ((ret = xml_yang_minmax_recurse(x, recurse, xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ main(int argc,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (commit){
|
if (commit){
|
||||||
if ((ret = candidate_commit(h, NULL, database, 0, VL_FULL, cb)) < 0)
|
if ((ret = candidate_commit(h, NULL, database, 0, 0, cb)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue