[ovs-dev] [PATCH] lib/tc: Fix sparse warnings.

Roi Dayan roid at mellanox.com
Thu Mar 22 10:38:16 UTC 2018



On 21/03/2018 22:11, Ian Stokes wrote:
> "sparse" complains with the warning 'incorrect type in argument 1
> (different base types)' in function nl_parse_flower_ip when parsing a key
> flag and in function nl_msg_put_flower_options when writing the key
> flag. Fix this by using network byte order when reading and writing key
> flags to netlink messages.
> 
> Fixes: 83e86606 ("netdev-tc-offloads: Add support for IP fragmentation")
> CC: Roi Dayan <roid at mellanox.com>
> Signed-off-by: Ian Stokes <ian.stokes at intel.com>
> ---
>   lib/tc.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/tc.c b/lib/tc.c
> index c446d84..6daa447 100644
> --- a/lib/tc.c
> +++ b/lib/tc.c
> @@ -377,8 +377,9 @@ nl_parse_flower_ip(struct nlattr **attrs, struct tc_flower *flower) {
>       }
>   
>       if (attrs[TCA_FLOWER_KEY_FLAGS_MASK]) {
> -        key->flags = ntohl(nl_attr_get_u32(attrs[TCA_FLOWER_KEY_FLAGS]));
> -        mask->flags = ntohl(nl_attr_get_u32(attrs[TCA_FLOWER_KEY_FLAGS_MASK]));
> +        key->flags = ntohl(nl_attr_get_be32(attrs[TCA_FLOWER_KEY_FLAGS]));
> +        mask->flags =
> +                ntohl(nl_attr_get_be32(attrs[TCA_FLOWER_KEY_FLAGS_MASK]));
>       }
>   
>       if (attrs[TCA_FLOWER_KEY_IPV4_SRC_MASK]) {
> @@ -1503,9 +1504,9 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower)
>           }
>   
>           if (flower->mask.flags) {
> -            nl_msg_put_u32(request, TCA_FLOWER_KEY_FLAGS,
> +            nl_msg_put_be32(request, TCA_FLOWER_KEY_FLAGS,
>                              htonl(flower->key.flags));
> -            nl_msg_put_u32(request, TCA_FLOWER_KEY_FLAGS_MASK,
> +            nl_msg_put_be32(request, TCA_FLOWER_KEY_FLAGS_MASK,
>                              htonl(flower->mask.flags));
>           }
>   
> 

Acked-by: Roi Dayan <roid at mellanox.com>


More information about the dev mailing list