From: Ihar Hrachyshka <ihrac...@redhat.com> This allows callers to avoid cleanup of the record in case the function fails.
Signed-off-by: Ihar Hrachyshka <ihrac...@redhat.com> Signed-off-by: Numan Siddique <num...@ovn.org> Acked-by: Mark Michelson <mmich...@redhat.com> (cherry picked from commit 77ed4be62f1802672cced672477d48d6e7c7424e) --- northd/northd.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 0e4b3b8460..c84b3ee009 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -4340,12 +4340,19 @@ ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, if (!ovn_port_assign_requested_tnl_id(sbrec_chassis_table, op)) { return false; } + /* Keep nonconflicting tunnel IDs that are already assigned. */ if (sb) { - op->sb = sb; - /* Keep nonconflicting tunnel IDs that are already assigned. */ if (!op->tunnel_key) { - ovn_port_add_tnlid(op, op->sb->tunnel_key); + ovn_port_add_tnlid(op, sb->tunnel_key); } + } + /* Assign new tunnel ids where needed. */ + if (!ovn_port_allocate_key(sbrec_chassis_table, op)) { + return false; + } + /* Create new binding, if needed. */ + if (sb) { + op->sb = sb; } else { /* XXX: the new SB port_binding will change in IDL, so need to handle * SB port_binding updates incrementally to achieve end-to-end @@ -4353,10 +4360,6 @@ ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, op->sb = sbrec_port_binding_insert(ovnsb_txn); sbrec_port_binding_set_logical_port(op->sb, op->key); } - /* Assign new tunnel ids where needed. */ - if (!ovn_port_allocate_key(sbrec_chassis_table, op)) { - return false; - } ovn_port_update_sbrec(ovnsb_txn, sbrec_chassis_by_name, sbrec_chassis_by_hostname, NULL, sbrec_mirror_table, op, NULL, NULL); @@ -4378,9 +4381,6 @@ ls_port_create(struct ovsdb_idl_txn *ovnsb_txn, struct hmap *ls_ports, if (!ls_port_init(op, ovnsb_txn, od, sb, sbrec_mirror_table, sbrec_chassis_table, sbrec_chassis_by_name, sbrec_chassis_by_hostname)) { - if (op->sb) { - sbrec_port_binding_delete(op->sb); - } ovn_port_destroy(ls_ports, op); return NULL; } @@ -4586,8 +4586,8 @@ ls_handle_lsp_changes(struct ovsdb_idl_txn *ovnsb_idl_txn, ni->sbrec_chassis_table, ni->sbrec_chassis_by_name, ni->sbrec_chassis_by_hostname)) { - if (op->sb) { - sbrec_port_binding_delete(op->sb); + if (sb) { + sbrec_port_binding_delete(sb); } ovn_port_destroy(&nd->ls_ports, op); goto fail; -- 2.49.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev