diff mbox series

[ovs-dev,v2] dpctl: manage ret value when dumping CT entries.

Message ID 1506418629-3920-1-git-send-email-antonio.fischetti@intel.com
State Accepted
Headers show
Series [ovs-dev,v2] dpctl: manage ret value when dumping CT entries. | expand

Commit Message

Fischetti, Antonio Sept. 26, 2017, 9:37 a.m. UTC
Manage error value returned by ct_dpif_dump_next.

Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
---
 lib/dpctl.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

Comments

Fischetti, Antonio Sept. 26, 2017, 9:45 a.m. UTC | #1
Actually I forgot to add in the commit message

Reviewed-by: Greg Rose <gvrose8192@gmail.com>

Can this please be added later?

Thanks, Antonio

> -----Original Message-----
> From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-bounces@openvswitch.org]
> On Behalf Of antonio.fischetti@intel.com
> Sent: Tuesday, September 26, 2017 10:37 AM
> To: dev@openvswitch.org
> Subject: [ovs-dev] [PATCH v2] 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>
> ---
>  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
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Fischetti, Antonio Oct. 16, 2017, 2:04 p.m. UTC | #2
Any comment on v2?

Thanks,
Antonio

> -----Original Message-----
> From: Fischetti, Antonio
> Sent: Tuesday, September 26, 2017 10:45 AM
> To: Fischetti, Antonio <antonio.fischetti@intel.com>; dev@openvswitch.org
> Subject: RE: [ovs-dev] [PATCH v2] dpctl: manage ret value when dumping CT
> entries.
> 
> Actually I forgot to add in the commit message
> 
> Reviewed-by: Greg Rose <gvrose8192@gmail.com>
> 
> Can this please be added later?
> 
> Thanks, Antonio
> 
> > -----Original Message-----
> > From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-
> bounces@openvswitch.org]
> > On Behalf Of antonio.fischetti@intel.com
> > Sent: Tuesday, September 26, 2017 10:37 AM
> > To: dev@openvswitch.org
> > Subject: [ovs-dev] [PATCH v2] 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>
> > ---
> >  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
> > dev@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Ben Pfaff Nov. 3, 2017, 9:55 p.m. UTC | #3
I applied this to master and added that tag.

Thanks,

Ben.

On Tue, Sep 26, 2017 at 09:45:16AM +0000, Fischetti, Antonio wrote:
> Actually I forgot to add in the commit message
> 
> Reviewed-by: Greg Rose <gvrose8192@gmail.com>
> 
> Can this please be added later?
> 
> Thanks, Antonio
> 
> > -----Original Message-----
> > From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-bounces@openvswitch.org]
> > On Behalf Of antonio.fischetti@intel.com
> > Sent: Tuesday, September 26, 2017 10:37 AM
> > To: dev@openvswitch.org
> > Subject: [ovs-dev] [PATCH v2] 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>
> > ---
> >  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
> > dev@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

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");