mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
dpctl: manage ret value when dumping CT entries.
Manage error value returned by ct_dpif_dump_next. Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Greg Rose <gvrose8192@gmail.com>
This commit is contained in:
committed by
Ben Pfaff
parent
cb9958e930
commit
97ee6d41e2
27
lib/dpctl.c
27
lib/dpctl.c
@@ -1304,7 +1304,7 @@ dpctl_dump_conntrack(int argc, const char *argv[],
|
||||
return error;
|
||||
}
|
||||
|
||||
while (!ct_dpif_dump_next(dump, &cte)) {
|
||||
while (!(error = ct_dpif_dump_next(dump, &cte))) {
|
||||
struct ds s = DS_EMPTY_INITIALIZER;
|
||||
|
||||
ct_dpif_format_entry(&cte, &s, dpctl_p->verbosity,
|
||||
@@ -1314,6 +1314,13 @@ dpctl_dump_conntrack(int argc, const char *argv[],
|
||||
dpctl_print(dpctl_p, "%s\n", ds_cstr(&s));
|
||||
ds_destroy(&s);
|
||||
}
|
||||
if (error == EOF) {
|
||||
/* Any CT entry was dumped with no issue. */
|
||||
error = 0;
|
||||
} else if (error) {
|
||||
dpctl_error(dpctl_p, error, "dumping conntrack entry");
|
||||
}
|
||||
|
||||
ct_dpif_dump_done(dump);
|
||||
dpif_close(dpif);
|
||||
return error;
|
||||
@@ -1407,7 +1414,7 @@ dpctl_ct_stats_show(int argc, const char *argv[],
|
||||
}
|
||||
|
||||
int tot_conn = 0;
|
||||
while (!ct_dpif_dump_next(dump, &cte)) {
|
||||
while (!(error = ct_dpif_dump_next(dump, &cte))) {
|
||||
ct_dpif_entry_uninit(&cte);
|
||||
tot_conn++;
|
||||
switch (cte.tuple_orig.ip_proto) {
|
||||
@@ -1448,6 +1455,13 @@ dpctl_ct_stats_show(int argc, const char *argv[],
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (error == EOF) {
|
||||
/* All CT entries were dumped with no issue. */
|
||||
error = 0;
|
||||
} else if (error) {
|
||||
dpctl_error(dpctl_p, error, "dumping conntrack entry");
|
||||
/* Fall through to show any other info we collected. */
|
||||
}
|
||||
|
||||
dpctl_print(dpctl_p, "Connections Stats:\n Total: %d\n", tot_conn);
|
||||
if (proto_stats[CT_STATS_TCP]) {
|
||||
@@ -1547,7 +1561,7 @@ dpctl_ct_bkts(int argc, const char *argv[],
|
||||
int tot_conn = 0;
|
||||
uint32_t *conn_per_bkts = xzalloc(tot_bkts * sizeof(uint32_t));
|
||||
|
||||
while (!ct_dpif_dump_next(dump, &cte)) {
|
||||
while (!(error = ct_dpif_dump_next(dump, &cte))) {
|
||||
ct_dpif_entry_uninit(&cte);
|
||||
tot_conn++;
|
||||
if (tot_bkts > 0) {
|
||||
@@ -1559,6 +1573,13 @@ dpctl_ct_bkts(int argc, const char *argv[],
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error == EOF) {
|
||||
/* All CT entries were dumped with no issue. */
|
||||
error = 0;
|
||||
} else if (error) {
|
||||
dpctl_error(dpctl_p, error, "dumping conntrack entry");
|
||||
/* Fall through and display all the collected info. */
|
||||
}
|
||||
|
||||
dpctl_print(dpctl_p, "Current Connections: %d\n", tot_conn);
|
||||
dpctl_print(dpctl_p, "\n");
|
||||
|
Reference in New Issue
Block a user