diff mbox series

[ovs-dev,ovs,v4] dpctl-netdev: Add the option 'pmd' for dump-flows

Message ID 20201015033359.91427-1-xiangxia.m.yue@gmail.com
State Accepted
Headers show
Series [ovs-dev,ovs,v4] dpctl-netdev: Add the option 'pmd' for dump-flows | expand

Commit Message

Tonghao Zhang Oct. 15, 2020, 3:33 a.m. UTC
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

"ovs-appctl dpctl/dump-flows" added the option
"pmd" which allow user to dump pmd specified.

That option is useful to dump rules of pmd
when we have a large number of rules in dp.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 NEWS          |  3 +++
 lib/dpctl.c   | 20 ++++++++++++++++----
 lib/dpctl.man |  6 +++++-
 3 files changed, 24 insertions(+), 5 deletions(-)

Comments

0-day Robot Oct. 15, 2020, 3:59 a.m. UTC | #1
Bleep bloop.  Greetings Tonghao Zhang, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line is 175 characters long (recommended limit is 79)
#101 FILE: lib/dpctl.man:107:
.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR] [\fBpmd=\fIpmd\fR]"

Lines checked: 118, Warnings: 1, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
Gaetan Rivet Oct. 15, 2020, 10:53 a.m. UTC | #2
On 15/10/20 11:33 +0800, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> "ovs-appctl dpctl/dump-flows" added the option
> "pmd" which allow user to dump pmd specified.
> 
> That option is useful to dump rules of pmd
> when we have a large number of rules in dp.
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>

Thanks for the changes!

Acked-by: Gaetan Rivet <grive@u256.net>

