From d71a3b3db66c8fb2f291d2c90f7f3a7c2e0b9f72 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 12 Jun 2023 00:09:26 +0200 Subject: [PATCH] confd: add support for "replace" operation When toggling settings like 'interfaces/interface/ipv6/enabled', which guards both link-local and all static addresses, the operation is not "create" or "delete", but "replace". Callback must take any "replace" on an 'enabled' node into account since none of the other nodes will be available in the diff. Signed-off-by: Joachim Wiberg --- src/confd/src/lib/lyx.c | 10 +++++++--- src/confd/src/lib/lyx.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/confd/src/lib/lyx.c b/src/confd/src/lib/lyx.c index 598c2984..11db09ac 100644 --- a/src/confd/src/lib/lyx.c +++ b/src/confd/src/lib/lyx.c @@ -17,15 +17,19 @@ enum lydx_op lydx_get_op(struct lyd_node *node) if (opstr && !strcmp(opstr, "delete")) return LYDX_OP_DELETE; + if (opstr && !strcmp(opstr, "replace")) + return LYDX_OP_REPLACE; + return LYDX_OP_NONE; } void lydx_diff_print(struct lydx_diff *nd, FILE *fp) { static const char opchar[] = { - [LYDX_OP_CREATE] = '+', - [LYDX_OP_DELETE] = '-', - [LYDX_OP_NONE] = '%', + [LYDX_OP_CREATE] = '+', + [LYDX_OP_DELETE] = '-', + [LYDX_OP_REPLACE] = '|', + [LYDX_OP_NONE] = '%', }; fprintf(fp, "%c%s %s%s ->%s%s\n", diff --git a/src/confd/src/lib/lyx.h b/src/confd/src/lib/lyx.h index 7d4e91e9..3a3a5ec2 100644 --- a/src/confd/src/lib/lyx.h +++ b/src/confd/src/lib/lyx.h @@ -15,6 +15,7 @@ enum lydx_op { LYDX_OP_NONE, LYDX_OP_CREATE, LYDX_OP_DELETE, + LYDX_OP_REPLACE, }; struct lydx_diff {