summaryrefslogtreecommitdiff
path: root/lib/filter_nb.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-02-24 00:06:41 +0200
committerIgor Ryzhov <iryzhov@nfware.com>2024-02-24 01:39:18 +0200
commit0b905f740459291bca12e552aea4975fb46e9d98 (patch)
treec557d44049cd49936d6f53d7d700a609b6b8348f /lib/filter_nb.c
parent38b85e0c2bc555b8827dbd2cb6515b6febf548b4 (diff)
lib: fix nb callbacks for containers inside choice case
Containers inside a choice's case must be treated as presence containers as they can be explicitly created and deleted. They must have `create` and `destroy` callbacks, otherwise the internal data they represent may never be deleted. The issue can be reproduced with the following steps: - create an access-list with destination-network params ``` # access-list test seq 1 permit ip any 10.10.10.0 0.0.0.255 ``` - delete the `destination-network` container ``` # mgmt delete-config /frr-filter:lib/access-list[name='test'][type='ipv4']/entry[sequence='1']/destination-network # mgmt commit apply MGMTD: No changes found to be committed! ``` As the `destination-network` container is non-presence, and all its leafs are mandatory, mgmtd doesn't see any changes to be commited and simply updates its YANG data tree without passing any updates to backend daemons. This commit fixes the issue by requiring `create` and `destroy` callbacks for containers inside choice's cases. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/filter_nb.c')
-rw-r--r--lib/filter_nb.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/filter_nb.c b/lib/filter_nb.c
index eba4e421c0..ec31f6d395 100644
--- a/lib/filter_nb.c
+++ b/lib/filter_nb.c
@@ -757,6 +757,32 @@ lib_access_list_entry_host_destroy(struct nb_cb_destroy_args *args)
}
/*
+ * XPath: /frr-filter:lib/access-list/entry/network
+ */
+static int lib_access_list_entry_network_create(struct nb_cb_create_args *args)
+{
+ /* Nothing to do here, everything is done in children callbacks */
+ return NB_OK;
+}
+
+static int lib_access_list_entry_network_destroy(struct nb_cb_destroy_args *args)
+{
+ struct filter_cisco *fc;
+ struct filter *f;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ f = nb_running_get_entry(args->dnode, NULL, true);
+ fc = &f->u.cfilter;
+ cisco_unset_addr_mask(&fc->addr, &fc->addr_mask);
+
+ acl_notify_route_map(f->acl, RMAP_EVENT_FILTER_DELETED);
+
+ return NB_OK;
+}
+
+/*
* XPath: /frr-filter:lib/access-list/entry/network/address
*/
static int
@@ -928,6 +954,35 @@ static int lib_access_list_entry_destination_host_destroy(
}
/*
+ * XPath: /frr-filter:lib/access-list/entry/destination-network
+ */
+static int
+lib_access_list_entry_destination_network_create(struct nb_cb_create_args *args)
+{
+ /* Nothing to do here, everything is done in children callbacks */
+ return NB_OK;
+}
+
+static int lib_access_list_entry_destination_network_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ struct filter_cisco *fc;
+ struct filter *f;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ f = nb_running_get_entry(args->dnode, NULL, true);
+ fc = &f->u.cfilter;
+ fc->extended = 0;
+ cisco_unset_addr_mask(&fc->mask, &fc->mask_mask);
+
+ acl_notify_route_map(f->acl, RMAP_EVENT_FILTER_DELETED);
+
+ return NB_OK;
+}
+
+/*
* XPath: /frr-filter:lib/access-list/entry/destination-network/address
*/
static int lib_access_list_entry_destination_network_address_modify(
@@ -1629,6 +1684,13 @@ const struct frr_yang_module_info frr_filter_info = {
}
},
{
+ .xpath = "/frr-filter:lib/access-list/entry/network",
+ .cbs = {
+ .create = lib_access_list_entry_network_create,
+ .destroy = lib_access_list_entry_network_destroy,
+ }
+ },
+ {
.xpath = "/frr-filter:lib/access-list/entry/network/address",
.cbs = {
.modify = lib_access_list_entry_network_address_modify,
@@ -1655,6 +1717,13 @@ const struct frr_yang_module_info frr_filter_info = {
}
},
{
+ .xpath = "/frr-filter:lib/access-list/entry/destination-network",
+ .cbs = {
+ .create = lib_access_list_entry_destination_network_create,
+ .destroy = lib_access_list_entry_destination_network_destroy,
+ }
+ },
+ {
.xpath = "/frr-filter:lib/access-list/entry/destination-network/address",
.cbs = {
.modify = lib_access_list_entry_destination_network_address_modify,