[ovs-dev] [PATCH 13/23] db-ctl-base: Don't die in ctl_set_column() on error.
Jakub Sitnicki
jkbs at redhat.com
Mon Jul 2 10:50:09 UTC 2018
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.
Signed-off-by: Jakub Sitnicki <jkbs at redhat.com>
---
lib/db-ctl-base.c | 19 ++++++++++++++-----
lib/db-ctl-base.h | 5 ++---
ovn/utilities/ovn-nbctl.c | 7 +++++--
utilities/ovs-vsctl.c | 7 +++++--
4 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
index d0590194b..033011c15 100644
--- a/lib/db-ctl-base.c
+++ b/lib/db-ctl-base.c
@@ -2417,12 +2417,21 @@ ctl_context_done(struct ctl_context *ctx,
invalidate_cache(ctx);
}
-void ctl_set_column(const char *table_name,
- const struct ovsdb_idl_row *row, const char *arg,
- struct ovsdb_symbol_table *symtab)
+char * OVS_WARN_UNUSED_RESULT
+ctl_set_column(const char *table_name, const struct ovsdb_idl_row *row,
+ const char *arg, struct ovsdb_symbol_table *symtab)
{
const struct ovsdb_idl_table_class *table;
+ char *error;
- die_if_error(get_table(table_name, &table));
- die_if_error(set_column(table, row, arg, symtab));
+ error = get_table(table_name, &table);
+ if (error) {
+ return error;
+ }
+ error = set_column(table, row, arg, symtab);
+ if (error) {
+ return error;
+ }
+
+ return NULL;
}
diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h
index 5599666f2..8c6ac19a3 100644
--- a/lib/db-ctl-base.h
+++ b/lib/db-ctl-base.h
@@ -276,8 +276,7 @@ char *ctl_get_row(struct ctl_context *, const struct ovsdb_idl_table_class *,
const char *record_id, bool must_exist,
const struct ovsdb_idl_row **);
-void ctl_set_column(const char *table_name,
- const struct ovsdb_idl_row *, const char *arg,
- struct ovsdb_symbol_table *);
+char *ctl_set_column(const char *table_name, const struct ovsdb_idl_row *,
+ const char *arg, struct ovsdb_symbol_table *);
#endif /* db-ctl-base.h */
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 622f8a6a6..798f6bef4 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -3279,8 +3279,11 @@ nbctl_lrp_add(struct ctl_context *ctx)
nbrec_logical_router_port_set_networks(lrp, networks, n_networks);
for (int i = 0; i < n_settings; i++) {
- ctl_set_column("Logical_Router_Port", &lrp->header_, settings[i],
- ctx->symtab);
+ char *error = ctl_set_column("Logical_Router_Port", &lrp->header_,
+ settings[i], ctx->symtab);
+ if (error) {
+ ctl_fatal("%s", error);
+ }
}
/* Insert the logical port into the logical router. */
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index d3614cfbc..6a9637a20 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -1591,8 +1591,11 @@ add_port(struct ctl_context *ctx,
}
for (i = 0; i < n_settings; i++) {
- ctl_set_column("Port", &port->header_, settings[i],
- ctx->symtab);
+ char *error = ctl_set_column("Port", &port->header_, settings[i],
+ ctx->symtab);
+ if (error) {
+ ctl_fatal("%s", error);
+ }
}
bridge_insert_port((bridge->parent ? bridge->parent->br_cfg
--
2.14.4
More information about the dev
mailing list