Skip to content

Commit

Permalink
ovn-nbctl: Fix removal of BFD entry on route deletion
Browse files Browse the repository at this point in the history
When creating a route with BFD, ovn-nbctl creates an entry both
in the Logical_Router_Static_Route and BFD tables.

However, before this patch, removing a route does not remove the
corresponding entry in the BFD table.

Fixes: c23a468 ("ovn-nbctl: add --bfd option to lr-route-add")
Reported-at: https://bugs.launchpad.net/ubuntu/+source/ovn/+bug/1998617
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
(cherry picked from commit 3755838)
  • Loading branch information
fnordahl authored and numansiddique committed Dec 6, 2022
1 parent 730dd68 commit b374438
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/ovn-nbctl.at
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,7 @@ AT_CHECK([ovn-nbctl lr-route-add lr0 0.0.0.0/0 192.168.0.1])
AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.1.0/24 11.0.1.1 lp0])
AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.2])
AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.10.0/24 lp0])
AT_CHECK([ovn-nbctl --bfd lr-route-add lr0 10.0.20.0/24 11.0.2.1 lp0])
AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.10.0/24 lp1], [1], [],
[ovn-nbctl: bad IPv4 nexthop argument: lp1
])
Expand Down Expand Up @@ -1544,13 +1545,18 @@ Route Table <main>:
10.0.0.0/24 11.0.0.1 dst-ip
10.0.1.0/24 11.0.1.1 dst-ip lp0
10.0.10.0/24 dst-ip lp0
10.0.20.0/24 11.0.2.1 dst-ip lp0 bfd
20.0.0.0/24 discard dst-ip
9.16.1.0/24 11.0.0.1 src-ip
10.0.0.0/24 11.0.0.2 src-ip
20.0.0.0/24 discard src-ip
0.0.0.0/0 192.168.0.1 dst-ip
])

check_row_count nb:BFD 1
AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.20.0/24])
check_row_count nb:BFD 0

AT_CHECK([ovn-nbctl lrp-add lr0 lp1 f0:00:00:00:00:02 11.0.0.254/24])
AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1 lp1])
AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
Expand Down
8 changes: 7 additions & 1 deletion utilities/ovn-nbctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4359,6 +4359,8 @@ nbctl_pre_lr_route_del(struct ctl_context *ctx)

ovsdb_idl_add_column(ctx->idl,
&nbrec_logical_router_static_route_col_policy);
ovsdb_idl_add_column(ctx->idl,
&nbrec_logical_router_static_route_col_bfd);
ovsdb_idl_add_column(ctx->idl,
&nbrec_logical_router_static_route_col_ip_prefix);
ovsdb_idl_add_column(ctx->idl,
Expand All @@ -4371,7 +4373,7 @@ nbctl_pre_lr_route_del(struct ctl_context *ctx)
}

static void
nbctl_lr_route_del(struct ctl_context *ctx)
nbctl_lr_route_del(struct ctl_context *ctx)
{
const struct nbrec_logical_router *lr;
char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr);
Expand Down Expand Up @@ -4488,6 +4490,10 @@ nbctl_lr_route_del(struct ctl_context *ctx)
}

/* Everything matched. Removing. */
if (lr->static_routes[i]->bfd) {
nbrec_bfd_delete(lr->static_routes[i]->bfd);
}

nbrec_logical_router_update_static_routes_delvalue(
lr, lr->static_routes[i]);
n_removed++;
Expand Down

0 comments on commit b374438

Please sign in to comment.