CLICON_XML_SORT option (in clixon-config.yang) has been removed and set to true permanently since setting it to false is obsolete.

This commit is contained in:
Olof hagsand 2019-01-02 17:43:58 +01:00
parent 0103d58994
commit 32ea957a52
14 changed files with 28 additions and 145 deletions

View file

@ -207,6 +207,8 @@ parse_configfile(clicon_handle h,
*xconfig = xt;
xt = NULL;
done:
if (cbret)
cbuf_free(cbret);
if (xt)
xml_free(xt);
if (f)
@ -275,11 +277,6 @@ clicon_options_main(clicon_handle h,
goto done;
/* Set clixon_conf pointer to handle */
clicon_conf_xml_set(h, xconfig);
/* Specific option handling */
if (clicon_option_bool(h, "CLICON_XML_SORT") == 1)
xml_child_sort = 1;
else
xml_child_sort = 0;
/* XXX Kludge to low-level functions to search for xml in all yang modules */
_CLICON_XML_NS_STRICT = clicon_option_bool(h, "CLICON_XML_NS_STRICT");
retval = 0;

View file

@ -988,8 +988,7 @@ xml_diff1(yang_stmt *ys,
clicon_err(OE_UNIX, errno, "Unknown element: %s", xml_name(x1c));
goto done;
}
/* XXX xml_child_sort is global */
if (match_base_child(x2, x1c, &x2c, xml_child_sort, yc) < 0)
if (match_base_child(x2, x1c, &x2c, yc) < 0)
goto done;
if (x2c == NULL){
if (cxvec_append(x1c, x1vec, x1veclen) < 0)
@ -1025,8 +1024,7 @@ xml_diff1(yang_stmt *ys,
clicon_err(OE_UNIX, errno, "Unknown element: %s", xml_name(x2c));
goto done;
}
/* XXX xml_child_sort is global */
if (match_base_child(x1, x2c, &x1c, xml_child_sort, yc) < 0)
if (match_base_child(x1, x2c, &x1c, yc) < 0)
goto done;
if (x1c == NULL)
if (cxvec_append(x2c, x2vec, x2veclen) < 0)
@ -1550,70 +1548,6 @@ xml_default(cxobj *xt,
return retval;
}
/*! Order XML children according to YANG
* @param[in] xt XML top of tree
* @param[in] arg Dummy (so it can be called from xml_apply)
* @see xml_sort XXX: how do they relate?
* Called from text_get *only*
*/
int
xml_order(cxobj *xt,
void *arg)
{
int retval = -1;
yang_stmt *y;
yang_stmt *yc;
int i;
int j0;
int j;
cxobj *xc;
cxobj *xj;
char *yname; /* yang child name */
char *xname; /* xml child name */
if ((y = (yang_stmt*)xml_spec(xt)) == NULL){
retval = 0;
goto done;
}
j0 = 0;
/* Go through yang node's children and ensure that the
* xml children follow this order.
* Do not order the list or leaf-list children (have same name).
*/
for (i=0; i<y->ys_len; i++){
yc = y->ys_stmt[i];
if (!yang_datanode(yc))
continue;
yname = yc->ys_argument;
/* First go thru xml children with same name in rest of list */
for (; j0<xml_child_nr(xt); j0++){
xc = xml_child_i(xt, j0);
if (xml_type(xc) != CX_ELMNT)
continue;
xname = xml_name(xc);
if (strcmp(xname, yname))
break;
}
/* Now we have children not with same name */
for (j=j0; j<xml_child_nr(xt); j++){
xc = xml_child_i(xt, j);
if (xml_type(xc) != CX_ELMNT)
continue;
xname = xml_name(xc);
if (strcmp(xname, yname))
continue;
/* reorder */
xj = xml_child_i(xt, j0);
xml_child_i_set(xt, j0, xc);
xml_child_i_set(xt, j, xj);
j0++;
}
}
retval = 0;
done:
return retval;
}
/*! Sanitize an xml tree: xml node has matching yang_stmt pointer
* @param[in] xt XML top of tree
*/
@ -2272,7 +2206,7 @@ xml_merge1(cxobj *x0,
}
/* See if there is a corresponding node in the base tree */
x0c = NULL;
if (yc && match_base_child(x0, x1c, &x0c, xml_child_sort, yc) < 0)
if (yc && match_base_child(x0, x1c, &x0c, yc) < 0)
goto done;
if (xml_merge1(x0c, (yang_node*)yc, x0, x1c, reason) < 0)
goto done;
@ -2354,7 +2288,7 @@ xml_merge(cxobj *x0,
break;
}
/* See if there is a corresponding node in the base tree */
if (match_base_child(x0, x1c, &x0c, xml_child_sort, yc) < 0)
if (match_base_child(x0, x1c, &x0c, yc) < 0)
goto done;
if (xml_merge1(x0c, (yang_node*)yc, x0, x1c, reason) < 0)
goto done;

View file

@ -69,13 +69,6 @@
* Variables
*/
/* Sort and binary search of XML children
* XXX kludge since low-level functions xml_merge/xml_diff calls
* match_base_child without handle
* @see clicon_xml_sort
*/
int xml_child_sort = 1;
/*! Given a child name and an XML object, return yang stmt of child
* If no xml parent, find root yang stmt matching name
* @param[in] x Child
@ -267,7 +260,6 @@ xml_cmp1(cxobj *x,
* Assume populated by yang spec.
* @param[in] x0 XML node
* @param[in] arg Dummy so it can be called by xml_apply()
* @see xml_order XXX: how do they relate?
*/
int
xml_sort(cxobj *x,
@ -566,7 +558,6 @@ xml_sort_verify(cxobj *x0,
* param[in] x0 Base tree node
* param[in] x1c Modification tree child
* param[in] yc Yang spec of tree child
* param[in] xml_sort Value of CLICON_XML_SORT option
* param[out] x0cp Matching base tree child (if any)
* @note XXX: room for optimization? on 1K calls we have 1M body calls and
500K xml_child_each/cvec_each calls.
@ -579,7 +570,6 @@ int
match_base_child(cxobj *x0,
cxobj *x1c,
cxobj **x0cp,
int xml_sort,
yang_stmt *yc)
{
int retval = -1;
@ -637,16 +627,12 @@ match_base_child(cxobj *x0,
break;
}
/* Get match. Sorting mode(optimized) or not?*/
if (xml_sort==0)
*x0cp = xml_match(x0, xml_name(x1c), yc->ys_keyword, keynr, keyvec, keyval);
if (xml_child_nr(x0)==0 || xml_spec(xml_child_i(x0,0))!=NULL){
yorder = yang_order(yc);
*x0cp = xml_search(x0, xml_name(x1c), yorder, yc->ys_keyword, keynr, keyvec, keyval);
}
else{
if (xml_child_nr(x0)==0 || xml_spec(xml_child_i(x0,0))!=NULL){
yorder = yang_order(yc);
*x0cp = xml_search(x0, xml_name(x1c), yorder, yc->ys_keyword, keynr, keyvec, keyval);
}
else{
*x0cp = xml_match(x0, xml_name(x1c), yc->ys_keyword, keynr, keyvec, keyval);
}
*x0cp = xml_match(x0, xml_name(x1c), yc->ys_keyword, keynr, keyvec, keyval);
}
ok:
retval = 0;