[ovs-dev] [PATCH 05/11] nx-match: Trim variable length fields when encoding as actions.

Ben Pfaff blp at nicira.com
Wed Jun 24 19:12:13 UTC 2015


On Fri, Jun 19, 2015 at 04:13:19PM -0700, Jesse Gross wrote:
> It is technically correct to send the entire maximum length of
> a field when it is variable length. However, it is awkward to
> do so and not what one would naively expect. Since receivers will
> internally zero-extend fields, we can do the opposite and trim
> off leading zeros. This results in encodings that are generally
> sensible without specific knowledge of what is being transmitted.
> (Of course, other implementations, such as controllers, may know
> exactly the expected length of the field and are free to encode
> it that way even if it has leading zeros.)
> 
> Signed-off-by: Jesse Gross <jesse at nicira.com>

Acked-by: Ben Pfaff <blp at nicira.com>

I personally find this implementation of mf_field_len() easier to read
(I know that's terribly nitpicky):

    int len = field_len(mf, value);
    if (mask && !is_all_ones(mask, mf->n_bytes)) {
        int mask_len = field_len(mf, mask);
        len = MAX(len, mask_len);
    }
    return len;



More information about the dev mailing list