[ovs-dev] [PATCH v3 ovn] ovn-nbctl: add --bfd option to lr-route-add
Numan Siddique
numans at ovn.org
Wed Feb 3 10:21:28 UTC 2021
On Sat, Jan 30, 2021 at 4:15 AM Lorenzo Bianconi
<lorenzo.bianconi at redhat.com> wrote:
>
> Introduce the --bfd option to lr-route-add command.
> 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 outport is specified, a new entry in the BFD table
> will be created using the nexthop as dst_ip and outport as logical_port.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
Thanks Lorenzo for v3. I applied this patch to master.
Numan
> ---
> Changes since v2:
> - move BFD entry allocation after possible error condition
> - drop unnecessary xstrdup
>
> Changes since v1:
> - introduce the capability to create the BFD entry if route outport has been
> specified
> ---
> tests/ovn-northd.at | 17 ++++++++++----
> tests/system-ovn.at | 5 ++--
> utilities/ovn-nbctl.8.xml | 11 +++++++++
> utilities/ovn-nbctl.c | 49 ++++++++++++++++++++++++++++++++++++++-
> 4 files changed, 73 insertions(+), 9 deletions(-)
>
> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
> index 8597ca1b9..c00225e99 100644
> --- a/tests/ovn-northd.at
> +++ b/tests/ovn-northd.at
> @@ -2342,7 +2342,7 @@ AT_KEYWORDS([northd-bfd])
> ovn_start
>
> check ovn-nbctl --wait=sb lr-add r0
> -for i in $(seq 1 4); do
> +for i in $(seq 1 5); do
> check ovn-nbctl --wait=sb lrp-add r0 r0-sw$i 00:00:00:00:00:0$i 192.168.$i.1/24
> check ovn-nbctl --wait=sb ls-add sw$i
> check ovn-nbctl --wait=sb lsp-add sw$i sw$i-r0
> @@ -2387,17 +2387,24 @@ 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])
> +
> +check ovn-nbctl --bfd lr-route-add r0 240.0.0.0/8 192.168.50.2 r0-sw5
> +check_column down bfd status logical_port=r0-sw5
> +AT_CHECK([ovn-nbctl lr-route-list r0 | grep 192.168.50.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
>
> ovn-nbctl destroy bfd $uuid
> -check_row_count bfd 2
> +check_row_count bfd 3
>
> AT_CLEANUP
>
> diff --git a/tests/system-ovn.at b/tests/system-ovn.at
> index 4580c05e7..05ccd861a 100644
> --- a/tests/system-ovn.at
> +++ b/tests/system-ovn.at
> @@ -5606,10 +5606,9 @@ NS_CHECK_EXEC([server], [bfdd-control allow 172.16.1.1], [0], [dnl
> Allowing connections from 172.16.1.1
> ])
>
> -uuid=$(ovn-nbctl create bfd logical_port=rp-public dst_ip=172.16.1.50 min_tx=250 min_rx=250 detect_mult=10)
> -check ovn-nbctl lr-route-add R1 100.0.0.0/8 172.16.1.50
> +check ovn-nbctl --bfd lr-route-add R1 100.0.0.0/8 172.16.1.50 rp-public
> +uuid=$(fetch_column nb:bfd _uuid logical_port="rp-public")
> 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 --wait=hv sync
>
> wait_column "up" nb:bfd status logical_port=rp-public
> diff --git a/utilities/ovn-nbctl.8.xml b/utilities/ovn-nbctl.8.xml
> index 6ed8bcb75..2cab592ce 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,16 @@
> 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.
> + If the lookup fails and <var>port</var> is specified, a new entry
> + in the BFD table will be created using the <var>nexthop</var> as
> + <var>dst_ip</var> and <var>port</var> as <var>logical_port</var>.
> + </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..3f28ba11a 100644
> --- a/utilities/ovn-nbctl.c
> +++ b/utilities/ovn-nbctl.c
> @@ -3960,6 +3960,29 @@ 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) {
> + 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;
> @@ -4014,6 +4037,18 @@ nbctl_lr_route_add(struct ctl_context *ctx)
> 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;
> }
> @@ -4038,6 +4073,18 @@ nbctl_lr_route_add(struct ctl_context *ctx)
> }
>
> 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);
> @@ -6551,7 +6598,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
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
More information about the dev
mailing list