summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorAlin Gabriel Serdean <aserdean@ovn.org>2018-08-07 00:34:45 +0300
committerAlin Gabriel Serdean <aserdean@ovn.org>2018-08-08 21:01:37 +0300
commit111b58cc7921e54caa384851c2f11c066014a49b (patch)
tree8d9c961a99cd3fd7e35fe8473c5b04734f0654b7 /utilities
parentb096fa42ddc2ed69fa86b60a501bd3c34e767b7f (diff)
downloadopenvswitch-111b58cc7921e54caa384851c2f11c066014a49b.tar.gz
ofctl: Fixup compare_flows function
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> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/ovs-ofctl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 8d14a9b59..c3b49dbac 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++) {