diff --git a/src/lib/cmdgen.c b/src/lib/cmdgen.c
index 4490a04..65d9d8a 100644
--- a/src/lib/cmdgen.c
+++ b/src/lib/cmdgen.c
@@ -87,7 +87,7 @@ char *yang_ext_map[] = { [CMD_START_EXT] = "cmd-start",
[VALUE_ONLY_EXT] = "value-only",
[VALUE_ONLY_ON_UPDATE_EXT] = "value-only-on-update",
[AFTER_NODE_ADD_STATIC_ARG_EXT] = "after-node-add-static-arg",
- [ON_NODE_DELETE_EXT] = "on-node-delete",
+ [ON_NODE_DELETE_EXT] = "on-node-delete-or-val-false",
[ADD_LEAF_AT_END] = "add_leaf_at_end",
[NOT_CMD_ARG_EXT] = "not-cmd-arg",
@@ -587,6 +587,19 @@ int create_cmd_arg_name(struct lyd_node *dnode, oper_t startcmd_op_val, char **a
if (get_extension(FLAG_EXT, dnode, NULL) == EXIT_SUCCESS) {
if (!strcmp("true", lyd_get_value(dnode)))
*arg_name = strdup(dnode->schema->name);
+ else if (!strcmp("false", lyd_get_value(dnode))) {
+ char *on_node_delete = NULL;
+ if (get_extension(ON_NODE_DELETE_EXT, dnode, &on_node_delete) == EXIT_SUCCESS) {
+ if (on_node_delete == NULL) {
+ fprintf(stderr,
+ "%s: ipr2cgen:on-leaf-delete extension found but failed to "
+ "get its arg value form node \"%s\"\n",
+ __func__, dnode->schema->name);
+ return EXIT_FAILURE;
+ }
+ *arg_name = on_node_delete;
+ }
+ }
return EXIT_SUCCESS;
}
diff --git a/tests/cases/test_ip_link_data.xml b/tests/cases/test_ip_link_data.xml
index 2f18480..5cac347 100644
--- a/tests/cases/test_ip_link_data.xml
+++ b/tests/cases/test_ip_link_data.xml
@@ -41,6 +41,9 @@
20
testIf2
0 10
+ 1.1.1.4
+ 1.1.1.2
+ true
diff --git a/tests/run_startup_tests.sh b/tests/run_startup_tests.sh
index e1f197e..f4299fc 100755
--- a/tests/run_startup_tests.sh
+++ b/tests/run_startup_tests.sh
@@ -365,7 +365,7 @@ check_vxlan() {
fi
echo "Checking l3miss field"
- if ! echo "$output" | grep -qP "on"; then
+ if ! echo "$output" | grep -qP "true"; then
echo "Error: VXLAN l3miss flag not found for VXLAN interface $1 (FAIL)."
delete_interfaces
exit 1
diff --git a/yang/iproute2-cmdgen-extensions.yang b/yang/iproute2-cmdgen-extensions.yang
index 41cbbb4..b8d367b 100644
--- a/yang/iproute2-cmdgen-extensions.yang
+++ b/yang/iproute2-cmdgen-extensions.yang
@@ -171,7 +171,7 @@ module iproute2-cmdgen-extensions {
"instruct iproute2 to add a static argument, to be used inside containers";
argument "static-arg";
}
- extension on-node-delete{
+ extension on-node-delete-or-val-false{
description
"when the node is deleted the provided 'arg' will be added to cmd,
example is nomaster with removig vrf from link";
diff --git a/yang/iproute2-ip-link.yang b/yang/iproute2-ip-link.yang
index 6e0a56d..e1329a1 100644
--- a/yang/iproute2-ip-link.yang
+++ b/yang/iproute2-ip-link.yang
@@ -342,7 +342,7 @@ module iproute2-ip-link {
grouping link-advance {
leaf master{
- ipr2cgen:on-node-delete "nomaster";
+ ipr2cgen:on-node-delete-or-val-false "nomaster";
type union {
type bond-ref;
type bridge-ref;
@@ -785,7 +785,7 @@ module iproute2-ip-link {
type enumeration{
enum "on";
}
- ipr2cgen:on-node-delete "noencap-remcsum ";
+ ipr2cgen:on-node-delete-or-val-false "noencap-remcsum ";
ipr2cgen:flag;
description
"specifies if UDP checksums are enabled in the secondary encapsulation.";
@@ -794,7 +794,7 @@ module iproute2-ip-link {
type enumeration{
enum "on";
}
- ipr2cgen:on-node-delete "noencap-remcsum";
+ ipr2cgen:on-node-delete-or-val-false "noencap-remcsum";
ipr2cgen:flag;
description
"specifies if Remote Checksum Offload is enabled.
@@ -1124,69 +1124,53 @@ module iproute2-ip-link {
to communicate to the remote VXLAN tunnel endpoint. example: 7770 7779";
}
leaf learning {
- ipr2cgen:on-node-delete "nolearning";
+ ipr2cgen:on-node-delete-or-val-false "nolearning";
ipr2cgen:flag;
- ipr2cgen:oper-value-map "true:on;false:off";
- type enumeration {
- enum "on";
- }
+ type boolean;
description
"specifies if unknown source link layer addresses and IP addresses are entered
into the VXLAN device forwarding database.";
}
leaf rsc {
- ipr2cgen:on-node-delete "norsc";
+ ipr2cgen:on-node-delete-or-val-false "norsc";
ipr2cgen:flag;
ipr2cgen:oper-value-map "true:on";
- type enumeration {
- enum "on";
- }
+ type boolean;
description
"specifies if route short circuit is turned on.";
}
leaf proxy {
- ipr2cgen:on-node-delete "noproxy";
+ ipr2cgen:on-node-delete-or-val-false "noproxy";
ipr2cgen:flag;
ipr2cgen:oper-value-map "true:on";
- type enumeration {
- enum "on";
- }
+ type boolean;
description
"specifies ARP proxy is turned on.";
}
leaf l2miss {
- ipr2cgen:on-node-delete "nol2miss";
+ ipr2cgen:on-node-delete-or-val-false "nol2miss";
ipr2cgen:flag;
- ipr2cgen:oper-value-map "true:on";
- type enumeration {
- enum "on";
- }
+ type boolean;
description
"specifies if netlink LLADDR miss notifications are generated.";
}
leaf l3miss {
- ipr2cgen:on-node-delete "nol3miss";
+ ipr2cgen:on-node-delete-or-val-false "nol3miss";
ipr2cgen:flag;
- ipr2cgen:oper-value-map "true:on";
- type enumeration {
- enum "on";
- }
+ type boolean;
description
"specifies if netlink IP ADDR miss notifications are generated.";
}
leaf udpcsum {
- ipr2cgen:on-node-delete "noudpcsum";
+ ipr2cgen:on-node-delete-or-val-false "noudpcsum";
ipr2cgen:flag;
ipr2cgen:oper-arg-name "udp_csum";
- ipr2cgen:oper-value-map "true:on";
- type enumeration {
- enum "on";
- }
+ type boolean;
description
"specifies if UDP checksum is calculated for transmitted packets over IPv4.";
@@ -1205,24 +1189,18 @@ module iproute2-ip-link {
"NUMBER - specifies the maximum number of FDB entries.";
}
leaf external {
- ipr2cgen:on-node-delete "noexternal";
+ ipr2cgen:on-node-delete-or-val-false "noexternal";
ipr2cgen:flag;
- ipr2cgen:oper-value-map "true:on";
- type enumeration {
- enum "on";
- }
+ type boolean;
description
"specifies whether an external control plane (e.g. ip route encap)
or the internal FDB should be used.";
}
leaf vnifilter {
- ipr2cgen:on-node-delete "novnifilter";
+ ipr2cgen:on-node-delete-or-val-false "novnifilter";
ipr2cgen:flag;
- ipr2cgen:oper-value-map "true:on";
- type enumeration {
- enum "on";
- }
+ type boolean;
description
"specifies whether the vxlan device is capable of vni filtering.
Only works with a vxlan device with external flag set. once enabled,
@@ -1409,7 +1387,7 @@ module iproute2-ip-link {
type enumeration{
enum "on";
}
- ipr2cgen:on-node-delete "noiseq";
+ ipr2cgen:on-node-delete-or-val-false "noiseq";
ipr2cgen:oper-value-map "true:on";
ipr2cgen:flag;
description
@@ -1419,7 +1397,7 @@ module iproute2-ip-link {
type enumeration{
enum "on";
}
- ipr2cgen:on-node-delete "nooseq";
+ ipr2cgen:on-node-delete-or-val-false "nooseq";
ipr2cgen:oper-value-map "true:on";
ipr2cgen:flag;
description
@@ -1429,7 +1407,7 @@ module iproute2-ip-link {
type enumeration{
enum "on";
}
- ipr2cgen:on-node-delete "noicsum";
+ ipr2cgen:on-node-delete-or-val-false "noicsum";
ipr2cgen:oper-value-map "true:on";
ipr2cgen:flag;
description
@@ -1440,7 +1418,7 @@ module iproute2-ip-link {
type enumeration{
enum "on";
}
- ipr2cgen:on-node-delete "noocsum";
+ ipr2cgen:on-node-delete-or-val-false "noocsum";
ipr2cgen:oper-value-map "true:on";
ipr2cgen:flag;
description
@@ -1467,7 +1445,7 @@ module iproute2-ip-link {
type enumeration{
enum "on";
}
- ipr2cgen:on-node-delete "nopmtudisc";
+ ipr2cgen:on-node-delete-or-val-false "nopmtudisc";
ipr2cgen:oper-value-map "true:on";
ipr2cgen:flag;
description
@@ -1479,7 +1457,7 @@ module iproute2-ip-link {
type enumeration{
enum "on";
}
- ipr2cgen:on-node-delete "noignore-df";
+ ipr2cgen:on-node-delete-or-val-false "noignore-df";
ipr2cgen:oper-value-map "true:on";
ipr2cgen:flag;
description