diff mbox series

[ovs-dev] ofctl: Fixup compare_flows function

Message ID 20180806213445.29084-1-aserdean@ovn.org
State Accepted
Headers show
Series [ovs-dev] ofctl: Fixup compare_flows function | expand

Commit Message

Alin-Gabriel Serdean Aug. 6, 2018, 9:34 p.m. UTC
In the case there was no sorting criteria the flows on Windows were being
rearranged because it was always returning zero.

Also check if there we need sorting to save a few cycles.

CC: Ben Pfaff <blp@ovn.org>
Co-authored-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
---
 utilities/ovs-ofctl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Ben Pfaff Aug. 6, 2018, 9:39 p.m. UTC | #1
On Tue, Aug 07, 2018 at 12:34:45AM +0300, Alin Gabriel Serdean wrote:
> In the case there was no sorting criteria the flows on Windows were being
> rearranged because it was always returning zero.
> 
> Also check if there we need sorting to save a few cycles.
> 
> CC: Ben Pfaff <blp@ovn.org>
> Co-authored-by: Ben Pfaff <blp@ovn.org>
> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>

Acked-by: Ben Pfaff <blp@ovn.org>
0-day Robot Aug. 6, 2018, 10:41 p.m. UTC | #2
Bleep bloop.  Greetings Alin Gabriel Serdean, 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:
ERROR: Too many signoffs; are you missing Co-authored-by lines?
ERROR: Co-authored-by/Signed-off-by corruption
Lines checked: 46, Warnings: 0, Errors: 2


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

Thanks,
0-day Robot
Alin-Gabriel Serdean Aug. 7, 2018, 12:59 p.m. UTC | #3
Can you also provide a Signed-off-by pls?

> -----Mesaj original-----
> De la: ovs-dev-bounces@openvswitch.org <ovs-dev-
> bounces@openvswitch.org> În numele Ben Pfaff
> Trimis: Tuesday, August 7, 2018 12:40 AM
> Către: Alin Gabriel Serdean <aserdean@ovn.org>
> Cc: dev@openvswitch.org
> Subiect: Re: [ovs-dev] [PATCH] ofctl: Fixup compare_flows function
> 
> On Tue, Aug 07, 2018 at 12:34:45AM +0300, Alin Gabriel Serdean wrote:
> > In the case there was no sorting criteria the flows on Windows were
> > being rearranged because it was always returning zero.
> >
> > Also check if there we need sorting to save a few cycles.
> >
> > CC: Ben Pfaff <blp@ovn.org>
> > Co-authored-by: Ben Pfaff <blp@ovn.org>
> > Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
> 
> Acked-by: Ben Pfaff <blp@ovn.org>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Ben Pfaff Aug. 7, 2018, 4:36 p.m. UTC | #4
Signed-off-by: Ben Pfaff <blp@ovn.org>

On Tue, Aug 07, 2018 at 03:59:59PM +0300, aserdean@ovn.org wrote:
> Can you also provide a Signed-off-by pls?
> 
> > -----Mesaj original-----
> > De la: ovs-dev-bounces@openvswitch.org <ovs-dev-
> > bounces@openvswitch.org> În numele Ben Pfaff
> > Trimis: Tuesday, August 7, 2018 12:40 AM
> > Către: Alin Gabriel Serdean <aserdean@ovn.org>
> > Cc: dev@openvswitch.org
> > Subiect: Re: [ovs-dev] [PATCH] ofctl: Fixup compare_flows function
> > 
> > On Tue, Aug 07, 2018 at 12:34:45AM +0300, Alin Gabriel Serdean wrote:
> > > In the case there was no sorting criteria the flows on Windows were
> > > being rearranged because it was always returning zero.
> > >
> > > Also check if there we need sorting to save a few cycles.
> > >
> > > CC: Ben Pfaff <blp@ovn.org>
> > > Co-authored-by: Ben Pfaff <blp@ovn.org>
> > > Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
> > 
> > Acked-by: Ben Pfaff <blp@ovn.org>
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Alin-Gabriel Serdean Aug. 8, 2018, 6:36 p.m. UTC | #5
On 7 Aug 2018, at 19:36, Ben Pfaff <blp@ovn.org> wrote:
> 
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> 
> On Tue, Aug 07, 2018 at 03:59:59PM +0300, aserdean@ovn.org wrote:
>> Can you also provide a Signed-off-by pls?
>> 
>>> -----Mesaj original-----
>>> De la: ovs-dev-bounces@openvswitch.org <ovs-dev-
>>> bounces@openvswitch.org> În numele Ben Pfaff
>>> Trimis: Tuesday, August 7, 2018 12:40 AM
>>> Către: Alin Gabriel Serdean <aserdean@ovn.org>
>>> Cc: dev@openvswitch.org
>>> Subiect: Re: [ovs-dev] [PATCH] ofctl: Fixup compare_flows function
>>> 
>>> On Tue, Aug 07, 2018 at 12:34:45AM +0300, Alin Gabriel Serdean wrote:
>>>> In the case there was no sorting criteria the flows on Windows were
>>>> being rearranged because it was always returning zero.
>>>> 
>>>> Also check if there we need sorting to save a few cycles.
>>>> 
>>>> CC: Ben Pfaff <blp@ovn.org>
>>>> Co-authored-by: Ben Pfaff <blp@ovn.org>
>>>> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
>>> 
>>> Acked-by: Ben Pfaff <blp@ovn.org>
>>> _______________________________________________
>>> dev mailing list
>>> dev@openvswitch.org
>>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>> 

Thanks! I applied this from master to branch-2.7
diff mbox series

Patch

diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 6acbbf140..d06c827c4 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1543,7 +1543,7 @@  compare_flows(const void *afs_, const void *bfs_)
         }
     }
 
-    return 0;
+    return a < b ? -1 : 1;
 }
 
 static void
@@ -1565,7 +1565,9 @@  ofctl_dump_flows(struct ovs_cmdl_context *ctx)
         run(vconn_dump_flows(vconn, &fsr, protocol, &fses, &n_fses),
             "dump flows");
 
-        qsort(fses, n_fses, sizeof *fses, compare_flows);
+        if (n_criteria) {
+            qsort(fses, n_fses, sizeof *fses, compare_flows);
+        }
 
         struct ds s = DS_EMPTY_INITIALIZER;
         for (size_t i = 0; i < n_fses; i++) {