Manage error value returned by ct_dpif_dump_next.
Signed-off-by: Antonio Fischetti <[email protected]>
---
lib/dpctl.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/lib/dpctl.c b/lib/dpctl.c
index 8951d6e..d229c97 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -1286,7 +1286,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,
@@ -1296,6 +1296,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;
@@ -1384,7 +1391,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) {
@@ -1425,6 +1432,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]) {
@@ -1521,7 +1535,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) {
@@ -1533,6 +1547,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");
--
2.4.11
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev