From 7558d40faa05e341c839e9d9e3d3f64daa24798a Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Wed, 4 Jan 2023 11:09:44 +0100 Subject: [PATCH] YANG device: allow replace of config bool as special case --- lib/src/clixon_yang.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index 99bc8a66..82baf366 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -2069,18 +2069,27 @@ yang_deviation(yang_stmt *ys, while ((yc = yn_each(yd, yc)) != NULL) { /* The properties to replace MUST exist in the target node.*/ kw = yang_keyword_get(yc); - if ((ytc = yang_find(ytarget, kw, NULL)) == NULL){ - clicon_err(OE_YANG, 0, "deviation %s: \"%s %s\" replaced but node does not exist in target %s", - nodeid, - yang_key2str(kw), yang_argument_get(yc), - yang_argument_get(ytarget)); - goto done; + ytc = yang_find(ytarget, kw, NULL); + switch (kw){ + case Y_CONFIG: /* special case: implicit default is config true */ + break; + default: + if (ytc == NULL){ + clicon_err(OE_YANG, 0, "deviation %s: \"%s %s\" replaced but node does not exist in target %s", + nodeid, + yang_key2str(kw), yang_argument_get(yc), + yang_argument_get(ytarget)); + goto done; + } + break; + } + if (ytc){ + /* Remove old */ + if (ys_prune_self(ytc) < 0) + goto done; + if (ys_free(ytc) < 0) + goto done; } - /* Remove old */ - if (ys_prune_self(ytc) < 0) - goto done; - if (ys_free(ytc) < 0) - goto done; /* Make a copy of deviate child and insert. */ if ((yc1 = ys_dup(yc)) == NULL) goto done;