Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sctp: remove extern from stream sched

Now each stream sched ops is defined in different .c file and
added into the global ops in another .c file, it uses extern
to make this work.

However extern is not good coding style to get them in and
even make C=2 reports errors for this.

This patch adds sctp_sched_ops_xxx_init for each stream sched
ops in their .c file, then get them into the global ops by
calling them when initializing sctp module.

Fixes: 637784ade221 ("sctp: introduce priority based stream scheduler")
Fixes: ac1ed8b82cd6 ("sctp: introduce round robin stream scheduler")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xin Long and committed by
David S. Miller
1ba896f6 af2697a0

+41 -9
+5
include/net/sctp/sctp.h
··· 195 195 int sctp_offload_init(void); 196 196 197 197 /* 198 + * sctp/stream_sched.c 199 + */ 200 + void sctp_sched_ops_init(void); 201 + 202 + /* 198 203 * sctp/stream.c 199 204 */ 200 205 int sctp_send_reset_streams(struct sctp_association *asoc,
+5
include/net/sctp/stream_sched.h
··· 69 69 int sctp_sched_init_sid(struct sctp_stream *stream, __u16 sid, gfp_t gfp); 70 70 struct sctp_sched_ops *sctp_sched_ops_from_stream(struct sctp_stream *stream); 71 71 72 + void sctp_sched_ops_register(enum sctp_sched_type sched, 73 + struct sctp_sched_ops *sched_ops); 74 + void sctp_sched_ops_prio_init(void); 75 + void sctp_sched_ops_rr_init(void); 76 + 72 77 #endif /* __sctp_stream_sched_h__ */
+1
net/sctp/protocol.c
··· 1499 1499 INIT_LIST_HEAD(&sctp_address_families); 1500 1500 sctp_v4_pf_init(); 1501 1501 sctp_v6_pf_init(); 1502 + sctp_sched_ops_init(); 1502 1503 1503 1504 status = register_pernet_subsys(&sctp_defaults_ops); 1504 1505 if (status)
+18 -7
net/sctp/stream_sched.c
··· 119 119 .unsched_all = sctp_sched_fcfs_unsched_all, 120 120 }; 121 121 122 + static void sctp_sched_ops_fcfs_init(void) 123 + { 124 + sctp_sched_ops_register(SCTP_SS_FCFS, &sctp_sched_fcfs); 125 + } 126 + 122 127 /* API to other parts of the stack */ 123 128 124 - extern struct sctp_sched_ops sctp_sched_prio; 125 - extern struct sctp_sched_ops sctp_sched_rr; 129 + static struct sctp_sched_ops *sctp_sched_ops[SCTP_SS_MAX + 1]; 126 130 127 - static struct sctp_sched_ops *sctp_sched_ops[] = { 128 - &sctp_sched_fcfs, 129 - &sctp_sched_prio, 130 - &sctp_sched_rr, 131 - }; 131 + void sctp_sched_ops_register(enum sctp_sched_type sched, 132 + struct sctp_sched_ops *sched_ops) 133 + { 134 + sctp_sched_ops[sched] = sched_ops; 135 + } 136 + 137 + void 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 133 144 int sctp_sched_set_sched(struct sctp_association *asoc, 134 145 enum sctp_sched_type sched)
+6 -1
net/sctp/stream_sched_prio.c
··· 333 333 sctp_sched_prio_unsched(soute); 334 334 } 335 335 336 - struct sctp_sched_ops sctp_sched_prio = { 336 + static struct sctp_sched_ops sctp_sched_prio = { 337 337 .set = sctp_sched_prio_set, 338 338 .get = sctp_sched_prio_get, 339 339 .init = sctp_sched_prio_init, ··· 345 345 .sched_all = sctp_sched_prio_sched_all, 346 346 .unsched_all = sctp_sched_prio_unsched_all, 347 347 }; 348 + 349 + void sctp_sched_ops_prio_init(void) 350 + { 351 + sctp_sched_ops_register(SCTP_SS_PRIO, &sctp_sched_prio); 352 + }
+6 -1
net/sctp/stream_sched_rr.c
··· 187 187 sctp_sched_rr_unsched(stream, soute); 188 188 } 189 189 190 - struct sctp_sched_ops sctp_sched_rr = { 190 + static struct sctp_sched_ops sctp_sched_rr = { 191 191 .set = sctp_sched_rr_set, 192 192 .get = sctp_sched_rr_get, 193 193 .init = sctp_sched_rr_init, ··· 199 199 .sched_all = sctp_sched_rr_sched_all, 200 200 .unsched_all = sctp_sched_rr_unsched_all, 201 201 }; 202 + 203 + void sctp_sched_ops_rr_init(void) 204 + { 205 + sctp_sched_ops_register(SCTP_SS_RR, &sctp_sched_rr); 206 + }