> ---
>  NEWS          |  3 +++
>  lib/dpctl.c   | 20 ++++++++++++++++----
>  lib/dpctl.man |  6 +++++-
>  3 files changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index 4619e73bf83b..276a5e878b3f 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -5,6 +5,9 @@ Post-v2.14.0
>         status of the storage that's backing a database.
>     - DPDK:
>       * Removed support for vhost-user dequeue zero-copy.
> +   - Userspace datapath:
> +     * Add the 'pmd' option to "ovs-appctl dpctl/dump-flows", which
> +       restricts a flow dump to a single PMD thread if set.
>     - The environment variable OVS_UNBOUND_CONF, if set, is now used
>       as the DNS resolver's (unbound) configuration file.
>  
> diff --git a/lib/dpctl.c b/lib/dpctl.c
> index 2f859a7531c9..33202813b544 100644
> --- a/lib/dpctl.c
> +++ b/lib/dpctl.c
> @@ -980,6 +980,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
>      struct dpif_flow_dump *flow_dump;
>      struct dpif_flow f;
>      int pmd_id = PMD_ID_NULL;
> +    bool pmd_id_filter = false;
>      int lastargc = 0;
>      int error;
>  
> @@ -996,6 +997,16 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
>                  goto out_free;
>              }
>              types_list = xstrdup(argv[--argc] + 5);
> +        } else if (!strncmp(argv[argc - 1], "pmd=", 4)) {
> +            if (!ovs_scan(argv[--argc], "pmd=%d", &pmd_id)) {
> +                error = EINVAL;
> +                goto out_free;
> +            }
> +
> +            if (pmd_id == -1) {
> +                pmd_id = NON_PMD_CORE_ID;
> +            }
> +            pmd_id_filter = true;
>          }
>      }
>  
> @@ -1070,7 +1081,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
>          /* If 'pmd_id' is specified, overlapping flows could be dumped from
>           * different pmd threads.  So, separates dumps from different pmds
>           * by printing a title line. */
> -        if (pmd_id != f.pmd_id) {
> +        if (!pmd_id_filter && pmd_id != f.pmd_id) {
>              if (f.pmd_id == NON_PMD_CORE_ID) {
>                  ds_put_format(&ds, "flow-dump from the main thread:\n");
>              } else {
> @@ -1079,7 +1090,8 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
>              }
>              pmd_id = f.pmd_id;
>          }
> -        if (flow_passes_type_filter(&f, &dump_types)) {
> +        if (pmd_id == f.pmd_id &&
> +            flow_passes_type_filter(&f, &dump_types)) {
>              format_dpif_flow(&ds, &f, portno_names, dpctl_p);
>              dpctl_print(dpctl_p, "%s\n", ds_cstr(&ds));
>          }
> @@ -2522,8 +2534,8 @@ static const struct dpctl_command all_commands[] = {
>      { "set-if", "dp iface...", 2, INT_MAX, dpctl_set_if, DP_RW },
>      { "dump-dps", "", 0, 0, dpctl_dump_dps, DP_RO },
>      { "show", "[dp...]", 0, INT_MAX, dpctl_show, DP_RO },
> -    { "dump-flows", "[dp] [filter=..] [type=..]",
> -      0, 3, dpctl_dump_flows, DP_RO },
> +    { "dump-flows", "[dp] [filter=..] [type=..] [pmd=..]",
> +      0, 4, dpctl_dump_flows, DP_RO },
>      { "add-flow", "[dp] flow actions", 2, 3, dpctl_add_flow, DP_RW },
>      { "mod-flow", "[dp] flow actions", 2, 3, dpctl_mod_flow, DP_RW },
>      { "get-flow", "[dp] ufid", 1, 2, dpctl_get_flow, DP_RO },
> diff --git a/lib/dpctl.man b/lib/dpctl.man
> index 727d1f7be8d4..0f63277861e5 100644
> --- a/lib/dpctl.man
> +++ b/lib/dpctl.man
> @@ -104,7 +104,7 @@ default.  When multiple datapaths exist, then a datapath name is
>  required.
>  .
>  .TP
> -.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR]"
> +.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR] [\fBpmd=\fIpmd\fR]"
>  Prints to the console all flow entries in datapath \fIdp\fR's flow
>  table.  Without \fB\-m\fR or \fB\-\-more\fR, output omits match fields
>  that a flow wildcards entirely; with \fB\-m\fR or \fB\-\-more\fR,
> @@ -118,6 +118,10 @@ The \fIfilter\fR is also useful to match wildcarded fields in the datapath
>  flow. As an example, \fBfilter='tcp,tp_src=100'\fR will match the
>  datapath flow containing '\fBtcp(src=80/0xff00,dst=8080/0xff)\fR'.
>  .IP
> +If \fBpmd=\fIpmd\fR is specified, only displays flows of the specified pmd.
> +Using \fBpmd=\fI-1\fR will restrict the dump to flows from the main thread.
> +This option is only supported by the \fBuserspace datapath\fR.
> +.IP
>  If \fBtype=\fItype\fR is specified, only displays flows of the specified types.
>  This option supported only for \fBovs\-appctl dpctl/dump\-flows\fR.
>  \fItype\fR is a comma separated list, which can contain any of the following:
> -- 
> 1.8.3.1
>
Tonghao Zhang Oct. 27, 2020, 2:03 a.m. UTC | #3
On Thu, Oct 15, 2020 at 6:53 PM Gaëtan Rivet <grive@u256.net> wrote:
>
> On 15/10/20 11:33 +0800, xiangxia.m.yue@gmail.com wrote:
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > "ovs-appctl dpctl/dump-flows" added the option
> > "pmd" which allow user to dump pmd specified.
> >
> > That option is useful to dump rules of pmd
> > when we have a large number of rules in dp.
> >
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> Thanks for the changes!
>
> Acked-by: Gaetan Rivet <grive@u256.net>
ping
> > ---
> >  NEWS          |  3 +++
> >  lib/dpctl.c   | 20 ++++++++++++++++----
> >  lib/dpctl.man |  6 +++++-
> >  3 files changed, 24 insertions(+), 5 deletions(-)
> >
> > diff --git a/NEWS b/NEWS
> > index 4619e73bf83b..276a5e878b3f 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -5,6 +5,9 @@ Post-v2.14.0
> >         status of the storage that's backing a database.
> >     - DPDK:
> >       * Removed support for vhost-user dequeue zero-copy.
> > +   - Userspace datapath:
> > +     * Add the 'pmd' option to "ovs-appctl dpctl/dump-flows", which
> > +       restricts a flow dump to a single PMD thread if set.
> >     - The environment variable OVS_UNBOUND_CONF, if set, is now used
> >       as the DNS resolver's (unbound) configuration file.
> >
> > diff --git a/lib/dpctl.c b/lib/dpctl.c
> > index 2f859a7531c9..33202813b544 100644
> > --- a/lib/dpctl.c
> > +++ b/lib/dpctl.c
> > @@ -980,6 +980,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
> >      struct dpif_flow_dump *flow_dump;
> >      struct dpif_flow f;
> >      int pmd_id = PMD_ID_NULL;
> > +    bool pmd_id_filter = false;
> >      int lastargc = 0;
> >      int error;
> >
> > @@ -996,6 +997,16 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
> >                  goto out_free;
> >              }
> >              types_list = xstrdup(argv[--argc] + 5);
> > +        } else if (!strncmp(argv[argc - 1], "pmd=", 4)) {
> > +            if (!ovs_scan(argv[--argc], "pmd=%d", &pmd_id)) {
> > +                error = EINVAL;
> > +                goto out_free;
> > +            }
> > +
> > +            if (pmd_id == -1) {
> > +                pmd_id = NON_PMD_CORE_ID;
> > +            }
> > +            pmd_id_filter = true;
> >          }
> >      }
> >
> > @@ -1070,7 +1081,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
> >          /* If 'pmd_id' is specified, overlapping flows could be dumped from
> >           * different pmd threads.  So, separates dumps from different pmds
> >           * by printing a title line. */
> > -        if (pmd_id != f.pmd_id) {
> > +        if (!pmd_id_filter && pmd_id != f.pmd_id) {
> >              if (f.pmd_id == NON_PMD_CORE_ID) {
> >                  ds_put_format(&ds, "flow-dump from the main thread:\n");
> >              } else {
> > @@ -1079,7 +1090,8 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
> >              }
> >              pmd_id = f.pmd_id;
> >          }
> > -        if (flow_passes_type_filter(&f, &dump_types)) {
> > +        if (pmd_id == f.pmd_id &&
> > +            flow_passes_type_filter(&f, &dump_types)) {
> >              format_dpif_flow(&ds, &f, portno_names, dpctl_p);
> >              dpctl_print(dpctl_p, "%s\n", ds_cstr(&ds));
> >          }
> > @@ -2522,8 +2534,8 @@ static const struct dpctl_command all_commands[] = {
> >      { "set-if", "dp iface...", 2, INT_MAX, dpctl_set_if, DP_RW },
> >      { "dump-dps", "", 0, 0, dpctl_dump_dps, DP_RO },
> >      { "show", "[dp...]", 0, INT_MAX, dpctl_show, DP_RO },
> > -    { "dump-flows", "[dp] [filter=..] [type=..]",
> > -      0, 3, dpctl_dump_flows, DP_RO },
> > +    { "dump-flows", "[dp] [filter=..] [type=..] [pmd=..]",
> > +      0, 4, dpctl_dump_flows, DP_RO },
> >      { "add-flow", "[dp] flow actions", 2, 3, dpctl_add_flow, DP_RW },
> >      { "mod-flow", "[dp] flow actions", 2, 3, dpctl_mod_flow, DP_RW },
> >      { "get-flow", "[dp] ufid", 1, 2, dpctl_get_flow, DP_RO },
> > diff --git a/lib/dpctl.man b/lib/dpctl.man
> > index 727d1f7be8d4..0f63277861e5 100644
> > --- a/lib/dpctl.man
> > +++ b/lib/dpctl.man
> > @@ -104,7 +104,7 @@ default.  When multiple datapaths exist, then a datapath name is
> >  required.
> >  .
> >  .TP
> > -.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR]"
> > +.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR] [\fBpmd=\fIpmd\fR]"
> >  Prints to the console all flow entries in datapath \fIdp\fR's flow
> >  table.  Without \fB\-m\fR or \fB\-\-more\fR, output omits match fields
> >  that a flow wildcards entirely; with \fB\-m\fR or \fB\-\-more\fR,
> > @@ -118,6 +118,10 @@ The \fIfilter\fR is also useful to match wildcarded fields in the datapath
> >  flow. As an example, \fBfilter='tcp,tp_src=100'\fR will match the
> >  datapath flow containing '\fBtcp(src=80/0xff00,dst=8080/0xff)\fR'.
> >  .IP
> > +If \fBpmd=\fIpmd\fR is specified, only displays flows of the specified pmd.
> > +Using \fBpmd=\fI-1\fR will restrict the dump to flows from the main thread.
> > +This option is only supported by the \fBuserspace datapath\fR.
> > +.IP
> >  If \fBtype=\fItype\fR is specified, only displays flows of the specified types.
> >  This option supported only for \fBovs\-appctl dpctl/dump\-flows\fR.
> >  \fItype\fR is a comma separated list, which can contain any of the following:
> > --
> > 1.8.3.1
> >
>
> --
> Gaëtan
Ilya Maximets Nov. 10, 2020, 9:26 a.m. UTC | #4
On 10/15/20 12:53 PM, Gaëtan Rivet wrote:
> On 15/10/20 11:33 +0800, xiangxia.m.yue@gmail.com wrote:
>> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>>
>> "ovs-appctl dpctl/dump-flows" added the option
>> "pmd" which allow user to dump pmd specified.
>>
>> That option is useful to dump rules of pmd
>> when we have a large number of rules in dp.
>>
>> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> Thanks for the changes!
> 
> Acked-by: Gaetan Rivet <grive@u256.net>

Thanks!
Applied to master.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/NEWS b/NEWS
index 4619e73bf83b..276a5e878b3f 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,9 @@  Post-v2.14.0
        status of the storage that's backing a database.
    - DPDK:
      * Removed support for vhost-user dequeue zero-copy.
+   - Userspace datapath:
+     * Add the 'pmd' option to "ovs-appctl dpctl/dump-flows", which
+       restricts a flow dump to a single PMD thread if set.
    - The environment variable OVS_UNBOUND_CONF, if set, is now used
      as the DNS resolver's (unbound) configuration file.
 
diff --git a/lib/dpctl.c b/lib/dpctl.c
index 2f859a7531c9..33202813b544 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -980,6 +980,7 @@  dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
     struct dpif_flow_dump *flow_dump;
     struct dpif_flow f;
     int pmd_id = PMD_ID_NULL;
+    bool pmd_id_filter = false;
     int lastargc = 0;
     int error;
 
@@ -996,6 +997,16 @@  dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
                 goto out_free;
             }
             types_list = xstrdup(argv[--argc] + 5);
