Looks good. Ethan
On Tue, Nov 15, 2011 at 17:17, Ben Pfaff <b...@nicira.com> wrote: > ovsdb_idl_get() doesn't work with synthetic records. Upcoming commits > will start synthesizing more ports and interfaces, so we should avoid > using ovsdb_idl_get(). > > In the long term it's probably a good idea to come up with a better way > to do synthetic database records, one that causes less trouble. > --- > vswitchd/bridge.c | 40 +++++++++++++++++++++------------------- > 1 files changed, 21 insertions(+), 19 deletions(-) > > diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c > index 67360ea..c7f2233 100644 > --- a/vswitchd/bridge.c > +++ b/vswitchd/bridge.c > @@ -1182,25 +1182,24 @@ bridge_add_ofproto_ports(struct bridge *br) > } > > static const char * > -get_ovsrec_key_value(const struct ovsdb_idl_row *row, > - const struct ovsdb_idl_column *column, > - const char *key) > +get_ovsrec_key_value(char **keys, char **values, size_t n, const char *key) > { > - const struct ovsdb_datum *datum; > - union ovsdb_atom atom; > - unsigned int idx; > + size_t i; > > - datum = ovsdb_idl_get(row, column, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING); > - atom.string = (char *) key; > - idx = ovsdb_datum_find_key(datum, &atom, OVSDB_TYPE_STRING); > - return idx == UINT_MAX ? NULL : datum->values[idx].string; > + for (i = 0; i < n; i++) { > + if (!strcmp(keys[i], key)) { > + return values[i]; > + } > + } > + return NULL; > } > > static const char * > bridge_get_other_config(const struct ovsrec_bridge *br_cfg, const char *key) > { > - return get_ovsrec_key_value(&br_cfg->header_, > - &ovsrec_bridge_col_other_config, key); > + return get_ovsrec_key_value(br_cfg->key_other_config, > + br_cfg->value_other_config, > + br_cfg->n_other_config, key); > } > > /* Set Flow eviction threshold */ > @@ -1638,8 +1637,9 @@ enable_system_stats(const struct ovsrec_open_vswitch > *cfg) > const char *enable; > > /* Use other-config:enable-system-stats by preference. */ > - enable = get_ovsrec_key_value(&cfg->header_, > - &ovsrec_open_vswitch_col_other_config, > + enable = get_ovsrec_key_value(cfg->key_other_config, > + cfg->value_other_config, > + cfg->n_other_config, > "enable-statistics"); > if (enable) { > return !strcmp(enable, "true"); > @@ -2412,8 +2412,9 @@ get_port_other_config(const struct ovsrec_port *port, > const char *key, > { > const char *value; > > - value = get_ovsrec_key_value(&port->header_, > &ovsrec_port_col_other_config, > - key); > + value = get_ovsrec_key_value(port->key_other_config, > + port->value_other_config, > + port->n_other_config, key); > return value ? value : default_value; > } > > @@ -2423,8 +2424,9 @@ get_interface_other_config(const struct > ovsrec_interface *iface, > { > const char *value; > > - value = get_ovsrec_key_value(&iface->header_, > - &ovsrec_interface_col_other_config, key); > + value = get_ovsrec_key_value(iface->key_other_config, > + iface->value_other_config, > + iface->n_other_config, key); > return value ? value : default_value; > } > > -- > 1.7.4.4 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev