summaryrefslogtreecommitdiff
path: root/ovn
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-06-08 14:51:12 -0700
committerBen Pfaff <blp@ovn.org>2018-06-12 08:24:25 -0700
commit05702a4b81aa6de70f433b5d99535227285764b3 (patch)
tree192e84a4d2b3334c08af83c78bb9701f8839a127 /ovn
parent789ddafa8b91ebafef5cda1f1e4d54b75fe20f83 (diff)
downloadopenvswitch-05702a4b81aa6de70f433b5d99535227285764b3.tar.gz
ovn-controller: Use chassis_lookup_by_name() instead of get_chassis().
This was duplicate functionality. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Han Zhou <hzhou8@ebay.com>
Diffstat (limited to 'ovn')
-rw-r--r--ovn/controller/chassis.c5
-rw-r--r--ovn/controller/chassis.h6
-rw-r--r--ovn/controller/ovn-controller.c24
-rw-r--r--ovn/controller/ovn-controller.h3
4 files changed, 11 insertions, 27 deletions
diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c
index c509e2fca..db5d2d03d 100644
--- a/ovn/controller/chassis.c
+++ b/ovn/controller/chassis.c
@@ -22,6 +22,7 @@
#include "lib/vswitch-idl.h"
#include "openvswitch/dynamic-string.h"
#include "openvswitch/vlog.h"
+#include "ovn/lib/chassis-index.h"
#include "ovn/lib/ovn-sb-idl.h"
#include "ovn-controller.h"
#include "lib/util.h"
@@ -76,8 +77,8 @@ get_cms_options(const struct smap *ext_ids)
* amenable to a transaction. */
const struct sbrec_chassis *
chassis_run(struct controller_ctx *ctx,
+ struct ovsdb_idl_index *sbrec_chassis_by_name,
const struct ovsrec_open_vswitch_table *ovs_table,
- const struct sbrec_chassis_table *chassis_table,
const char *chassis_id,
const struct ovsrec_bridge *br_int)
{
@@ -139,7 +140,7 @@ chassis_run(struct controller_ctx *ctx,
const char *iface_types_str = ds_cstr(&iface_types);
const struct sbrec_chassis *chassis_rec
- = get_chassis(chassis_table, chassis_id);
+ = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
const char *encap_csum = smap_get_def(&cfg->external_ids,
"ovn-encap-csum", "true");
if (chassis_rec) {
diff --git a/ovn/controller/chassis.h b/ovn/controller/chassis.h
index 6d4787854..f5245c363 100644
--- a/ovn/controller/chassis.h
+++ b/ovn/controller/chassis.h
@@ -20,6 +20,7 @@
struct controller_ctx;
struct ovsdb_idl;
+struct ovsdb_idl_index;
struct ovsrec_bridge;
struct ovsrec_open_vswitch_table;
struct sbrec_chassis;
@@ -27,8 +28,9 @@ struct sbrec_chassis_table;
void chassis_register_ovs_idl(struct ovsdb_idl *);
const struct sbrec_chassis *chassis_run(
- struct controller_ctx *, const struct ovsrec_open_vswitch_table *,
- const struct sbrec_chassis_table *,
+ struct controller_ctx *,
+ struct ovsdb_idl_index *sbrec_chassis_by_name,
+ const struct ovsrec_open_vswitch_table *,
const char *chassis_id, const struct ovsrec_bridge *br_int);
bool chassis_cleanup(struct controller_ctx *, const struct sbrec_chassis *);
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index cd4208556..1754c51a0 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -94,21 +94,6 @@ get_local_datapath(const struct hmap *local_datapaths, uint32_t tunnel_key)
: NULL);
}
-const struct sbrec_chassis *
-get_chassis(const struct sbrec_chassis_table *chassis_table,
- const char *chassis_id)
-{
- const struct sbrec_chassis *chassis_rec;
-
- SBREC_CHASSIS_TABLE_FOR_EACH (chassis_rec, chassis_table) {
- if (!strcmp(chassis_rec->name, chassis_id)) {
- break;
- }
- }
-
- return chassis_rec;
-}
-
uint32_t
get_tunnel_type(const char *name)
{
@@ -691,9 +676,8 @@ main(int argc, char *argv[])
const struct sbrec_chassis *chassis = NULL;
if (chassis_id) {
- chassis = chassis_run(&ctx,
+ chassis = chassis_run(&ctx, sbrec_chassis_by_name,
ovsrec_open_vswitch_table_get(ctx.ovs_idl),
- sbrec_chassis_table_get(ctx.ovnsb_idl),
chassis_id, br_int);
encaps_run(&ctx,
ovsrec_bridge_table_get(ctx.ovs_idl), br_int,
@@ -881,8 +865,6 @@ main(int argc, char *argv[])
const struct ovsrec_open_vswitch_table *ovs_table
= ovsrec_open_vswitch_table_get(ctx.ovs_idl);
- const struct sbrec_chassis_table *chassis_table
- = sbrec_chassis_table_get(ctx.ovnsb_idl);
const struct sbrec_port_binding_table *port_binding_table
= sbrec_port_binding_table_get(ctx.ovnsb_idl);
@@ -890,7 +872,9 @@ main(int argc, char *argv[])
ovs_table);
const char *chassis_id = get_chassis_id(ovs_table);
const struct sbrec_chassis *chassis
- = chassis_id ? get_chassis(chassis_table, chassis_id) : NULL;
+ = (chassis_id
+ ? chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id)
+ : NULL);
/* Run all of the cleanup functions, even if one of them returns false.
* We're done if all of them return true. */
diff --git a/ovn/controller/ovn-controller.h b/ovn/controller/ovn-controller.h
index 7a172a787..6f4e96188 100644
--- a/ovn/controller/ovn-controller.h
+++ b/ovn/controller/ovn-controller.h
@@ -78,9 +78,6 @@ struct local_datapath *get_local_datapath(const struct hmap *,
const struct ovsrec_bridge *get_bridge(const struct ovsrec_bridge_table *,
const char *br_name);
-const struct sbrec_chassis *get_chassis(const struct sbrec_chassis_table *,
- const char *chassis_id);
-
/* Must be a bit-field ordered from most-preferred (higher number) to
* least-preferred (lower number). */
enum chassis_tunnel_type {