2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00

lib/classifier: Fix array splicing.

Array splicing was broken when multiple elements were being moved,
resulting in the priority order being mixed.  This came up when the
highest priority rule from a subtable was removed and the subtable
needed to be moved down the priority list by more than one position.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Jarno Rajahalme
2014-05-11 23:38:44 -07:00
parent ef7889b47d
commit 75264fe5f1

View File

@@ -224,12 +224,14 @@ cls_subtable_cache_splice(struct cls_subtable_entry *to,
to = start; start = end; end = temp;
}
if (to < start) {
/* Move elements [start, end) to (to) one by one. */
while (start != end) {
struct cls_subtable_entry temp = *start;
/* Shift array by one, making space for the element at 'temp'. */
memmove(to + 1, to, (start - to) * sizeof *to);
*to = temp;
start++;
start++; to++;
}
} /* Else nothing to be done. */
}