On Tue, Aug 29, 2017 at 07:30:23AM +0300, Roi Dayan wrote:
> From: Paul Blakey <[email protected]>
> 
> If we find that we need to change from a SET to SET_MASKED action,
> then we write the mask to the actions opfbuf. But if there was netlink
> pad added to the buffer when writing the key, mask won't follow the
> key data as per SET_MASKED spec.
> 
> Fix that by removing the padding before writing the mask, and
> readding it if needed for alignment.
> 
> Fixes: 6d670e7f0d45 ("lib/odp: Masked set action execution and printing.")
> Signed-off-by: Paul Blakey <[email protected]>
> Reviewed-by: Roi Dayan <[email protected]>

Some minor nits below but that notwithstanding

Acked-by: Simon Horman <[email protected]>

> ---
>  lib/odp-util.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index 4f1499e..0594840 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -1990,8 +1990,17 @@ parse_odp_action(const char *s, const struct simap 
> *port_names,
>          if (size == nl_attr_get_size(key)) {
>              /* Change to masked set action if not fully masked. */
>              if (!is_all_ones(mask + 1, size)) {
> +                /* remove padding of eariler key payload  */
> +                actions->size -= NLA_ALIGN(key->nla_len) - key->nla_len;
> +
> +                /* put mask payload right after key payload */
>                  key->nla_len += size;
>                  ofpbuf_put(actions, mask + 1, size);
> +
> +                /* add back the netlink padding, if needed */

Maybe:

                 /* Add new padding as needed */

> +                ofpbuf_put_zeros(actions, NLA_ALIGN(key->nla_len) -
> +                                          key->nla_len);

The indentation of the above seems wrong:

+                ofpbuf_put_zeros(actions, NLA_ALIGN(key->nla_len) -
+                                 key->nla_len);

> +
>                  /* 'actions' may have been reallocated by ofpbuf_put(). */
>                  nested = ofpbuf_at_assert(actions, start_ofs, sizeof 
> *nested);
>                  nested->nla_type = OVS_ACTION_ATTR_SET_MASKED;
> -- 
> 2.7.0
> 
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to