Skip to content

Commit

Permalink
ofctl: Fixup compare_flows function
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Ben Pfaff <[email protected]>
Signed-off-by: Alin Gabriel Serdean <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
aserdean and blp committed Aug 8, 2018
1 parent b096fa4 commit 111b58c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utilities/ovs-ofctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ compare_flows(const void *afs_, const void *bfs_)
}
}

return 0;
return a < b ? -1 : 1;
}

static void
Expand All @@ -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++) {
Expand Down

0 comments on commit 111b58c

Please sign in to comment.