History

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.

Xin Long committed 9 years ago

Commit 1da4fc91 parent 50317fc6 files · +39 −30Browse files

Unified · Split

6 files
  1. include/linux/sctp.h +16 −16
  2. include/net/sctp/sm.h +1 −1
  3. include/net/sctp/ulpevent.h +1 −1
  4. net/sctp/sm_make_chunk.c +3 −2
  5. net/sctp/stream.c +17 −9
  6. net/sctp/ulpevent.c +1 −1
include/linux/sctp.h+16−16
@@ -716,28 +716,28 @@ struct sctp_reconf_chunk { · 715 unmodified lines
716 716
717struct sctp_strreset_outreq {717struct 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
725struct sctp_strreset_inreq {725struct 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
731struct sctp_strreset_tsnreq {731struct 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
736struct sctp_strreset_addstrm {736struct 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
743enum {743enum {
@@ -752,16 +752,16 @@ enum { · 8 unmodified lines
752 752
753struct sctp_strreset_resp {753struct 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
759struct sctp_strreset_resptsn {759struct 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__ */
include/net/sctp/sm.h+1−1
@@ -261,7 +261,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, · 260 unmodified lines
261 struct sctp_fwdtsn_skip *skiplist);261 struct sctp_fwdtsn_skip *skiplist);
262struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc);262struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc);
263struct sctp_chunk *sctp_make_strreset_req(const struct sctp_association *asoc,263struct 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);
266struct sctp_chunk *sctp_make_strreset_tsnreq(266struct sctp_chunk *sctp_make_strreset_tsnreq(
267 const struct sctp_association *asoc);267 const struct sctp_association *asoc);
include/net/sctp/ulpevent.h+1−1
@@ -130,7 +130,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( · 129 unmodified lines
130 130
131struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(131struct 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
135struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(135struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
136 const struct sctp_association *asoc, __u16 flags,136 const struct sctp_association *asoc, __u16 flags,
net/sctp/sm_make_chunk.c+3−2
@@ -3591,7 +3591,7 @@ static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc, · 3590 unmodified lines
3591 */3591 */
3592struct sctp_chunk *sctp_make_strreset_req(3592struct 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, · 190 unmodified lines
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) {
net/sctp/stream.c+17−9
@@ -118,6 +118,7 @@ int sctp_send_reset_streams(struct sctp_association *asoc, · 117 unmodified lines
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, · 24 unmodified lines
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: · 144 unmodified lines
305}311}
306 312
307static struct sctp_paramhdr *sctp_chunk_lookup_strreset_param(313static 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( · 33 unmodified lines
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( · 86 unmodified lines
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( · 322 unmodified lines
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( · 18 unmodified lines
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)
net/sctp/ulpevent.c+1−1
@@ -847,7 +847,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( · 846 unmodified lines
847 847
848struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(848struct 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;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t