Skip to content

Commit

Permalink
ovn-nbctl: Don't die in nbctl_qos_add().
Browse files Browse the repository at this point in the history
Propagate the error via the context instead.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
Jakub Sitnicki authored and blp committed Jul 9, 2018
1 parent cac6eb9 commit 5de75b9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions ovn/utilities/ovn-nbctl.c
Expand Up @@ -1899,42 +1899,44 @@ nbctl_qos_add(struct ctl_context *ctx)

char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls);
if (error) {
ctl_fatal("%s", error);
ctx->error = error;
return;
}

for (int i = 5; i < ctx->argc; i++) {
if (!strncmp(ctx->argv[i], "dscp=", 5)) {
if (!ovs_scan(ctx->argv[i] + 5, "%"SCNd64, &dscp)
|| dscp < 0 || dscp > 63) {
ctl_fatal("%s: dscp must in range 0...63.", ctx->argv[i] + 5);
ctl_error(ctx, "%s: dscp must in range 0...63.",
ctx->argv[i] + 5);
return;
}
}
else if (!strncmp(ctx->argv[i], "rate=", 5)) {
if (!ovs_scan(ctx->argv[i] + 5, "%"SCNd64, &rate)
|| rate < 1 || rate > UINT32_MAX) {
ctl_fatal("%s: rate must in range 1...4294967295.",
ctl_error(ctx, "%s: rate must in range 1...4294967295.",
ctx->argv[i] + 5);
return;
}
}
else if (!strncmp(ctx->argv[i], "burst=", 6)) {
if (!ovs_scan(ctx->argv[i] + 6, "%"SCNd64, &burst)
|| burst < 1 || burst > UINT32_MAX) {
ctl_fatal("%s: burst must in range 1...4294967295.",
ctl_error(ctx, "%s: burst must in range 1...4294967295.",
ctx->argv[i] + 6);
return;
}
} else {
ctl_fatal("%s: must be start of \"dscp=\", \"rate=\", \"burst=\".",
ctx->argv[i]);
ctl_error(ctx, "%s: must be start of \"dscp=\", \"rate=\", "
"\"burst=\".", ctx->argv[i]);
return;
}
}

/* Validate rate and dscp. */
if (-1 == dscp && !rate) {
ctl_fatal("One of the rate or dscp must be configured.");
ctl_error(ctx, "One of the rate or dscp must be configured.");
return;
}

Expand Down Expand Up @@ -1963,8 +1965,9 @@ nbctl_qos_add(struct ctl_context *ctx)
if (!qos_cmp(&ls->qos_rules[i], &qos)) {
bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
if (!may_exist) {
ctl_fatal("Same qos already existed on the ls %s.",
ctl_error(ctx, "Same qos already existed on the ls %s.",
ctx->argv[1]);
return;
}
return;
}
Expand Down

0 comments on commit 5de75b9

Please sign in to comment.