diff options
author | Simon Horman <horms@verge.net.au> | 2013-04-18 21:54:58 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-04-29 14:09:08 -0400 |
commit | eee1d5a14780b9391ec51f3feaf4cffb521ddbb1 (patch) | |
tree | a8ba60a185c99ac5c0035438749f2f1a8e44bf1b | |
parent | 00bd1cc24a7dd295ee095dc50791aab6ede46c7a (diff) |
sctp: Correct type and usage of sctp_end_cksum()
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>
-rw-r--r-- | include/net/sctp/checksum.h | 2 | ||||
-rw-r--r-- | net/netfilter/nf_nat_proto_sctp.c | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h index befc8d2a1b9f..5a2110d3176d 100644 --- a/include/net/sctp/checksum.h +++ b/include/net/sctp/checksum.h | |||
@@ -77,7 +77,7 @@ static inline __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32) | |||
77 | return sctp_crc32c(crc32, buffer, length); | 77 | return sctp_crc32c(crc32, buffer, length); |
78 | } | 78 | } |
79 | 79 | ||
80 | static inline __le32 sctp_end_cksum(__be32 crc32) | 80 | static inline __le32 sctp_end_cksum(__u32 crc32) |
81 | { | 81 | { |
82 | return cpu_to_le32(~crc32); | 82 | return cpu_to_le32(~crc32); |
83 | } | 83 | } |
diff --git a/net/netfilter/nf_nat_proto_sctp.c b/net/netfilter/nf_nat_proto_sctp.c index e64faa5ca893..396e55d46f90 100644 --- a/net/netfilter/nf_nat_proto_sctp.c +++ b/net/netfilter/nf_nat_proto_sctp.c | |||
@@ -36,7 +36,7 @@ sctp_manip_pkt(struct sk_buff *skb, | |||
36 | { | 36 | { |
37 | struct sk_buff *frag; | 37 | struct sk_buff *frag; |
38 | sctp_sctphdr_t *hdr; | 38 | sctp_sctphdr_t *hdr; |
39 | __be32 crc32; | 39 | __u32 crc32; |
40 | 40 | ||
41 | if (!skb_make_writable(skb, hdroff + sizeof(*hdr))) | 41 | if (!skb_make_writable(skb, hdroff + sizeof(*hdr))) |
42 | return false; | 42 | return false; |
@@ -55,8 +55,7 @@ sctp_manip_pkt(struct sk_buff *skb, | |||
55 | skb_walk_frags(skb, frag) | 55 | skb_walk_frags(skb, frag) |
56 | crc32 = sctp_update_cksum((u8 *)frag->data, skb_headlen(frag), | 56 | crc32 = sctp_update_cksum((u8 *)frag->data, skb_headlen(frag), |
57 | crc32); | 57 | crc32); |
58 | crc32 = sctp_end_cksum(crc32); | 58 | hdr->checksum = sctp_end_cksum(crc32); |
59 | hdr->checksum = crc32; | ||
60 | 59 | ||
61 | return true; | 60 | return true; |
62 | } | 61 | } |