From 7e0f69b581705064e2fd767426c5227150a31e6f Mon Sep 17 00:00:00 2001 From: Ian Stokes Date: Wed, 21 Mar 2018 20:11:22 +0000 Subject: [PATCH 2/2] lib/tc: Fix sparse warnings. "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") Signed-off-by: Ian Stokes Signed-off-by: Ben Pfaff Acked-by: Roi Dayan --- lib/tc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/tc.c b/lib/tc.c index c446d8407..6daa44710 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)); } -- 2.17.0