Skip to content

Commit

Permalink
ovn-controller: Rename init functions that just register IDL columns.
Browse files Browse the repository at this point in the history
The generic *_init() names for these functions made it sounds like they
do something more than just register IDL columns, even though that's all
they do.  Also, the controller_ctx that was passed into each of them was
only used to get the IDL handle.  This commit renames them and changes
their parameter type to simplify and make all of this clearer.

Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Justin Pettit <[email protected]>
  • Loading branch information
blp committed Jul 30, 2015
1 parent 30a4256 commit 4a5a9e0
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 48 deletions.
24 changes: 12 additions & 12 deletions ovn/controller/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
VLOG_DEFINE_THIS_MODULE(binding);

void
binding_init(struct controller_ctx *ctx)
binding_register_ovs_idl(struct ovsdb_idl *ovs_idl)
{
ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_open_vswitch);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_open_vswitch_col_bridges);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_open_vswitch);
ovsdb_idl_add_column(ovs_idl, &ovsrec_open_vswitch_col_bridges);

ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_bridge);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_bridge_col_name);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_bridge_col_ports);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_bridge);
ovsdb_idl_add_column(ovs_idl, &ovsrec_bridge_col_name);
ovsdb_idl_add_column(ovs_idl, &ovsrec_bridge_col_ports);

ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_port);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_port_col_name);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_port_col_interfaces);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_port);
ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_name);
ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_interfaces);

ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_interface);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_interface_col_name);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_interface_col_external_ids);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_interface);
ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_name);
ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_external_ids);
}

static void
Expand Down
3 changes: 2 additions & 1 deletion ovn/controller/binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
#include <stdbool.h>

struct controller_ctx;
struct ovsdb_idl;
struct ovsrec_bridge;

void binding_init(struct controller_ctx *);
void binding_register_ovs_idl(struct ovsdb_idl *);
void binding_run(struct controller_ctx *, const struct ovsrec_bridge *br_int,
const char *chassis_id);
bool binding_cleanup(struct controller_ctx *, const char *chassis_id);
Expand Down
6 changes: 3 additions & 3 deletions ovn/controller/chassis.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
VLOG_DEFINE_THIS_MODULE(chassis);

void
chassis_init(struct controller_ctx *ctx)
chassis_register_ovs_idl(struct ovsdb_idl *ovs_idl)
{
ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_open_vswitch);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_open_vswitch_col_external_ids);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_open_vswitch);
ovsdb_idl_add_column(ovs_idl, &ovsrec_open_vswitch_col_external_ids);
}

void
Expand Down
3 changes: 2 additions & 1 deletion ovn/controller/chassis.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
#include <stdbool.h>

struct controller_ctx;
struct ovsdb_idl;
struct ovsrec_bridge;

void chassis_init(struct controller_ctx *);
void chassis_register_ovs_idl(struct ovsdb_idl *);
void chassis_run(struct controller_ctx *, const char *chassis_id);
bool chassis_cleanup(struct controller_ctx *, const char *chassis_id);

Expand Down
22 changes: 11 additions & 11 deletions ovn/controller/encaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
VLOG_DEFINE_THIS_MODULE(encaps);

void
encaps_init(struct controller_ctx *ctx)
encaps_register_ovs_idl(struct ovsdb_idl *ovs_idl)
{
ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_bridge);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_bridge_col_ports);
ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_port);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_port_col_name);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_port_col_interfaces);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_port_col_external_ids);
ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_interface);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_interface_col_name);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_interface_col_type);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_interface_col_options);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_bridge);
ovsdb_idl_add_column(ovs_idl, &ovsrec_bridge_col_ports);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_port);
ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_name);
ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_interfaces);
ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_external_ids);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_interface);
ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_name);
ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_type);
ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_options);
}

/* Enough context to create a new tunnel, using tunnel_add(). */
Expand Down
3 changes: 2 additions & 1 deletion ovn/controller/encaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
#include <stdbool.h>

struct controller_ctx;
struct ovsdb_idl;
struct ovsrec_bridge;

void encaps_init(struct controller_ctx *);
void encaps_register_ovs_idl(struct ovsdb_idl *);
void encaps_run(struct controller_ctx *,
const struct ovsrec_bridge *br_int, const char *chassis_id);
bool encaps_cleanup(struct controller_ctx *,
Expand Down
11 changes: 4 additions & 7 deletions ovn/controller/ovn-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,13 @@ main(int argc, char *argv[])
/* Connect to OVS OVSDB instance. We do not monitor all tables by
* default, so modules must register their interest explicitly. */
ctx.ovs_idl = ovsdb_idl_create(ovs_remote, &ovsrec_idl_class, false, true);

/* Register interest in "external_ids" column in "Open_vSwitch" table,
* since we'll need to get the OVN OVSDB remote. */
ovsdb_idl_add_table(ctx.ovs_idl, &ovsrec_table_open_vswitch);
ovsdb_idl_add_column(ctx.ovs_idl, &ovsrec_open_vswitch_col_external_ids);
chassis_register_ovs_idl(ctx.ovs_idl);
encaps_register_ovs_idl(ctx.ovs_idl);
binding_register_ovs_idl(ctx.ovs_idl);
physical_register_ovs_idl(ctx.ovs_idl);

chassis_init(&ctx);
encaps_init(&ctx);
binding_init(&ctx);
physical_init(&ctx);
pipeline_init();

get_initial_snapshot(ctx.ovs_idl);
Expand Down
22 changes: 11 additions & 11 deletions ovn/controller/physical.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
#include "vswitch-idl.h"

void
physical_init(struct controller_ctx *ctx)
physical_register_ovs_idl(struct ovsdb_idl *ovs_idl)
{
ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_bridge);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_bridge_col_ports);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_bridge);
ovsdb_idl_add_column(ovs_idl, &ovsrec_bridge_col_ports);

ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_port);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_port_col_name);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_port_col_interfaces);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_port_col_external_ids);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_port);
ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_name);
ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_interfaces);
ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_external_ids);

ovsdb_idl_add_table(ctx->ovs_idl, &ovsrec_table_interface);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_interface_col_name);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_interface_col_ofport);
ovsdb_idl_add_column(ctx->ovs_idl, &ovsrec_interface_col_external_ids);
ovsdb_idl_add_table(ovs_idl, &ovsrec_table_interface);
ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_name);
ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_ofport);
ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_external_ids);
}

void
Expand Down
3 changes: 2 additions & 1 deletion ovn/controller/physical.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

struct controller_ctx;
struct hmap;
struct ovsdb_idl;
struct ovsrec_bridge;

void physical_init(struct controller_ctx *);
void physical_register_ovs_idl(struct ovsdb_idl *);
void physical_run(struct controller_ctx *, const struct ovsrec_bridge *br_int,
const char *chassis_id, struct hmap *flow_table);

Expand Down

0 comments on commit 4a5a9e0

Please sign in to comment.