nx-match: Handle receiving variable length fields.
authorJesse Gross <jesse@nicira.com>
Thu, 7 May 2015 01:00:52 +0000 (18:00 -0700)
committerJesse Gross <jesse@nicira.com>
Thu, 25 Jun 2015 18:08:57 +0000 (11:08 -0700)
commit11b8d04900417e722bb9cfad6021870bdee37fd6
tree0fc78d5c32aebe85a485c9e00d17b223ae164c90
parent899bb63d41d0de38749304d51ea259ec529271b1
nx-match: Handle receiving variable length fields.

This adds support for receiving variable length fields encoded in
NXM/OXM and mapping them into OVS internal structures. In order
for this to make sense, we need to define some semantics:

There are three lengths that matter in this process: the maximum
size of the field (represented as the existing mf->n_bytes), the
size of the field in the incoming NXM (given by the length in the
NXM header), and the currently configured length of the field
(defined by the consumer of the field and outside the scope of
this patch).

Fields are modeled as being their maximum length and have the
characteristics expected by exsiting code (i.e. exact match fields
have masks that are all 1's for the whole field, etc.). Incoming
NXMs are stored in the field in the least significant bits. If
the NXM length is larger than the field, is is truncated, if it
is smaller it is zero-extended. When the field is consumed, the
component that needs data picks the configured length out of the
generated field.

In most cases, the configured and NXM lengths will be equal and
these edge cases do not matter. However, since we cannot easily
enforce that the lengths match (and might not even know what the
right length is, such as in the case of a string parsed by
ovs-ofctl), these semantics should provide deterministic results
that are easy to understand and not require most existing code
to be aware of variable length fields.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/nx-match.c