Introduce the --bfd option to lr-route-add-bfd. If the BFD session UUID is provided, it will be used for the OVN route otherwise the next-hop will be used to perform a lookup in the OVN BFD table.
Signed-off-by: Lorenzo Bianconi <[email protected]> --- tests/ovn-northd.at | 9 ++++++--- utilities/ovn-nbctl.8.xml | 8 ++++++++ utilities/ovn-nbctl.c | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 8597ca1b9..4edeac985 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -2387,12 +2387,15 @@ check_column 1000 bfd min_tx logical_port=r0-sw1 check_column 1000 bfd min_rx logical_port=r0-sw1 check_column 100 bfd detect_mult logical_port=r0-sw1 -check ovn-nbctl lr-route-add r0 100.0.0.0/8 192.168.10.2 -route_uuid=$(fetch_column nb:logical_router_static_route _uuid ip_prefix="100.0.0.0/8") -check ovn-nbctl set logical_router_static_route $route_uuid bfd=$uuid +check ovn-nbctl --bfd=$uuid lr-route-add r0 100.0.0.0/8 192.168.10.2 check_column down bfd status logical_port=r0-sw1 AT_CHECK([ovn-nbctl lr-route-list r0 | grep 192.168.10.2 | grep -q bfd],[0]) +check ovn-nbctl --bfd lr-route-add r0 200.0.0.0/8 192.168.20.2 +check_column down bfd status logical_port=r0-sw2 +AT_CHECK([ovn-nbctl lr-route-list r0 | grep 192.168.20.2 | grep -q bfd],[0]) + +route_uuid=$(fetch_column nb:logical_router_static_route _uuid ip_prefix="100.0.0.0/8") check ovn-nbctl clear logical_router_static_route $route_uuid bfd check_column admin_down bfd status logical_port=r0-sw1 diff --git a/utilities/ovn-nbctl.8.xml b/utilities/ovn-nbctl.8.xml index 6ed8bcb75..cab28b24e 100644 --- a/utilities/ovn-nbctl.8.xml +++ b/utilities/ovn-nbctl.8.xml @@ -659,6 +659,7 @@ <dl> <dt>[<code>--may-exist</code>] [<code>--policy</code>=<var>POLICY</var>] [<code>--ecmp</code>] [<code>--ecmp-symmetric-reply</code>] + [<code>--bfd=<var>UUID</var></code>] <code>lr-route-add</code> <var>router</var> <var>prefix</var> <var>nexthop</var> [<var>port</var>]</dt> <dd> @@ -695,6 +696,13 @@ it is not necessary to set both. </p> + <p> + <code>--bfd</code> option is used to link a BFD session to the + OVN route. If the BFD session UUID is provided, it will be used + for the OVN route otherwise the next-hop will be used to perform + a lookup in the OVN BFD table. + </p> + <p> It is an error if a route with <var>prefix</var> and <var>POLICY</var> already exists, unless <code>--may-exist</code>, diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index 1b7be1ef9..d9b8b7ded 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -3960,6 +3960,31 @@ nbctl_lr_route_add(struct ctl_context *ctx) goto cleanup; } + struct shash_node *bfd = shash_find(&ctx->options, "--bfd"); + const struct nbrec_bfd *nb_bt = NULL; + if (bfd) { + if (bfd->data) { + char *data = xstrdup(bfd->data); + struct uuid bfd_uuid; + if (uuid_from_string(&bfd_uuid, data)) { + nb_bt = nbrec_bfd_get_for_uuid(ctx->idl, &bfd_uuid); + } + free(data); + } else { + const struct nbrec_bfd *iter; + NBREC_BFD_FOR_EACH (iter, ctx->idl) { + if (!strcmp(iter->dst_ip, next_hop)) { + nb_bt = iter; + break; + } + } + } + if (!nb_bt) { + ctl_error(ctx, "no entry found in the BFD table"); + goto cleanup; + } + } + bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL; bool ecmp_symmetric_reply = shash_find(&ctx->options, "--ecmp-symmetric-reply") != NULL; @@ -4007,6 +4032,9 @@ nbctl_lr_route_add(struct ctl_context *ctx) nbrec_logical_router_static_route_verify_nexthop(route); nbrec_logical_router_static_route_set_ip_prefix(route, prefix); nbrec_logical_router_static_route_set_nexthop(route, next_hop); + if (nb_bt) { + nbrec_logical_router_static_route_set_bfd(route, nb_bt); + } if (ctx->argc == 5) { nbrec_logical_router_static_route_set_output_port( route, ctx->argv[4]); @@ -4038,6 +4066,9 @@ nbctl_lr_route_add(struct ctl_context *ctx) } nbrec_logical_router_update_static_routes_addvalue(lr, route); + if (nb_bt) { + nbrec_logical_router_static_route_set_bfd(route, nb_bt); + } cleanup: free(next_hop); @@ -6551,7 +6582,7 @@ static const struct ctl_command_syntax nbctl_commands[] = { /* logical router route commands. */ { "lr-route-add", 3, 4, "ROUTER PREFIX NEXTHOP [PORT]", NULL, nbctl_lr_route_add, NULL, "--may-exist,--ecmp,--ecmp-symmetric-reply," - "--policy=", RW }, + "--policy=,--bfd?", RW }, { "lr-route-del", 1, 4, "ROUTER [PREFIX [NEXTHOP [PORT]]]", NULL, nbctl_lr_route_del, NULL, "--if-exists,--policy=", RW }, { "lr-route-list", 1, 1, "ROUTER", NULL, nbctl_lr_route_list, NULL, -- 2.29.2 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
