Skip to content

Commit

Permalink
ovs-vsctl: Correctly exit on errors for non-map types in "remove" com…
Browse files Browse the repository at this point in the history
…mand.

Reported-by: Thomas Graf <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Thomas Graf <[email protected]>
  • Loading branch information
blp committed Sep 2, 2014
1 parent 2e34a6a commit d6d2a5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions tests/ovs-vsctl.at
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,9 @@ AT_CHECK([RUN_OVS_VSCTL([set port br1 name br2])],
AT_CHECK([RUN_OVS_VSCTL([remove bridge br1 name br1])],
[1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([remove bridge br1 flood-vlans true])],
[1], [], [ovs-vsctl: "true" is not a valid integer
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([clear bridge br1 name])],
[1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
], [OVS_VSCTL_CLEANUP])
Expand Down
14 changes: 9 additions & 5 deletions utilities/ovs-vsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3528,11 +3528,15 @@ cmd_remove(struct vsctl_context *ctx)
rm_type.n_max = UINT_MAX;
error = ovsdb_datum_from_string(&rm, &rm_type,
ctx->argv[i], ctx->symtab);
if (error && ovsdb_type_is_map(&rm_type)) {
free(error);
rm_type.value.type = OVSDB_TYPE_VOID;
die_if_error(ovsdb_datum_from_string(&rm, &rm_type,
ctx->argv[i], ctx->symtab));
if (error) {
if (ovsdb_type_is_map(&rm_type)) {
rm_type.value.type = OVSDB_TYPE_VOID;
free(error);
die_if_error(ovsdb_datum_from_string(
&rm, &rm_type, ctx->argv[i], ctx->symtab));
} else {
vsctl_fatal("%s", error);
}
}
ovsdb_datum_subtract(&old, type, &rm, &rm_type);
ovsdb_datum_destroy(&rm, &rm_type);
Expand Down

0 comments on commit d6d2a5b

Please sign in to comment.