Correct me if I'm wrong, but couldn't this be done automatically by just
setting "isRoot: false" for the BFD table in ovn-nb.ovsschema?
On 3/1/21 8:12 AM, Lorenzo Bianconi wrote:
Remove BFD entry if its the last reference in static_routes table has
been removed.
Signed-off-by: Lorenzo Bianconi <[email protected]>
---
tests/ovn-nbctl.at | 11 ++++++++---
utilities/ovn-nbctl.c | 17 +++++++++++++++++
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at
index 6d91aa4c5..e9aeaa6e5 100644
--- a/tests/ovn-nbctl.at
+++ b/tests/ovn-nbctl.at
@@ -1633,10 +1633,15 @@ IPv6 Routes
])
AT_CHECK([ovn-nbctl lrp-add lr0 lr0-p0 00:00:01:01:02:03 192.168.10.1/24])
-bfd_uuid=$(ovn-nbctl create bfd logical_port=lr0-p0 dst_ip=100.0.0.50
status=down min_tx=250 min_rx=250 detect_mult=10)
-AT_CHECK([ovn-nbctl lr-route-add lr0 100.0.0.0/24 192.168.0.1])
+bfd_uuid=$(ovn-nbctl create bfd logical_port=lr0-p0 dst_ip=192.168.10.2
status=down min_tx=250 min_rx=250 detect_mult=10)
+AT_CHECK([ovn-nbctl lr-route-add lr0 100.0.0.0/24 192.168.10.2])
route_uuid=$(fetch_column nb:logical_router_static_route _uuid
ip_prefix="100.0.0.0/24")
-AT_CHECK([ovn-nbctl set logical_router_static_route $route_uuid
bfd=$bfd_uuid])])
+AT_CHECK([ovn-nbctl set logical_router_static_route $route_uuid bfd=$bfd_uuid])
+AT_CHECK([ovn-nbctl --bfd lr-route-add lr0 200.0.0.0/24 192.168.10.2 lr0-p0])
+AT_CHECK([ovn-nbctl lr-route-del lr0 100.0.0.0/24 192.168.10.2])
+check_row_count nb:BFD 1
+AT_CHECK([ovn-nbctl lr-route-del lr0 200.0.0.0/24 192.168.10.2])
+check_row_count nb:BFD 0])
dnl ---------------------------------------------------------------------
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
index 2c77f4ba7..5ea6c6249 100644
--- a/utilities/ovn-nbctl.c
+++ b/utilities/ovn-nbctl.c
@@ -4211,6 +4211,23 @@ nbctl_lr_route_del(struct ctl_context *ctx)
}
}
+ if (lr->static_routes[i]->bfd) {
+ /* Check if this is the last reference to the BFD entry. */
+ size_t j;
+
+ for (j = 0; j < lr->n_static_routes; j++) {
+ if (lr->static_routes[j] == lr->static_routes[i]) {
+ continue;
+ }
+ if (lr->static_routes[j]->bfd == lr->static_routes[i]->bfd) {
+ break;
+ }
+ }
+ if (j == lr->n_static_routes) {
+ nbrec_bfd_delete(lr->static_routes[i]->bfd);
+ }
+ }
+
/* Everything matched. Removing. */
nbrec_logical_router_update_static_routes_delvalue(
lr, lr->static_routes[i]);
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev