diff options
author | Xin Long <lucien.xin@gmail.com> | 2017-10-28 07:43:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-29 05:03:24 -0400 |
commit | 1da4fc97cbf89514e417a3df46eaec864a9b8a48 (patch) | |
tree | 95dad261a5cad98743fd05b00eda6c722976427c | |
parent | 50317fce2cc70a2bbbc4b42c31bbad510382a53c (diff) |
sctp: fix some type cast warnings introduced by stream reconf
These warnings were found by running 'make C=2 M=net/sctp/'.
They are introduced by not aware of Endian when coding stream
reconf patches.
Since commit c0d8bab6ae51 ("sctp: add get and set sockopt for
reconf_enable") enabled stream reconf feature for users, the
Fixes tag below would use it.
Fixes: c0d8bab6ae51 ("sctp: add get and set sockopt for reconf_enable")
Reported-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/sctp.h | 32 | ||||
-rw-r--r-- | include/net/sctp/sm.h | 2 | ||||
-rw-r--r-- | include/net/sctp/ulpevent.h | 2 | ||||
-rw-r--r-- | net/sctp/sm_make_chunk.c | 5 | ||||
-rw-r--r-- | net/sctp/stream.c | 26 | ||||
-rw-r--r-- | net/sctp/ulpevent.c | 2 |
6 files changed, 39 insertions, 30 deletions
diff --git a/include/linux/sctp.h b/include/linux/sctp.h index 82b171e1aa0b..09d7412e9cb0 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h | |||
@@ -716,28 +716,28 @@ struct sctp_reconf_chunk { | |||
716 | 716 | ||
717 | struct sctp_strreset_outreq { | 717 | struct sctp_strreset_outreq { |
718 | struct sctp_paramhdr param_hdr; | 718 | struct sctp_paramhdr param_hdr; |
719 | __u32 request_seq; | 719 | __be32 request_seq; |
720 | __u32 response_seq; | 720 | __be32 response_seq; |
721 | __u32 send_reset_at_tsn; | 721 | __be32 send_reset_at_tsn; |
722 | __u16 list_of_streams[0]; | 722 | __be16 list_of_streams[0]; |
723 | }; | 723 | }; |
724 | 724 | ||
725 | struct sctp_strreset_inreq { | 725 | struct sctp_strreset_inreq { |
726 | struct sctp_paramhdr param_hdr; | 726 | struct sctp_paramhdr param_hdr; |
727 | __u32 request_seq; | 727 | __be32 request_seq; |
728 | __u16 list_of_streams[0]; | 728 | __be16 list_of_streams[0]; |
729 | }; | 729 | }; |
730 | 730 | ||
731 | struct sctp_strreset_tsnreq { | 731 | struct sctp_strreset_tsnreq { |
732 | struct sctp_paramhdr param_hdr; | 732 | struct sctp_paramhdr param_hdr; |
733 | __u32 request_seq; | 733 | __be32 request_seq; |
734 | }; | 734 | }; |
735 | 735 | ||
736 | struct sctp_strreset_addstrm { | 736 | struct sctp_strreset_addstrm { |
737 | struct sctp_paramhdr param_hdr; | 737 | struct sctp_paramhdr param_hdr; |
738 | __u32 request_seq; | 738 | __be32 request_seq; |
739 | __u16 number_of_streams; | 739 | __be16 number_of_streams; |
740 | __u16 reserved; | 740 | __be16 reserved; |
741 | }; | 741 | }; |
742 | 742 | ||
743 | enum { | 743 | enum { |
@@ -752,16 +752,16 @@ enum { | |||
752 | 752 | ||
753 | struct sctp_strreset_resp { | 753 | struct sctp_strreset_resp { |
754 | struct sctp_paramhdr param_hdr; | 754 | struct sctp_paramhdr param_hdr; |
755 | __u32 response_seq; | 755 | __be32 response_seq; |
756 | __u32 result; | 756 | __be32 result; |
757 | }; | 757 | }; |
758 | 758 | ||
759 | struct sctp_strreset_resptsn { | 759 | struct sctp_strreset_resptsn { |
760 | struct sctp_paramhdr param_hdr; | 760 | struct sctp_paramhdr param_hdr; |
761 | __u32 response_seq; | 761 | __be32 response_seq; |
762 | __u32 result; | 762 | __be32 result; |
763 | __u32 senders_next_tsn; | 763 | __be32 senders_next_tsn; |
764 | __u32 receivers_next_tsn; | 764 | __be32 receivers_next_tsn; |
765 | }; | 765 | }; |
766 | 766 | ||
767 | #endif /* __LINUX_SCTP_H__ */ | 767 | #endif /* __LINUX_SCTP_H__ */ |
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h index 2db3d3a9ce1d..88233cf8b8d4 100644 --- a/include/net/sctp/sm.h +++ b/include/net/sctp/sm.h | |||
@@ -261,7 +261,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, | |||
261 | struct sctp_fwdtsn_skip *skiplist); | 261 | struct sctp_fwdtsn_skip *skiplist); |
262 | struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc); | 262 | struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc); |
263 | struct sctp_chunk *sctp_make_strreset_req(const struct sctp_association *asoc, | 263 | struct sctp_chunk *sctp_make_strreset_req(const struct sctp_association *asoc, |
264 | __u16 stream_num, __u16 *stream_list, | 264 | __u16 stream_num, __be16 *stream_list, |
265 | bool out, bool in); | 265 | bool out, bool in); |
266 | struct sctp_chunk *sctp_make_strreset_tsnreq( | 266 | struct sctp_chunk *sctp_make_strreset_tsnreq( |
267 | const struct sctp_association *asoc); | 267 | const struct sctp_association *asoc); |
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h index b8c86ec1a8f5..231dc42f1da6 100644 --- a/include/net/sctp/ulpevent.h +++ b/include/net/sctp/ulpevent.h | |||
@@ -130,7 +130,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( | |||
130 | 130 | ||
131 | struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event( | 131 | struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event( |
132 | const struct sctp_association *asoc, __u16 flags, | 132 | const struct sctp_association *asoc, __u16 flags, |
133 | __u16 stream_num, __u16 *stream_list, gfp_t gfp); | 133 | __u16 stream_num, __be16 *stream_list, gfp_t gfp); |
134 | 134 | ||
135 | struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event( | 135 | struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event( |
136 | const struct sctp_association *asoc, __u16 flags, | 136 | const struct sctp_association *asoc, __u16 flags, |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index ca8f196b6c6c..57c55045f5a7 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -3591,7 +3591,7 @@ static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc, | |||
3591 | */ | 3591 | */ |
3592 | struct sctp_chunk *sctp_make_strreset_req( | 3592 | struct sctp_chunk *sctp_make_strreset_req( |
3593 | const struct sctp_association *asoc, | 3593 | const struct sctp_association *asoc, |
3594 | __u16 stream_num, __u16 *stream_list, | 3594 | __u16 stream_num, __be16 *stream_list, |
3595 | bool out, bool in) | 3595 | bool out, bool in) |
3596 | { | 3596 | { |
3597 | struct sctp_strreset_outreq outreq; | 3597 | struct sctp_strreset_outreq outreq; |
@@ -3788,7 +3788,8 @@ bool sctp_verify_reconf(const struct sctp_association *asoc, | |||
3788 | { | 3788 | { |
3789 | struct sctp_reconf_chunk *hdr; | 3789 | struct sctp_reconf_chunk *hdr; |
3790 | union sctp_params param; | 3790 | union sctp_params param; |
3791 | __u16 last = 0, cnt = 0; | 3791 | __be16 last = 0; |
3792 | __u16 cnt = 0; | ||
3792 | 3793 | ||
3793 | hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; | 3794 | hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; |
3794 | sctp_walk_params(param, hdr, params) { | 3795 | sctp_walk_params(param, hdr, params) { |
diff --git a/net/sctp/stream.c b/net/sctp/stream.c index 63ea15503714..fa8371ff05c4 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c | |||
@@ -118,6 +118,7 @@ int sctp_send_reset_streams(struct sctp_association *asoc, | |||
118 | __u16 i, str_nums, *str_list; | 118 | __u16 i, str_nums, *str_list; |
119 | struct sctp_chunk *chunk; | 119 | struct sctp_chunk *chunk; |
120 | int retval = -EINVAL; | 120 | int retval = -EINVAL; |
121 | __be16 *nstr_list; | ||
121 | bool out, in; | 122 | bool out, in; |
122 | 123 | ||
123 | if (!asoc->peer.reconf_capable || | 124 | if (!asoc->peer.reconf_capable || |
@@ -148,13 +149,18 @@ int sctp_send_reset_streams(struct sctp_association *asoc, | |||
148 | if (str_list[i] >= stream->incnt) | 149 | if (str_list[i] >= stream->incnt) |
149 | goto out; | 150 | goto out; |
150 | 151 | ||
152 | nstr_list = kcalloc(str_nums, sizeof(__be16), GFP_KERNEL); | ||
153 | if (!nstr_list) { | ||
154 | retval = -ENOMEM; | ||
155 | goto out; | ||
156 | } | ||
157 | |||
151 | for (i = 0; i < str_nums; i++) | 158 | for (i = 0; i < str_nums; i++) |
152 | str_list[i] = htons(str_list[i]); | 159 | nstr_list[i] = htons(str_list[i]); |
153 | 160 | ||
154 | chunk = sctp_make_strreset_req(asoc, str_nums, str_list, out, in); | 161 | chunk = sctp_make_strreset_req(asoc, str_nums, nstr_list, out, in); |
155 | 162 | ||
156 | for (i = 0; i < str_nums; i++) | 163 | kfree(nstr_list); |
157 | str_list[i] = ntohs(str_list[i]); | ||
158 | 164 | ||
159 | if (!chunk) { | 165 | if (!chunk) { |
160 | retval = -ENOMEM; | 166 | retval = -ENOMEM; |
@@ -305,7 +311,7 @@ out: | |||
305 | } | 311 | } |
306 | 312 | ||
307 | static struct sctp_paramhdr *sctp_chunk_lookup_strreset_param( | 313 | static struct sctp_paramhdr *sctp_chunk_lookup_strreset_param( |
308 | struct sctp_association *asoc, __u32 resp_seq, | 314 | struct sctp_association *asoc, __be32 resp_seq, |
309 | __be16 type) | 315 | __be16 type) |
310 | { | 316 | { |
311 | struct sctp_chunk *chunk = asoc->strreset_chunk; | 317 | struct sctp_chunk *chunk = asoc->strreset_chunk; |
@@ -345,8 +351,9 @@ struct sctp_chunk *sctp_process_strreset_outreq( | |||
345 | { | 351 | { |
346 | struct sctp_strreset_outreq *outreq = param.v; | 352 | struct sctp_strreset_outreq *outreq = param.v; |
347 | struct sctp_stream *stream = &asoc->stream; | 353 | struct sctp_stream *stream = &asoc->stream; |
348 | __u16 i, nums, flags = 0, *str_p = NULL; | ||
349 | __u32 result = SCTP_STRRESET_DENIED; | 354 | __u32 result = SCTP_STRRESET_DENIED; |
355 | __u16 i, nums, flags = 0; | ||
356 | __be16 *str_p = NULL; | ||
350 | __u32 request_seq; | 357 | __u32 request_seq; |
351 | 358 | ||
352 | request_seq = ntohl(outreq->request_seq); | 359 | request_seq = ntohl(outreq->request_seq); |
@@ -439,8 +446,9 @@ struct sctp_chunk *sctp_process_strreset_inreq( | |||
439 | struct sctp_stream *stream = &asoc->stream; | 446 | struct sctp_stream *stream = &asoc->stream; |
440 | __u32 result = SCTP_STRRESET_DENIED; | 447 | __u32 result = SCTP_STRRESET_DENIED; |
441 | struct sctp_chunk *chunk = NULL; | 448 | struct sctp_chunk *chunk = NULL; |
442 | __u16 i, nums, *str_p; | ||
443 | __u32 request_seq; | 449 | __u32 request_seq; |
450 | __u16 i, nums; | ||
451 | __be16 *str_p; | ||
444 | 452 | ||
445 | request_seq = ntohl(inreq->request_seq); | 453 | request_seq = ntohl(inreq->request_seq); |
446 | if (TSN_lt(asoc->strreset_inseq, request_seq) || | 454 | if (TSN_lt(asoc->strreset_inseq, request_seq) || |
@@ -769,7 +777,7 @@ struct sctp_chunk *sctp_process_strreset_resp( | |||
769 | 777 | ||
770 | if (req->type == SCTP_PARAM_RESET_OUT_REQUEST) { | 778 | if (req->type == SCTP_PARAM_RESET_OUT_REQUEST) { |
771 | struct sctp_strreset_outreq *outreq; | 779 | struct sctp_strreset_outreq *outreq; |
772 | __u16 *str_p; | 780 | __be16 *str_p; |
773 | 781 | ||
774 | outreq = (struct sctp_strreset_outreq *)req; | 782 | outreq = (struct sctp_strreset_outreq *)req; |
775 | str_p = outreq->list_of_streams; | 783 | str_p = outreq->list_of_streams; |
@@ -794,7 +802,7 @@ struct sctp_chunk *sctp_process_strreset_resp( | |||
794 | nums, str_p, GFP_ATOMIC); | 802 | nums, str_p, GFP_ATOMIC); |
795 | } else if (req->type == SCTP_PARAM_RESET_IN_REQUEST) { | 803 | } else if (req->type == SCTP_PARAM_RESET_IN_REQUEST) { |
796 | struct sctp_strreset_inreq *inreq; | 804 | struct sctp_strreset_inreq *inreq; |
797 | __u16 *str_p; | 805 | __be16 *str_p; |
798 | 806 | ||
799 | /* if the result is performed, it's impossible for inreq */ | 807 | /* if the result is performed, it's impossible for inreq */ |
800 | if (result == SCTP_STRRESET_PERFORMED) | 808 | if (result == SCTP_STRRESET_PERFORMED) |
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c index 67abc0194f30..5447228bf1a0 100644 --- a/net/sctp/ulpevent.c +++ b/net/sctp/ulpevent.c | |||
@@ -847,7 +847,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( | |||
847 | 847 | ||
848 | struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event( | 848 | struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event( |
849 | const struct sctp_association *asoc, __u16 flags, __u16 stream_num, | 849 | const struct sctp_association *asoc, __u16 flags, __u16 stream_num, |
850 | __u16 *stream_list, gfp_t gfp) | 850 | __be16 *stream_list, gfp_t gfp) |
851 | { | 851 | { |
852 | struct sctp_stream_reset_event *sreset; | 852 | struct sctp_stream_reset_event *sreset; |
853 | struct sctp_ulpevent *event; | 853 | struct sctp_ulpevent *event; |