From ec933537f9b04b35ef4b79fb2b4743f9095da209 Mon Sep 17 00:00:00 2001 From: Mohammad Heib Date: Tue, 2 Aug 2022 17:22:28 +0300 Subject: [PATCH] northd: handle virtual lport type update 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: cd3b685043fa (northd: handle container lport type update) Signed-off-by: Mohammad Heib Acked-by: Dumitru Ceara Signed-off-by: Numan Siddique (cherry picked from commit 49b73c3504f78a26afa84b79c5d52bd9b224348f) --- northd/northd.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index ec21fc7772..3acecfd9f8 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -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; } @@ -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); @@ -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);