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
716716
717717 struct sctp_strreset_outreq {
718718 struct sctp_paramhdr param_hdr;
719− __u32 request_seq;
720− __u32 response_seq;
721− __u32 send_reset_at_tsn;
722− __u16 list_of_streams[0];
719+ __be32 request_seq;
720+ __be32 response_seq;
721+ __be32 send_reset_at_tsn;
722+ __be16 list_of_streams[0];
723723 };
724724
725725 struct sctp_strreset_inreq {
726726 struct sctp_paramhdr param_hdr;
727− __u32 request_seq;
728− __u16 list_of_streams[0];
727+ __be32 request_seq;
728+ __be16 list_of_streams[0];
729729 };
730730
731731 struct sctp_strreset_tsnreq {
732732 struct sctp_paramhdr param_hdr;
733− __u32 request_seq;
733+ __be32 request_seq;
734734 };
735735
736736 struct sctp_strreset_addstrm {
737737 struct sctp_paramhdr param_hdr;
738− __u32 request_seq;
739− __u16 number_of_streams;
740− __u16 reserved;
738+ __be32 request_seq;
739+ __be16 number_of_streams;
740+ __be16 reserved;
741741 };
742742
743743 enum {
@@ -752,16 +752,16 @@ enum { · 8 unmodified lines
752752
753753 struct sctp_strreset_resp {
754754 struct sctp_paramhdr param_hdr;
755− __u32 response_seq;
756− __u32 result;
755+ __be32 response_seq;
756+ __be32 result;
757757 };
758758
759759 struct sctp_strreset_resptsn {
760760 struct sctp_paramhdr param_hdr;
761− __u32 response_seq;
762− __u32 result;
763− __u32 senders_next_tsn;
764− __u32 receivers_next_tsn;
761+ __be32 response_seq;
762+ __be32 result;
763+ __be32 senders_next_tsn;
764+ __be32 receivers_next_tsn;
765765 };
766766
767767 #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
261261 struct sctp_fwdtsn_skip *skiplist);
262262 struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc);
263263 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,
265265 bool out, bool in);
266266 struct sctp_chunk *sctp_make_strreset_tsnreq(
267267 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
130130
131131 struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(
132132 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);
134134
135135 struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
136136 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
35913591 */
35923592 struct sctp_chunk *sctp_make_strreset_req(
35933593 const struct sctp_association *asoc,
3594− __u16 stream_num, __u16 *stream_list,
3594+ __u16 stream_num, __be16 *stream_list,
35953595 bool out, bool in)
35963596 {
35973597 struct sctp_strreset_outreq outreq;
@@ -3788,7 +3788,8 @@ bool sctp_verify_reconf(const struct sctp_association *asoc, · 190 unmodified lines
37883788 {
37893789 struct sctp_reconf_chunk *hdr;
37903790 union sctp_params param;
3791− __u16 last = 0, cnt = 0;
3791+ __be16 last = 0;
3792+ __u16 cnt = 0;
37923793
37933794 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr;
37943795 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
118118 __u16 i, str_nums, *str_list;
119119 struct sctp_chunk *chunk;
120120 int retval = -EINVAL;
121+ __be16 *nstr_list;
121122 bool out, in;
122123
123124 if (!asoc->peer.reconf_capable ||
@@ -148,13 +149,18 @@ int sctp_send_reset_streams(struct sctp_association *asoc, · 24 unmodified lines
148149 if (str_list[i] >= stream->incnt)
149150 goto out;
150151
152+ nstr_list = kcalloc(str_nums, sizeof(__be16), GFP_KERNEL);
153+ if (!nstr_list) {
154+ retval = -ENOMEM;
155+ goto out;
156+ }
157+
151158 for (i = 0; i < str_nums; i++)
152− str_list[i] = htons(str_list[i]);
159+ nstr_list[i] = htons(str_list[i]);
153160
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);
155162
156− for (i = 0; i < str_nums; i++)
157− str_list[i] = ntohs(str_list[i]);
163+ kfree(nstr_list);
158164
159165 if (!chunk) {
160166 retval = -ENOMEM;
@@ -305,7 +311,7 @@ out: · 144 unmodified lines
305311 }
306312
307313 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,
309315 __be16 type)
310316 {
311317 struct sctp_chunk *chunk = asoc->strreset_chunk;
@@ -345,8 +351,9 @@ struct sctp_chunk *sctp_process_strreset_outreq( · 33 unmodified lines
345351 {
346352 struct sctp_strreset_outreq *outreq = param.v;
347353 struct sctp_stream *stream = &asoc->stream;
348− __u16 i, nums, flags = 0, *str_p = NULL;
349354 __u32 result = SCTP_STRRESET_DENIED;
355+ __u16 i, nums, flags = 0;
356+ __be16 *str_p = NULL;
350357 __u32 request_seq;
351358
352359 request_seq = ntohl(outreq->request_seq);
@@ -439,8 +446,9 @@ struct sctp_chunk *sctp_process_strreset_inreq( · 86 unmodified lines
439446 struct sctp_stream *stream = &asoc->stream;
440447 __u32 result = SCTP_STRRESET_DENIED;
441448 struct sctp_chunk *chunk = NULL;
442− __u16 i, nums, *str_p;
443449 __u32 request_seq;
450+ __u16 i, nums;
451+ __be16 *str_p;
444452
445453 request_seq = ntohl(inreq->request_seq);
446454 if (TSN_lt(asoc->strreset_inseq, request_seq) ||
@@ -769,7 +777,7 @@ struct sctp_chunk *sctp_process_strreset_resp( · 322 unmodified lines
769777
770778 if (req->type == SCTP_PARAM_RESET_OUT_REQUEST) {
771779 struct sctp_strreset_outreq *outreq;
772− __u16 *str_p;
780+ __be16 *str_p;
773781
774782 outreq = (struct sctp_strreset_outreq *)req;
775783 str_p = outreq->list_of_streams;
@@ -794,7 +802,7 @@ struct sctp_chunk *sctp_process_strreset_resp( · 18 unmodified lines
794802 nums, str_p, GFP_ATOMIC);
795803 } else if (req->type == SCTP_PARAM_RESET_IN_REQUEST) {
796804 struct sctp_strreset_inreq *inreq;
797− __u16 *str_p;
805+ __be16 *str_p;
798806
799807 /* if the result is performed, it's impossible for inreq */
800808 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
847847
848848 struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(
849849 const struct sctp_association *asoc, __u16 flags, __u16 stream_num,
850− __u16 *stream_list, gfp_t gfp)
850+ __be16 *stream_list, gfp_t gfp)
851851 {
852852 struct sctp_stream_reset_event *sreset;
853853 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