]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sctp: Correct type and usage of sctp_end_cksum()
authorSimon Horman <horms@verge.net.au>
Fri, 19 Apr 2013 01:54:58 +0000 (10:54 +0900)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 29 Apr 2013 18:09:08 +0000 (20:09 +0200)
Change the type of the crc32 parameter of sctp_end_cksum()
from __be32 to __u32 to reflect that fact that it is passed
to cpu_to_le32().

There are five in-tree users of sctp_end_cksum().
The following four had warnings flagged by sparse which are
no longer present with this change.

net/netfilter/ipvs/ip_vs_proto_sctp.c:sctp_nat_csum()
net/netfilter/ipvs/ip_vs_proto_sctp.c:sctp_csum_check()
net/sctp/input.c:sctp_rcv_checksum()
net/sctp/output.c:sctp_packet_transmit()

The fifth user is net/netfilter/nf_nat_proto_sctp.c:sctp_manip_pkt().
It has been updated to pass a __u32 instead of a __be32,
the value in question was already calculated in cpu byte-order.

net/netfilter/nf_nat_proto_sctp.c:sctp_manip_pkt() has also
been updated to assign the return value of sctp_end_cksum()
directly to a variable of type __le32, matching the
type of the return value. Previously the return value
was assigned to a variable of type __be32 and then that variable
was finally assigned to another variable of type __le32.

Problems flagged by sparse.
Compile and sparse tested only.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/sctp/checksum.h
net/netfilter/nf_nat_proto_sctp.c

index befc8d2a1b9f2703b5f31eabfe7c313ae0b05bcd..5a2110d3176dc4e532897e598262e4ce7259430d 100644 (file)
@@ -77,7 +77,7 @@ static inline __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32)
        return sctp_crc32c(crc32, buffer, length);
 }
 
-static inline __le32 sctp_end_cksum(__be32 crc32)
+static inline __le32 sctp_end_cksum(__u32 crc32)
 {
        return cpu_to_le32(~crc32);
 }
index e64faa5ca89314ac0d3dadef64366b70b60c3cdc..396e55d46f90c77ea25a88cc1e94decc76f81050 100644 (file)
@@ -36,7 +36,7 @@ sctp_manip_pkt(struct sk_buff *skb,
 {
        struct sk_buff *frag;
        sctp_sctphdr_t *hdr;
-       __be32 crc32;
+       __u32 crc32;
 
        if (!skb_make_writable(skb, hdroff + sizeof(*hdr)))
                return false;
@@ -55,8 +55,7 @@ sctp_manip_pkt(struct sk_buff *skb,
        skb_walk_frags(skb, frag)
                crc32 = sctp_update_cksum((u8 *)frag->data, skb_headlen(frag),
                                          crc32);
-       crc32 = sctp_end_cksum(crc32);
-       hdr->checksum = crc32;
+       hdr->checksum = sctp_end_cksum(crc32);
 
        return true;
 }