Message ID | 1521663082-8334-1-git-send-email-ian.stokes@intel.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev] lib/tc: Fix sparse warnings. | expand |
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@mellanox.com> > Signed-off-by: Ian Stokes <ian.stokes@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@mellanox.com>
On Thu, Mar 22, 2018 at 12:38:16PM +0200, Roi Dayan wrote: > > > 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@mellanox.com> > >Signed-off-by: Ian Stokes <ian.stokes@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@mellanox.com> Thanks Ian and Roi, I applied this to master.
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)); }
"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@mellanox.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com> --- lib/tc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)