Skip to content

Commit

Permalink
northd: handle virtual lport type update
Browse files Browse the repository at this point in the history
ovn-northd re-create sbrec row for lport of type
virtual when the type explicitly updated in NBDB.

This approach was applied to handle container lport
type updates and avoid handling issues in the ovn-controller,
this patch expanded that approach to handle lport of type
virtual in the same way.

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2099288
Fixes: cd3b685 (northd: handle container lport type update)
Signed-off-by: Mohammad Heib <mheib@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
(cherry picked from commit 49b73c3)
  • Loading branch information
mohammadheib authored and numansiddique committed Aug 2, 2022
1 parent 822f78a commit ec93353
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions northd/northd.c
Expand Up @@ -1815,9 +1815,9 @@ lsp_is_router(const struct nbrec_logical_switch_port *nbsp)
static bool
lsp_is_type_changed(const struct sbrec_port_binding *sb,
const struct nbrec_logical_switch_port *nbsp,
bool *is_old_container_lport)
bool *update_sbrec)
{
*is_old_container_lport = false;
*update_sbrec = false;
if (!sb || !nbsp) {
return false;
}
Expand All @@ -1829,13 +1829,19 @@ lsp_is_type_changed(const struct sbrec_port_binding *sb,
*/
if ((!sb->parent_port && nbsp->parent_name) ||
(sb->parent_port && !nbsp->parent_name)) {
*is_old_container_lport = true;
*update_sbrec = true;
return true;
} else {
return false;
}
}

/* Cover cases where port changed to/from virtual port */
if (!strcmp(sb->type, "virtual") ||
!strcmp(nbsp->type, "virtual")) {
*update_sbrec = true;
}

/* Both lports are not "VIF's" it is safe to use strcmp. */
if (sb->type[0] && nbsp->type[0]) {
return strcmp(sb->type, nbsp->type);
Expand Down Expand Up @@ -2536,19 +2542,18 @@ join_logical_ports(struct northd_input *input_data,
* created one and recompute everything that is needed
* for this lport.
*
* This change will affect container lport type changes
* only for now, this change is needed in container
* lport cases to avoid port type conflicts in the
* ovn-controller when the user clears the parent_port
* field in the container lport.
* This change will affect container/virtual lport type
* changes only for now, this change is needed in
* contaier/virtual lport cases to avoid port type
* conflicts in the ovn-controller when the user clears
* the parent_port field in the container lport or updated
* the lport type.
*
* This approach can be applied to all other lport types
* changes by removing the is_old_container_lport.
*/
bool is_old_container_lport = false;
bool update_sbrec = false;
if (op->sb && lsp_is_type_changed(op->sb, nbsp,
&is_old_container_lport)
&& is_old_container_lport) {
&update_sbrec)
&& update_sbrec) {
ovs_list_remove(&op->list);
sbrec_port_binding_delete(op->sb);
ovn_port_destroy(ports, op);
Expand Down

0 comments on commit ec93353

Please sign in to comment.