From 97b58dde0f92fc83165a6db816456073f5ddf727 Mon Sep 17 00:00:00 2001
Message-Id: <97b58dde0f92fc83165a6db816456073f5ddf727.1612349784.git.lorenzo.bianconi@redhat.com>
From: Lorenzo Bianconi
--may-exist
] [--policy
=POLICY]
[--ecmp
] [--ecmp-symmetric-reply
]
+ [--bfd[=UUID
]]
lr-route-add
router
prefix nexthop [port]
+ --bfd
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.
+ If the lookup fails and port is specified, a new entry
+ in the BFD table will be created using the nexthop as
+ dst_ip and port as logical_port.
+
It is an error if a route with prefix and
POLICY already exists, unless --may-exist
,
--ecmp
, or --ecmp-symmetric-reply
is
--- a/utilities/ovn-nbctl.c
+++ b/utilities/ovn-nbctl.c
@@ -3957,6 +3957,29 @@ nbctl_lr_route_add(struct ctl_context *c
goto cleanup;
}
+ struct shash_node *bfd = shash_find(&ctx->options, "--bfd");
+ const struct nbrec_bfd *nb_bt = NULL;
+ if (bfd) {
+ if (bfd->data) {
+ struct uuid bfd_uuid;
+ if (uuid_from_string(&bfd_uuid, bfd->data)) {
+ nb_bt = nbrec_bfd_get_for_uuid(ctx->idl, &bfd_uuid);
+ }
+ if (!nb_bt) {
+ ctl_error(ctx, "no entry found in the BFD table");
+ goto cleanup;
+ }
+ } else {
+ const struct nbrec_bfd *iter;
+ NBREC_BFD_FOR_EACH (iter, ctx->idl) {
+ if (!strcmp(iter->dst_ip, next_hop)) {
+ nb_bt = iter;
+ break;
+ }
+ }
+ }
+ }
+
bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
bool ecmp_symmetric_reply = shash_find(&ctx->options,
"--ecmp-symmetric-reply") != NULL;
@@ -4011,6 +4034,18 @@ nbctl_lr_route_add(struct ctl_context *c
if (policy) {
nbrec_logical_router_static_route_set_policy(route, policy);
}
+ if (bfd) {
+ if (!nb_bt) {
+ if (ctx->argc != 5) {
+ ctl_error(ctx, "insert entry in the BFD table failed");
+ goto cleanup;
+ }
+ nb_bt = nbrec_bfd_insert(ctx->txn);
+ nbrec_bfd_set_dst_ip(nb_bt, next_hop);
+ nbrec_bfd_set_logical_port(nb_bt, ctx->argv[4]);
+ }
+ nbrec_logical_router_static_route_set_bfd(route, nb_bt);
+ }
free(rt_prefix);
goto cleanup;
}
@@ -4035,6 +4070,18 @@ nbctl_lr_route_add(struct ctl_context *c
}
nbrec_logical_router_update_static_routes_addvalue(lr, route);
+ if (bfd) {
+ if (!nb_bt) {
+ if (ctx->argc != 5) {
+ ctl_error(ctx, "insert entry in the BFD table failed");
+ goto cleanup;
+ }
+ nb_bt = nbrec_bfd_insert(ctx->txn);
+ nbrec_bfd_set_dst_ip(nb_bt, next_hop);
+ nbrec_bfd_set_logical_port(nb_bt, ctx->argv[4]);
+ }
+ nbrec_logical_router_static_route_set_bfd(route, nb_bt);
+ }
cleanup:
free(next_hop);
@@ -6548,7 +6595,7 @@ static const struct ctl_command_syntax n
/* 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,