On Mon, Jun 11, 2018 at 3:14 PM, Ben Pfaff <[email protected]> wrote: > > The remaining controller_ctx members were ovsdb_idl_txn pointers that could > be passed to functions directly, so this commit makes that change and > removes the structure. > > Signed-off-by: Ben Pfaff <[email protected]> > --- > ovn/controller/bfd.h | 1 - > ovn/controller/binding.c | 33 ++++++++++++----------- > ovn/controller/binding.h | 7 ++--- > ovn/controller/chassis.c | 16 ++++++------ > ovn/controller/chassis.h | 7 ++--- > ovn/controller/encaps.c | 13 ++++----- > ovn/controller/encaps.h | 6 ++--- > ovn/controller/ofctrl.h | 1 - > ovn/controller/ovn-controller.c | 58 ++++++++++++++++++++--------------------- > ovn/controller/ovn-controller.h | 5 ---- > ovn/controller/patch.c | 22 ++++++++-------- > ovn/controller/patch.h | 4 +-- > ovn/controller/physical.h | 1 - > ovn/controller/pinctrl.c | 28 ++++++++++---------- > ovn/controller/pinctrl.h | 6 ++--- > 15 files changed, 103 insertions(+), 105 deletions(-) > > diff --git a/ovn/controller/bfd.h b/ovn/controller/bfd.h > index bc7615d28ca7..7ea345a3e642 100644 > --- a/ovn/controller/bfd.h > +++ b/ovn/controller/bfd.h > @@ -16,7 +16,6 @@ > #ifndef OVN_BFD_H > #define OVN_BFD_H 1 > > -struct controller_ctx; > struct hmap; > struct ovsdb_idl; > struct ovsdb_idl_index; > diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c > index 5a3896c1d39f..2b27f3cbd9ad 100644 > --- a/ovn/controller/binding.c > +++ b/ovn/controller/binding.c > @@ -206,7 +206,7 @@ get_qos_params(const struct sbrec_port_binding *pb, struct hmap *queue_map) > } > > static const struct ovsrec_qos * > -get_noop_qos(struct controller_ctx *ctx, > +get_noop_qos(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_qos_table *qos_table) > { > const struct ovsrec_qos *qos; > @@ -216,25 +216,25 @@ get_noop_qos(struct controller_ctx *ctx, > } > } > > - if (!ctx->ovs_idl_txn) { > + if (!ovs_idl_txn) { > return NULL; > } > - qos = ovsrec_qos_insert(ctx->ovs_idl_txn); > + qos = ovsrec_qos_insert(ovs_idl_txn); > ovsrec_qos_set_type(qos, "linux-noop"); > return qos; > } > > static bool > -set_noop_qos(struct controller_ctx *ctx, > +set_noop_qos(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_port_table *port_table, > const struct ovsrec_qos_table *qos_table, > struct sset *egress_ifaces) > { > - if (!ctx->ovs_idl_txn) { > + if (!ovs_idl_txn) { > return false; > } > > - const struct ovsrec_qos *noop_qos = get_noop_qos(ctx, qos_table); > + const struct ovsrec_qos *noop_qos = get_noop_qos(ovs_idl_txn, qos_table); > if (!noop_qos) { > return false; > } > @@ -392,7 +392,8 @@ update_local_lport_ids(struct sset *local_lport_ids, > } > > static void > -consider_local_datapath(struct controller_ctx *ctx, > +consider_local_datapath(struct ovsdb_idl_txn *ovnsb_idl_txn, > + struct ovsdb_idl_txn *ovs_idl_txn, > struct ovsdb_idl_index *sbrec_chassis_by_name, > struct ovsdb_idl_index *sbrec_datapath_binding_by_key, > struct ovsdb_idl_index *sbrec_port_binding_by_datapath, > @@ -422,7 +423,7 @@ consider_local_datapath(struct controller_ctx *ctx, > sbrec_port_binding_by_datapath, > sbrec_port_binding_by_name, > binding_rec->datapath, false, local_datapaths); > - if (iface_rec && qos_map && ctx->ovs_idl_txn) { > + if (iface_rec && qos_map && ovs_idl_txn) { > get_qos_params(binding_rec, qos_map); > } > /* This port is in our chassis unless it is a localport. */ > @@ -480,7 +481,7 @@ consider_local_datapath(struct controller_ctx *ctx, > update_local_lport_ids(local_lport_ids, binding_rec); > } > > - if (ctx->ovnsb_idl_txn) { > + if (ovnsb_idl_txn) { > const char *vif_chassis = smap_get(&binding_rec->options, > "requested-chassis"); > bool can_bind = !vif_chassis || !vif_chassis[0] > @@ -545,7 +546,8 @@ consider_localnet_port(const struct sbrec_port_binding *binding_rec, > } > > void > -binding_run(struct controller_ctx *ctx, > +binding_run(struct ovsdb_idl_txn *ovnsb_idl_txn, > + struct ovsdb_idl_txn *ovs_idl_txn, > struct ovsdb_idl_index *sbrec_chassis_by_name, > struct ovsdb_idl_index *sbrec_datapath_binding_by_key, > struct ovsdb_idl_index *sbrec_port_binding_by_datapath, > @@ -578,7 +580,8 @@ binding_run(struct controller_ctx *ctx, > * chassis and update the binding accordingly. This includes both > * directly connected logical ports and children of those ports. */ > SBREC_PORT_BINDING_TABLE_FOR_EACH (binding_rec, port_binding_table) { > - consider_local_datapath(ctx, sbrec_chassis_by_name, > + consider_local_datapath(ovnsb_idl_txn, ovs_idl_txn, > + sbrec_chassis_by_name, > sbrec_datapath_binding_by_key, > sbrec_port_binding_by_datapath, > sbrec_port_binding_by_name, > @@ -599,7 +602,7 @@ binding_run(struct controller_ctx *ctx, > } > > if (!sset_is_empty(&egress_ifaces) > - && set_noop_qos(ctx, port_table, qos_table, &egress_ifaces)) { > + && set_noop_qos(ovs_idl_txn, port_table, qos_table, &egress_ifaces)) { > const char *entry; > SSET_FOR_EACH (entry, &egress_ifaces) { > setup_qos(entry, &qos_map); > @@ -614,11 +617,11 @@ binding_run(struct controller_ctx *ctx, > /* Returns true if the database is all cleaned up, false if more work is > * required. */ > bool > -binding_cleanup(struct controller_ctx *ctx, > +binding_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn, > const struct sbrec_port_binding_table *port_binding_table, > const struct sbrec_chassis *chassis_rec) > { > - if (!ctx->ovnsb_idl_txn) { > + if (!ovnsb_idl_txn) { > return false; > } > if (!chassis_rec) { > @@ -626,7 +629,7 @@ binding_cleanup(struct controller_ctx *ctx, > } > > ovsdb_idl_txn_add_comment( > - ctx->ovnsb_idl_txn, > + ovnsb_idl_txn, > "ovn-controller: removing all port bindings for '%s'", > chassis_rec->name); > > diff --git a/ovn/controller/binding.h b/ovn/controller/binding.h > index 21d63f577671..837e1099f0c0 100644 > --- a/ovn/controller/binding.h > +++ b/ovn/controller/binding.h > @@ -19,10 +19,10 @@ > > #include <stdbool.h> > > -struct controller_ctx; > struct hmap; > struct ovsdb_idl; > struct ovsdb_idl_index; > +struct ovsdb_idl_txn; > struct ovsrec_bridge; > struct ovsrec_port_table; > struct ovsrec_qos_table; > @@ -31,7 +31,8 @@ struct sbrec_port_binding_table; > struct sset; > > void binding_register_ovs_idl(struct ovsdb_idl *); > -void binding_run(struct controller_ctx *, > +void binding_run(struct ovsdb_idl_txn *ovnsb_idl_txn, > + struct ovsdb_idl_txn *ovs_idl_txn, > struct ovsdb_idl_index *sbrec_chassis_by_name, > struct ovsdb_idl_index *sbrec_datapath_binding_by_key, > struct ovsdb_idl_index *sbrec_port_binding_by_datapath, > @@ -44,7 +45,7 @@ void binding_run(struct controller_ctx *, > const struct sset *active_tunnels, > struct hmap *local_datapaths, > struct sset *local_lports, struct sset *local_lport_ids); > -bool binding_cleanup(struct controller_ctx *, > +bool binding_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn, > const struct sbrec_port_binding_table *, > const struct sbrec_chassis *); > > diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c > index db5d2d03dbf6..797c16c3ccbe 100644 > --- a/ovn/controller/chassis.c > +++ b/ovn/controller/chassis.c > @@ -76,13 +76,13 @@ get_cms_options(const struct smap *ext_ids) > /* Returns this chassis's Chassis record, if it is available and is currently > * amenable to a transaction. */ > const struct sbrec_chassis * > -chassis_run(struct controller_ctx *ctx, > +chassis_run(struct ovsdb_idl_txn *ovnsb_idl_txn, > struct ovsdb_idl_index *sbrec_chassis_by_name, > const struct ovsrec_open_vswitch_table *ovs_table, > const char *chassis_id, > const struct ovsrec_bridge *br_int) > { > - if (!ctx->ovnsb_idl_txn) { > + if (!ovnsb_idl_txn) { > return NULL; > } > > @@ -209,7 +209,7 @@ chassis_run(struct controller_ctx *ctx, > } > } > > - ovsdb_idl_txn_add_comment(ctx->ovnsb_idl_txn, > + ovsdb_idl_txn_add_comment(ovnsb_idl_txn, > "ovn-controller: registering chassis '%s'", > chassis_id); > > @@ -218,7 +218,7 @@ chassis_run(struct controller_ctx *ctx, > smap_add(&ext_ids, "ovn-bridge-mappings", bridge_mappings); > smap_add(&ext_ids, "datapath-type", datapath_type); > smap_add(&ext_ids, "iface-types", iface_types_str); > - chassis_rec = sbrec_chassis_insert(ctx->ovnsb_idl_txn); > + chassis_rec = sbrec_chassis_insert(ovnsb_idl_txn); > sbrec_chassis_set_name(chassis_rec, chassis_id); > sbrec_chassis_set_hostname(chassis_rec, hostname); > sbrec_chassis_set_external_ids(chassis_rec, &ext_ids); > @@ -232,7 +232,7 @@ chassis_run(struct controller_ctx *ctx, > for (int i = 0; i < n_encaps; i++) { > const char *type = pop_tunnel_name(&req_tunnels); > > - encaps[i] = sbrec_encap_insert(ctx->ovnsb_idl_txn); > + encaps[i] = sbrec_encap_insert(ovnsb_idl_txn); > > sbrec_encap_set_type(encaps[i], type); > sbrec_encap_set_ip(encaps[i], encap_ip); > @@ -249,14 +249,14 @@ chassis_run(struct controller_ctx *ctx, > /* Returns true if the database is all cleaned up, false if more work is > * required. */ > bool > -chassis_cleanup(struct controller_ctx *ctx, > +chassis_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn, > const struct sbrec_chassis *chassis_rec) > { > if (!chassis_rec) { > return true; > } > - if (ctx->ovnsb_idl_txn) { > - ovsdb_idl_txn_add_comment(ctx->ovnsb_idl_txn, > + if (ovnsb_idl_txn) { > + ovsdb_idl_txn_add_comment(ovnsb_idl_txn, > "ovn-controller: unregistering chassis '%s'", > chassis_rec->name); > sbrec_chassis_delete(chassis_rec); > diff --git a/ovn/controller/chassis.h b/ovn/controller/chassis.h > index f5245c363683..6b1c357d217d 100644 > --- a/ovn/controller/chassis.h > +++ b/ovn/controller/chassis.h > @@ -18,9 +18,9 @@ > > #include <stdbool.h> > > -struct controller_ctx; > struct ovsdb_idl; > struct ovsdb_idl_index; > +struct ovsdb_idl_txn; > struct ovsrec_bridge; > struct ovsrec_open_vswitch_table; > struct sbrec_chassis; > @@ -28,10 +28,11 @@ struct sbrec_chassis_table; > > void chassis_register_ovs_idl(struct ovsdb_idl *); > const struct sbrec_chassis *chassis_run( > - struct controller_ctx *, > + struct ovsdb_idl_txn *ovnsb_idl_txn, > 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 *); > +bool chassis_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn, > + const struct sbrec_chassis *); > > #endif /* ovn/chassis.h */ > diff --git a/ovn/controller/encaps.c b/ovn/controller/encaps.c > index edcc86977ab8..fde017586ffb 100644 > --- a/ovn/controller/encaps.c > +++ b/ovn/controller/encaps.c > @@ -153,13 +153,13 @@ preferred_encap(const struct sbrec_chassis *chassis_rec) > } > > void > -encaps_run(struct controller_ctx *ctx, > +encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_bridge_table *bridge_table, > const struct ovsrec_bridge *br_int, > const struct sbrec_chassis_table *chassis_table, > const char *chassis_id) > { > - if (!ctx->ovs_idl_txn || !br_int) { > + if (!ovs_idl_txn || !br_int) { > return; > } > > @@ -172,7 +172,7 @@ encaps_run(struct controller_ctx *ctx, > .br_int = br_int > }; > > - tc.ovs_txn = ctx->ovs_idl_txn; > + tc.ovs_txn = ovs_idl_txn; > ovsdb_idl_txn_add_comment(tc.ovs_txn, > "ovn-controller: modifying OVS tunnels '%s'", > chassis_id); > @@ -228,7 +228,8 @@ encaps_run(struct controller_ctx *ctx, > /* Returns true if the database is all cleaned up, false if more work is > * required. */ > bool > -encaps_cleanup(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int) > +encaps_cleanup(struct ovsdb_idl_txn *ovs_idl_txn, > + const struct ovsrec_bridge *br_int) > { > if (!br_int) { > return true; > @@ -245,8 +246,8 @@ encaps_cleanup(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int) > } > > bool any_changes = n != br_int->n_ports; > - if (any_changes && ctx->ovs_idl_txn) { > - ovsdb_idl_txn_add_comment(ctx->ovs_idl_txn, > + if (any_changes && ovs_idl_txn) { > + ovsdb_idl_txn_add_comment(ovs_idl_txn, > "ovn-controller: destroying tunnels"); > ovsrec_bridge_verify_ports(br_int); > ovsrec_bridge_set_ports(br_int, ports, n); > diff --git a/ovn/controller/encaps.h b/ovn/controller/encaps.h > index 429643f3f0cf..054bdfa7804d 100644 > --- a/ovn/controller/encaps.h > +++ b/ovn/controller/encaps.h > @@ -18,19 +18,19 @@ > > #include <stdbool.h> > > -struct controller_ctx; > struct ovsdb_idl; > +struct ovsdb_idl_txn; > struct ovsrec_bridge; > struct ovsrec_bridge_table; > struct sbrec_chassis_table; > > void encaps_register_ovs_idl(struct ovsdb_idl *); > -void encaps_run(struct controller_ctx *, > +void encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_bridge_table *, > const struct ovsrec_bridge *br_int, > const struct sbrec_chassis_table *, > const char *chassis_id); > -bool encaps_cleanup(struct controller_ctx *, > +bool encaps_cleanup(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_bridge *br_int); > > #endif /* ovn/encaps.h */ > diff --git a/ovn/controller/ofctrl.h b/ovn/controller/ofctrl.h > index a8b3afc456da..886b9bd21e9a 100644 > --- a/ovn/controller/ofctrl.h > +++ b/ovn/controller/ofctrl.h > @@ -22,7 +22,6 @@ > #include "openvswitch/meta-flow.h" > #include "ovsdb-idl.h" > > -struct controller_ctx; > struct ovn_extend_table; > struct hmap; > struct match; > diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c > index 11a12fd05604..6ee72a9fafb4 100644 > --- a/ovn/controller/ovn-controller.c > +++ b/ovn/controller/ovn-controller.c > @@ -196,29 +196,29 @@ update_sb_monitors(struct ovsdb_idl *ovnsb_idl, > } > > static const struct ovsrec_bridge * > -create_br_int(struct controller_ctx *ctx, > +create_br_int(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_open_vswitch *cfg, > const char *bridge_name) > { > - if (!ctx->ovs_idl_txn) { > + if (!ovs_idl_txn) { > return NULL; > } > > - ovsdb_idl_txn_add_comment(ctx->ovs_idl_txn, > + ovsdb_idl_txn_add_comment(ovs_idl_txn, > "ovn-controller: creating integration bridge '%s'", bridge_name); > > struct ovsrec_interface *iface; > - iface = ovsrec_interface_insert(ctx->ovs_idl_txn); > + iface = ovsrec_interface_insert(ovs_idl_txn); > ovsrec_interface_set_name(iface, bridge_name); > ovsrec_interface_set_type(iface, "internal"); > > struct ovsrec_port *port; > - port = ovsrec_port_insert(ctx->ovs_idl_txn); > + port = ovsrec_port_insert(ovs_idl_txn); > ovsrec_port_set_name(port, bridge_name); > ovsrec_port_set_interfaces(port, &iface, 1); > > struct ovsrec_bridge *bridge; > - bridge = ovsrec_bridge_insert(ctx->ovs_idl_txn); > + bridge = ovsrec_bridge_insert(ovs_idl_txn); > ovsrec_bridge_set_name(bridge, bridge_name); > ovsrec_bridge_set_fail_mode(bridge, "secure"); > const struct smap oc = SMAP_CONST1(&oc, "disable-in-band", "true"); > @@ -238,7 +238,7 @@ create_br_int(struct controller_ctx *ctx, > } > > static const struct ovsrec_bridge * > -get_br_int(struct controller_ctx *ctx, > +get_br_int(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_bridge_table *bridge_table, > const struct ovsrec_open_vswitch_table *ovs_table) > { > @@ -253,7 +253,7 @@ get_br_int(struct controller_ctx *ctx, > > const struct ovsrec_bridge *br = get_bridge(bridge_table, br_int_name); > if (!br) { > - return create_br_int(ctx, cfg, br_int_name); > + return create_br_int(ovs_idl_txn, cfg, br_int_name); > } > return br; > } > @@ -642,10 +642,9 @@ main(int argc, char *argv[]) > free(new_ovnsb_remote); > } > > - struct controller_ctx ctx = { > - .ovs_idl_txn = ovsdb_idl_loop_run(&ovs_idl_loop), > - .ovnsb_idl_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop), > - }; > + struct ovsdb_idl_txn *ovs_idl_txn = ovsdb_idl_loop_run(&ovs_idl_loop); > + struct ovsdb_idl_txn *ovnsb_idl_txn > + = ovsdb_idl_loop_run(&ovnsb_idl_loop); > > update_probe_interval(ovsrec_open_vswitch_table_get(ovs_idl_loop.idl), > ovnsb_remote, ovnsb_idl_loop.idl); > @@ -667,21 +666,22 @@ main(int argc, char *argv[]) > struct sset active_tunnels = SSET_INITIALIZER(&active_tunnels); > > const struct ovsrec_bridge *br_int > - = get_br_int(&ctx, ovsrec_bridge_table_get(ovs_idl_loop.idl), > + = get_br_int(ovs_idl_txn, > + ovsrec_bridge_table_get(ovs_idl_loop.idl), > ovsrec_open_vswitch_table_get(ovs_idl_loop.idl)); > const char *chassis_id > = get_chassis_id(ovsrec_open_vswitch_table_get(ovs_idl_loop.idl)); > > const struct sbrec_chassis *chassis = NULL; > if (chassis_id) { > - chassis = chassis_run(&ctx, sbrec_chassis_by_name, > + chassis = chassis_run(ovnsb_idl_txn, sbrec_chassis_by_name, > ovsrec_open_vswitch_table_get(ovs_idl_loop.idl), > chassis_id, br_int); > - encaps_run(&ctx, > + encaps_run(ovs_idl_txn, > ovsrec_bridge_table_get(ovs_idl_loop.idl), br_int, > sbrec_chassis_table_get(ovnsb_idl_loop.idl), chassis_id); > bfd_calculate_active_tunnels(br_int, &active_tunnels); > - binding_run(&ctx, sbrec_chassis_by_name, > + binding_run(ovnsb_idl_txn, ovs_idl_txn, sbrec_chassis_by_name, > sbrec_datapath_binding_by_key, > sbrec_port_binding_by_datapath, > sbrec_port_binding_by_name, > @@ -700,7 +700,7 @@ main(int argc, char *argv[]) > port_groups_init(sbrec_port_group_table_get(ovnsb_idl_loop.idl), > &port_groups); > > - patch_run(&ctx, > + patch_run(ovs_idl_txn, > ovsrec_bridge_table_get(ovs_idl_loop.idl), > ovsrec_open_vswitch_table_get(ovs_idl_loop.idl), > ovsrec_port_table_get(ovs_idl_loop.idl), > @@ -710,7 +710,7 @@ main(int argc, char *argv[]) > enum mf_field_id mff_ovn_geneve = ofctrl_run(br_int, > &pending_ct_zones); > > - pinctrl_run(&ctx, sbrec_chassis_by_name, > + pinctrl_run(ovnsb_idl_txn, sbrec_chassis_by_name, > sbrec_datapath_binding_by_key, > sbrec_port_binding_by_datapath, > sbrec_port_binding_by_key, > @@ -721,7 +721,7 @@ main(int argc, char *argv[]) > &local_datapaths, &active_tunnels); > update_ct_zones(&local_lports, &local_datapaths, &ct_zones, > ct_zone_bitmap, &pending_ct_zones); > - if (ctx.ovs_idl_txn) { > + if (ovs_idl_txn) { > if (ofctrl_can_put()) { > stopwatch_start(CONTROLLER_LOOP_STOPWATCH_NAME, > time_msec()); > @@ -767,7 +767,7 @@ main(int argc, char *argv[]) > > hmap_destroy(&flow_table); > } > - if (ctx.ovnsb_idl_txn) { > + if (ovnsb_idl_txn) { > int64_t cur_cfg = ofctrl_get_cur_cfg(); > if (cur_cfg && cur_cfg != chassis->nb_cfg) { > sbrec_chassis_set_nb_cfg(chassis, cur_cfg); > @@ -827,7 +827,7 @@ main(int argc, char *argv[]) > > if (br_int) { > ofctrl_wait(); > - pinctrl_wait(&ctx); > + pinctrl_wait(ovnsb_idl_txn); > } > > ovsdb_idl_loop_commit_and_wait(&ovnsb_idl_loop); > @@ -851,10 +851,9 @@ main(int argc, char *argv[]) > /* It's time to exit. Clean up the databases. */ > bool done = false; > while (!done) { > - struct controller_ctx ctx = { > - .ovs_idl_txn = ovsdb_idl_loop_run(&ovs_idl_loop), > - .ovnsb_idl_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop), > - }; > + struct ovsdb_idl_txn *ovs_idl_txn = ovsdb_idl_loop_run(&ovs_idl_loop); > + struct ovsdb_idl_txn *ovnsb_idl_txn > + = ovsdb_idl_loop_run(&ovnsb_idl_loop); > > const struct ovsrec_bridge_table *bridge_table > = ovsrec_bridge_table_get(ovs_idl_loop.idl); > @@ -864,7 +863,8 @@ main(int argc, char *argv[]) > const struct sbrec_port_binding_table *port_binding_table > = sbrec_port_binding_table_get(ovnsb_idl_loop.idl); > > - const struct ovsrec_bridge *br_int = get_br_int(&ctx, bridge_table, > + const struct ovsrec_bridge *br_int = get_br_int(ovs_idl_txn, > + bridge_table, > ovs_table); > const char *chassis_id = get_chassis_id(ovs_table); > const struct sbrec_chassis *chassis > @@ -874,9 +874,9 @@ main(int argc, char *argv[]) > > /* 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, port_binding_table, chassis); > - done = chassis_cleanup(&ctx, chassis) && done; > - done = encaps_cleanup(&ctx, br_int) && done; > + done = binding_cleanup(ovnsb_idl_txn, port_binding_table, chassis); > + done = chassis_cleanup(ovnsb_idl_txn, chassis) && done; > + done = encaps_cleanup(ovs_idl_txn, br_int) && done; > if (done) { > poll_immediate_wake(); > } > diff --git a/ovn/controller/ovn-controller.h b/ovn/controller/ovn-controller.h > index c57340e34358..3b15620ae42a 100644 > --- a/ovn/controller/ovn-controller.h > +++ b/ovn/controller/ovn-controller.h > @@ -25,11 +25,6 @@ struct ovsrec_bridge_table; > /* Linux supports a maximum of 64K zones, which seems like a fine default. */ > #define MAX_CT_ZONES 65535 > > -struct controller_ctx { > - struct ovsdb_idl_txn *ovnsb_idl_txn; > - struct ovsdb_idl_txn *ovs_idl_txn; > -}; > - > /* States to move through when a new conntrack zone has been allocated. */ > enum ct_zone_pending_state { > CT_ZONE_OF_QUEUED, /* Waiting to send conntrack flush command. */ > diff --git a/ovn/controller/patch.c b/ovn/controller/patch.c > index 2e747e95595e..a6770c6d5bd3 100644 > --- a/ovn/controller/patch.c > +++ b/ovn/controller/patch.c > @@ -56,7 +56,7 @@ match_patch_port(const struct ovsrec_port *port, const char *peer) > * > * If such a patch port already exists, removes it from 'existing_ports'. */ > static void > -create_patch_port(struct controller_ctx *ctx, > +create_patch_port(struct ovsdb_idl_txn *ovs_idl_txn, > const char *key, const char *value, > const struct ovsrec_bridge *src, const char *src_name, > const struct ovsrec_bridge *dst, const char *dst_name, > @@ -70,19 +70,19 @@ create_patch_port(struct controller_ctx *ctx, > } > } > > - ovsdb_idl_txn_add_comment(ctx->ovs_idl_txn, > + ovsdb_idl_txn_add_comment(ovs_idl_txn, > "ovn-controller: creating patch port '%s' from '%s' to '%s'", > src_name, src->name, dst->name); > > struct ovsrec_interface *iface; > - iface = ovsrec_interface_insert(ctx->ovs_idl_txn); > + iface = ovsrec_interface_insert(ovs_idl_txn); > ovsrec_interface_set_name(iface, src_name); > ovsrec_interface_set_type(iface, "patch"); > const struct smap options = SMAP_CONST1(&options, "peer", dst_name); > ovsrec_interface_set_options(iface, &options); > > struct ovsrec_port *port; > - port = ovsrec_port_insert(ctx->ovs_idl_txn); > + port = ovsrec_port_insert(ovs_idl_txn); > ovsrec_port_set_name(port, src_name); > ovsrec_port_set_interfaces(port, &iface, 1); > const struct smap ids = SMAP_CONST1(&ids, key, value); > @@ -133,7 +133,7 @@ remove_port(const struct ovsrec_bridge_table *bridge_table, > * the local bridge mappings. Removes any patch ports for bridge mappings that > * already existed from 'existing_ports'. */ > static void > -add_bridge_mappings(struct controller_ctx *ctx, > +add_bridge_mappings(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_bridge_table *bridge_table, > const struct ovsrec_open_vswitch_table *ovs_table, > const struct sbrec_port_binding_table *port_binding_table, > @@ -214,9 +214,9 @@ add_bridge_mappings(struct controller_ctx *ctx, > > char *name1 = patch_port_name(br_int->name, binding->logical_port); > char *name2 = patch_port_name(binding->logical_port, br_int->name); > - create_patch_port(ctx, patch_port_id, binding->logical_port, > + create_patch_port(ovs_idl_txn, patch_port_id, binding->logical_port, > br_int, name1, br_ln, name2, existing_ports); > - create_patch_port(ctx, patch_port_id, binding->logical_port, > + create_patch_port(ovs_idl_txn, patch_port_id, binding->logical_port, > br_ln, name2, br_int, name1, existing_ports); > free(name1); > free(name2); > @@ -226,7 +226,7 @@ add_bridge_mappings(struct controller_ctx *ctx, > } > > void > -patch_run(struct controller_ctx *ctx, > +patch_run(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_bridge_table *bridge_table, > const struct ovsrec_open_vswitch_table *ovs_table, > const struct ovsrec_port_table *port_table, > @@ -234,7 +234,7 @@ patch_run(struct controller_ctx *ctx, > const struct ovsrec_bridge *br_int, > const struct sbrec_chassis *chassis) > { > - if (!ctx->ovs_idl_txn) { > + if (!ovs_idl_txn) { > return; > } > > @@ -258,8 +258,8 @@ patch_run(struct controller_ctx *ctx, > /* Create in the database any patch ports that should exist. Remove from > * 'existing_ports' any patch ports that do exist in the database and > * should be there. */ > - add_bridge_mappings(ctx, bridge_table, ovs_table, port_binding_table, > - br_int, &existing_ports, chassis); > + add_bridge_mappings(ovs_idl_txn, bridge_table, ovs_table, > + port_binding_table, br_int, &existing_ports, chassis); > > /* Now 'existing_ports' only still contains patch ports that exist in the > * database but shouldn't. Delete them from the database. */ > diff --git a/ovn/controller/patch.h b/ovn/controller/patch.h > index 601f5bf06e8d..dd052cfd875f 100644 > --- a/ovn/controller/patch.h > +++ b/ovn/controller/patch.h > @@ -22,8 +22,8 @@ > * This module adds and removes patch ports between the integration bridge and > * physical bridges, as directed by other-config:ovn-bridge-mappings. */ > > -struct controller_ctx; > struct hmap; > +struct ovsdb_idl_txn; > struct ovsrec_bridge; > struct ovsrec_bridge_table; > struct ovsrec_open_vswitch_table; > @@ -31,7 +31,7 @@ struct ovsrec_port_table; > struct sbrec_port_binding_table; > struct sbrec_chassis; > > -void patch_run(struct controller_ctx *, > +void patch_run(struct ovsdb_idl_txn *ovs_idl_txn, > const struct ovsrec_bridge_table *, > const struct ovsrec_open_vswitch_table *, > const struct ovsrec_port_table *, > diff --git a/ovn/controller/physical.h b/ovn/controller/physical.h > index 8b737d1712d1..a7a4def37bb6 100644 > --- a/ovn/controller/physical.h > +++ b/ovn/controller/physical.h > @@ -27,7 +27,6 @@ > > #include "openvswitch/meta-flow.h" > > -struct controller_ctx; > struct hmap; > struct ovsdb_idl_index; > struct ovsrec_bridge; > diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c > index fbb90252a705..a0bf602cdda7 100644 > --- a/ovn/controller/pinctrl.c > +++ b/ovn/controller/pinctrl.c > @@ -67,11 +67,11 @@ static void pinctrl_handle_put_mac_binding(const struct flow *md, > static void init_put_mac_bindings(void); > static void destroy_put_mac_bindings(void); > static void run_put_mac_bindings( > - struct controller_ctx *, > + struct ovsdb_idl_txn *ovnsb_idl_txn, > struct ovsdb_idl_index *sbrec_datapath_binding_by_key, > struct ovsdb_idl_index *sbrec_port_binding_by_key, > const struct sbrec_mac_binding_table *); > -static void wait_put_mac_bindings(struct controller_ctx *); > +static void wait_put_mac_bindings(struct ovsdb_idl_txn *ovnsb_idl_txn); > static void flush_put_mac_bindings(void); > > static void init_send_garps(void); > @@ -1245,7 +1245,7 @@ pinctrl_recv(const struct sbrec_dns_table *dns_table, > } > > void > -pinctrl_run(struct controller_ctx *ctx, > +pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, > struct ovsdb_idl_index *sbrec_chassis_by_name, > struct ovsdb_idl_index *sbrec_datapath_binding_by_key, > struct ovsdb_idl_index *sbrec_port_binding_by_datapath, > @@ -1292,7 +1292,7 @@ pinctrl_run(struct controller_ctx *ctx, > ofpbuf_delete(msg); > } > > - run_put_mac_bindings(ctx, sbrec_datapath_binding_by_key, > + run_put_mac_bindings(ovnsb_idl_txn, sbrec_datapath_binding_by_key, > sbrec_port_binding_by_key, mac_binding_table); > send_garp_run(sbrec_chassis_by_name, sbrec_port_binding_by_datapath, > sbrec_port_binding_by_name, br_int, chassis, > @@ -1593,9 +1593,9 @@ send_ipv6_ras(struct ovsdb_idl_index *sbrec_port_binding_by_datapath, > } > > void > -pinctrl_wait(struct controller_ctx *ctx) > +pinctrl_wait(struct ovsdb_idl_txn *ovnsb_idl_txn) > { > - wait_put_mac_bindings(ctx); > + wait_put_mac_bindings(ovnsb_idl_txn); > rconn_run_wait(swconn); > rconn_recv_wait(swconn); > send_garp_wait(); > @@ -1617,7 +1617,7 @@ pinctrl_destroy(void) > * updating the MAC_Binding table in the southbound database. > * > * This code could be a lot simpler if the database could always be updated, > - * but in fact we can only update it when ctx->ovnsb_idl_txn is nonnull. Thus, > + * but in fact we can only update it when 'ovnsb_idl_txn' is nonnull. Thus, > * we buffer up a few put_mac_bindings (but we don't keep them longer > * than 1 second) and apply them whenever a database transaction is > * available. */ > @@ -1703,7 +1703,7 @@ pinctrl_handle_put_mac_binding(const struct flow *md, > } > > static void > -run_put_mac_binding(struct controller_ctx *ctx, > +run_put_mac_binding(struct ovsdb_idl_txn *ovnsb_idl_txn, > struct ovsdb_idl_index *sbrec_datapath_binding_by_key, > struct ovsdb_idl_index *sbrec_port_binding_by_key, > const struct sbrec_mac_binding_table *mac_binding_table, > @@ -1746,7 +1746,7 @@ run_put_mac_binding(struct controller_ctx *ctx, > } > > /* Add new IP-MAC binding for this logical port. */ > - b = sbrec_mac_binding_insert(ctx->ovnsb_idl_txn); > + b = sbrec_mac_binding_insert(ovnsb_idl_txn); > sbrec_mac_binding_set_logical_port(b, pb->logical_port); > sbrec_mac_binding_set_ip(b, pmb->ip_s); > sbrec_mac_binding_set_mac(b, mac_string); > @@ -1754,27 +1754,27 @@ run_put_mac_binding(struct controller_ctx *ctx, > } > > static void > -run_put_mac_bindings(struct controller_ctx *ctx, > +run_put_mac_bindings(struct ovsdb_idl_txn *ovnsb_idl_txn, > struct ovsdb_idl_index *sbrec_datapath_binding_by_key, > struct ovsdb_idl_index *sbrec_port_binding_by_key, > const struct sbrec_mac_binding_table *mac_binding_table) > { > - if (!ctx->ovnsb_idl_txn) { > + if (!ovnsb_idl_txn) { > return; > } > > const struct put_mac_binding *pmb; > HMAP_FOR_EACH (pmb, hmap_node, &put_mac_bindings) { > - run_put_mac_binding(ctx, sbrec_datapath_binding_by_key, > + run_put_mac_binding(ovnsb_idl_txn, sbrec_datapath_binding_by_key, > sbrec_port_binding_by_key, mac_binding_table, pmb); > } > flush_put_mac_bindings(); > } > > static void > -wait_put_mac_bindings(struct controller_ctx *ctx) > +wait_put_mac_bindings(struct ovsdb_idl_txn *ovnsb_idl_txn) > { > - if (ctx->ovnsb_idl_txn && !hmap_is_empty(&put_mac_bindings)) { > + if (ovnsb_idl_txn && !hmap_is_empty(&put_mac_bindings)) { > poll_immediate_wake(); > } > } > diff --git a/ovn/controller/pinctrl.h b/ovn/controller/pinctrl.h > index 19bfa88c8c8a..60014ebe37b2 100644 > --- a/ovn/controller/pinctrl.h > +++ b/ovn/controller/pinctrl.h > @@ -22,17 +22,17 @@ > #include "lib/sset.h" > #include "openvswitch/meta-flow.h" > > -struct controller_ctx; > struct hmap; > struct lport_index; > struct ovsdb_idl_index; > +struct ovsdb_idl_txn; > struct ovsrec_bridge; > struct sbrec_chassis; > struct sbrec_dns_table; > struct sbrec_mac_binding_table; > > void pinctrl_init(void); > -void pinctrl_run(struct controller_ctx *, > +void pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, > struct ovsdb_idl_index *sbrec_chassis_by_name, > struct ovsdb_idl_index *sbrec_datapath_binding_by_key, > struct ovsdb_idl_index *sbrec_port_binding_by_datapath, > @@ -43,7 +43,7 @@ void pinctrl_run(struct controller_ctx *, > const struct ovsrec_bridge *, const struct sbrec_chassis *, > const struct hmap *local_datapaths, > const struct sset *active_tunnels); > -void pinctrl_wait(struct controller_ctx *); > +void pinctrl_wait(struct ovsdb_idl_txn *ovnsb_idl_txn); > void pinctrl_destroy(void); > > #endif /* ovn/pinctrl.h */ > -- > 2.16.1 > > _______________________________________________ > dev mailing list > [email protected] > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Acked-by: Han Zhou <[email protected]> _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
