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
|
|
@ -510,7 +510,7 @@ from_client_edit_config(clicon_handle h,
|
|||
}
|
||||
/* 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;
|
||||
/* xmldb_put (difflist handling) requires list keys */
|
||||
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;
|
||||
}
|
||||
}
|
||||
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)
|
||||
goto done;
|
||||
xmldb_copy(h, "running", "candidate");
|
||||
|
|
|
|||
|
|
@ -465,7 +465,6 @@ startup_commit(clicon_handle h,
|
|||
* @param[in] h Clicon handle
|
||||
* @param[in] db The (candidate) database. The wanted backend state
|
||||
* @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
|
||||
* @retval 1 Validation OK
|
||||
* @retval 0 Validation failed (with xret set)
|
||||
|
|
@ -478,7 +477,6 @@ static int
|
|||
validate_common(clicon_handle h,
|
||||
char *db,
|
||||
transaction_data_t *td,
|
||||
validate_level vlev,
|
||||
cxobj **xret)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -546,18 +544,16 @@ validate_common(clicon_handle h,
|
|||
if (plugin_transaction_begin_all(h, td) < 0)
|
||||
goto done;
|
||||
|
||||
if (vlev == VL_FULL){
|
||||
/* 5. Make generic validation on all new or changed data.
|
||||
Note this is only call that uses 3-values */
|
||||
if ((ret = generic_validate(h, yspec, td, xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
/* 5. Make generic validation on all new or changed data.
|
||||
Note this is only call that uses 3-values */
|
||||
if ((ret = generic_validate(h, yspec, td, xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
||||
/* 6. Call plugin transaction validate callbacks */
|
||||
if (plugin_transaction_validate_all(h, td) < 0)
|
||||
goto done;
|
||||
}
|
||||
/* 6. Call plugin transaction validate callbacks */
|
||||
if (plugin_transaction_validate_all(h, td) < 0)
|
||||
goto done;
|
||||
|
||||
/* 7. Call plugin transaction complete callbacks */
|
||||
if (plugin_transaction_complete_all(h, td) < 0)
|
||||
|
|
@ -598,7 +594,7 @@ candidate_validate(clicon_handle h,
|
|||
if ((td = transaction_new()) == NULL)
|
||||
goto done;
|
||||
/* 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.
|
||||
* (1) xerr is set -> translate to cbret; (2) cbret set use that; otherwise
|
||||
* use clicon_err.
|
||||
|
|
@ -652,7 +648,7 @@ candidate_validate(clicon_handle h,
|
|||
* @param[in] xe Request: <rpc><xn></rpc> (or NULL)
|
||||
* @param[in] db A candidate database, not necessarily "candidate"
|
||||
* @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)
|
||||
* @retval 1 Validation OK
|
||||
* @retval 0 Validation failed (with cbret set)
|
||||
|
|
@ -663,7 +659,7 @@ candidate_commit(clicon_handle h,
|
|||
cxobj *xe,
|
||||
char *db,
|
||||
uint32_t myid,
|
||||
validate_level vlev,
|
||||
validate_level vlev, // obsolete
|
||||
cbuf *cbret)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -679,7 +675,7 @@ candidate_commit(clicon_handle h,
|
|||
/* Common steps (with validate). Load candidate and running and compute diffs
|
||||
* 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;
|
||||
|
||||
/* If the confirmed-commit feature is enabled, execute phase 2:
|
||||
|
|
@ -824,7 +820,7 @@ from_client_commit(clicon_handle h,
|
|||
goto done;
|
||||
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");
|
||||
if (ret < 0)
|
||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
|
|
@ -1091,7 +1087,7 @@ load_failsafe(clicon_handle h,
|
|||
goto done;
|
||||
if (xmldb_db_reset(h, "running") < 0)
|
||||
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 (xmldb_copy(h, "tmp", "running") < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -653,7 +653,7 @@ do_rollback(clicon_handle h,
|
|||
confirmed_commit_persist_id_set(h, NULL);
|
||||
}
|
||||
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
|
||||
* had itself been previously and successfully committed.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue