aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-11-28 11:00:14 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-28 11:00:14 -0500
commita51a40b7abb619c38fe60d896a6916be280171ea (patch)
tree39fb89151c14acafe4811c2b31116245f12e21c6
parentf95d5bf03b5ec0d7ea8e552e15abe70c646249b5 (diff)
parent1ba896f6f52bfafac6dec4ca583cdd9a073858e8 (diff)
Merge branch 'sctp-fix-sparse-errors'
Xin Long says: ==================== sctp: fix some other sparse errors After the last fixes for sparse errors, there are still three sparse errors in sctp codes, two of them are type cast, and the other one is using extern. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sctp/checksum.h13
-rw-r--r--include/net/sctp/sctp.h5
-rw-r--r--include/net/sctp/stream_sched.h5
-rw-r--r--net/sctp/protocol.c1
-rw-r--r--net/sctp/stream.c2
-rw-r--r--net/sctp/stream_sched.c25
-rw-r--r--net/sctp/stream_sched_prio.c7
-rw-r--r--net/sctp/stream_sched_rr.c7
8 files changed, 49 insertions, 16 deletions
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
index 4a5b9a306c69..32ee65a30aff 100644
--- a/include/net/sctp/checksum.h
+++ b/include/net/sctp/checksum.h
@@ -48,31 +48,32 @@ static inline __wsum sctp_csum_update(const void *buff, int len, __wsum sum)
48 /* This uses the crypto implementation of crc32c, which is either 48 /* This uses the crypto implementation of crc32c, which is either
49 * implemented w/ hardware support or resolves to __crc32c_le(). 49 * implemented w/ hardware support or resolves to __crc32c_le().
50 */ 50 */
51 return crc32c(sum, buff, len); 51 return (__force __wsum)crc32c((__force __u32)sum, buff, len);
52} 52}
53 53
54static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2, 54static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2,
55 int offset, int len) 55 int offset, int len)
56{ 56{
57 return __crc32c_le_combine(csum, csum2, len); 57 return (__force __wsum)__crc32c_le_combine((__force __u32)csum,
58 (__force __u32)csum2, len);
58} 59}
59 60
60static inline __le32 sctp_compute_cksum(const struct sk_buff *skb, 61static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
61 unsigned int offset) 62 unsigned int offset)
62{ 63{
63 struct sctphdr *sh = sctp_hdr(skb); 64 struct sctphdr *sh = sctp_hdr(skb);
64 __le32 ret, old = sh->checksum;
65 const struct skb_checksum_ops ops = { 65 const struct skb_checksum_ops ops = {
66 .update = sctp_csum_update, 66 .update = sctp_csum_update,
67 .combine = sctp_csum_combine, 67 .combine = sctp_csum_combine,
68 }; 68 };
69 __le32 old = sh->checksum;
70 __wsum new;
69 71
70 sh->checksum = 0; 72 sh->checksum = 0;
71 ret = cpu_to_le32(~__skb_checksum(skb, offset, skb->len - offset, 73 new = ~__skb_checksum(skb, offset, skb->len - offset, ~(__wsum)0, &ops);
72 ~(__u32)0, &ops));
73 sh->checksum = old; 74 sh->checksum = old;
74 75
75 return ret; 76 return cpu_to_le32((__force __u32)new);
76} 77}
77 78
78#endif /* __sctp_checksum_h__ */ 79#endif /* __sctp_checksum_h__ */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 749a42882437..906a9c0efa71 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -195,6 +195,11 @@ void sctp_remaddr_proc_exit(struct net *net);
195int sctp_offload_init(void); 195int sctp_offload_init(void);
196 196
197/* 197/*
198 * sctp/stream_sched.c
199 */
200void sctp_sched_ops_init(void);
201
202/*
198 * sctp/stream.c 203 * sctp/stream.c
199 */ 204 */
200int sctp_send_reset_streams(struct sctp_association *asoc, 205int sctp_send_reset_streams(struct sctp_association *asoc,
diff --git a/include/net/sctp/stream_sched.h b/include/net/sctp/stream_sched.h
index c676550a4c7d..5c5da48f65e7 100644
--- a/include/net/sctp/stream_sched.h
+++ b/include/net/sctp/stream_sched.h
@@ -69,4 +69,9 @@ void sctp_sched_dequeue_common(struct sctp_outq *q, struct sctp_chunk *ch);
69int sctp_sched_init_sid(struct sctp_stream *stream, __u16 sid, gfp_t gfp); 69int sctp_sched_init_sid(struct sctp_stream *stream, __u16 sid, gfp_t gfp);
70struct sctp_sched_ops *sctp_sched_ops_from_stream(struct sctp_stream *stream); 70struct sctp_sched_ops *sctp_sched_ops_from_stream(struct sctp_stream *stream);
71 71
72void sctp_sched_ops_register(enum sctp_sched_type sched,
73 struct sctp_sched_ops *sched_ops);
74void sctp_sched_ops_prio_init(void);
75void sctp_sched_ops_rr_init(void);
76
72#endif /* __sctp_stream_sched_h__ */ 77#endif /* __sctp_stream_sched_h__ */
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index f5172c21349b..6a38c2503649 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1499,6 +1499,7 @@ static __init int sctp_init(void)
1499 INIT_LIST_HEAD(&sctp_address_families); 1499 INIT_LIST_HEAD(&sctp_address_families);
1500 sctp_v4_pf_init(); 1500 sctp_v4_pf_init();
1501 sctp_v6_pf_init(); 1501 sctp_v6_pf_init();
1502 sctp_sched_ops_init();
1502 1503
1503 status = register_pernet_subsys(&sctp_defaults_ops); 1504 status = register_pernet_subsys(&sctp_defaults_ops);
1504 if (status) 1505 if (status)
diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index a20145b3a949..76ea66be0bbe 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -64,7 +64,7 @@ static void sctp_stream_outq_migrate(struct sctp_stream *stream,
64 */ 64 */
65 65
66 /* Mark as failed send. */ 66 /* Mark as failed send. */
67 sctp_chunk_fail(ch, SCTP_ERROR_INV_STRM); 67 sctp_chunk_fail(ch, (__force __u32)SCTP_ERROR_INV_STRM);
68 if (asoc->peer.prsctp_capable && 68 if (asoc->peer.prsctp_capable &&
69 SCTP_PR_PRIO_ENABLED(ch->sinfo.sinfo_flags)) 69 SCTP_PR_PRIO_ENABLED(ch->sinfo.sinfo_flags))
70 asoc->sent_cnt_removable--; 70 asoc->sent_cnt_removable--;
diff --git a/net/sctp/stream_sched.c b/net/sctp/stream_sched.c
index 0b83ec51e43b..d8c162a4089c 100644
--- a/net/sctp/stream_sched.c
+++ b/net/sctp/stream_sched.c
@@ -119,16 +119,27 @@ static struct sctp_sched_ops sctp_sched_fcfs = {
119 .unsched_all = sctp_sched_fcfs_unsched_all, 119 .unsched_all = sctp_sched_fcfs_unsched_all,
120}; 120};
121 121
122static void sctp_sched_ops_fcfs_init(void)
123{
124 sctp_sched_ops_register(SCTP_SS_FCFS, &sctp_sched_fcfs);
125}
126
122/* API to other parts of the stack */ 127/* API to other parts of the stack */
123 128
124extern struct sctp_sched_ops sctp_sched_prio; 129static struct sctp_sched_ops *sctp_sched_ops[SCTP_SS_MAX + 1];
125extern struct sctp_sched_ops sctp_sched_rr;
126 130
127static struct sctp_sched_ops *sctp_sched_ops[] = { 131void sctp_sched_ops_register(enum sctp_sched_type sched,
128 &sctp_sched_fcfs, 132 struct sctp_sched_ops *sched_ops)
129 &sctp_sched_prio, 133{
130 &sctp_sched_rr, 134 sctp_sched_ops[sched] = sched_ops;
131}; 135}
136
137void sctp_sched_ops_init(void)
138{
139 sctp_sched_ops_fcfs_init();
140 sctp_sched_ops_prio_init();
141 sctp_sched_ops_rr_init();
142}
132 143
133int sctp_sched_set_sched(struct sctp_association *asoc, 144int sctp_sched_set_sched(struct sctp_association *asoc,
134 enum sctp_sched_type sched) 145 enum sctp_sched_type sched)
diff --git a/net/sctp/stream_sched_prio.c b/net/sctp/stream_sched_prio.c
index 384dbf3c8760..7997d35dd0fd 100644
--- a/net/sctp/stream_sched_prio.c
+++ b/net/sctp/stream_sched_prio.c
@@ -333,7 +333,7 @@ static void sctp_sched_prio_unsched_all(struct sctp_stream *stream)
333 sctp_sched_prio_unsched(soute); 333 sctp_sched_prio_unsched(soute);
334} 334}
335 335
336struct sctp_sched_ops sctp_sched_prio = { 336static struct sctp_sched_ops sctp_sched_prio = {
337 .set = sctp_sched_prio_set, 337 .set = sctp_sched_prio_set,
338 .get = sctp_sched_prio_get, 338 .get = sctp_sched_prio_get,
339 .init = sctp_sched_prio_init, 339 .init = sctp_sched_prio_init,
@@ -345,3 +345,8 @@ struct sctp_sched_ops sctp_sched_prio = {
345 .sched_all = sctp_sched_prio_sched_all, 345 .sched_all = sctp_sched_prio_sched_all,
346 .unsched_all = sctp_sched_prio_unsched_all, 346 .unsched_all = sctp_sched_prio_unsched_all,
347}; 347};
348
349void sctp_sched_ops_prio_init(void)
350{
351 sctp_sched_ops_register(SCTP_SS_PRIO, &sctp_sched_prio);
352}
diff --git a/net/sctp/stream_sched_rr.c b/net/sctp/stream_sched_rr.c
index 7612a438c5b9..1155692448f1 100644
--- a/net/sctp/stream_sched_rr.c
+++ b/net/sctp/stream_sched_rr.c
@@ -187,7 +187,7 @@ static void sctp_sched_rr_unsched_all(struct sctp_stream *stream)
187 sctp_sched_rr_unsched(stream, soute); 187 sctp_sched_rr_unsched(stream, soute);
188} 188}
189 189
190struct sctp_sched_ops sctp_sched_rr = { 190static struct sctp_sched_ops sctp_sched_rr = {
191 .set = sctp_sched_rr_set, 191 .set = sctp_sched_rr_set,
192 .get = sctp_sched_rr_get, 192 .get = sctp_sched_rr_get,
193 .init = sctp_sched_rr_init, 193 .init = sctp_sched_rr_init,
@@ -199,3 +199,8 @@ struct sctp_sched_ops sctp_sched_rr = {
199 .sched_all = sctp_sched_rr_sched_all, 199 .sched_all = sctp_sched_rr_sched_all,
200 .unsched_all = sctp_sched_rr_unsched_all, 200 .unsched_all = sctp_sched_rr_unsched_all,
201}; 201};
202
203void sctp_sched_ops_rr_init(void)
204{
205 sctp_sched_ops_register(SCTP_SS_RR, &sctp_sched_rr);
206}