diff mbox

[ovs-dev,1/4] Revert "ovn-controller: Use new ovsdb-idl helpers to make logic more readable."

Message ID 1466797931-23871-2-git-send-email-russell@ovn.org
State Superseded
Headers show

Commit Message

Russell Bryant June 24, 2016, 7:52 p.m. UTC
This reverts commit 9a33cd70f4f8bf5922ef05caf32e6da748c57f1a.

Signed-off-by: Russell Bryant <russell@ovn.org>
---
 ovn/controller/binding.c | 11 +++++++----
 ovn/controller/encaps.c  | 19 ++++++++++++++-----
 ovn/controller/lport.c   | 18 ++++++++++++------
 ovsdb/ovsdb-idlc.in      | 12 ------------
 4 files changed, 33 insertions(+), 27 deletions(-)
diff mbox

Patch

diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index 9921a49..e36c8f4 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -266,12 +266,15 @@  binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
         process_full_binding = false;
     } else {
         SBREC_PORT_BINDING_FOR_EACH_TRACKED(binding_rec, ctx->ovnsb_idl) {
-            if (sbrec_port_binding_is_deleted(binding_rec)) {
+            bool is_deleted = sbrec_port_binding_row_get_seqno(binding_rec,
+                OVSDB_IDL_CHANGE_DELETE) > 0;
+
+            if (is_deleted) {
                 remove_local_datapath_by_binding(local_datapaths, binding_rec);
-            } else {
-                consider_local_datapath(ctx, &lports, chassis_rec, binding_rec,
-                                        local_datapaths);
+                continue;
             }
+            consider_local_datapath(ctx, &lports, chassis_rec, binding_rec,
+                                    local_datapaths);
         }
     }
 
diff --git a/ovn/controller/encaps.c b/ovn/controller/encaps.c
index 18268a6..495f8f6 100644
--- a/ovn/controller/encaps.c
+++ b/ovn/controller/encaps.c
@@ -1,4 +1,4 @@ 
-/* Copyright (c) 2015, 2016 Nicira, Inc.
+/* Copyright (c) 2015 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -404,7 +404,12 @@  encaps_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
         process_full_encaps = false;
     } else {
         SBREC_CHASSIS_FOR_EACH_TRACKED (chassis_rec, ctx->ovnsb_idl) {
-            if (sbrec_chassis_is_deleted(chassis_rec)) {
+            bool is_deleted = sbrec_chassis_row_get_seqno(chassis_rec,
+                                                          OVSDB_IDL_CHANGE_DELETE) > 0;
+            bool is_new = sbrec_chassis_row_get_seqno(chassis_rec,
+                                                      OVSDB_IDL_CHANGE_MODIFY) == 0;
+
+            if (is_deleted) {
                 /* Lookup the tunnel by row uuid and remove it. */
                 struct port_hash_node *port_hash =
                     port_lookup_by_uuid(&tc.tunnel_hmap_by_uuid,
@@ -419,10 +424,14 @@  encaps_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
                     free(port_hash);
                     binding_reset_processing();
                 }
-            } else if (sbrec_chassis_is_new(chassis_rec)) {
-                check_and_add_tunnel(chassis_rec, chassis_id);
-            } else {
+                continue;
+            }
+            if (!is_new) {
                 check_and_update_tunnel(chassis_rec);
+                continue;
+            } else {
+                check_and_add_tunnel(chassis_rec, chassis_id);
+                continue;
             }
         }
     }
diff --git a/ovn/controller/lport.c b/ovn/controller/lport.c
index a5e9ad3..2ce6387 100644
--- a/ovn/controller/lport.c
+++ b/ovn/controller/lport.c
@@ -107,11 +107,14 @@  lport_index_fill(struct lport_index *lports, struct ovsdb_idl *ovnsb_idl)
         full_lport_rebuild = false;
     } else {
         SBREC_PORT_BINDING_FOR_EACH_TRACKED (pb, ovnsb_idl) {
-            if (sbrec_port_binding_is_deleted(pb)) {
+            bool is_delete = sbrec_port_binding_row_get_seqno(pb,
+                OVSDB_IDL_CHANGE_DELETE) > 0;
+
+            if (is_delete) {
                 lport_index_remove(lports, &pb->header_.uuid);
-            } else {
-                consider_lport_index(lports, pb);
+                continue;
             }
+            consider_lport_index(lports, pb);
         }
     }
 }
@@ -245,11 +248,14 @@  mcgroup_index_fill(struct mcgroup_index *mcgroups, struct ovsdb_idl *ovnsb_idl)
         full_mc_rebuild = false;
     } else {
         SBREC_MULTICAST_GROUP_FOR_EACH_TRACKED (mg, ovnsb_idl) {
-            if (sbrec_multicast_group_is_deleted(mg)) {
+            bool is_delete = sbrec_multicast_group_row_get_seqno(mg,
+                OVSDB_IDL_CHANGE_DELETE) > 0;
+
+            if (is_delete) {
                 mcgroup_index_remove(mcgroups, &mg->header_.uuid);
-            } else {
-                consider_mcgroup_index(mcgroups, mg);
+                continue;
             }
+            consider_mcgroup_index(mcgroups, mg);
         }
     }
 }
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 0d836c0..19a86dc 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -186,18 +186,6 @@  const struct %(s)s *%(s)s_track_get_next(const struct %(s)s *);
              (ROW); \\
              (ROW) = %(s)s_track_get_next(ROW))
 
-/* Returns true if 'row' was inserted since the last change tracking reset. */
-static inline bool %(s)s_is_new(const struct %(s)s *row)
-{
-    return %(s)s_row_get_seqno(row, OVSDB_IDL_CHANGE_MODIFY) == 0;
-}
-
-/* Returns true if 'row' was deleted since the last change tracking reset. */
-static inline bool %(s)s_is_deleted(const struct %(s)s *row)
-{
-    return %(s)s_row_get_seqno(row, OVSDB_IDL_CHANGE_DELETE) > 0;
-}
-
 void %(s)s_init(struct %(s)s *);
 void %(s)s_delete(const struct %(s)s *);
 struct %(s)s *%(s)s_insert(struct ovsdb_idl_txn *);