Message ID | 20161218081834.18541-13-blp@ovn.org |
---|---|
State | Accepted |
Headers | show |
On Sun, Dec 18, 2016 at 12:18 AM, Ben Pfaff <blp@ovn.org> wrote: > Signed-off-by: Ben Pfaff <blp@ovn.org> > Acked-by: Mickey Spiegel <mickeys.dev@gmail.com> --- > ovn/controller/binding.c | 26 ++++++++++---------------- > ovn/controller/binding.h | 6 +++--- > ovn/controller/chassis.c | 12 +++--------- > ovn/controller/chassis.h | 3 ++- > ovn/controller/ovn-controller.c | 8 +++++--- > 5 files changed, 23 insertions(+), 32 deletions(-) > > diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c > index 2759e23..4ad01b0 100644 > --- a/ovn/controller/binding.c > +++ b/ovn/controller/binding.c > @@ -413,21 +413,20 @@ consider_local_datapath(struct controller_ctx *ctx, > > void > binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge > *br_int, > - const char *chassis_id, const struct ldatapath_index > *ldatapaths, > + const struct sbrec_chassis *chassis_rec, > + const struct ldatapath_index *ldatapaths, > const struct lport_index *lports, struct hmap > *local_datapaths, > struct sset *all_lports) > { > - const struct sbrec_chassis *chassis_rec; > + if (!chassis_rec) { > + return; > + } > + > const struct sbrec_port_binding *binding_rec; > struct shash lport_to_iface = SHASH_INITIALIZER(&lport_to_iface); > struct sset egress_ifaces = SSET_INITIALIZER(&egress_ifaces); > struct hmap qos_map; > > - chassis_rec = get_chassis(ctx->ovnsb_idl, chassis_id); > - if (!chassis_rec) { > - return; > - } > - > hmap_init(&qos_map); > if (br_int) { > get_local_iface_ids(br_int, &lport_to_iface, all_lports, > @@ -462,25 +461,20 @@ binding_run(struct controller_ctx *ctx, const struct > ovsrec_bridge *br_int, > /* Returns true if the database is all cleaned up, false if more work is > * required. */ > bool > -binding_cleanup(struct controller_ctx *ctx, const char *chassis_id) > +binding_cleanup(struct controller_ctx *ctx, > + const struct sbrec_chassis *chassis_rec) > { > if (!ctx->ovnsb_idl_txn) { > return false; > } > - > - if (!chassis_id) { > - return true; > - } > - > - const struct sbrec_chassis *chassis_rec > - = get_chassis(ctx->ovnsb_idl, chassis_id); > if (!chassis_rec) { > return true; > } > > ovsdb_idl_txn_add_comment( > ctx->ovnsb_idl_txn, > - "ovn-controller: removing all port bindings for '%s'", > chassis_id); > + "ovn-controller: removing all port bindings for '%s'", > + chassis_rec->name); > > const struct sbrec_port_binding *binding_rec; > bool any_changes = false; > diff --git a/ovn/controller/binding.h b/ovn/controller/binding.h > index 0bb293d..3bfa7d1 100644 > --- a/ovn/controller/binding.h > +++ b/ovn/controller/binding.h > @@ -25,14 +25,14 @@ struct ldatapath_index; > struct lport_index; > struct ovsdb_idl; > struct ovsrec_bridge; > -struct simap; > +struct sbrec_chassis; > struct sset; > > void binding_register_ovs_idl(struct ovsdb_idl *); > void binding_run(struct controller_ctx *, const struct ovsrec_bridge > *br_int, > - const char *chassis_id, const struct ldatapath_index *, > + const struct sbrec_chassis *, const struct > ldatapath_index *, > const struct lport_index *, struct hmap *local_datapaths, > struct sset *all_lports); > -bool binding_cleanup(struct controller_ctx *, const char *chassis_id); > +bool binding_cleanup(struct controller_ctx *, const struct sbrec_chassis > *); > > #endif /* ovn/binding.h */ > diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c > index 70cd159..db8cc2e 100644 > --- a/ovn/controller/chassis.c > +++ b/ovn/controller/chassis.c > @@ -233,22 +233,16 @@ chassis_run(struct controller_ctx *ctx, const char > *chassis_id, > /* Returns true if the database is all cleaned up, false if more work is > * required. */ > bool > -chassis_cleanup(struct controller_ctx *ctx, const char *chassis_id) > +chassis_cleanup(struct controller_ctx *ctx, > + const struct sbrec_chassis *chassis_rec) > { > - if (!chassis_id) { > - return true; > - } > - > - /* Delete Chassis row. */ > - const struct sbrec_chassis *chassis_rec > - = get_chassis(ctx->ovnsb_idl, chassis_id); > if (!chassis_rec) { > return true; > } > if (ctx->ovnsb_idl_txn) { > ovsdb_idl_txn_add_comment(ctx->ovnsb_idl_txn, > "ovn-controller: unregistering chassis > '%s'", > - chassis_id); > + chassis_rec->name); > sbrec_chassis_delete(chassis_rec); > } > return false; > diff --git a/ovn/controller/chassis.h b/ovn/controller/chassis.h > index 016d71c..2cc47fc 100644 > --- a/ovn/controller/chassis.h > +++ b/ovn/controller/chassis.h > @@ -21,11 +21,12 @@ > struct controller_ctx; > struct ovsdb_idl; > struct ovsrec_bridge; > +struct sbrec_chassis; > > void chassis_register_ovs_idl(struct ovsdb_idl *); > const struct sbrec_chassis *chassis_run(struct controller_ctx *, > const char *chassis_id, > const struct ovsrec_bridge > *br_int); > -bool chassis_cleanup(struct controller_ctx *, const char *chassis_id); > +bool chassis_cleanup(struct controller_ctx *, const struct sbrec_chassis > *); > > #endif /* ovn/chassis.h */ > diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn- > controller.c > index 7d146b6..64c73e4 100644 > --- a/ovn/controller/ovn-controller.c > +++ b/ovn/controller/ovn-controller.c > @@ -505,7 +505,7 @@ main(int argc, char *argv[]) > if (chassis_id) { > chassis = chassis_run(&ctx, chassis_id, br_int); > encaps_run(&ctx, br_int, chassis_id); > - binding_run(&ctx, br_int, chassis_id, &ldatapaths, &lports, > + binding_run(&ctx, br_int, chassis, &ldatapaths, &lports, > &local_datapaths, &all_lports); > } > > @@ -595,11 +595,13 @@ main(int argc, char *argv[]) > > const struct ovsrec_bridge *br_int = get_br_int(&ctx); > const char *chassis_id = get_chassis_id(ctx.ovs_idl); > + const struct sbrec_chassis *chassis > + = chassis_id ? get_chassis(ctx.ovnsb_idl, 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. */ > - done = binding_cleanup(&ctx, chassis_id); > - done = chassis_cleanup(&ctx, chassis_id) && done; > + done = binding_cleanup(&ctx, chassis); > + done = chassis_cleanup(&ctx, chassis) && done; > done = encaps_cleanup(&ctx, br_int) && done; > if (done) { > poll_immediate_wake(); > -- > 2.10.2 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev >
diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c index 2759e23..4ad01b0 100644 --- a/ovn/controller/binding.c +++ b/ovn/controller/binding.c @@ -413,21 +413,20 @@ consider_local_datapath(struct controller_ctx *ctx, void binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, - const char *chassis_id, const struct ldatapath_index *ldatapaths, + const struct sbrec_chassis *chassis_rec, + const struct ldatapath_index *ldatapaths, const struct lport_index *lports, struct hmap *local_datapaths, struct sset *all_lports) { - const struct sbrec_chassis *chassis_rec; + if (!chassis_rec) { + return; + } + const struct sbrec_port_binding *binding_rec; struct shash lport_to_iface = SHASH_INITIALIZER(&lport_to_iface); struct sset egress_ifaces = SSET_INITIALIZER(&egress_ifaces); struct hmap qos_map; - chassis_rec = get_chassis(ctx->ovnsb_idl, chassis_id); - if (!chassis_rec) { - return; - } - hmap_init(&qos_map); if (br_int) { get_local_iface_ids(br_int, &lport_to_iface, all_lports, @@ -462,25 +461,20 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, /* Returns true if the database is all cleaned up, false if more work is * required. */ bool -binding_cleanup(struct controller_ctx *ctx, const char *chassis_id) +binding_cleanup(struct controller_ctx *ctx, + const struct sbrec_chassis *chassis_rec) { if (!ctx->ovnsb_idl_txn) { return false; } - - if (!chassis_id) { - return true; - } - - const struct sbrec_chassis *chassis_rec - = get_chassis(ctx->ovnsb_idl, chassis_id); if (!chassis_rec) { return true; } ovsdb_idl_txn_add_comment( ctx->ovnsb_idl_txn, - "ovn-controller: removing all port bindings for '%s'", chassis_id); + "ovn-controller: removing all port bindings for '%s'", + chassis_rec->name); const struct sbrec_port_binding *binding_rec; bool any_changes = false; diff --git a/ovn/controller/binding.h b/ovn/controller/binding.h index 0bb293d..3bfa7d1 100644 --- a/ovn/controller/binding.h +++ b/ovn/controller/binding.h @@ -25,14 +25,14 @@ struct ldatapath_index; struct lport_index; struct ovsdb_idl; struct ovsrec_bridge; -struct simap; +struct sbrec_chassis; struct sset; void binding_register_ovs_idl(struct ovsdb_idl *); void binding_run(struct controller_ctx *, const struct ovsrec_bridge *br_int, - const char *chassis_id, const struct ldatapath_index *, + const struct sbrec_chassis *, const struct ldatapath_index *, const struct lport_index *, struct hmap *local_datapaths, struct sset *all_lports); -bool binding_cleanup(struct controller_ctx *, const char *chassis_id); +bool binding_cleanup(struct controller_ctx *, const struct sbrec_chassis *); #endif /* ovn/binding.h */ diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c index 70cd159..db8cc2e 100644 --- a/ovn/controller/chassis.c +++ b/ovn/controller/chassis.c @@ -233,22 +233,16 @@ chassis_run(struct controller_ctx *ctx, const char *chassis_id, /* Returns true if the database is all cleaned up, false if more work is * required. */ bool -chassis_cleanup(struct controller_ctx *ctx, const char *chassis_id) +chassis_cleanup(struct controller_ctx *ctx, + const struct sbrec_chassis *chassis_rec) { - if (!chassis_id) { - return true; - } - - /* Delete Chassis row. */ - const struct sbrec_chassis *chassis_rec - = get_chassis(ctx->ovnsb_idl, chassis_id); if (!chassis_rec) { return true; } if (ctx->ovnsb_idl_txn) { ovsdb_idl_txn_add_comment(ctx->ovnsb_idl_txn, "ovn-controller: unregistering chassis '%s'", - chassis_id); + chassis_rec->name); sbrec_chassis_delete(chassis_rec); } return false; diff --git a/ovn/controller/chassis.h b/ovn/controller/chassis.h index 016d71c..2cc47fc 100644 --- a/ovn/controller/chassis.h +++ b/ovn/controller/chassis.h @@ -21,11 +21,12 @@ struct controller_ctx; struct ovsdb_idl; struct ovsrec_bridge; +struct sbrec_chassis; void chassis_register_ovs_idl(struct ovsdb_idl *); const struct sbrec_chassis *chassis_run(struct controller_ctx *, const char *chassis_id, const struct ovsrec_bridge *br_int); -bool chassis_cleanup(struct controller_ctx *, const char *chassis_id); +bool chassis_cleanup(struct controller_ctx *, const struct sbrec_chassis *); #endif /* ovn/chassis.h */ diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 7d146b6..64c73e4 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -505,7 +505,7 @@ main(int argc, char *argv[]) if (chassis_id) { chassis = chassis_run(&ctx, chassis_id, br_int); encaps_run(&ctx, br_int, chassis_id); - binding_run(&ctx, br_int, chassis_id, &ldatapaths, &lports, + binding_run(&ctx, br_int, chassis, &ldatapaths, &lports, &local_datapaths, &all_lports); } @@ -595,11 +595,13 @@ main(int argc, char *argv[]) const struct ovsrec_bridge *br_int = get_br_int(&ctx); const char *chassis_id = get_chassis_id(ctx.ovs_idl); + const struct sbrec_chassis *chassis + = chassis_id ? get_chassis(ctx.ovnsb_idl, 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. */ - done = binding_cleanup(&ctx, chassis_id); - done = chassis_cleanup(&ctx, chassis_id) && done; + done = binding_cleanup(&ctx, chassis); + done = chassis_cleanup(&ctx, chassis) && done; done = encaps_cleanup(&ctx, br_int) && done; if (done) { poll_immediate_wake();
Signed-off-by: Ben Pfaff <blp@ovn.org> --- ovn/controller/binding.c | 26 ++++++++++---------------- ovn/controller/binding.h | 6 +++--- ovn/controller/chassis.c | 12 +++--------- ovn/controller/chassis.h | 3 ++- ovn/controller/ovn-controller.c | 8 +++++--- 5 files changed, 23 insertions(+), 32 deletions(-)