Re: [PATCH net-next] cls_flower: Support multiple masks per priority

Jiri Pirko
2018-04-30T09:44:40Z

Mon, Apr 30, 2018 at 10:28:29AM CEST, paulb@mellanox.com wrote:
>Currently flower doesn't support inserting filters with different masks
>on a single priority, even if the actual flows (key + mask) inserted
>aren't overlapping, as with the use case of offloading openvswitch
>datapath flows. Instead one must go up one level, and assign different
>priorities for each mask, which will create a different flower
>instances.
>
>This patch opens flower to support more than one mask per priority,
>and a single flower instance. It does so by adding another hash table
>on top of the existing one which will store the different masks,
>and the filters that share it.
>
>The user is left with the responsibilty of ensuring non overlapping

s/responsibilty/responsibility

>flows, otherwise precedence is not guaranteed.
>
>Signed-off-by: Paul Blakey <paulb@mellanox.com>

Looks good to me.

One small nit below.
Feel free to append my tag to v2:
Signed-off-by: Jiri Pirko <jiri@mellanox.com>

[...]

>@@ -103,15 +113,22 @@ static void fl_mask_update_range(struct fl_flow_mask *mask)
> {
> const u8 *bytes = (const u8 *) &mask->key;
> size_t size = sizeof(mask->key);
>- size_t i, first = 0, last = size - 1;
>+ size_t i, first = 0, last;
>
>- for (i = 0; i < sizeof(mask->key); i++) {
>+ for (i = 0; i < size; i++) {
>+ if (bytes[i]) {
>+ first = i;
>+ break;
>+ }
>+ }
>+ last = first;
>+ for (i = size - 1; i != first; i--) {
> if (bytes[i]) {
>- if (!first && i)
>- first = i;
> last = i;
>+ break;
> }
> }
>+

Remove this newline.

> mask->range.start = rounddown(first, sizeof(long));
> mask->range.end = roundup(last + 1, sizeof(long));
> } …