+        } else if (!strncmp(argv[argc - 1], "pmd=", 4)) {
+            if (!ovs_scan(argv[--argc], "pmd=%d", &pmd_id)) {
+                error = EINVAL;
+                goto out_free;
+            }
+
+            if (pmd_id == -1) {
+                pmd_id = NON_PMD_CORE_ID;
+            }
+            pmd_id_filter = true;
         }
     }
 
@@ -1070,7 +1081,7 @@  dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
         /* If 'pmd_id' is specified, overlapping flows could be dumped from
          * different pmd threads.  So, separates dumps from different pmds
          * by printing a title line. */
-        if (pmd_id != f.pmd_id) {
+        if (!pmd_id_filter && pmd_id != f.pmd_id) {
             if (f.pmd_id == NON_PMD_CORE_ID) {
                 ds_put_format(&ds, "flow-dump from the main thread:\n");
             } else {
@@ -1079,7 +1090,8 @@  dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
             }
             pmd_id = f.pmd_id;
         }
-        if (flow_passes_type_filter(&f, &dump_types)) {
+        if (pmd_id == f.pmd_id &&
+            flow_passes_type_filter(&f, &dump_types)) {
             format_dpif_flow(&ds, &f, portno_names, dpctl_p);
             dpctl_print(dpctl_p, "%s\n", ds_cstr(&ds));
         }
@@ -2522,8 +2534,8 @@  static const struct dpctl_command all_commands[] = {
     { "set-if", "dp iface...", 2, INT_MAX, dpctl_set_if, DP_RW },
     { "dump-dps", "", 0, 0, dpctl_dump_dps, DP_RO },
     { "show", "[dp...]", 0, INT_MAX, dpctl_show, DP_RO },
-    { "dump-flows", "[dp] [filter=..] [type=..]",
-      0, 3, dpctl_dump_flows, DP_RO },
+    { "dump-flows", "[dp] [filter=..] [type=..] [pmd=..]",
+      0, 4, dpctl_dump_flows, DP_RO },
     { "add-flow", "[dp] flow actions", 2, 3, dpctl_add_flow, DP_RW },
     { "mod-flow", "[dp] flow actions", 2, 3, dpctl_mod_flow, DP_RW },
     { "get-flow", "[dp] ufid", 1, 2, dpctl_get_flow, DP_RO },
diff --git a/lib/dpctl.man b/lib/dpctl.man
index 727d1f7be8d4..0f63277861e5 100644
--- a/lib/dpctl.man
+++ b/lib/dpctl.man
@@ -104,7 +104,7 @@  default.  When multiple datapaths exist, then a datapath name is
 required.
 .
 .TP
-.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR]"
+.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR] [\fBpmd=\fIpmd\fR]"
 Prints to the console all flow entries in datapath \fIdp\fR's flow
 table.  Without \fB\-m\fR or \fB\-\-more\fR, output omits match fields
 that a flow wildcards entirely; with \fB\-m\fR or \fB\-\-more\fR,
@@ -118,6 +118,10 @@  The \fIfilter\fR is also useful to match wildcarded fields in the datapath
 flow. As an example, \fBfilter='tcp,tp_src=100'\fR will match the
 datapath flow containing '\fBtcp(src=80/0xff00,dst=8080/0xff)\fR'.
 .IP
+If \fBpmd=\fIpmd\fR is specified, only displays flows of the specified pmd.
+Using \fBpmd=\fI-1\fR will restrict the dump to flows from the main thread.
+This option is only supported by the \fBuserspace datapath\fR.
+.IP
 If \fBtype=\fItype\fR is specified, only displays flows of the specified types.
 This option supported only for \fBovs\-appctl dpctl/dump\-flows\fR.
 \fItype\fR is a comma separated list, which can contain any of the following: