diff mbox series

[ovs-dev,v6,1/6] northd: Don't cleanup op in ovn_port_allocate_key.

Message ID 20240412015727.4152034-2-ihrachys@redhat.com
State Superseded, archived
Headers show
Series Correct tunnel ids exhaustion scenario. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Ihar Hrachyshka April 12, 2024, 1:57 a.m. UTC
Let the callers do the cleanup as needed.

Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
---
 northd/northd.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/northd/northd.c b/northd/northd.c
index 02cf5b234..f2406890c 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -4006,7 +4006,6 @@  ovn_port_assign_requested_tnl_id(
 
 static bool
 ovn_port_allocate_key(const struct sbrec_chassis_table *sbrec_chassis_table,
-                      struct hmap *ports,
                       struct ovn_port *op)
 {
     if (!op->tunnel_key) {
@@ -4015,11 +4014,6 @@  ovn_port_allocate_key(const struct sbrec_chassis_table *sbrec_chassis_table,
                                             1, (1u << (key_bits - 1)) - 1,
                                             &op->od->port_key_hint);
         if (!op->tunnel_key) {
-            if (op->sb) {
-                sbrec_port_binding_delete(op->sb);
-            }
-            ovs_list_remove(&op->list);
-            ovn_port_destroy(ports, op);
             return false;
         }
     }
@@ -4084,10 +4078,17 @@  build_ports(struct ovsdb_idl_txn *ovnsb_txn,
 
     /* Assign new tunnel ids where needed. */
     LIST_FOR_EACH_SAFE (op, list, &both) {
-        ovn_port_allocate_key(sbrec_chassis_table, ports, op);
+        if (!ovn_port_allocate_key(sbrec_chassis_table, op)) {
+            sbrec_port_binding_delete(op->sb);
+            ovs_list_remove(&op->list);
+            ovn_port_destroy(ports, op);
+        }
     }
     LIST_FOR_EACH_SAFE (op, list, &nb_only) {
-        ovn_port_allocate_key(sbrec_chassis_table, ports, op);
+        if (!ovn_port_allocate_key(sbrec_chassis_table, op)) {
+            ovs_list_remove(&op->list);
+            ovn_port_destroy(ports, op);
+        }
     }
 
     /* For logical ports that are in both databases, update the southbound
@@ -4318,7 +4319,12 @@  ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *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, ls_ports, op)) {
+    if (!ovn_port_allocate_key(sbrec_chassis_table, op)) {
+        if (op->sb) {
+            sbrec_port_binding_delete(op->sb);
+        }
+        ovs_list_remove(&op->list);
+        ovn_port_destroy(ls_ports, op);
         return false;
     }
     ovn_port_update_sbrec(ovnsb_txn, sbrec_chassis_by_name,