On Wed, May 27, 2015 at 10:48 AM, Jesse Gross <je...@nicira.com> wrote:
> When formatting netlink attributes if no mask is present a wildcarded
> attribute is synthesized for the purposes of later processing. In
> the case of nested attributes this must be done recursively, filling
> in the correct attributes at each level rather than just generating
> a set of zeros of the correct size. This is done already but it
> always uses the attribute type for the top level keys - this corresponds
> to nested ENCAP attributes. However, we have several levels of potentially
> nested attributes for tunnels that each have their own types.
>
> This uses an approach similar to the kernel where we have sets of
> tables for the type of each attribute linked together by pointers.
> This allows the mask generation function to automatically traverse
> the nested attributes and always get the right types.
>
> Signed-off-by: Jesse Gross <je...@nicira.com>
> ---
>  lib/odp-util.c | 151 
> ++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 86 insertions(+), 65 deletions(-)
>
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index 4845d28..09a1ff2 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -1208,45 +1208,73 @@ odp_actions_from_string(const char *s, const struct 
> simap *port_names,
>      return 0;
>  }
>
> +
> +struct attr_len_tbl {
> +    int len;
> +    const struct attr_len_tbl *next;
> +    int next_max;
> +};
> +#define ATTR_LEN_VARIABLE -2
> +#define ATTR_LEN_NESTED   -3
> +

Might be nice to also '#define ATTR_LEN_INVALID -1' for completeness.
Although it is expected to be used in
tables, but only a possible return value from function calls,

There are still a few places '-2' are hard coded, including some
comments. It might be nice to change them those as well.

Overall, nice change.
Acked-by: Andy Zhou <az...@nicira.com>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to