diff options
-rw-r--r-- | include/net/sctp/sm.h | 3 | ||||
-rw-r--r-- | net/sctp/sm_sideeffect.c | 2 | ||||
-rw-r--r-- | net/sctp/sm_statefuns.c | 619 |
3 files changed, 341 insertions, 283 deletions
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h index bcef13023ac3..b5887e1677e4 100644 --- a/include/net/sctp/sm.h +++ b/include/net/sctp/sm.h | |||
@@ -77,7 +77,8 @@ typedef struct { | |||
77 | int action; | 77 | int action; |
78 | } sctp_sm_command_t; | 78 | } sctp_sm_command_t; |
79 | 79 | ||
80 | typedef sctp_disposition_t (sctp_state_fn_t) (const struct sctp_endpoint *, | 80 | typedef sctp_disposition_t (sctp_state_fn_t) (struct net *, |
81 | const struct sctp_endpoint *, | ||
81 | const struct sctp_association *, | 82 | const struct sctp_association *, |
82 | const sctp_subtype_t type, | 83 | const sctp_subtype_t type, |
83 | void *arg, | 84 | void *arg, |
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 02c4c1c066a7..bcfebb91559d 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c | |||
@@ -1123,7 +1123,7 @@ int sctp_do_sm(struct net *net, sctp_event_t event_type, sctp_subtype_t subtype, | |||
1123 | sctp_init_cmd_seq(&commands); | 1123 | sctp_init_cmd_seq(&commands); |
1124 | 1124 | ||
1125 | DEBUG_PRE; | 1125 | DEBUG_PRE; |
1126 | status = (*state_fn->fn)(ep, asoc, subtype, event_arg, &commands); | 1126 | status = (*state_fn->fn)(net, ep, asoc, subtype, event_arg, &commands); |
1127 | DEBUG_POST; | 1127 | DEBUG_POST; |
1128 | 1128 | ||
1129 | error = sctp_side_effects(event_type, subtype, state, | 1129 | error = sctp_side_effects(event_type, subtype, state, |
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index ff2530c848b0..19f3bff84193 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
@@ -66,7 +66,8 @@ | |||
66 | #include <net/sctp/sm.h> | 66 | #include <net/sctp/sm.h> |
67 | #include <net/sctp/structs.h> | 67 | #include <net/sctp/structs.h> |
68 | 68 | ||
69 | static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | 69 | static struct sctp_packet *sctp_abort_pkt_new(struct net *net, |
70 | const struct sctp_endpoint *ep, | ||
70 | const struct sctp_association *asoc, | 71 | const struct sctp_association *asoc, |
71 | struct sctp_chunk *chunk, | 72 | struct sctp_chunk *chunk, |
72 | const void *payload, | 73 | const void *payload, |
@@ -77,34 +78,40 @@ static int sctp_eat_data(const struct sctp_association *asoc, | |||
77 | static struct sctp_packet *sctp_ootb_pkt_new(struct net *net, | 78 | static struct sctp_packet *sctp_ootb_pkt_new(struct net *net, |
78 | const struct sctp_association *asoc, | 79 | const struct sctp_association *asoc, |
79 | const struct sctp_chunk *chunk); | 80 | const struct sctp_chunk *chunk); |
80 | static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | 81 | static void sctp_send_stale_cookie_err(struct net *net, |
82 | const struct sctp_endpoint *ep, | ||
81 | const struct sctp_association *asoc, | 83 | const struct sctp_association *asoc, |
82 | const struct sctp_chunk *chunk, | 84 | const struct sctp_chunk *chunk, |
83 | sctp_cmd_seq_t *commands, | 85 | sctp_cmd_seq_t *commands, |
84 | struct sctp_chunk *err_chunk); | 86 | struct sctp_chunk *err_chunk); |
85 | static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep, | 87 | static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net, |
88 | const struct sctp_endpoint *ep, | ||
86 | const struct sctp_association *asoc, | 89 | const struct sctp_association *asoc, |
87 | const sctp_subtype_t type, | 90 | const sctp_subtype_t type, |
88 | void *arg, | 91 | void *arg, |
89 | sctp_cmd_seq_t *commands); | 92 | sctp_cmd_seq_t *commands); |
90 | static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | 93 | static sctp_disposition_t sctp_sf_shut_8_4_5(struct net *net, |
94 | const struct sctp_endpoint *ep, | ||
91 | const struct sctp_association *asoc, | 95 | const struct sctp_association *asoc, |
92 | const sctp_subtype_t type, | 96 | const sctp_subtype_t type, |
93 | void *arg, | 97 | void *arg, |
94 | sctp_cmd_seq_t *commands); | 98 | sctp_cmd_seq_t *commands); |
95 | static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | 99 | static sctp_disposition_t sctp_sf_tabort_8_4_8(struct net *net, |
100 | const struct sctp_endpoint *ep, | ||
96 | const struct sctp_association *asoc, | 101 | const struct sctp_association *asoc, |
97 | const sctp_subtype_t type, | 102 | const sctp_subtype_t type, |
98 | void *arg, | 103 | void *arg, |
99 | sctp_cmd_seq_t *commands); | 104 | sctp_cmd_seq_t *commands); |
100 | static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk); | 105 | static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk); |
101 | 106 | ||
102 | static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, | 107 | static sctp_disposition_t sctp_stop_t1_and_abort(struct net *net, |
108 | sctp_cmd_seq_t *commands, | ||
103 | __be16 error, int sk_err, | 109 | __be16 error, int sk_err, |
104 | const struct sctp_association *asoc, | 110 | const struct sctp_association *asoc, |
105 | struct sctp_transport *transport); | 111 | struct sctp_transport *transport); |
106 | 112 | ||
107 | static sctp_disposition_t sctp_sf_abort_violation( | 113 | static sctp_disposition_t sctp_sf_abort_violation( |
114 | struct net *net, | ||
108 | const struct sctp_endpoint *ep, | 115 | const struct sctp_endpoint *ep, |
109 | const struct sctp_association *asoc, | 116 | const struct sctp_association *asoc, |
110 | void *arg, | 117 | void *arg, |
@@ -113,6 +120,7 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
113 | const size_t paylen); | 120 | const size_t paylen); |
114 | 121 | ||
115 | static sctp_disposition_t sctp_sf_violation_chunklen( | 122 | static sctp_disposition_t sctp_sf_violation_chunklen( |
123 | struct net *net, | ||
116 | const struct sctp_endpoint *ep, | 124 | const struct sctp_endpoint *ep, |
117 | const struct sctp_association *asoc, | 125 | const struct sctp_association *asoc, |
118 | const sctp_subtype_t type, | 126 | const sctp_subtype_t type, |
@@ -120,6 +128,7 @@ static sctp_disposition_t sctp_sf_violation_chunklen( | |||
120 | sctp_cmd_seq_t *commands); | 128 | sctp_cmd_seq_t *commands); |
121 | 129 | ||
122 | static sctp_disposition_t sctp_sf_violation_paramlen( | 130 | static sctp_disposition_t sctp_sf_violation_paramlen( |
131 | struct net *net, | ||
123 | const struct sctp_endpoint *ep, | 132 | const struct sctp_endpoint *ep, |
124 | const struct sctp_association *asoc, | 133 | const struct sctp_association *asoc, |
125 | const sctp_subtype_t type, | 134 | const sctp_subtype_t type, |
@@ -127,6 +136,7 @@ static sctp_disposition_t sctp_sf_violation_paramlen( | |||
127 | sctp_cmd_seq_t *commands); | 136 | sctp_cmd_seq_t *commands); |
128 | 137 | ||
129 | static sctp_disposition_t sctp_sf_violation_ctsn( | 138 | static sctp_disposition_t sctp_sf_violation_ctsn( |
139 | struct net *net, | ||
130 | const struct sctp_endpoint *ep, | 140 | const struct sctp_endpoint *ep, |
131 | const struct sctp_association *asoc, | 141 | const struct sctp_association *asoc, |
132 | const sctp_subtype_t type, | 142 | const sctp_subtype_t type, |
@@ -134,18 +144,21 @@ static sctp_disposition_t sctp_sf_violation_ctsn( | |||
134 | sctp_cmd_seq_t *commands); | 144 | sctp_cmd_seq_t *commands); |
135 | 145 | ||
136 | static sctp_disposition_t sctp_sf_violation_chunk( | 146 | static sctp_disposition_t sctp_sf_violation_chunk( |
147 | struct net *net, | ||
137 | const struct sctp_endpoint *ep, | 148 | const struct sctp_endpoint *ep, |
138 | const struct sctp_association *asoc, | 149 | const struct sctp_association *asoc, |
139 | const sctp_subtype_t type, | 150 | const sctp_subtype_t type, |
140 | void *arg, | 151 | void *arg, |
141 | sctp_cmd_seq_t *commands); | 152 | sctp_cmd_seq_t *commands); |
142 | 153 | ||
143 | static sctp_ierror_t sctp_sf_authenticate(const struct sctp_endpoint *ep, | 154 | static sctp_ierror_t sctp_sf_authenticate(struct net *net, |
155 | const struct sctp_endpoint *ep, | ||
144 | const struct sctp_association *asoc, | 156 | const struct sctp_association *asoc, |
145 | const sctp_subtype_t type, | 157 | const sctp_subtype_t type, |
146 | struct sctp_chunk *chunk); | 158 | struct sctp_chunk *chunk); |
147 | 159 | ||
148 | static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | 160 | static sctp_disposition_t __sctp_sf_do_9_1_abort(struct net *net, |
161 | const struct sctp_endpoint *ep, | ||
149 | const struct sctp_association *asoc, | 162 | const struct sctp_association *asoc, |
150 | const sctp_subtype_t type, | 163 | const sctp_subtype_t type, |
151 | void *arg, | 164 | void *arg, |
@@ -205,7 +218,8 @@ sctp_chunk_length_valid(struct sctp_chunk *chunk, | |||
205 | * | 218 | * |
206 | * The return value is the disposition of the chunk. | 219 | * The return value is the disposition of the chunk. |
207 | */ | 220 | */ |
208 | sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | 221 | sctp_disposition_t sctp_sf_do_4_C(struct net *net, |
222 | const struct sctp_endpoint *ep, | ||
209 | const struct sctp_association *asoc, | 223 | const struct sctp_association *asoc, |
210 | const sctp_subtype_t type, | 224 | const sctp_subtype_t type, |
211 | void *arg, | 225 | void *arg, |
@@ -213,10 +227,9 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | |||
213 | { | 227 | { |
214 | struct sctp_chunk *chunk = arg; | 228 | struct sctp_chunk *chunk = arg; |
215 | struct sctp_ulpevent *ev; | 229 | struct sctp_ulpevent *ev; |
216 | struct net *net; | ||
217 | 230 | ||
218 | if (!sctp_vtag_verify_either(chunk, asoc)) | 231 | if (!sctp_vtag_verify_either(chunk, asoc)) |
219 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 232 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
220 | 233 | ||
221 | /* RFC 2960 6.10 Bundling | 234 | /* RFC 2960 6.10 Bundling |
222 | * | 235 | * |
@@ -224,11 +237,11 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | |||
224 | * SHUTDOWN COMPLETE with any other chunks. | 237 | * SHUTDOWN COMPLETE with any other chunks. |
225 | */ | 238 | */ |
226 | if (!chunk->singleton) | 239 | if (!chunk->singleton) |
227 | return sctp_sf_violation_chunk(ep, asoc, type, arg, commands); | 240 | return sctp_sf_violation_chunk(net, ep, asoc, type, arg, commands); |
228 | 241 | ||
229 | /* Make sure that the SHUTDOWN_COMPLETE chunk has a valid length. */ | 242 | /* Make sure that the SHUTDOWN_COMPLETE chunk has a valid length. */ |
230 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 243 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
231 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 244 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
232 | commands); | 245 | commands); |
233 | 246 | ||
234 | /* RFC 2960 10.2 SCTP-to-ULP | 247 | /* RFC 2960 10.2 SCTP-to-ULP |
@@ -261,7 +274,6 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | |||
261 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 274 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
262 | SCTP_STATE(SCTP_STATE_CLOSED)); | 275 | SCTP_STATE(SCTP_STATE_CLOSED)); |
263 | 276 | ||
264 | net = sock_net(asoc->base.sk); | ||
265 | SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS); | 277 | SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS); |
266 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); | 278 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
267 | 279 | ||
@@ -292,7 +304,8 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | |||
292 | * | 304 | * |
293 | * The return value is the disposition of the chunk. | 305 | * The return value is the disposition of the chunk. |
294 | */ | 306 | */ |
295 | sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | 307 | sctp_disposition_t sctp_sf_do_5_1B_init(struct net *net, |
308 | const struct sctp_endpoint *ep, | ||
296 | const struct sctp_association *asoc, | 309 | const struct sctp_association *asoc, |
297 | const sctp_subtype_t type, | 310 | const sctp_subtype_t type, |
298 | void *arg, | 311 | void *arg, |
@@ -304,7 +317,6 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
304 | struct sctp_chunk *err_chunk; | 317 | struct sctp_chunk *err_chunk; |
305 | struct sctp_packet *packet; | 318 | struct sctp_packet *packet; |
306 | sctp_unrecognized_param_t *unk_param; | 319 | sctp_unrecognized_param_t *unk_param; |
307 | struct net *net; | ||
308 | int len; | 320 | int len; |
309 | 321 | ||
310 | /* 6.10 Bundling | 322 | /* 6.10 Bundling |
@@ -317,22 +329,21 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
317 | * with an INIT chunk that is bundled with other chunks. | 329 | * with an INIT chunk that is bundled with other chunks. |
318 | */ | 330 | */ |
319 | if (!chunk->singleton) | 331 | if (!chunk->singleton) |
320 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 332 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
321 | 333 | ||
322 | /* If the packet is an OOTB packet which is temporarily on the | 334 | /* If the packet is an OOTB packet which is temporarily on the |
323 | * control endpoint, respond with an ABORT. | 335 | * control endpoint, respond with an ABORT. |
324 | */ | 336 | */ |
325 | net = sock_net(ep->base.sk); | ||
326 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { | 337 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { |
327 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); | 338 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); |
328 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 339 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
329 | } | 340 | } |
330 | 341 | ||
331 | /* 3.1 A packet containing an INIT chunk MUST have a zero Verification | 342 | /* 3.1 A packet containing an INIT chunk MUST have a zero Verification |
332 | * Tag. | 343 | * Tag. |
333 | */ | 344 | */ |
334 | if (chunk->sctp_hdr->vtag != 0) | 345 | if (chunk->sctp_hdr->vtag != 0) |
335 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 346 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
336 | 347 | ||
337 | /* Make sure that the INIT chunk has a valid length. | 348 | /* Make sure that the INIT chunk has a valid length. |
338 | * Normally, this would cause an ABORT with a Protocol Violation | 349 | * Normally, this would cause an ABORT with a Protocol Violation |
@@ -340,7 +351,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
340 | * just discard the packet. | 351 | * just discard the packet. |
341 | */ | 352 | */ |
342 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) | 353 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) |
343 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 354 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
344 | 355 | ||
345 | /* If the INIT is coming toward a closing socket, we'll send back | 356 | /* If the INIT is coming toward a closing socket, we'll send back |
346 | * and ABORT. Essentially, this catches the race of INIT being | 357 | * and ABORT. Essentially, this catches the race of INIT being |
@@ -349,7 +360,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
349 | * can treat this OOTB | 360 | * can treat this OOTB |
350 | */ | 361 | */ |
351 | if (sctp_sstate(ep->base.sk, CLOSING)) | 362 | if (sctp_sstate(ep->base.sk, CLOSING)) |
352 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 363 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
353 | 364 | ||
354 | /* Verify the INIT chunk before processing it. */ | 365 | /* Verify the INIT chunk before processing it. */ |
355 | err_chunk = NULL; | 366 | err_chunk = NULL; |
@@ -360,7 +371,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
360 | * Send an ABORT, with causes if there is any. | 371 | * Send an ABORT, with causes if there is any. |
361 | */ | 372 | */ |
362 | if (err_chunk) { | 373 | if (err_chunk) { |
363 | packet = sctp_abort_pkt_new(ep, asoc, arg, | 374 | packet = sctp_abort_pkt_new(net, ep, asoc, arg, |
364 | (__u8 *)(err_chunk->chunk_hdr) + | 375 | (__u8 *)(err_chunk->chunk_hdr) + |
365 | sizeof(sctp_chunkhdr_t), | 376 | sizeof(sctp_chunkhdr_t), |
366 | ntohs(err_chunk->chunk_hdr->length) - | 377 | ntohs(err_chunk->chunk_hdr->length) - |
@@ -377,7 +388,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
377 | return SCTP_DISPOSITION_NOMEM; | 388 | return SCTP_DISPOSITION_NOMEM; |
378 | } | 389 | } |
379 | } else { | 390 | } else { |
380 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, | 391 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, |
381 | commands); | 392 | commands); |
382 | } | 393 | } |
383 | } | 394 | } |
@@ -489,7 +500,8 @@ nomem: | |||
489 | * | 500 | * |
490 | * The return value is the disposition of the chunk. | 501 | * The return value is the disposition of the chunk. |
491 | */ | 502 | */ |
492 | sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | 503 | sctp_disposition_t sctp_sf_do_5_1C_ack(struct net *net, |
504 | const struct sctp_endpoint *ep, | ||
493 | const struct sctp_association *asoc, | 505 | const struct sctp_association *asoc, |
494 | const sctp_subtype_t type, | 506 | const sctp_subtype_t type, |
495 | void *arg, | 507 | void *arg, |
@@ -501,18 +513,18 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
501 | struct sctp_packet *packet; | 513 | struct sctp_packet *packet; |
502 | 514 | ||
503 | if (!sctp_vtag_verify(chunk, asoc)) | 515 | if (!sctp_vtag_verify(chunk, asoc)) |
504 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 516 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
505 | 517 | ||
506 | /* 6.10 Bundling | 518 | /* 6.10 Bundling |
507 | * An endpoint MUST NOT bundle INIT, INIT ACK or | 519 | * An endpoint MUST NOT bundle INIT, INIT ACK or |
508 | * SHUTDOWN COMPLETE with any other chunks. | 520 | * SHUTDOWN COMPLETE with any other chunks. |
509 | */ | 521 | */ |
510 | if (!chunk->singleton) | 522 | if (!chunk->singleton) |
511 | return sctp_sf_violation_chunk(ep, asoc, type, arg, commands); | 523 | return sctp_sf_violation_chunk(net, ep, asoc, type, arg, commands); |
512 | 524 | ||
513 | /* Make sure that the INIT-ACK chunk has a valid length */ | 525 | /* Make sure that the INIT-ACK chunk has a valid length */ |
514 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_initack_chunk_t))) | 526 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_initack_chunk_t))) |
515 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 527 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
516 | commands); | 528 | commands); |
517 | /* Grab the INIT header. */ | 529 | /* Grab the INIT header. */ |
518 | chunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data; | 530 | chunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data; |
@@ -531,7 +543,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
531 | * the association. | 543 | * the association. |
532 | */ | 544 | */ |
533 | if (err_chunk) { | 545 | if (err_chunk) { |
534 | packet = sctp_abort_pkt_new(ep, asoc, arg, | 546 | packet = sctp_abort_pkt_new(net, ep, asoc, arg, |
535 | (__u8 *)(err_chunk->chunk_hdr) + | 547 | (__u8 *)(err_chunk->chunk_hdr) + |
536 | sizeof(sctp_chunkhdr_t), | 548 | sizeof(sctp_chunkhdr_t), |
537 | ntohs(err_chunk->chunk_hdr->length) - | 549 | ntohs(err_chunk->chunk_hdr->length) - |
@@ -542,7 +554,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
542 | if (packet) { | 554 | if (packet) { |
543 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 555 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
544 | SCTP_PACKET(packet)); | 556 | SCTP_PACKET(packet)); |
545 | SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_OUTCTRLCHUNKS); | 557 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
546 | error = SCTP_ERROR_INV_PARAM; | 558 | error = SCTP_ERROR_INV_PARAM; |
547 | } | 559 | } |
548 | } | 560 | } |
@@ -559,10 +571,10 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
559 | * was malformed. | 571 | * was malformed. |
560 | */ | 572 | */ |
561 | if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) | 573 | if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) |
562 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 574 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
563 | 575 | ||
564 | SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_ABORTEDS); | 576 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
565 | return sctp_stop_t1_and_abort(commands, error, ECONNREFUSED, | 577 | return sctp_stop_t1_and_abort(net, commands, error, ECONNREFUSED, |
566 | asoc, chunk->transport); | 578 | asoc, chunk->transport); |
567 | } | 579 | } |
568 | 580 | ||
@@ -638,7 +650,8 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
638 | * | 650 | * |
639 | * The return value is the disposition of the chunk. | 651 | * The return value is the disposition of the chunk. |
640 | */ | 652 | */ |
641 | sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | 653 | sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net, |
654 | const struct sctp_endpoint *ep, | ||
642 | const struct sctp_association *asoc, | 655 | const struct sctp_association *asoc, |
643 | const sctp_subtype_t type, void *arg, | 656 | const sctp_subtype_t type, void *arg, |
644 | sctp_cmd_seq_t *commands) | 657 | sctp_cmd_seq_t *commands) |
@@ -651,15 +664,13 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
651 | int error = 0; | 664 | int error = 0; |
652 | struct sctp_chunk *err_chk_p; | 665 | struct sctp_chunk *err_chk_p; |
653 | struct sock *sk; | 666 | struct sock *sk; |
654 | struct net *net; | ||
655 | 667 | ||
656 | /* If the packet is an OOTB packet which is temporarily on the | 668 | /* If the packet is an OOTB packet which is temporarily on the |
657 | * control endpoint, respond with an ABORT. | 669 | * control endpoint, respond with an ABORT. |
658 | */ | 670 | */ |
659 | net = sock_net(ep->base.sk); | ||
660 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { | 671 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { |
661 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); | 672 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); |
662 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 673 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
663 | } | 674 | } |
664 | 675 | ||
665 | /* Make sure that the COOKIE_ECHO chunk has a valid length. | 676 | /* Make sure that the COOKIE_ECHO chunk has a valid length. |
@@ -668,7 +679,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
668 | * in sctp_unpack_cookie(). | 679 | * in sctp_unpack_cookie(). |
669 | */ | 680 | */ |
670 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 681 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
671 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 682 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
672 | 683 | ||
673 | /* If the endpoint is not listening or if the number of associations | 684 | /* If the endpoint is not listening or if the number of associations |
674 | * on the TCP-style socket exceed the max backlog, respond with an | 685 | * on the TCP-style socket exceed the max backlog, respond with an |
@@ -677,7 +688,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
677 | sk = ep->base.sk; | 688 | sk = ep->base.sk; |
678 | if (!sctp_sstate(sk, LISTENING) || | 689 | if (!sctp_sstate(sk, LISTENING) || |
679 | (sctp_style(sk, TCP) && sk_acceptq_is_full(sk))) | 690 | (sctp_style(sk, TCP) && sk_acceptq_is_full(sk))) |
680 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 691 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
681 | 692 | ||
682 | /* "Decode" the chunk. We have no optional parameters so we | 693 | /* "Decode" the chunk. We have no optional parameters so we |
683 | * are in good shape. | 694 | * are in good shape. |
@@ -710,13 +721,13 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
710 | goto nomem; | 721 | goto nomem; |
711 | 722 | ||
712 | case -SCTP_IERROR_STALE_COOKIE: | 723 | case -SCTP_IERROR_STALE_COOKIE: |
713 | sctp_send_stale_cookie_err(ep, asoc, chunk, commands, | 724 | sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, |
714 | err_chk_p); | 725 | err_chk_p); |
715 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 726 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
716 | 727 | ||
717 | case -SCTP_IERROR_BAD_SIG: | 728 | case -SCTP_IERROR_BAD_SIG: |
718 | default: | 729 | default: |
719 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 730 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
720 | } | 731 | } |
721 | } | 732 | } |
722 | 733 | ||
@@ -763,14 +774,14 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
763 | skb_pull(chunk->auth_chunk, sizeof(sctp_chunkhdr_t)); | 774 | skb_pull(chunk->auth_chunk, sizeof(sctp_chunkhdr_t)); |
764 | auth.transport = chunk->transport; | 775 | auth.transport = chunk->transport; |
765 | 776 | ||
766 | ret = sctp_sf_authenticate(ep, new_asoc, type, &auth); | 777 | ret = sctp_sf_authenticate(net, ep, new_asoc, type, &auth); |
767 | 778 | ||
768 | /* We can now safely free the auth_chunk clone */ | 779 | /* We can now safely free the auth_chunk clone */ |
769 | kfree_skb(chunk->auth_chunk); | 780 | kfree_skb(chunk->auth_chunk); |
770 | 781 | ||
771 | if (ret != SCTP_IERROR_NO_ERROR) { | 782 | if (ret != SCTP_IERROR_NO_ERROR) { |
772 | sctp_association_free(new_asoc); | 783 | sctp_association_free(new_asoc); |
773 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 784 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
774 | } | 785 | } |
775 | } | 786 | } |
776 | 787 | ||
@@ -863,23 +874,23 @@ nomem: | |||
863 | * | 874 | * |
864 | * The return value is the disposition of the chunk. | 875 | * The return value is the disposition of the chunk. |
865 | */ | 876 | */ |
866 | sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep, | 877 | sctp_disposition_t sctp_sf_do_5_1E_ca(struct net *net, |
878 | const struct sctp_endpoint *ep, | ||
867 | const struct sctp_association *asoc, | 879 | const struct sctp_association *asoc, |
868 | const sctp_subtype_t type, void *arg, | 880 | const sctp_subtype_t type, void *arg, |
869 | sctp_cmd_seq_t *commands) | 881 | sctp_cmd_seq_t *commands) |
870 | { | 882 | { |
871 | struct sctp_chunk *chunk = arg; | 883 | struct sctp_chunk *chunk = arg; |
872 | struct sctp_ulpevent *ev; | 884 | struct sctp_ulpevent *ev; |
873 | struct net *net; | ||
874 | 885 | ||
875 | if (!sctp_vtag_verify(chunk, asoc)) | 886 | if (!sctp_vtag_verify(chunk, asoc)) |
876 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 887 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
877 | 888 | ||
878 | /* Verify that the chunk length for the COOKIE-ACK is OK. | 889 | /* Verify that the chunk length for the COOKIE-ACK is OK. |
879 | * If we don't do this, any bundled chunks may be junked. | 890 | * If we don't do this, any bundled chunks may be junked. |
880 | */ | 891 | */ |
881 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 892 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
882 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 893 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
883 | commands); | 894 | commands); |
884 | 895 | ||
885 | /* Reset init error count upon receipt of COOKIE-ACK, | 896 | /* Reset init error count upon receipt of COOKIE-ACK, |
@@ -900,7 +911,6 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep, | |||
900 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); | 911 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); |
901 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 912 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
902 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); | 913 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); |
903 | net = sock_net(ep->base.sk); | ||
904 | SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); | 914 | SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); |
905 | SCTP_INC_STATS(net, SCTP_MIB_ACTIVEESTABS); | 915 | SCTP_INC_STATS(net, SCTP_MIB_ACTIVEESTABS); |
906 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); | 916 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); |
@@ -967,7 +977,8 @@ static sctp_disposition_t sctp_sf_heartbeat(const struct sctp_endpoint *ep, | |||
967 | } | 977 | } |
968 | 978 | ||
969 | /* Generate a HEARTBEAT packet on the given transport. */ | 979 | /* Generate a HEARTBEAT packet on the given transport. */ |
970 | sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep, | 980 | sctp_disposition_t sctp_sf_sendbeat_8_3(struct net *net, |
981 | const struct sctp_endpoint *ep, | ||
971 | const struct sctp_association *asoc, | 982 | const struct sctp_association *asoc, |
972 | const sctp_subtype_t type, | 983 | const sctp_subtype_t type, |
973 | void *arg, | 984 | void *arg, |
@@ -976,13 +987,11 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep, | |||
976 | struct sctp_transport *transport = (struct sctp_transport *) arg; | 987 | struct sctp_transport *transport = (struct sctp_transport *) arg; |
977 | 988 | ||
978 | if (asoc->overall_error_count >= asoc->max_retrans) { | 989 | if (asoc->overall_error_count >= asoc->max_retrans) { |
979 | struct net *net; | ||
980 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, | 990 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, |
981 | SCTP_ERROR(ETIMEDOUT)); | 991 | SCTP_ERROR(ETIMEDOUT)); |
982 | /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ | 992 | /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ |
983 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 993 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
984 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); | 994 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); |
985 | net = sock_net(ep->base.sk); | ||
986 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); | 995 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
987 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); | 996 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
988 | return SCTP_DISPOSITION_DELETE_TCB; | 997 | return SCTP_DISPOSITION_DELETE_TCB; |
@@ -1039,7 +1048,8 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep, | |||
1039 | * | 1048 | * |
1040 | * The return value is the disposition of the chunk. | 1049 | * The return value is the disposition of the chunk. |
1041 | */ | 1050 | */ |
1042 | sctp_disposition_t sctp_sf_beat_8_3(const struct sctp_endpoint *ep, | 1051 | sctp_disposition_t sctp_sf_beat_8_3(struct net *net, |
1052 | const struct sctp_endpoint *ep, | ||
1043 | const struct sctp_association *asoc, | 1053 | const struct sctp_association *asoc, |
1044 | const sctp_subtype_t type, | 1054 | const sctp_subtype_t type, |
1045 | void *arg, | 1055 | void *arg, |
@@ -1050,11 +1060,11 @@ sctp_disposition_t sctp_sf_beat_8_3(const struct sctp_endpoint *ep, | |||
1050 | size_t paylen = 0; | 1060 | size_t paylen = 0; |
1051 | 1061 | ||
1052 | if (!sctp_vtag_verify(chunk, asoc)) | 1062 | if (!sctp_vtag_verify(chunk, asoc)) |
1053 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 1063 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
1054 | 1064 | ||
1055 | /* Make sure that the HEARTBEAT chunk has a valid length. */ | 1065 | /* Make sure that the HEARTBEAT chunk has a valid length. */ |
1056 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_heartbeat_chunk_t))) | 1066 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_heartbeat_chunk_t))) |
1057 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 1067 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
1058 | commands); | 1068 | commands); |
1059 | 1069 | ||
1060 | /* 8.3 The receiver of the HEARTBEAT should immediately | 1070 | /* 8.3 The receiver of the HEARTBEAT should immediately |
@@ -1106,7 +1116,8 @@ nomem: | |||
1106 | * | 1116 | * |
1107 | * The return value is the disposition of the chunk. | 1117 | * The return value is the disposition of the chunk. |
1108 | */ | 1118 | */ |
1109 | sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, | 1119 | sctp_disposition_t sctp_sf_backbeat_8_3(struct net *net, |
1120 | const struct sctp_endpoint *ep, | ||
1110 | const struct sctp_association *asoc, | 1121 | const struct sctp_association *asoc, |
1111 | const sctp_subtype_t type, | 1122 | const sctp_subtype_t type, |
1112 | void *arg, | 1123 | void *arg, |
@@ -1119,12 +1130,12 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, | |||
1119 | unsigned long max_interval; | 1130 | unsigned long max_interval; |
1120 | 1131 | ||
1121 | if (!sctp_vtag_verify(chunk, asoc)) | 1132 | if (!sctp_vtag_verify(chunk, asoc)) |
1122 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 1133 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
1123 | 1134 | ||
1124 | /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ | 1135 | /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ |
1125 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t) + | 1136 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t) + |
1126 | sizeof(sctp_sender_hb_info_t))) | 1137 | sizeof(sctp_sender_hb_info_t))) |
1127 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 1138 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
1128 | commands); | 1139 | commands); |
1129 | 1140 | ||
1130 | hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data; | 1141 | hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data; |
@@ -1213,7 +1224,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa, | |||
1213 | /* Association is NULL since this may be a restart attack and we | 1224 | /* Association is NULL since this may be a restart attack and we |
1214 | * want to send back the attacker's vtag. | 1225 | * want to send back the attacker's vtag. |
1215 | */ | 1226 | */ |
1216 | pkt = sctp_abort_pkt_new(ep, NULL, init, errhdr, len); | 1227 | pkt = sctp_abort_pkt_new(net, ep, NULL, init, errhdr, len); |
1217 | 1228 | ||
1218 | if (!pkt) | 1229 | if (!pkt) |
1219 | goto out; | 1230 | goto out; |
@@ -1370,6 +1381,7 @@ static char sctp_tietags_compare(struct sctp_association *new_asoc, | |||
1370 | * chunk handling. | 1381 | * chunk handling. |
1371 | */ | 1382 | */ |
1372 | static sctp_disposition_t sctp_sf_do_unexpected_init( | 1383 | static sctp_disposition_t sctp_sf_do_unexpected_init( |
1384 | struct net *net, | ||
1373 | const struct sctp_endpoint *ep, | 1385 | const struct sctp_endpoint *ep, |
1374 | const struct sctp_association *asoc, | 1386 | const struct sctp_association *asoc, |
1375 | const sctp_subtype_t type, | 1387 | const sctp_subtype_t type, |
@@ -1394,20 +1406,20 @@ static sctp_disposition_t sctp_sf_do_unexpected_init( | |||
1394 | * with an INIT chunk that is bundled with other chunks. | 1406 | * with an INIT chunk that is bundled with other chunks. |
1395 | */ | 1407 | */ |
1396 | if (!chunk->singleton) | 1408 | if (!chunk->singleton) |
1397 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 1409 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
1398 | 1410 | ||
1399 | /* 3.1 A packet containing an INIT chunk MUST have a zero Verification | 1411 | /* 3.1 A packet containing an INIT chunk MUST have a zero Verification |
1400 | * Tag. | 1412 | * Tag. |
1401 | */ | 1413 | */ |
1402 | if (chunk->sctp_hdr->vtag != 0) | 1414 | if (chunk->sctp_hdr->vtag != 0) |
1403 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 1415 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
1404 | 1416 | ||
1405 | /* Make sure that the INIT chunk has a valid length. | 1417 | /* Make sure that the INIT chunk has a valid length. |
1406 | * In this case, we generate a protocol violation since we have | 1418 | * In this case, we generate a protocol violation since we have |
1407 | * an association established. | 1419 | * an association established. |
1408 | */ | 1420 | */ |
1409 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) | 1421 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) |
1410 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 1422 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
1411 | commands); | 1423 | commands); |
1412 | /* Grab the INIT header. */ | 1424 | /* Grab the INIT header. */ |
1413 | chunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data; | 1425 | chunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data; |
@@ -1424,7 +1436,7 @@ static sctp_disposition_t sctp_sf_do_unexpected_init( | |||
1424 | * Send an ABORT, with causes if there is any. | 1436 | * Send an ABORT, with causes if there is any. |
1425 | */ | 1437 | */ |
1426 | if (err_chunk) { | 1438 | if (err_chunk) { |
1427 | packet = sctp_abort_pkt_new(ep, asoc, arg, | 1439 | packet = sctp_abort_pkt_new(net, ep, asoc, arg, |
1428 | (__u8 *)(err_chunk->chunk_hdr) + | 1440 | (__u8 *)(err_chunk->chunk_hdr) + |
1429 | sizeof(sctp_chunkhdr_t), | 1441 | sizeof(sctp_chunkhdr_t), |
1430 | ntohs(err_chunk->chunk_hdr->length) - | 1442 | ntohs(err_chunk->chunk_hdr->length) - |
@@ -1433,14 +1445,14 @@ static sctp_disposition_t sctp_sf_do_unexpected_init( | |||
1433 | if (packet) { | 1445 | if (packet) { |
1434 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 1446 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
1435 | SCTP_PACKET(packet)); | 1447 | SCTP_PACKET(packet)); |
1436 | SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_OUTCTRLCHUNKS); | 1448 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
1437 | retval = SCTP_DISPOSITION_CONSUME; | 1449 | retval = SCTP_DISPOSITION_CONSUME; |
1438 | } else { | 1450 | } else { |
1439 | retval = SCTP_DISPOSITION_NOMEM; | 1451 | retval = SCTP_DISPOSITION_NOMEM; |
1440 | } | 1452 | } |
1441 | goto cleanup; | 1453 | goto cleanup; |
1442 | } else { | 1454 | } else { |
1443 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, | 1455 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, |
1444 | commands); | 1456 | commands); |
1445 | } | 1457 | } |
1446 | } | 1458 | } |
@@ -1582,7 +1594,8 @@ cleanup: | |||
1582 | * | 1594 | * |
1583 | * The return value is the disposition of the chunk. | 1595 | * The return value is the disposition of the chunk. |
1584 | */ | 1596 | */ |
1585 | sctp_disposition_t sctp_sf_do_5_2_1_siminit(const struct sctp_endpoint *ep, | 1597 | sctp_disposition_t sctp_sf_do_5_2_1_siminit(struct net *net, |
1598 | const struct sctp_endpoint *ep, | ||
1586 | const struct sctp_association *asoc, | 1599 | const struct sctp_association *asoc, |
1587 | const sctp_subtype_t type, | 1600 | const sctp_subtype_t type, |
1588 | void *arg, | 1601 | void *arg, |
@@ -1591,7 +1604,7 @@ sctp_disposition_t sctp_sf_do_5_2_1_siminit(const struct sctp_endpoint *ep, | |||
1591 | /* Call helper to do the real work for both simulataneous and | 1604 | /* Call helper to do the real work for both simulataneous and |
1592 | * duplicate INIT chunk handling. | 1605 | * duplicate INIT chunk handling. |
1593 | */ | 1606 | */ |
1594 | return sctp_sf_do_unexpected_init(ep, asoc, type, arg, commands); | 1607 | return sctp_sf_do_unexpected_init(net, ep, asoc, type, arg, commands); |
1595 | } | 1608 | } |
1596 | 1609 | ||
1597 | /* | 1610 | /* |
@@ -1635,7 +1648,8 @@ sctp_disposition_t sctp_sf_do_5_2_1_siminit(const struct sctp_endpoint *ep, | |||
1635 | * | 1648 | * |
1636 | * The return value is the disposition of the chunk. | 1649 | * The return value is the disposition of the chunk. |
1637 | */ | 1650 | */ |
1638 | sctp_disposition_t sctp_sf_do_5_2_2_dupinit(const struct sctp_endpoint *ep, | 1651 | sctp_disposition_t sctp_sf_do_5_2_2_dupinit(struct net *net, |
1652 | const struct sctp_endpoint *ep, | ||
1639 | const struct sctp_association *asoc, | 1653 | const struct sctp_association *asoc, |
1640 | const sctp_subtype_t type, | 1654 | const sctp_subtype_t type, |
1641 | void *arg, | 1655 | void *arg, |
@@ -1644,7 +1658,7 @@ sctp_disposition_t sctp_sf_do_5_2_2_dupinit(const struct sctp_endpoint *ep, | |||
1644 | /* Call helper to do the real work for both simulataneous and | 1658 | /* Call helper to do the real work for both simulataneous and |
1645 | * duplicate INIT chunk handling. | 1659 | * duplicate INIT chunk handling. |
1646 | */ | 1660 | */ |
1647 | return sctp_sf_do_unexpected_init(ep, asoc, type, arg, commands); | 1661 | return sctp_sf_do_unexpected_init(net, ep, asoc, type, arg, commands); |
1648 | } | 1662 | } |
1649 | 1663 | ||
1650 | 1664 | ||
@@ -1657,19 +1671,19 @@ sctp_disposition_t sctp_sf_do_5_2_2_dupinit(const struct sctp_endpoint *ep, | |||
1657 | * An unexpected INIT ACK usually indicates the processing of an old or | 1671 | * An unexpected INIT ACK usually indicates the processing of an old or |
1658 | * duplicated INIT chunk. | 1672 | * duplicated INIT chunk. |
1659 | */ | 1673 | */ |
1660 | sctp_disposition_t sctp_sf_do_5_2_3_initack(const struct sctp_endpoint *ep, | 1674 | sctp_disposition_t sctp_sf_do_5_2_3_initack(struct net *net, |
1675 | const struct sctp_endpoint *ep, | ||
1661 | const struct sctp_association *asoc, | 1676 | const struct sctp_association *asoc, |
1662 | const sctp_subtype_t type, | 1677 | const sctp_subtype_t type, |
1663 | void *arg, sctp_cmd_seq_t *commands) | 1678 | void *arg, sctp_cmd_seq_t *commands) |
1664 | { | 1679 | { |
1665 | struct net *net = sock_net(ep->base.sk); | ||
1666 | /* Per the above section, we'll discard the chunk if we have an | 1680 | /* Per the above section, we'll discard the chunk if we have an |
1667 | * endpoint. If this is an OOTB INIT-ACK, treat it as such. | 1681 | * endpoint. If this is an OOTB INIT-ACK, treat it as such. |
1668 | */ | 1682 | */ |
1669 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) | 1683 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) |
1670 | return sctp_sf_ootb(ep, asoc, type, arg, commands); | 1684 | return sctp_sf_ootb(net, ep, asoc, type, arg, commands); |
1671 | else | 1685 | else |
1672 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 1686 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
1673 | } | 1687 | } |
1674 | 1688 | ||
1675 | /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A') | 1689 | /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A') |
@@ -1677,7 +1691,8 @@ sctp_disposition_t sctp_sf_do_5_2_3_initack(const struct sctp_endpoint *ep, | |||
1677 | * Section 5.2.4 | 1691 | * Section 5.2.4 |
1678 | * A) In this case, the peer may have restarted. | 1692 | * A) In this case, the peer may have restarted. |
1679 | */ | 1693 | */ |
1680 | static sctp_disposition_t sctp_sf_do_dupcook_a(const struct sctp_endpoint *ep, | 1694 | static sctp_disposition_t sctp_sf_do_dupcook_a(struct net *net, |
1695 | const struct sctp_endpoint *ep, | ||
1681 | const struct sctp_association *asoc, | 1696 | const struct sctp_association *asoc, |
1682 | struct sctp_chunk *chunk, | 1697 | struct sctp_chunk *chunk, |
1683 | sctp_cmd_seq_t *commands, | 1698 | sctp_cmd_seq_t *commands, |
@@ -1713,7 +1728,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_a(const struct sctp_endpoint *ep, | |||
1713 | * its peer. | 1728 | * its peer. |
1714 | */ | 1729 | */ |
1715 | if (sctp_state(asoc, SHUTDOWN_ACK_SENT)) { | 1730 | if (sctp_state(asoc, SHUTDOWN_ACK_SENT)) { |
1716 | disposition = sctp_sf_do_9_2_reshutack(ep, asoc, | 1731 | disposition = sctp_sf_do_9_2_reshutack(net, ep, asoc, |
1717 | SCTP_ST_CHUNK(chunk->chunk_hdr->type), | 1732 | SCTP_ST_CHUNK(chunk->chunk_hdr->type), |
1718 | chunk, commands); | 1733 | chunk, commands); |
1719 | if (SCTP_DISPOSITION_NOMEM == disposition) | 1734 | if (SCTP_DISPOSITION_NOMEM == disposition) |
@@ -1776,7 +1791,8 @@ nomem: | |||
1776 | * after responding to the local endpoint's INIT | 1791 | * after responding to the local endpoint's INIT |
1777 | */ | 1792 | */ |
1778 | /* This case represents an initialization collision. */ | 1793 | /* This case represents an initialization collision. */ |
1779 | static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep, | 1794 | static sctp_disposition_t sctp_sf_do_dupcook_b(struct net *net, |
1795 | const struct sctp_endpoint *ep, | ||
1780 | const struct sctp_association *asoc, | 1796 | const struct sctp_association *asoc, |
1781 | struct sctp_chunk *chunk, | 1797 | struct sctp_chunk *chunk, |
1782 | sctp_cmd_seq_t *commands, | 1798 | sctp_cmd_seq_t *commands, |
@@ -1797,7 +1813,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep, | |||
1797 | sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc)); | 1813 | sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc)); |
1798 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 1814 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
1799 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); | 1815 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); |
1800 | SCTP_INC_STATS(sock_net(new_asoc->base.sk), SCTP_MIB_CURRESTAB); | 1816 | SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); |
1801 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); | 1817 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); |
1802 | 1818 | ||
1803 | repl = sctp_make_cookie_ack(new_asoc, chunk); | 1819 | repl = sctp_make_cookie_ack(new_asoc, chunk); |
@@ -1846,7 +1862,8 @@ nomem: | |||
1846 | * but a new tag of its own. | 1862 | * but a new tag of its own. |
1847 | */ | 1863 | */ |
1848 | /* This case represents an initialization collision. */ | 1864 | /* This case represents an initialization collision. */ |
1849 | static sctp_disposition_t sctp_sf_do_dupcook_c(const struct sctp_endpoint *ep, | 1865 | static sctp_disposition_t sctp_sf_do_dupcook_c(struct net *net, |
1866 | const struct sctp_endpoint *ep, | ||
1850 | const struct sctp_association *asoc, | 1867 | const struct sctp_association *asoc, |
1851 | struct sctp_chunk *chunk, | 1868 | struct sctp_chunk *chunk, |
1852 | sctp_cmd_seq_t *commands, | 1869 | sctp_cmd_seq_t *commands, |
@@ -1867,7 +1884,8 @@ static sctp_disposition_t sctp_sf_do_dupcook_c(const struct sctp_endpoint *ep, | |||
1867 | * enter the ESTABLISHED state, if it has not already done so. | 1884 | * enter the ESTABLISHED state, if it has not already done so. |
1868 | */ | 1885 | */ |
1869 | /* This case represents an initialization collision. */ | 1886 | /* This case represents an initialization collision. */ |
1870 | static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep, | 1887 | static sctp_disposition_t sctp_sf_do_dupcook_d(struct net *net, |
1888 | const struct sctp_endpoint *ep, | ||
1871 | const struct sctp_association *asoc, | 1889 | const struct sctp_association *asoc, |
1872 | struct sctp_chunk *chunk, | 1890 | struct sctp_chunk *chunk, |
1873 | sctp_cmd_seq_t *commands, | 1891 | sctp_cmd_seq_t *commands, |
@@ -1889,7 +1907,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep, | |||
1889 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); | 1907 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); |
1890 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 1908 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
1891 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); | 1909 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); |
1892 | SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_CURRESTAB); | 1910 | SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); |
1893 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, | 1911 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, |
1894 | SCTP_NULL()); | 1912 | SCTP_NULL()); |
1895 | 1913 | ||
@@ -1961,7 +1979,8 @@ nomem: | |||
1961 | * | 1979 | * |
1962 | * The return value is the disposition of the chunk. | 1980 | * The return value is the disposition of the chunk. |
1963 | */ | 1981 | */ |
1964 | sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep, | 1982 | sctp_disposition_t sctp_sf_do_5_2_4_dupcook(struct net *net, |
1983 | const struct sctp_endpoint *ep, | ||
1965 | const struct sctp_association *asoc, | 1984 | const struct sctp_association *asoc, |
1966 | const sctp_subtype_t type, | 1985 | const sctp_subtype_t type, |
1967 | void *arg, | 1986 | void *arg, |
@@ -1980,7 +1999,7 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep, | |||
1980 | * done later. | 1999 | * done later. |
1981 | */ | 2000 | */ |
1982 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 2001 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
1983 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2002 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
1984 | commands); | 2003 | commands); |
1985 | 2004 | ||
1986 | /* "Decode" the chunk. We have no optional parameters so we | 2005 | /* "Decode" the chunk. We have no optional parameters so we |
@@ -2014,12 +2033,12 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep, | |||
2014 | goto nomem; | 2033 | goto nomem; |
2015 | 2034 | ||
2016 | case -SCTP_IERROR_STALE_COOKIE: | 2035 | case -SCTP_IERROR_STALE_COOKIE: |
2017 | sctp_send_stale_cookie_err(ep, asoc, chunk, commands, | 2036 | sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, |
2018 | err_chk_p); | 2037 | err_chk_p); |
2019 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2038 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2020 | case -SCTP_IERROR_BAD_SIG: | 2039 | case -SCTP_IERROR_BAD_SIG: |
2021 | default: | 2040 | default: |
2022 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2041 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2023 | } | 2042 | } |
2024 | } | 2043 | } |
2025 | 2044 | ||
@@ -2030,27 +2049,27 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep, | |||
2030 | 2049 | ||
2031 | switch (action) { | 2050 | switch (action) { |
2032 | case 'A': /* Association restart. */ | 2051 | case 'A': /* Association restart. */ |
2033 | retval = sctp_sf_do_dupcook_a(ep, asoc, chunk, commands, | 2052 | retval = sctp_sf_do_dupcook_a(net, ep, asoc, chunk, commands, |
2034 | new_asoc); | 2053 | new_asoc); |
2035 | break; | 2054 | break; |
2036 | 2055 | ||
2037 | case 'B': /* Collision case B. */ | 2056 | case 'B': /* Collision case B. */ |
2038 | retval = sctp_sf_do_dupcook_b(ep, asoc, chunk, commands, | 2057 | retval = sctp_sf_do_dupcook_b(net, ep, asoc, chunk, commands, |
2039 | new_asoc); | 2058 | new_asoc); |
2040 | break; | 2059 | break; |
2041 | 2060 | ||
2042 | case 'C': /* Collision case C. */ | 2061 | case 'C': /* Collision case C. */ |
2043 | retval = sctp_sf_do_dupcook_c(ep, asoc, chunk, commands, | 2062 | retval = sctp_sf_do_dupcook_c(net, ep, asoc, chunk, commands, |
2044 | new_asoc); | 2063 | new_asoc); |
2045 | break; | 2064 | break; |
2046 | 2065 | ||
2047 | case 'D': /* Collision case D. */ | 2066 | case 'D': /* Collision case D. */ |
2048 | retval = sctp_sf_do_dupcook_d(ep, asoc, chunk, commands, | 2067 | retval = sctp_sf_do_dupcook_d(net, ep, asoc, chunk, commands, |
2049 | new_asoc); | 2068 | new_asoc); |
2050 | break; | 2069 | break; |
2051 | 2070 | ||
2052 | default: /* Discard packet for all others. */ | 2071 | default: /* Discard packet for all others. */ |
2053 | retval = sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2072 | retval = sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2054 | break; | 2073 | break; |
2055 | } | 2074 | } |
2056 | 2075 | ||
@@ -2076,6 +2095,7 @@ nomem: | |||
2076 | * See sctp_sf_do_9_1_abort(). | 2095 | * See sctp_sf_do_9_1_abort(). |
2077 | */ | 2096 | */ |
2078 | sctp_disposition_t sctp_sf_shutdown_pending_abort( | 2097 | sctp_disposition_t sctp_sf_shutdown_pending_abort( |
2098 | struct net *net, | ||
2079 | const struct sctp_endpoint *ep, | 2099 | const struct sctp_endpoint *ep, |
2080 | const struct sctp_association *asoc, | 2100 | const struct sctp_association *asoc, |
2081 | const sctp_subtype_t type, | 2101 | const sctp_subtype_t type, |
@@ -2085,7 +2105,7 @@ sctp_disposition_t sctp_sf_shutdown_pending_abort( | |||
2085 | struct sctp_chunk *chunk = arg; | 2105 | struct sctp_chunk *chunk = arg; |
2086 | 2106 | ||
2087 | if (!sctp_vtag_verify_either(chunk, asoc)) | 2107 | if (!sctp_vtag_verify_either(chunk, asoc)) |
2088 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2108 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2089 | 2109 | ||
2090 | /* Make sure that the ABORT chunk has a valid length. | 2110 | /* Make sure that the ABORT chunk has a valid length. |
2091 | * Since this is an ABORT chunk, we have to discard it | 2111 | * Since this is an ABORT chunk, we have to discard it |
@@ -2098,7 +2118,7 @@ sctp_disposition_t sctp_sf_shutdown_pending_abort( | |||
2098 | * packet. | 2118 | * packet. |
2099 | */ | 2119 | */ |
2100 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) | 2120 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) |
2101 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2121 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2102 | 2122 | ||
2103 | /* ADD-IP: Special case for ABORT chunks | 2123 | /* ADD-IP: Special case for ABORT chunks |
2104 | * F4) One special consideration is that ABORT Chunks arriving | 2124 | * F4) One special consideration is that ABORT Chunks arriving |
@@ -2107,9 +2127,9 @@ sctp_disposition_t sctp_sf_shutdown_pending_abort( | |||
2107 | */ | 2127 | */ |
2108 | if (SCTP_ADDR_DEL == | 2128 | if (SCTP_ADDR_DEL == |
2109 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) | 2129 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) |
2110 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 2130 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
2111 | 2131 | ||
2112 | return __sctp_sf_do_9_1_abort(ep, asoc, type, arg, commands); | 2132 | return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); |
2113 | } | 2133 | } |
2114 | 2134 | ||
2115 | /* | 2135 | /* |
@@ -2117,7 +2137,8 @@ sctp_disposition_t sctp_sf_shutdown_pending_abort( | |||
2117 | * | 2137 | * |
2118 | * See sctp_sf_do_9_1_abort(). | 2138 | * See sctp_sf_do_9_1_abort(). |
2119 | */ | 2139 | */ |
2120 | sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | 2140 | sctp_disposition_t sctp_sf_shutdown_sent_abort(struct net *net, |
2141 | const struct sctp_endpoint *ep, | ||
2121 | const struct sctp_association *asoc, | 2142 | const struct sctp_association *asoc, |
2122 | const sctp_subtype_t type, | 2143 | const sctp_subtype_t type, |
2123 | void *arg, | 2144 | void *arg, |
@@ -2126,7 +2147,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2126 | struct sctp_chunk *chunk = arg; | 2147 | struct sctp_chunk *chunk = arg; |
2127 | 2148 | ||
2128 | if (!sctp_vtag_verify_either(chunk, asoc)) | 2149 | if (!sctp_vtag_verify_either(chunk, asoc)) |
2129 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2150 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2130 | 2151 | ||
2131 | /* Make sure that the ABORT chunk has a valid length. | 2152 | /* Make sure that the ABORT chunk has a valid length. |
2132 | * Since this is an ABORT chunk, we have to discard it | 2153 | * Since this is an ABORT chunk, we have to discard it |
@@ -2139,7 +2160,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2139 | * packet. | 2160 | * packet. |
2140 | */ | 2161 | */ |
2141 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) | 2162 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) |
2142 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2163 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2143 | 2164 | ||
2144 | /* ADD-IP: Special case for ABORT chunks | 2165 | /* ADD-IP: Special case for ABORT chunks |
2145 | * F4) One special consideration is that ABORT Chunks arriving | 2166 | * F4) One special consideration is that ABORT Chunks arriving |
@@ -2148,7 +2169,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2148 | */ | 2169 | */ |
2149 | if (SCTP_ADDR_DEL == | 2170 | if (SCTP_ADDR_DEL == |
2150 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) | 2171 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) |
2151 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 2172 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
2152 | 2173 | ||
2153 | /* Stop the T2-shutdown timer. */ | 2174 | /* Stop the T2-shutdown timer. */ |
2154 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 2175 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
@@ -2158,7 +2179,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2158 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 2179 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
2159 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); | 2180 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); |
2160 | 2181 | ||
2161 | return __sctp_sf_do_9_1_abort(ep, asoc, type, arg, commands); | 2182 | return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); |
2162 | } | 2183 | } |
2163 | 2184 | ||
2164 | /* | 2185 | /* |
@@ -2167,6 +2188,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2167 | * See sctp_sf_do_9_1_abort(). | 2188 | * See sctp_sf_do_9_1_abort(). |
2168 | */ | 2189 | */ |
2169 | sctp_disposition_t sctp_sf_shutdown_ack_sent_abort( | 2190 | sctp_disposition_t sctp_sf_shutdown_ack_sent_abort( |
2191 | struct net *net, | ||
2170 | const struct sctp_endpoint *ep, | 2192 | const struct sctp_endpoint *ep, |
2171 | const struct sctp_association *asoc, | 2193 | const struct sctp_association *asoc, |
2172 | const sctp_subtype_t type, | 2194 | const sctp_subtype_t type, |
@@ -2176,7 +2198,7 @@ sctp_disposition_t sctp_sf_shutdown_ack_sent_abort( | |||
2176 | /* The same T2 timer, so we should be able to use | 2198 | /* The same T2 timer, so we should be able to use |
2177 | * common function with the SHUTDOWN-SENT state. | 2199 | * common function with the SHUTDOWN-SENT state. |
2178 | */ | 2200 | */ |
2179 | return sctp_sf_shutdown_sent_abort(ep, asoc, type, arg, commands); | 2201 | return sctp_sf_shutdown_sent_abort(net, ep, asoc, type, arg, commands); |
2180 | } | 2202 | } |
2181 | 2203 | ||
2182 | /* | 2204 | /* |
@@ -2193,7 +2215,8 @@ sctp_disposition_t sctp_sf_shutdown_ack_sent_abort( | |||
2193 | * | 2215 | * |
2194 | * The return value is the disposition of the chunk. | 2216 | * The return value is the disposition of the chunk. |
2195 | */ | 2217 | */ |
2196 | sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | 2218 | sctp_disposition_t sctp_sf_cookie_echoed_err(struct net *net, |
2219 | const struct sctp_endpoint *ep, | ||
2197 | const struct sctp_association *asoc, | 2220 | const struct sctp_association *asoc, |
2198 | const sctp_subtype_t type, | 2221 | const sctp_subtype_t type, |
2199 | void *arg, | 2222 | void *arg, |
@@ -2203,13 +2226,13 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | |||
2203 | sctp_errhdr_t *err; | 2226 | sctp_errhdr_t *err; |
2204 | 2227 | ||
2205 | if (!sctp_vtag_verify(chunk, asoc)) | 2228 | if (!sctp_vtag_verify(chunk, asoc)) |
2206 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2229 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2207 | 2230 | ||
2208 | /* Make sure that the ERROR chunk has a valid length. | 2231 | /* Make sure that the ERROR chunk has a valid length. |
2209 | * The parameter walking depends on this as well. | 2232 | * The parameter walking depends on this as well. |
2210 | */ | 2233 | */ |
2211 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) | 2234 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) |
2212 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2235 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2213 | commands); | 2236 | commands); |
2214 | 2237 | ||
2215 | /* Process the error here */ | 2238 | /* Process the error here */ |
@@ -2219,7 +2242,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | |||
2219 | */ | 2242 | */ |
2220 | sctp_walk_errors(err, chunk->chunk_hdr) { | 2243 | sctp_walk_errors(err, chunk->chunk_hdr) { |
2221 | if (SCTP_ERROR_STALE_COOKIE == err->cause) | 2244 | if (SCTP_ERROR_STALE_COOKIE == err->cause) |
2222 | return sctp_sf_do_5_2_6_stale(ep, asoc, type, | 2245 | return sctp_sf_do_5_2_6_stale(net, ep, asoc, type, |
2223 | arg, commands); | 2246 | arg, commands); |
2224 | } | 2247 | } |
2225 | 2248 | ||
@@ -2228,7 +2251,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | |||
2228 | * we are discarding the packet, there should be no adverse | 2251 | * we are discarding the packet, there should be no adverse |
2229 | * affects. | 2252 | * affects. |
2230 | */ | 2253 | */ |
2231 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2254 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2232 | } | 2255 | } |
2233 | 2256 | ||
2234 | /* | 2257 | /* |
@@ -2256,7 +2279,8 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | |||
2256 | * | 2279 | * |
2257 | * The return value is the disposition of the chunk. | 2280 | * The return value is the disposition of the chunk. |
2258 | */ | 2281 | */ |
2259 | static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep, | 2282 | static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net, |
2283 | const struct sctp_endpoint *ep, | ||
2260 | const struct sctp_association *asoc, | 2284 | const struct sctp_association *asoc, |
2261 | const sctp_subtype_t type, | 2285 | const sctp_subtype_t type, |
2262 | void *arg, | 2286 | void *arg, |
@@ -2378,7 +2402,8 @@ nomem: | |||
2378 | * | 2402 | * |
2379 | * The return value is the disposition of the chunk. | 2403 | * The return value is the disposition of the chunk. |
2380 | */ | 2404 | */ |
2381 | sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | 2405 | sctp_disposition_t sctp_sf_do_9_1_abort(struct net *net, |
2406 | const struct sctp_endpoint *ep, | ||
2382 | const struct sctp_association *asoc, | 2407 | const struct sctp_association *asoc, |
2383 | const sctp_subtype_t type, | 2408 | const sctp_subtype_t type, |
2384 | void *arg, | 2409 | void *arg, |
@@ -2387,7 +2412,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2387 | struct sctp_chunk *chunk = arg; | 2412 | struct sctp_chunk *chunk = arg; |
2388 | 2413 | ||
2389 | if (!sctp_vtag_verify_either(chunk, asoc)) | 2414 | if (!sctp_vtag_verify_either(chunk, asoc)) |
2390 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2415 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2391 | 2416 | ||
2392 | /* Make sure that the ABORT chunk has a valid length. | 2417 | /* Make sure that the ABORT chunk has a valid length. |
2393 | * Since this is an ABORT chunk, we have to discard it | 2418 | * Since this is an ABORT chunk, we have to discard it |
@@ -2400,7 +2425,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2400 | * packet. | 2425 | * packet. |
2401 | */ | 2426 | */ |
2402 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) | 2427 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) |
2403 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2428 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2404 | 2429 | ||
2405 | /* ADD-IP: Special case for ABORT chunks | 2430 | /* ADD-IP: Special case for ABORT chunks |
2406 | * F4) One special consideration is that ABORT Chunks arriving | 2431 | * F4) One special consideration is that ABORT Chunks arriving |
@@ -2409,12 +2434,13 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2409 | */ | 2434 | */ |
2410 | if (SCTP_ADDR_DEL == | 2435 | if (SCTP_ADDR_DEL == |
2411 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) | 2436 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) |
2412 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 2437 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
2413 | 2438 | ||
2414 | return __sctp_sf_do_9_1_abort(ep, asoc, type, arg, commands); | 2439 | return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); |
2415 | } | 2440 | } |
2416 | 2441 | ||
2417 | static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | 2442 | static sctp_disposition_t __sctp_sf_do_9_1_abort(struct net *net, |
2443 | const struct sctp_endpoint *ep, | ||
2418 | const struct sctp_association *asoc, | 2444 | const struct sctp_association *asoc, |
2419 | const sctp_subtype_t type, | 2445 | const sctp_subtype_t type, |
2420 | void *arg, | 2446 | void *arg, |
@@ -2423,7 +2449,6 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2423 | struct sctp_chunk *chunk = arg; | 2449 | struct sctp_chunk *chunk = arg; |
2424 | unsigned int len; | 2450 | unsigned int len; |
2425 | __be16 error = SCTP_ERROR_NO_ERROR; | 2451 | __be16 error = SCTP_ERROR_NO_ERROR; |
2426 | struct net *net; | ||
2427 | 2452 | ||
2428 | /* See if we have an error cause code in the chunk. */ | 2453 | /* See if we have an error cause code in the chunk. */ |
2429 | len = ntohs(chunk->chunk_hdr->length); | 2454 | len = ntohs(chunk->chunk_hdr->length); |
@@ -2432,7 +2457,7 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2432 | sctp_errhdr_t *err; | 2457 | sctp_errhdr_t *err; |
2433 | sctp_walk_errors(err, chunk->chunk_hdr); | 2458 | sctp_walk_errors(err, chunk->chunk_hdr); |
2434 | if ((void *)err != (void *)chunk->chunk_end) | 2459 | if ((void *)err != (void *)chunk->chunk_end) |
2435 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2460 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2436 | 2461 | ||
2437 | error = ((sctp_errhdr_t *)chunk->skb->data)->cause; | 2462 | error = ((sctp_errhdr_t *)chunk->skb->data)->cause; |
2438 | } | 2463 | } |
@@ -2440,7 +2465,6 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2440 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET)); | 2465 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET)); |
2441 | /* ASSOC_FAILED will DELETE_TCB. */ | 2466 | /* ASSOC_FAILED will DELETE_TCB. */ |
2442 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error)); | 2467 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error)); |
2443 | net = sock_net(ep->base.sk); | ||
2444 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); | 2468 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
2445 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); | 2469 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
2446 | 2470 | ||
@@ -2452,7 +2476,8 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2452 | * | 2476 | * |
2453 | * See sctp_sf_do_9_1_abort() above. | 2477 | * See sctp_sf_do_9_1_abort() above. |
2454 | */ | 2478 | */ |
2455 | sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep, | 2479 | sctp_disposition_t sctp_sf_cookie_wait_abort(struct net *net, |
2480 | const struct sctp_endpoint *ep, | ||
2456 | const struct sctp_association *asoc, | 2481 | const struct sctp_association *asoc, |
2457 | const sctp_subtype_t type, | 2482 | const sctp_subtype_t type, |
2458 | void *arg, | 2483 | void *arg, |
@@ -2463,7 +2488,7 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep, | |||
2463 | __be16 error = SCTP_ERROR_NO_ERROR; | 2488 | __be16 error = SCTP_ERROR_NO_ERROR; |
2464 | 2489 | ||
2465 | if (!sctp_vtag_verify_either(chunk, asoc)) | 2490 | if (!sctp_vtag_verify_either(chunk, asoc)) |
2466 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2491 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2467 | 2492 | ||
2468 | /* Make sure that the ABORT chunk has a valid length. | 2493 | /* Make sure that the ABORT chunk has a valid length. |
2469 | * Since this is an ABORT chunk, we have to discard it | 2494 | * Since this is an ABORT chunk, we have to discard it |
@@ -2476,27 +2501,28 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep, | |||
2476 | * packet. | 2501 | * packet. |
2477 | */ | 2502 | */ |
2478 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) | 2503 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) |
2479 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2504 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2480 | 2505 | ||
2481 | /* See if we have an error cause code in the chunk. */ | 2506 | /* See if we have an error cause code in the chunk. */ |
2482 | len = ntohs(chunk->chunk_hdr->length); | 2507 | len = ntohs(chunk->chunk_hdr->length); |
2483 | if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) | 2508 | if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) |
2484 | error = ((sctp_errhdr_t *)chunk->skb->data)->cause; | 2509 | error = ((sctp_errhdr_t *)chunk->skb->data)->cause; |
2485 | 2510 | ||
2486 | return sctp_stop_t1_and_abort(commands, error, ECONNREFUSED, asoc, | 2511 | return sctp_stop_t1_and_abort(net, commands, error, ECONNREFUSED, asoc, |
2487 | chunk->transport); | 2512 | chunk->transport); |
2488 | } | 2513 | } |
2489 | 2514 | ||
2490 | /* | 2515 | /* |
2491 | * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state) | 2516 | * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state) |
2492 | */ | 2517 | */ |
2493 | sctp_disposition_t sctp_sf_cookie_wait_icmp_abort(const struct sctp_endpoint *ep, | 2518 | sctp_disposition_t sctp_sf_cookie_wait_icmp_abort(struct net *net, |
2519 | const struct sctp_endpoint *ep, | ||
2494 | const struct sctp_association *asoc, | 2520 | const struct sctp_association *asoc, |
2495 | const sctp_subtype_t type, | 2521 | const sctp_subtype_t type, |
2496 | void *arg, | 2522 | void *arg, |
2497 | sctp_cmd_seq_t *commands) | 2523 | sctp_cmd_seq_t *commands) |
2498 | { | 2524 | { |
2499 | return sctp_stop_t1_and_abort(commands, SCTP_ERROR_NO_ERROR, | 2525 | return sctp_stop_t1_and_abort(net, commands, SCTP_ERROR_NO_ERROR, |
2500 | ENOPROTOOPT, asoc, | 2526 | ENOPROTOOPT, asoc, |
2501 | (struct sctp_transport *)arg); | 2527 | (struct sctp_transport *)arg); |
2502 | } | 2528 | } |
@@ -2504,7 +2530,8 @@ sctp_disposition_t sctp_sf_cookie_wait_icmp_abort(const struct sctp_endpoint *ep | |||
2504 | /* | 2530 | /* |
2505 | * Process an ABORT. (COOKIE-ECHOED state) | 2531 | * Process an ABORT. (COOKIE-ECHOED state) |
2506 | */ | 2532 | */ |
2507 | sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep, | 2533 | sctp_disposition_t sctp_sf_cookie_echoed_abort(struct net *net, |
2534 | const struct sctp_endpoint *ep, | ||
2508 | const struct sctp_association *asoc, | 2535 | const struct sctp_association *asoc, |
2509 | const sctp_subtype_t type, | 2536 | const sctp_subtype_t type, |
2510 | void *arg, | 2537 | void *arg, |
@@ -2513,7 +2540,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep, | |||
2513 | /* There is a single T1 timer, so we should be able to use | 2540 | /* There is a single T1 timer, so we should be able to use |
2514 | * common function with the COOKIE-WAIT state. | 2541 | * common function with the COOKIE-WAIT state. |
2515 | */ | 2542 | */ |
2516 | return sctp_sf_cookie_wait_abort(ep, asoc, type, arg, commands); | 2543 | return sctp_sf_cookie_wait_abort(net, ep, asoc, type, arg, commands); |
2517 | } | 2544 | } |
2518 | 2545 | ||
2519 | /* | 2546 | /* |
@@ -2521,7 +2548,8 @@ sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep, | |||
2521 | * | 2548 | * |
2522 | * This is common code called by several sctp_sf_*_abort() functions above. | 2549 | * This is common code called by several sctp_sf_*_abort() functions above. |
2523 | */ | 2550 | */ |
2524 | static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, | 2551 | static sctp_disposition_t sctp_stop_t1_and_abort(struct net *net, |
2552 | sctp_cmd_seq_t *commands, | ||
2525 | __be16 error, int sk_err, | 2553 | __be16 error, int sk_err, |
2526 | const struct sctp_association *asoc, | 2554 | const struct sctp_association *asoc, |
2527 | struct sctp_transport *transport) | 2555 | struct sctp_transport *transport) |
@@ -2529,7 +2557,7 @@ static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, | |||
2529 | SCTP_DEBUG_PRINTK("ABORT received (INIT).\n"); | 2557 | SCTP_DEBUG_PRINTK("ABORT received (INIT).\n"); |
2530 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 2558 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
2531 | SCTP_STATE(SCTP_STATE_CLOSED)); | 2559 | SCTP_STATE(SCTP_STATE_CLOSED)); |
2532 | SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_ABORTEDS); | 2560 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
2533 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 2561 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
2534 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); | 2562 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); |
2535 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err)); | 2563 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err)); |
@@ -2572,7 +2600,8 @@ static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, | |||
2572 | * | 2600 | * |
2573 | * The return value is the disposition of the chunk. | 2601 | * The return value is the disposition of the chunk. |
2574 | */ | 2602 | */ |
2575 | sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | 2603 | sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net, |
2604 | const struct sctp_endpoint *ep, | ||
2576 | const struct sctp_association *asoc, | 2605 | const struct sctp_association *asoc, |
2577 | const sctp_subtype_t type, | 2606 | const sctp_subtype_t type, |
2578 | void *arg, | 2607 | void *arg, |
@@ -2585,12 +2614,12 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | |||
2585 | __u32 ctsn; | 2614 | __u32 ctsn; |
2586 | 2615 | ||
2587 | if (!sctp_vtag_verify(chunk, asoc)) | 2616 | if (!sctp_vtag_verify(chunk, asoc)) |
2588 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2617 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2589 | 2618 | ||
2590 | /* Make sure that the SHUTDOWN chunk has a valid length. */ | 2619 | /* Make sure that the SHUTDOWN chunk has a valid length. */ |
2591 | if (!sctp_chunk_length_valid(chunk, | 2620 | if (!sctp_chunk_length_valid(chunk, |
2592 | sizeof(struct sctp_shutdown_chunk_t))) | 2621 | sizeof(struct sctp_shutdown_chunk_t))) |
2593 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2622 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2594 | commands); | 2623 | commands); |
2595 | 2624 | ||
2596 | /* Convert the elaborate header. */ | 2625 | /* Convert the elaborate header. */ |
@@ -2610,7 +2639,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | |||
2610 | * sender with an ABORT. | 2639 | * sender with an ABORT. |
2611 | */ | 2640 | */ |
2612 | if (!TSN_lt(ctsn, asoc->next_tsn)) | 2641 | if (!TSN_lt(ctsn, asoc->next_tsn)) |
2613 | return sctp_sf_violation_ctsn(ep, asoc, type, arg, commands); | 2642 | return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); |
2614 | 2643 | ||
2615 | /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT | 2644 | /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT |
2616 | * When a peer sends a SHUTDOWN, SCTP delivers this notification to | 2645 | * When a peer sends a SHUTDOWN, SCTP delivers this notification to |
@@ -2634,7 +2663,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | |||
2634 | disposition = SCTP_DISPOSITION_CONSUME; | 2663 | disposition = SCTP_DISPOSITION_CONSUME; |
2635 | 2664 | ||
2636 | if (sctp_outq_is_empty(&asoc->outqueue)) { | 2665 | if (sctp_outq_is_empty(&asoc->outqueue)) { |
2637 | disposition = sctp_sf_do_9_2_shutdown_ack(ep, asoc, type, | 2666 | disposition = sctp_sf_do_9_2_shutdown_ack(net, ep, asoc, type, |
2638 | arg, commands); | 2667 | arg, commands); |
2639 | } | 2668 | } |
2640 | 2669 | ||
@@ -2660,7 +2689,8 @@ out: | |||
2660 | * The Cumulative TSN Ack of the received SHUTDOWN chunk | 2689 | * The Cumulative TSN Ack of the received SHUTDOWN chunk |
2661 | * MUST be processed. | 2690 | * MUST be processed. |
2662 | */ | 2691 | */ |
2663 | sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(const struct sctp_endpoint *ep, | 2692 | sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(struct net *net, |
2693 | const struct sctp_endpoint *ep, | ||
2664 | const struct sctp_association *asoc, | 2694 | const struct sctp_association *asoc, |
2665 | const sctp_subtype_t type, | 2695 | const sctp_subtype_t type, |
2666 | void *arg, | 2696 | void *arg, |
@@ -2671,12 +2701,12 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(const struct sctp_endpoint *ep, | |||
2671 | __u32 ctsn; | 2701 | __u32 ctsn; |
2672 | 2702 | ||
2673 | if (!sctp_vtag_verify(chunk, asoc)) | 2703 | if (!sctp_vtag_verify(chunk, asoc)) |
2674 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2704 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2675 | 2705 | ||
2676 | /* Make sure that the SHUTDOWN chunk has a valid length. */ | 2706 | /* Make sure that the SHUTDOWN chunk has a valid length. */ |
2677 | if (!sctp_chunk_length_valid(chunk, | 2707 | if (!sctp_chunk_length_valid(chunk, |
2678 | sizeof(struct sctp_shutdown_chunk_t))) | 2708 | sizeof(struct sctp_shutdown_chunk_t))) |
2679 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2709 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2680 | commands); | 2710 | commands); |
2681 | 2711 | ||
2682 | sdh = (sctp_shutdownhdr_t *)chunk->skb->data; | 2712 | sdh = (sctp_shutdownhdr_t *)chunk->skb->data; |
@@ -2693,7 +2723,7 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(const struct sctp_endpoint *ep, | |||
2693 | * sender with an ABORT. | 2723 | * sender with an ABORT. |
2694 | */ | 2724 | */ |
2695 | if (!TSN_lt(ctsn, asoc->next_tsn)) | 2725 | if (!TSN_lt(ctsn, asoc->next_tsn)) |
2696 | return sctp_sf_violation_ctsn(ep, asoc, type, arg, commands); | 2726 | return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); |
2697 | 2727 | ||
2698 | /* verify, by checking the Cumulative TSN Ack field of the | 2728 | /* verify, by checking the Cumulative TSN Ack field of the |
2699 | * chunk, that all its outstanding DATA chunks have been | 2729 | * chunk, that all its outstanding DATA chunks have been |
@@ -2712,7 +2742,8 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(const struct sctp_endpoint *ep, | |||
2712 | * that belong to this association, it should discard the INIT chunk and | 2742 | * that belong to this association, it should discard the INIT chunk and |
2713 | * retransmit the SHUTDOWN ACK chunk. | 2743 | * retransmit the SHUTDOWN ACK chunk. |
2714 | */ | 2744 | */ |
2715 | sctp_disposition_t sctp_sf_do_9_2_reshutack(const struct sctp_endpoint *ep, | 2745 | sctp_disposition_t sctp_sf_do_9_2_reshutack(struct net *net, |
2746 | const struct sctp_endpoint *ep, | ||
2716 | const struct sctp_association *asoc, | 2747 | const struct sctp_association *asoc, |
2717 | const sctp_subtype_t type, | 2748 | const sctp_subtype_t type, |
2718 | void *arg, | 2749 | void *arg, |
@@ -2723,7 +2754,7 @@ sctp_disposition_t sctp_sf_do_9_2_reshutack(const struct sctp_endpoint *ep, | |||
2723 | 2754 | ||
2724 | /* Make sure that the chunk has a valid length */ | 2755 | /* Make sure that the chunk has a valid length */ |
2725 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 2756 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
2726 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2757 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2727 | commands); | 2758 | commands); |
2728 | 2759 | ||
2729 | /* Since we are not going to really process this INIT, there | 2760 | /* Since we are not going to really process this INIT, there |
@@ -2775,7 +2806,8 @@ nomem: | |||
2775 | * | 2806 | * |
2776 | * The return value is the disposition of the chunk. | 2807 | * The return value is the disposition of the chunk. |
2777 | */ | 2808 | */ |
2778 | sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep, | 2809 | sctp_disposition_t sctp_sf_do_ecn_cwr(struct net *net, |
2810 | const struct sctp_endpoint *ep, | ||
2779 | const struct sctp_association *asoc, | 2811 | const struct sctp_association *asoc, |
2780 | const sctp_subtype_t type, | 2812 | const sctp_subtype_t type, |
2781 | void *arg, | 2813 | void *arg, |
@@ -2786,10 +2818,10 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep, | |||
2786 | u32 lowest_tsn; | 2818 | u32 lowest_tsn; |
2787 | 2819 | ||
2788 | if (!sctp_vtag_verify(chunk, asoc)) | 2820 | if (!sctp_vtag_verify(chunk, asoc)) |
2789 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2821 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2790 | 2822 | ||
2791 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) | 2823 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) |
2792 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2824 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2793 | commands); | 2825 | commands); |
2794 | 2826 | ||
2795 | cwr = (sctp_cwrhdr_t *) chunk->skb->data; | 2827 | cwr = (sctp_cwrhdr_t *) chunk->skb->data; |
@@ -2830,7 +2862,8 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep, | |||
2830 | * | 2862 | * |
2831 | * The return value is the disposition of the chunk. | 2863 | * The return value is the disposition of the chunk. |
2832 | */ | 2864 | */ |
2833 | sctp_disposition_t sctp_sf_do_ecne(const struct sctp_endpoint *ep, | 2865 | sctp_disposition_t sctp_sf_do_ecne(struct net *net, |
2866 | const struct sctp_endpoint *ep, | ||
2834 | const struct sctp_association *asoc, | 2867 | const struct sctp_association *asoc, |
2835 | const sctp_subtype_t type, | 2868 | const sctp_subtype_t type, |
2836 | void *arg, | 2869 | void *arg, |
@@ -2840,10 +2873,10 @@ sctp_disposition_t sctp_sf_do_ecne(const struct sctp_endpoint *ep, | |||
2840 | struct sctp_chunk *chunk = arg; | 2873 | struct sctp_chunk *chunk = arg; |
2841 | 2874 | ||
2842 | if (!sctp_vtag_verify(chunk, asoc)) | 2875 | if (!sctp_vtag_verify(chunk, asoc)) |
2843 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2876 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2844 | 2877 | ||
2845 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) | 2878 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) |
2846 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2879 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2847 | commands); | 2880 | commands); |
2848 | 2881 | ||
2849 | ecne = (sctp_ecnehdr_t *) chunk->skb->data; | 2882 | ecne = (sctp_ecnehdr_t *) chunk->skb->data; |
@@ -2886,7 +2919,8 @@ sctp_disposition_t sctp_sf_do_ecne(const struct sctp_endpoint *ep, | |||
2886 | * | 2919 | * |
2887 | * The return value is the disposition of the chunk. | 2920 | * The return value is the disposition of the chunk. |
2888 | */ | 2921 | */ |
2889 | sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep, | 2922 | sctp_disposition_t sctp_sf_eat_data_6_2(struct net *net, |
2923 | const struct sctp_endpoint *ep, | ||
2890 | const struct sctp_association *asoc, | 2924 | const struct sctp_association *asoc, |
2891 | const sctp_subtype_t type, | 2925 | const sctp_subtype_t type, |
2892 | void *arg, | 2926 | void *arg, |
@@ -2899,11 +2933,11 @@ sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep, | |||
2899 | if (!sctp_vtag_verify(chunk, asoc)) { | 2933 | if (!sctp_vtag_verify(chunk, asoc)) { |
2900 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 2934 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
2901 | SCTP_NULL()); | 2935 | SCTP_NULL()); |
2902 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2936 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2903 | } | 2937 | } |
2904 | 2938 | ||
2905 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t))) | 2939 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t))) |
2906 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2940 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2907 | commands); | 2941 | commands); |
2908 | 2942 | ||
2909 | error = sctp_eat_data(asoc, chunk, commands ); | 2943 | error = sctp_eat_data(asoc, chunk, commands ); |
@@ -2912,16 +2946,16 @@ sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep, | |||
2912 | break; | 2946 | break; |
2913 | case SCTP_IERROR_HIGH_TSN: | 2947 | case SCTP_IERROR_HIGH_TSN: |
2914 | case SCTP_IERROR_BAD_STREAM: | 2948 | case SCTP_IERROR_BAD_STREAM: |
2915 | SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_IN_DATA_CHUNK_DISCARDS); | 2949 | SCTP_INC_STATS(net, SCTP_MIB_IN_DATA_CHUNK_DISCARDS); |
2916 | goto discard_noforce; | 2950 | goto discard_noforce; |
2917 | case SCTP_IERROR_DUP_TSN: | 2951 | case SCTP_IERROR_DUP_TSN: |
2918 | case SCTP_IERROR_IGNORE_TSN: | 2952 | case SCTP_IERROR_IGNORE_TSN: |
2919 | SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_IN_DATA_CHUNK_DISCARDS); | 2953 | SCTP_INC_STATS(net, SCTP_MIB_IN_DATA_CHUNK_DISCARDS); |
2920 | goto discard_force; | 2954 | goto discard_force; |
2921 | case SCTP_IERROR_NO_DATA: | 2955 | case SCTP_IERROR_NO_DATA: |
2922 | goto consume; | 2956 | goto consume; |
2923 | case SCTP_IERROR_PROTO_VIOLATION: | 2957 | case SCTP_IERROR_PROTO_VIOLATION: |
2924 | return sctp_sf_abort_violation(ep, asoc, chunk, commands, | 2958 | return sctp_sf_abort_violation(net, ep, asoc, chunk, commands, |
2925 | (u8 *)chunk->subh.data_hdr, sizeof(sctp_datahdr_t)); | 2959 | (u8 *)chunk->subh.data_hdr, sizeof(sctp_datahdr_t)); |
2926 | default: | 2960 | default: |
2927 | BUG(); | 2961 | BUG(); |
@@ -3007,7 +3041,8 @@ consume: | |||
3007 | * | 3041 | * |
3008 | * The return value is the disposition of the chunk. | 3042 | * The return value is the disposition of the chunk. |
3009 | */ | 3043 | */ |
3010 | sctp_disposition_t sctp_sf_eat_data_fast_4_4(const struct sctp_endpoint *ep, | 3044 | sctp_disposition_t sctp_sf_eat_data_fast_4_4(struct net *net, |
3045 | const struct sctp_endpoint *ep, | ||
3011 | const struct sctp_association *asoc, | 3046 | const struct sctp_association *asoc, |
3012 | const sctp_subtype_t type, | 3047 | const sctp_subtype_t type, |
3013 | void *arg, | 3048 | void *arg, |
@@ -3019,11 +3054,11 @@ sctp_disposition_t sctp_sf_eat_data_fast_4_4(const struct sctp_endpoint *ep, | |||
3019 | if (!sctp_vtag_verify(chunk, asoc)) { | 3054 | if (!sctp_vtag_verify(chunk, asoc)) { |
3020 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3055 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3021 | SCTP_NULL()); | 3056 | SCTP_NULL()); |
3022 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3057 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3023 | } | 3058 | } |
3024 | 3059 | ||
3025 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t))) | 3060 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t))) |
3026 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3061 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3027 | commands); | 3062 | commands); |
3028 | 3063 | ||
3029 | error = sctp_eat_data(asoc, chunk, commands ); | 3064 | error = sctp_eat_data(asoc, chunk, commands ); |
@@ -3037,7 +3072,7 @@ sctp_disposition_t sctp_sf_eat_data_fast_4_4(const struct sctp_endpoint *ep, | |||
3037 | case SCTP_IERROR_NO_DATA: | 3072 | case SCTP_IERROR_NO_DATA: |
3038 | goto consume; | 3073 | goto consume; |
3039 | case SCTP_IERROR_PROTO_VIOLATION: | 3074 | case SCTP_IERROR_PROTO_VIOLATION: |
3040 | return sctp_sf_abort_violation(ep, asoc, chunk, commands, | 3075 | return sctp_sf_abort_violation(net, ep, asoc, chunk, commands, |
3041 | (u8 *)chunk->subh.data_hdr, sizeof(sctp_datahdr_t)); | 3076 | (u8 *)chunk->subh.data_hdr, sizeof(sctp_datahdr_t)); |
3042 | default: | 3077 | default: |
3043 | BUG(); | 3078 | BUG(); |
@@ -3097,7 +3132,8 @@ consume: | |||
3097 | * | 3132 | * |
3098 | * The return value is the disposition of the chunk. | 3133 | * The return value is the disposition of the chunk. |
3099 | */ | 3134 | */ |
3100 | sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep, | 3135 | sctp_disposition_t sctp_sf_eat_sack_6_2(struct net *net, |
3136 | const struct sctp_endpoint *ep, | ||
3101 | const struct sctp_association *asoc, | 3137 | const struct sctp_association *asoc, |
3102 | const sctp_subtype_t type, | 3138 | const sctp_subtype_t type, |
3103 | void *arg, | 3139 | void *arg, |
@@ -3108,18 +3144,18 @@ sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep, | |||
3108 | __u32 ctsn; | 3144 | __u32 ctsn; |
3109 | 3145 | ||
3110 | if (!sctp_vtag_verify(chunk, asoc)) | 3146 | if (!sctp_vtag_verify(chunk, asoc)) |
3111 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3147 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3112 | 3148 | ||
3113 | /* Make sure that the SACK chunk has a valid length. */ | 3149 | /* Make sure that the SACK chunk has a valid length. */ |
3114 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_sack_chunk_t))) | 3150 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_sack_chunk_t))) |
3115 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3151 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3116 | commands); | 3152 | commands); |
3117 | 3153 | ||
3118 | /* Pull the SACK chunk from the data buffer */ | 3154 | /* Pull the SACK chunk from the data buffer */ |
3119 | sackh = sctp_sm_pull_sack(chunk); | 3155 | sackh = sctp_sm_pull_sack(chunk); |
3120 | /* Was this a bogus SACK? */ | 3156 | /* Was this a bogus SACK? */ |
3121 | if (!sackh) | 3157 | if (!sackh) |
3122 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3158 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3123 | chunk->subh.sack_hdr = sackh; | 3159 | chunk->subh.sack_hdr = sackh; |
3124 | ctsn = ntohl(sackh->cum_tsn_ack); | 3160 | ctsn = ntohl(sackh->cum_tsn_ack); |
3125 | 3161 | ||
@@ -3140,7 +3176,7 @@ sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep, | |||
3140 | * sender with an ABORT. | 3176 | * sender with an ABORT. |
3141 | */ | 3177 | */ |
3142 | if (!TSN_lt(ctsn, asoc->next_tsn)) | 3178 | if (!TSN_lt(ctsn, asoc->next_tsn)) |
3143 | return sctp_sf_violation_ctsn(ep, asoc, type, arg, commands); | 3179 | return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); |
3144 | 3180 | ||
3145 | /* Return this SACK for further processing. */ | 3181 | /* Return this SACK for further processing. */ |
3146 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK, SCTP_SACKH(sackh)); | 3182 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK, SCTP_SACKH(sackh)); |
@@ -3169,7 +3205,8 @@ sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep, | |||
3169 | * | 3205 | * |
3170 | * The return value is the disposition of the chunk. | 3206 | * The return value is the disposition of the chunk. |
3171 | */ | 3207 | */ |
3172 | static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | 3208 | static sctp_disposition_t sctp_sf_tabort_8_4_8(struct net *net, |
3209 | const struct sctp_endpoint *ep, | ||
3173 | const struct sctp_association *asoc, | 3210 | const struct sctp_association *asoc, |
3174 | const sctp_subtype_t type, | 3211 | const sctp_subtype_t type, |
3175 | void *arg, | 3212 | void *arg, |
@@ -3178,9 +3215,7 @@ static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | |||
3178 | struct sctp_packet *packet = NULL; | 3215 | struct sctp_packet *packet = NULL; |
3179 | struct sctp_chunk *chunk = arg; | 3216 | struct sctp_chunk *chunk = arg; |
3180 | struct sctp_chunk *abort; | 3217 | struct sctp_chunk *abort; |
3181 | struct net *net; | ||
3182 | 3218 | ||
3183 | net = sock_net(ep->base.sk); | ||
3184 | packet = sctp_ootb_pkt_new(net, asoc, chunk); | 3219 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
3185 | 3220 | ||
3186 | if (packet) { | 3221 | if (packet) { |
@@ -3207,7 +3242,7 @@ static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | |||
3207 | 3242 | ||
3208 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); | 3243 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
3209 | 3244 | ||
3210 | sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3245 | sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3211 | return SCTP_DISPOSITION_CONSUME; | 3246 | return SCTP_DISPOSITION_CONSUME; |
3212 | } | 3247 | } |
3213 | 3248 | ||
@@ -3222,7 +3257,8 @@ static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | |||
3222 | * | 3257 | * |
3223 | * The return value is the disposition of the chunk. | 3258 | * The return value is the disposition of the chunk. |
3224 | */ | 3259 | */ |
3225 | sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep, | 3260 | sctp_disposition_t sctp_sf_operr_notify(struct net *net, |
3261 | const struct sctp_endpoint *ep, | ||
3226 | const struct sctp_association *asoc, | 3262 | const struct sctp_association *asoc, |
3227 | const sctp_subtype_t type, | 3263 | const sctp_subtype_t type, |
3228 | void *arg, | 3264 | void *arg, |
@@ -3232,15 +3268,15 @@ sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep, | |||
3232 | sctp_errhdr_t *err; | 3268 | sctp_errhdr_t *err; |
3233 | 3269 | ||
3234 | if (!sctp_vtag_verify(chunk, asoc)) | 3270 | if (!sctp_vtag_verify(chunk, asoc)) |
3235 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3271 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3236 | 3272 | ||
3237 | /* Make sure that the ERROR chunk has a valid length. */ | 3273 | /* Make sure that the ERROR chunk has a valid length. */ |
3238 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) | 3274 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) |
3239 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3275 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3240 | commands); | 3276 | commands); |
3241 | sctp_walk_errors(err, chunk->chunk_hdr); | 3277 | sctp_walk_errors(err, chunk->chunk_hdr); |
3242 | if ((void *)err != (void *)chunk->chunk_end) | 3278 | if ((void *)err != (void *)chunk->chunk_end) |
3243 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, | 3279 | return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, |
3244 | (void *)err, commands); | 3280 | (void *)err, commands); |
3245 | 3281 | ||
3246 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR, | 3282 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR, |
@@ -3259,7 +3295,8 @@ sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep, | |||
3259 | * | 3295 | * |
3260 | * The return value is the disposition. | 3296 | * The return value is the disposition. |
3261 | */ | 3297 | */ |
3262 | sctp_disposition_t sctp_sf_do_9_2_final(const struct sctp_endpoint *ep, | 3298 | sctp_disposition_t sctp_sf_do_9_2_final(struct net *net, |
3299 | const struct sctp_endpoint *ep, | ||
3263 | const struct sctp_association *asoc, | 3300 | const struct sctp_association *asoc, |
3264 | const sctp_subtype_t type, | 3301 | const sctp_subtype_t type, |
3265 | void *arg, | 3302 | void *arg, |
@@ -3268,14 +3305,13 @@ sctp_disposition_t sctp_sf_do_9_2_final(const struct sctp_endpoint *ep, | |||
3268 | struct sctp_chunk *chunk = arg; | 3305 | struct sctp_chunk *chunk = arg; |
3269 | struct sctp_chunk *reply; | 3306 | struct sctp_chunk *reply; |
3270 | struct sctp_ulpevent *ev; | 3307 | struct sctp_ulpevent *ev; |
3271 | struct net *net; | ||
3272 | 3308 | ||
3273 | if (!sctp_vtag_verify(chunk, asoc)) | 3309 | if (!sctp_vtag_verify(chunk, asoc)) |
3274 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3310 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3275 | 3311 | ||
3276 | /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ | 3312 | /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ |
3277 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 3313 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
3278 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3314 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3279 | commands); | 3315 | commands); |
3280 | /* 10.2 H) SHUTDOWN COMPLETE notification | 3316 | /* 10.2 H) SHUTDOWN COMPLETE notification |
3281 | * | 3317 | * |
@@ -3308,7 +3344,6 @@ sctp_disposition_t sctp_sf_do_9_2_final(const struct sctp_endpoint *ep, | |||
3308 | 3344 | ||
3309 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 3345 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
3310 | SCTP_STATE(SCTP_STATE_CLOSED)); | 3346 | SCTP_STATE(SCTP_STATE_CLOSED)); |
3311 | net = sock_net(asoc->base.sk); | ||
3312 | SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS); | 3347 | SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS); |
3313 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); | 3348 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
3314 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply)); | 3349 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply)); |
@@ -3343,7 +3378,8 @@ nomem: | |||
3343 | * receiver of the OOTB packet shall discard the OOTB packet and take | 3378 | * receiver of the OOTB packet shall discard the OOTB packet and take |
3344 | * no further action. | 3379 | * no further action. |
3345 | */ | 3380 | */ |
3346 | sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | 3381 | sctp_disposition_t sctp_sf_ootb(struct net *net, |
3382 | const struct sctp_endpoint *ep, | ||
3347 | const struct sctp_association *asoc, | 3383 | const struct sctp_association *asoc, |
3348 | const sctp_subtype_t type, | 3384 | const sctp_subtype_t type, |
3349 | void *arg, | 3385 | void *arg, |
@@ -3356,16 +3392,14 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | |||
3356 | __u8 *ch_end; | 3392 | __u8 *ch_end; |
3357 | int ootb_shut_ack = 0; | 3393 | int ootb_shut_ack = 0; |
3358 | int ootb_cookie_ack = 0; | 3394 | int ootb_cookie_ack = 0; |
3359 | struct net *net; | ||
3360 | 3395 | ||
3361 | net = sock_net(asoc->base.sk); | ||
3362 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); | 3396 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); |
3363 | 3397 | ||
3364 | ch = (sctp_chunkhdr_t *) chunk->chunk_hdr; | 3398 | ch = (sctp_chunkhdr_t *) chunk->chunk_hdr; |
3365 | do { | 3399 | do { |
3366 | /* Report violation if the chunk is less then minimal */ | 3400 | /* Report violation if the chunk is less then minimal */ |
3367 | if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t)) | 3401 | if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t)) |
3368 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3402 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3369 | commands); | 3403 | commands); |
3370 | 3404 | ||
3371 | /* Now that we know we at least have a chunk header, | 3405 | /* Now that we know we at least have a chunk header, |
@@ -3380,7 +3414,7 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | |||
3380 | * sending an ABORT of its own. | 3414 | * sending an ABORT of its own. |
3381 | */ | 3415 | */ |
3382 | if (SCTP_CID_ABORT == ch->type) | 3416 | if (SCTP_CID_ABORT == ch->type) |
3383 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3417 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3384 | 3418 | ||
3385 | /* RFC 8.4, 7) If the packet contains a "Stale cookie" ERROR | 3419 | /* RFC 8.4, 7) If the packet contains a "Stale cookie" ERROR |
3386 | * or a COOKIE ACK the SCTP Packet should be silently | 3420 | * or a COOKIE ACK the SCTP Packet should be silently |
@@ -3402,18 +3436,18 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | |||
3402 | /* Report violation if chunk len overflows */ | 3436 | /* Report violation if chunk len overflows */ |
3403 | ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length)); | 3437 | ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length)); |
3404 | if (ch_end > skb_tail_pointer(skb)) | 3438 | if (ch_end > skb_tail_pointer(skb)) |
3405 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3439 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3406 | commands); | 3440 | commands); |
3407 | 3441 | ||
3408 | ch = (sctp_chunkhdr_t *) ch_end; | 3442 | ch = (sctp_chunkhdr_t *) ch_end; |
3409 | } while (ch_end < skb_tail_pointer(skb)); | 3443 | } while (ch_end < skb_tail_pointer(skb)); |
3410 | 3444 | ||
3411 | if (ootb_shut_ack) | 3445 | if (ootb_shut_ack) |
3412 | return sctp_sf_shut_8_4_5(ep, asoc, type, arg, commands); | 3446 | return sctp_sf_shut_8_4_5(net, ep, asoc, type, arg, commands); |
3413 | else if (ootb_cookie_ack) | 3447 | else if (ootb_cookie_ack) |
3414 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3448 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3415 | else | 3449 | else |
3416 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 3450 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
3417 | } | 3451 | } |
3418 | 3452 | ||
3419 | /* | 3453 | /* |
@@ -3437,7 +3471,8 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | |||
3437 | * | 3471 | * |
3438 | * The return value is the disposition of the chunk. | 3472 | * The return value is the disposition of the chunk. |
3439 | */ | 3473 | */ |
3440 | static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | 3474 | static sctp_disposition_t sctp_sf_shut_8_4_5(struct net *net, |
3475 | const struct sctp_endpoint *ep, | ||
3441 | const struct sctp_association *asoc, | 3476 | const struct sctp_association *asoc, |
3442 | const sctp_subtype_t type, | 3477 | const sctp_subtype_t type, |
3443 | void *arg, | 3478 | void *arg, |
@@ -3446,9 +3481,7 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | |||
3446 | struct sctp_packet *packet = NULL; | 3481 | struct sctp_packet *packet = NULL; |
3447 | struct sctp_chunk *chunk = arg; | 3482 | struct sctp_chunk *chunk = arg; |
3448 | struct sctp_chunk *shut; | 3483 | struct sctp_chunk *shut; |
3449 | struct net *net; | ||
3450 | 3484 | ||
3451 | net = sock_net(ep->base.sk); | ||
3452 | packet = sctp_ootb_pkt_new(net, asoc, chunk); | 3485 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
3453 | 3486 | ||
3454 | if (packet) { | 3487 | if (packet) { |
@@ -3479,13 +3512,13 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | |||
3479 | * the reset of the packet. | 3512 | * the reset of the packet. |
3480 | */ | 3513 | */ |
3481 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 3514 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
3482 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3515 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3483 | 3516 | ||
3484 | /* We need to discard the rest of the packet to prevent | 3517 | /* We need to discard the rest of the packet to prevent |
3485 | * potential bomming attacks from additional bundled chunks. | 3518 | * potential bomming attacks from additional bundled chunks. |
3486 | * This is documented in SCTP Threats ID. | 3519 | * This is documented in SCTP Threats ID. |
3487 | */ | 3520 | */ |
3488 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3521 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3489 | } | 3522 | } |
3490 | 3523 | ||
3491 | return SCTP_DISPOSITION_NOMEM; | 3524 | return SCTP_DISPOSITION_NOMEM; |
@@ -3502,7 +3535,8 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | |||
3502 | * chunks. --piggy ] | 3535 | * chunks. --piggy ] |
3503 | * | 3536 | * |
3504 | */ | 3537 | */ |
3505 | sctp_disposition_t sctp_sf_do_8_5_1_E_sa(const struct sctp_endpoint *ep, | 3538 | sctp_disposition_t sctp_sf_do_8_5_1_E_sa(struct net *net, |
3539 | const struct sctp_endpoint *ep, | ||
3506 | const struct sctp_association *asoc, | 3540 | const struct sctp_association *asoc, |
3507 | const sctp_subtype_t type, | 3541 | const sctp_subtype_t type, |
3508 | void *arg, | 3542 | void *arg, |
@@ -3512,7 +3546,7 @@ sctp_disposition_t sctp_sf_do_8_5_1_E_sa(const struct sctp_endpoint *ep, | |||
3512 | 3546 | ||
3513 | /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ | 3547 | /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ |
3514 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 3548 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
3515 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3549 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3516 | commands); | 3550 | commands); |
3517 | 3551 | ||
3518 | /* Although we do have an association in this case, it corresponds | 3552 | /* Although we do have an association in this case, it corresponds |
@@ -3520,13 +3554,14 @@ sctp_disposition_t sctp_sf_do_8_5_1_E_sa(const struct sctp_endpoint *ep, | |||
3520 | * packet and the state function that handles OOTB SHUTDOWN_ACK is | 3554 | * packet and the state function that handles OOTB SHUTDOWN_ACK is |
3521 | * called with a NULL association. | 3555 | * called with a NULL association. |
3522 | */ | 3556 | */ |
3523 | SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_OUTOFBLUES); | 3557 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); |
3524 | 3558 | ||
3525 | return sctp_sf_shut_8_4_5(ep, NULL, type, arg, commands); | 3559 | return sctp_sf_shut_8_4_5(net, ep, NULL, type, arg, commands); |
3526 | } | 3560 | } |
3527 | 3561 | ||
3528 | /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. */ | 3562 | /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. */ |
3529 | sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | 3563 | sctp_disposition_t sctp_sf_do_asconf(struct net *net, |
3564 | const struct sctp_endpoint *ep, | ||
3530 | const struct sctp_association *asoc, | 3565 | const struct sctp_association *asoc, |
3531 | const sctp_subtype_t type, void *arg, | 3566 | const sctp_subtype_t type, void *arg, |
3532 | sctp_cmd_seq_t *commands) | 3567 | sctp_cmd_seq_t *commands) |
@@ -3542,7 +3577,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3542 | if (!sctp_vtag_verify(chunk, asoc)) { | 3577 | if (!sctp_vtag_verify(chunk, asoc)) { |
3543 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3578 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3544 | SCTP_NULL()); | 3579 | SCTP_NULL()); |
3545 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3580 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3546 | } | 3581 | } |
3547 | 3582 | ||
3548 | /* ADD-IP: Section 4.1.1 | 3583 | /* ADD-IP: Section 4.1.1 |
@@ -3552,11 +3587,11 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3552 | * described in [I-D.ietf-tsvwg-sctp-auth]. | 3587 | * described in [I-D.ietf-tsvwg-sctp-auth]. |
3553 | */ | 3588 | */ |
3554 | if (!sctp_addip_noauth && !chunk->auth) | 3589 | if (!sctp_addip_noauth && !chunk->auth) |
3555 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 3590 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
3556 | 3591 | ||
3557 | /* Make sure that the ASCONF ADDIP chunk has a valid length. */ | 3592 | /* Make sure that the ASCONF ADDIP chunk has a valid length. */ |
3558 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_addip_chunk_t))) | 3593 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_addip_chunk_t))) |
3559 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3594 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3560 | commands); | 3595 | commands); |
3561 | 3596 | ||
3562 | hdr = (sctp_addiphdr_t *)chunk->skb->data; | 3597 | hdr = (sctp_addiphdr_t *)chunk->skb->data; |
@@ -3565,7 +3600,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3565 | addr_param = (union sctp_addr_param *)hdr->params; | 3600 | addr_param = (union sctp_addr_param *)hdr->params; |
3566 | length = ntohs(addr_param->p.length); | 3601 | length = ntohs(addr_param->p.length); |
3567 | if (length < sizeof(sctp_paramhdr_t)) | 3602 | if (length < sizeof(sctp_paramhdr_t)) |
3568 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, | 3603 | return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, |
3569 | (void *)addr_param, commands); | 3604 | (void *)addr_param, commands); |
3570 | 3605 | ||
3571 | /* Verify the ASCONF chunk before processing it. */ | 3606 | /* Verify the ASCONF chunk before processing it. */ |
@@ -3573,7 +3608,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3573 | (sctp_paramhdr_t *)((void *)addr_param + length), | 3608 | (sctp_paramhdr_t *)((void *)addr_param + length), |
3574 | (void *)chunk->chunk_end, | 3609 | (void *)chunk->chunk_end, |
3575 | &err_param)) | 3610 | &err_param)) |
3576 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, | 3611 | return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, |
3577 | (void *)err_param, commands); | 3612 | (void *)err_param, commands); |
3578 | 3613 | ||
3579 | /* ADDIP 5.2 E1) Compare the value of the serial number to the value | 3614 | /* ADDIP 5.2 E1) Compare the value of the serial number to the value |
@@ -3653,7 +3688,8 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3653 | * When building TLV parameters for the ASCONF Chunk that will add or | 3688 | * When building TLV parameters for the ASCONF Chunk that will add or |
3654 | * delete IP addresses the D0 to D13 rules should be applied: | 3689 | * delete IP addresses the D0 to D13 rules should be applied: |
3655 | */ | 3690 | */ |
3656 | sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | 3691 | sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, |
3692 | const struct sctp_endpoint *ep, | ||
3657 | const struct sctp_association *asoc, | 3693 | const struct sctp_association *asoc, |
3658 | const sctp_subtype_t type, void *arg, | 3694 | const sctp_subtype_t type, void *arg, |
3659 | sctp_cmd_seq_t *commands) | 3695 | sctp_cmd_seq_t *commands) |
@@ -3668,7 +3704,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3668 | if (!sctp_vtag_verify(asconf_ack, asoc)) { | 3704 | if (!sctp_vtag_verify(asconf_ack, asoc)) { |
3669 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3705 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3670 | SCTP_NULL()); | 3706 | SCTP_NULL()); |
3671 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3707 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3672 | } | 3708 | } |
3673 | 3709 | ||
3674 | /* ADD-IP, Section 4.1.2: | 3710 | /* ADD-IP, Section 4.1.2: |
@@ -3678,11 +3714,11 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3678 | * described in [I-D.ietf-tsvwg-sctp-auth]. | 3714 | * described in [I-D.ietf-tsvwg-sctp-auth]. |
3679 | */ | 3715 | */ |
3680 | if (!sctp_addip_noauth && !asconf_ack->auth) | 3716 | if (!sctp_addip_noauth && !asconf_ack->auth) |
3681 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 3717 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
3682 | 3718 | ||
3683 | /* Make sure that the ADDIP chunk has a valid length. */ | 3719 | /* Make sure that the ADDIP chunk has a valid length. */ |
3684 | if (!sctp_chunk_length_valid(asconf_ack, sizeof(sctp_addip_chunk_t))) | 3720 | if (!sctp_chunk_length_valid(asconf_ack, sizeof(sctp_addip_chunk_t))) |
3685 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3721 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3686 | commands); | 3722 | commands); |
3687 | 3723 | ||
3688 | addip_hdr = (sctp_addiphdr_t *)asconf_ack->skb->data; | 3724 | addip_hdr = (sctp_addiphdr_t *)asconf_ack->skb->data; |
@@ -3693,7 +3729,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3693 | (sctp_paramhdr_t *)addip_hdr->params, | 3729 | (sctp_paramhdr_t *)addip_hdr->params, |
3694 | (void *)asconf_ack->chunk_end, | 3730 | (void *)asconf_ack->chunk_end, |
3695 | &err_param)) | 3731 | &err_param)) |
3696 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, | 3732 | return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, |
3697 | (void *)err_param, commands); | 3733 | (void *)err_param, commands); |
3698 | 3734 | ||
3699 | if (last_asconf) { | 3735 | if (last_asconf) { |
@@ -3711,7 +3747,6 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3711 | */ | 3747 | */ |
3712 | if (ADDIP_SERIAL_gte(rcvd_serial, sent_serial + 1) && | 3748 | if (ADDIP_SERIAL_gte(rcvd_serial, sent_serial + 1) && |
3713 | !(asoc->addip_last_asconf)) { | 3749 | !(asoc->addip_last_asconf)) { |
3714 | struct net *net; | ||
3715 | abort = sctp_make_abort(asoc, asconf_ack, | 3750 | abort = sctp_make_abort(asoc, asconf_ack, |
3716 | sizeof(sctp_errhdr_t)); | 3751 | sizeof(sctp_errhdr_t)); |
3717 | if (abort) { | 3752 | if (abort) { |
@@ -3729,14 +3764,12 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3729 | SCTP_ERROR(ECONNABORTED)); | 3764 | SCTP_ERROR(ECONNABORTED)); |
3730 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 3765 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
3731 | SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); | 3766 | SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); |
3732 | net = sock_net(asoc->base.sk); | ||
3733 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); | 3767 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
3734 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); | 3768 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
3735 | return SCTP_DISPOSITION_ABORT; | 3769 | return SCTP_DISPOSITION_ABORT; |
3736 | } | 3770 | } |
3737 | 3771 | ||
3738 | if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { | 3772 | if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { |
3739 | struct net *net; | ||
3740 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 3773 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
3741 | SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO)); | 3774 | SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO)); |
3742 | 3775 | ||
@@ -3765,7 +3798,6 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3765 | SCTP_ERROR(ECONNABORTED)); | 3798 | SCTP_ERROR(ECONNABORTED)); |
3766 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 3799 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
3767 | SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); | 3800 | SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); |
3768 | net = sock_net(asoc->base.sk); | ||
3769 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); | 3801 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
3770 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); | 3802 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
3771 | return SCTP_DISPOSITION_ABORT; | 3803 | return SCTP_DISPOSITION_ABORT; |
@@ -3788,7 +3820,8 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3788 | * | 3820 | * |
3789 | * The return value is the disposition of the chunk. | 3821 | * The return value is the disposition of the chunk. |
3790 | */ | 3822 | */ |
3791 | sctp_disposition_t sctp_sf_eat_fwd_tsn(const struct sctp_endpoint *ep, | 3823 | sctp_disposition_t sctp_sf_eat_fwd_tsn(struct net *net, |
3824 | const struct sctp_endpoint *ep, | ||
3792 | const struct sctp_association *asoc, | 3825 | const struct sctp_association *asoc, |
3793 | const sctp_subtype_t type, | 3826 | const sctp_subtype_t type, |
3794 | void *arg, | 3827 | void *arg, |
@@ -3803,12 +3836,12 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn(const struct sctp_endpoint *ep, | |||
3803 | if (!sctp_vtag_verify(chunk, asoc)) { | 3836 | if (!sctp_vtag_verify(chunk, asoc)) { |
3804 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3837 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3805 | SCTP_NULL()); | 3838 | SCTP_NULL()); |
3806 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3839 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3807 | } | 3840 | } |
3808 | 3841 | ||
3809 | /* Make sure that the FORWARD_TSN chunk has valid length. */ | 3842 | /* Make sure that the FORWARD_TSN chunk has valid length. */ |
3810 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_fwdtsn_chunk))) | 3843 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_fwdtsn_chunk))) |
3811 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3844 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3812 | commands); | 3845 | commands); |
3813 | 3846 | ||
3814 | fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; | 3847 | fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; |
@@ -3855,6 +3888,7 @@ discard_noforce: | |||
3855 | } | 3888 | } |
3856 | 3889 | ||
3857 | sctp_disposition_t sctp_sf_eat_fwd_tsn_fast( | 3890 | sctp_disposition_t sctp_sf_eat_fwd_tsn_fast( |
3891 | struct net *net, | ||
3858 | const struct sctp_endpoint *ep, | 3892 | const struct sctp_endpoint *ep, |
3859 | const struct sctp_association *asoc, | 3893 | const struct sctp_association *asoc, |
3860 | const sctp_subtype_t type, | 3894 | const sctp_subtype_t type, |
@@ -3870,12 +3904,12 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn_fast( | |||
3870 | if (!sctp_vtag_verify(chunk, asoc)) { | 3904 | if (!sctp_vtag_verify(chunk, asoc)) { |
3871 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3905 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3872 | SCTP_NULL()); | 3906 | SCTP_NULL()); |
3873 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3907 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3874 | } | 3908 | } |
3875 | 3909 | ||
3876 | /* Make sure that the FORWARD_TSN chunk has a valid length. */ | 3910 | /* Make sure that the FORWARD_TSN chunk has a valid length. */ |
3877 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_fwdtsn_chunk))) | 3911 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_fwdtsn_chunk))) |
3878 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3912 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3879 | commands); | 3913 | commands); |
3880 | 3914 | ||
3881 | fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; | 3915 | fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; |
@@ -3942,7 +3976,8 @@ gen_shutdown: | |||
3942 | * | 3976 | * |
3943 | * The return value is the disposition of the chunk. | 3977 | * The return value is the disposition of the chunk. |
3944 | */ | 3978 | */ |
3945 | static sctp_ierror_t sctp_sf_authenticate(const struct sctp_endpoint *ep, | 3979 | static sctp_ierror_t sctp_sf_authenticate(struct net *net, |
3980 | const struct sctp_endpoint *ep, | ||
3946 | const struct sctp_association *asoc, | 3981 | const struct sctp_association *asoc, |
3947 | const sctp_subtype_t type, | 3982 | const sctp_subtype_t type, |
3948 | struct sctp_chunk *chunk) | 3983 | struct sctp_chunk *chunk) |
@@ -4015,7 +4050,8 @@ nomem: | |||
4015 | return SCTP_IERROR_NOMEM; | 4050 | return SCTP_IERROR_NOMEM; |
4016 | } | 4051 | } |
4017 | 4052 | ||
4018 | sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, | 4053 | sctp_disposition_t sctp_sf_eat_auth(struct net *net, |
4054 | const struct sctp_endpoint *ep, | ||
4019 | const struct sctp_association *asoc, | 4055 | const struct sctp_association *asoc, |
4020 | const sctp_subtype_t type, | 4056 | const sctp_subtype_t type, |
4021 | void *arg, | 4057 | void *arg, |
@@ -4028,21 +4064,21 @@ sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, | |||
4028 | 4064 | ||
4029 | /* Make sure that the peer has AUTH capable */ | 4065 | /* Make sure that the peer has AUTH capable */ |
4030 | if (!asoc->peer.auth_capable) | 4066 | if (!asoc->peer.auth_capable) |
4031 | return sctp_sf_unk_chunk(ep, asoc, type, arg, commands); | 4067 | return sctp_sf_unk_chunk(net, ep, asoc, type, arg, commands); |
4032 | 4068 | ||
4033 | if (!sctp_vtag_verify(chunk, asoc)) { | 4069 | if (!sctp_vtag_verify(chunk, asoc)) { |
4034 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 4070 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
4035 | SCTP_NULL()); | 4071 | SCTP_NULL()); |
4036 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4072 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4037 | } | 4073 | } |
4038 | 4074 | ||
4039 | /* Make sure that the AUTH chunk has valid length. */ | 4075 | /* Make sure that the AUTH chunk has valid length. */ |
4040 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_auth_chunk))) | 4076 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_auth_chunk))) |
4041 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4077 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4042 | commands); | 4078 | commands); |
4043 | 4079 | ||
4044 | auth_hdr = (struct sctp_authhdr *)chunk->skb->data; | 4080 | auth_hdr = (struct sctp_authhdr *)chunk->skb->data; |
4045 | error = sctp_sf_authenticate(ep, asoc, type, chunk); | 4081 | error = sctp_sf_authenticate(net, ep, asoc, type, chunk); |
4046 | switch (error) { | 4082 | switch (error) { |
4047 | case SCTP_IERROR_AUTH_BAD_HMAC: | 4083 | case SCTP_IERROR_AUTH_BAD_HMAC: |
4048 | /* Generate the ERROR chunk and discard the rest | 4084 | /* Generate the ERROR chunk and discard the rest |
@@ -4059,10 +4095,10 @@ sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, | |||
4059 | /* Fall Through */ | 4095 | /* Fall Through */ |
4060 | case SCTP_IERROR_AUTH_BAD_KEYID: | 4096 | case SCTP_IERROR_AUTH_BAD_KEYID: |
4061 | case SCTP_IERROR_BAD_SIG: | 4097 | case SCTP_IERROR_BAD_SIG: |
4062 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4098 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4063 | 4099 | ||
4064 | case SCTP_IERROR_PROTO_VIOLATION: | 4100 | case SCTP_IERROR_PROTO_VIOLATION: |
4065 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4101 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4066 | commands); | 4102 | commands); |
4067 | 4103 | ||
4068 | case SCTP_IERROR_NOMEM: | 4104 | case SCTP_IERROR_NOMEM: |
@@ -4111,7 +4147,8 @@ sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, | |||
4111 | * | 4147 | * |
4112 | * The return value is the disposition of the chunk. | 4148 | * The return value is the disposition of the chunk. |
4113 | */ | 4149 | */ |
4114 | sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep, | 4150 | sctp_disposition_t sctp_sf_unk_chunk(struct net *net, |
4151 | const struct sctp_endpoint *ep, | ||
4115 | const struct sctp_association *asoc, | 4152 | const struct sctp_association *asoc, |
4116 | const sctp_subtype_t type, | 4153 | const sctp_subtype_t type, |
4117 | void *arg, | 4154 | void *arg, |
@@ -4124,20 +4161,20 @@ sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep, | |||
4124 | SCTP_DEBUG_PRINTK("Processing the unknown chunk id %d.\n", type.chunk); | 4161 | SCTP_DEBUG_PRINTK("Processing the unknown chunk id %d.\n", type.chunk); |
4125 | 4162 | ||
4126 | if (!sctp_vtag_verify(unk_chunk, asoc)) | 4163 | if (!sctp_vtag_verify(unk_chunk, asoc)) |
4127 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4164 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4128 | 4165 | ||
4129 | /* Make sure that the chunk has a valid length. | 4166 | /* Make sure that the chunk has a valid length. |
4130 | * Since we don't know the chunk type, we use a general | 4167 | * Since we don't know the chunk type, we use a general |
4131 | * chunkhdr structure to make a comparison. | 4168 | * chunkhdr structure to make a comparison. |
4132 | */ | 4169 | */ |
4133 | if (!sctp_chunk_length_valid(unk_chunk, sizeof(sctp_chunkhdr_t))) | 4170 | if (!sctp_chunk_length_valid(unk_chunk, sizeof(sctp_chunkhdr_t))) |
4134 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4171 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4135 | commands); | 4172 | commands); |
4136 | 4173 | ||
4137 | switch (type.chunk & SCTP_CID_ACTION_MASK) { | 4174 | switch (type.chunk & SCTP_CID_ACTION_MASK) { |
4138 | case SCTP_CID_ACTION_DISCARD: | 4175 | case SCTP_CID_ACTION_DISCARD: |
4139 | /* Discard the packet. */ | 4176 | /* Discard the packet. */ |
4140 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4177 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4141 | break; | 4178 | break; |
4142 | case SCTP_CID_ACTION_DISCARD_ERR: | 4179 | case SCTP_CID_ACTION_DISCARD_ERR: |
4143 | /* Generate an ERROR chunk as response. */ | 4180 | /* Generate an ERROR chunk as response. */ |
@@ -4152,7 +4189,7 @@ sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep, | |||
4152 | } | 4189 | } |
4153 | 4190 | ||
4154 | /* Discard the packet. */ | 4191 | /* Discard the packet. */ |
4155 | sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4192 | sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4156 | return SCTP_DISPOSITION_CONSUME; | 4193 | return SCTP_DISPOSITION_CONSUME; |
4157 | break; | 4194 | break; |
4158 | case SCTP_CID_ACTION_SKIP: | 4195 | case SCTP_CID_ACTION_SKIP: |
@@ -4194,7 +4231,8 @@ sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep, | |||
4194 | * | 4231 | * |
4195 | * The return value is the disposition of the chunk. | 4232 | * The return value is the disposition of the chunk. |
4196 | */ | 4233 | */ |
4197 | sctp_disposition_t sctp_sf_discard_chunk(const struct sctp_endpoint *ep, | 4234 | sctp_disposition_t sctp_sf_discard_chunk(struct net *net, |
4235 | const struct sctp_endpoint *ep, | ||
4198 | const struct sctp_association *asoc, | 4236 | const struct sctp_association *asoc, |
4199 | const sctp_subtype_t type, | 4237 | const sctp_subtype_t type, |
4200 | void *arg, | 4238 | void *arg, |
@@ -4207,7 +4245,7 @@ sctp_disposition_t sctp_sf_discard_chunk(const struct sctp_endpoint *ep, | |||
4207 | * chunkhdr structure to make a comparison. | 4245 | * chunkhdr structure to make a comparison. |
4208 | */ | 4246 | */ |
4209 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 4247 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
4210 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4248 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4211 | commands); | 4249 | commands); |
4212 | 4250 | ||
4213 | SCTP_DEBUG_PRINTK("Chunk %d is discarded\n", type.chunk); | 4251 | SCTP_DEBUG_PRINTK("Chunk %d is discarded\n", type.chunk); |
@@ -4232,13 +4270,14 @@ sctp_disposition_t sctp_sf_discard_chunk(const struct sctp_endpoint *ep, | |||
4232 | * | 4270 | * |
4233 | * The return value is the disposition of the chunk. | 4271 | * The return value is the disposition of the chunk. |
4234 | */ | 4272 | */ |
4235 | sctp_disposition_t sctp_sf_pdiscard(const struct sctp_endpoint *ep, | 4273 | sctp_disposition_t sctp_sf_pdiscard(struct net *net, |
4274 | const struct sctp_endpoint *ep, | ||
4236 | const struct sctp_association *asoc, | 4275 | const struct sctp_association *asoc, |
4237 | const sctp_subtype_t type, | 4276 | const sctp_subtype_t type, |
4238 | void *arg, | 4277 | void *arg, |
4239 | sctp_cmd_seq_t *commands) | 4278 | sctp_cmd_seq_t *commands) |
4240 | { | 4279 | { |
4241 | SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_IN_PKT_DISCARDS); | 4280 | SCTP_INC_STATS(net, SCTP_MIB_IN_PKT_DISCARDS); |
4242 | sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL()); | 4281 | sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL()); |
4243 | 4282 | ||
4244 | return SCTP_DISPOSITION_CONSUME; | 4283 | return SCTP_DISPOSITION_CONSUME; |
@@ -4259,7 +4298,8 @@ sctp_disposition_t sctp_sf_pdiscard(const struct sctp_endpoint *ep, | |||
4259 | * We simply tag the chunk as a violation. The state machine will log | 4298 | * We simply tag the chunk as a violation. The state machine will log |
4260 | * the violation and continue. | 4299 | * the violation and continue. |
4261 | */ | 4300 | */ |
4262 | sctp_disposition_t sctp_sf_violation(const struct sctp_endpoint *ep, | 4301 | sctp_disposition_t sctp_sf_violation(struct net *net, |
4302 | const struct sctp_endpoint *ep, | ||
4263 | const struct sctp_association *asoc, | 4303 | const struct sctp_association *asoc, |
4264 | const sctp_subtype_t type, | 4304 | const sctp_subtype_t type, |
4265 | void *arg, | 4305 | void *arg, |
@@ -4269,7 +4309,7 @@ sctp_disposition_t sctp_sf_violation(const struct sctp_endpoint *ep, | |||
4269 | 4309 | ||
4270 | /* Make sure that the chunk has a valid length. */ | 4310 | /* Make sure that the chunk has a valid length. */ |
4271 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 4311 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
4272 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4312 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4273 | commands); | 4313 | commands); |
4274 | 4314 | ||
4275 | return SCTP_DISPOSITION_VIOLATION; | 4315 | return SCTP_DISPOSITION_VIOLATION; |
@@ -4279,6 +4319,7 @@ sctp_disposition_t sctp_sf_violation(const struct sctp_endpoint *ep, | |||
4279 | * Common function to handle a protocol violation. | 4319 | * Common function to handle a protocol violation. |
4280 | */ | 4320 | */ |
4281 | static sctp_disposition_t sctp_sf_abort_violation( | 4321 | static sctp_disposition_t sctp_sf_abort_violation( |
4322 | struct net *net, | ||
4282 | const struct sctp_endpoint *ep, | 4323 | const struct sctp_endpoint *ep, |
4283 | const struct sctp_association *asoc, | 4324 | const struct sctp_association *asoc, |
4284 | void *arg, | 4325 | void *arg, |
@@ -4289,7 +4330,6 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4289 | struct sctp_packet *packet = NULL; | 4330 | struct sctp_packet *packet = NULL; |
4290 | struct sctp_chunk *chunk = arg; | 4331 | struct sctp_chunk *chunk = arg; |
4291 | struct sctp_chunk *abort = NULL; | 4332 | struct sctp_chunk *abort = NULL; |
4292 | struct net *net; | ||
4293 | 4333 | ||
4294 | /* SCTP-AUTH, Section 6.3: | 4334 | /* SCTP-AUTH, Section 6.3: |
4295 | * It should be noted that if the receiver wants to tear | 4335 | * It should be noted that if the receiver wants to tear |
@@ -4310,7 +4350,6 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4310 | if (!abort) | 4350 | if (!abort) |
4311 | goto nomem; | 4351 | goto nomem; |
4312 | 4352 | ||
4313 | net = sock_net(ep->base.sk); | ||
4314 | if (asoc) { | 4353 | if (asoc) { |
4315 | /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ | 4354 | /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ |
4316 | if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && | 4355 | if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && |
@@ -4369,7 +4408,7 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4369 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); | 4408 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
4370 | 4409 | ||
4371 | discard: | 4410 | discard: |
4372 | sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands); | 4411 | sctp_sf_pdiscard(net, ep, asoc, SCTP_ST_CHUNK(0), arg, commands); |
4373 | return SCTP_DISPOSITION_ABORT; | 4412 | return SCTP_DISPOSITION_ABORT; |
4374 | 4413 | ||
4375 | nomem_pkt: | 4414 | nomem_pkt: |
@@ -4398,6 +4437,7 @@ nomem: | |||
4398 | * Generate an ABORT chunk and terminate the association. | 4437 | * Generate an ABORT chunk and terminate the association. |
4399 | */ | 4438 | */ |
4400 | static sctp_disposition_t sctp_sf_violation_chunklen( | 4439 | static sctp_disposition_t sctp_sf_violation_chunklen( |
4440 | struct net *net, | ||
4401 | const struct sctp_endpoint *ep, | 4441 | const struct sctp_endpoint *ep, |
4402 | const struct sctp_association *asoc, | 4442 | const struct sctp_association *asoc, |
4403 | const sctp_subtype_t type, | 4443 | const sctp_subtype_t type, |
@@ -4406,7 +4446,7 @@ static sctp_disposition_t sctp_sf_violation_chunklen( | |||
4406 | { | 4446 | { |
4407 | static const char err_str[]="The following chunk had invalid length:"; | 4447 | static const char err_str[]="The following chunk had invalid length:"; |
4408 | 4448 | ||
4409 | return sctp_sf_abort_violation(ep, asoc, arg, commands, err_str, | 4449 | return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, |
4410 | sizeof(err_str)); | 4450 | sizeof(err_str)); |
4411 | } | 4451 | } |
4412 | 4452 | ||
@@ -4417,6 +4457,7 @@ static sctp_disposition_t sctp_sf_violation_chunklen( | |||
4417 | * the length is considered as invalid. | 4457 | * the length is considered as invalid. |
4418 | */ | 4458 | */ |
4419 | static sctp_disposition_t sctp_sf_violation_paramlen( | 4459 | static sctp_disposition_t sctp_sf_violation_paramlen( |
4460 | struct net *net, | ||
4420 | const struct sctp_endpoint *ep, | 4461 | const struct sctp_endpoint *ep, |
4421 | const struct sctp_association *asoc, | 4462 | const struct sctp_association *asoc, |
4422 | const sctp_subtype_t type, | 4463 | const sctp_subtype_t type, |
@@ -4426,7 +4467,6 @@ static sctp_disposition_t sctp_sf_violation_paramlen( | |||
4426 | struct sctp_chunk *chunk = arg; | 4467 | struct sctp_chunk *chunk = arg; |
4427 | struct sctp_paramhdr *param = ext; | 4468 | struct sctp_paramhdr *param = ext; |
4428 | struct sctp_chunk *abort = NULL; | 4469 | struct sctp_chunk *abort = NULL; |
4429 | struct net *net; | ||
4430 | 4470 | ||
4431 | if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) | 4471 | if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) |
4432 | goto discard; | 4472 | goto discard; |
@@ -4436,7 +4476,6 @@ static sctp_disposition_t sctp_sf_violation_paramlen( | |||
4436 | if (!abort) | 4476 | if (!abort) |
4437 | goto nomem; | 4477 | goto nomem; |
4438 | 4478 | ||
4439 | net = sock_net(asoc->base.sk); | ||
4440 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); | 4479 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); |
4441 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); | 4480 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
4442 | 4481 | ||
@@ -4448,7 +4487,7 @@ static sctp_disposition_t sctp_sf_violation_paramlen( | |||
4448 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); | 4487 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
4449 | 4488 | ||
4450 | discard: | 4489 | discard: |
4451 | sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands); | 4490 | sctp_sf_pdiscard(net, ep, asoc, SCTP_ST_CHUNK(0), arg, commands); |
4452 | return SCTP_DISPOSITION_ABORT; | 4491 | return SCTP_DISPOSITION_ABORT; |
4453 | nomem: | 4492 | nomem: |
4454 | return SCTP_DISPOSITION_NOMEM; | 4493 | return SCTP_DISPOSITION_NOMEM; |
@@ -4461,6 +4500,7 @@ nomem: | |||
4461 | * error code. | 4500 | * error code. |
4462 | */ | 4501 | */ |
4463 | static sctp_disposition_t sctp_sf_violation_ctsn( | 4502 | static sctp_disposition_t sctp_sf_violation_ctsn( |
4503 | struct net *net, | ||
4464 | const struct sctp_endpoint *ep, | 4504 | const struct sctp_endpoint *ep, |
4465 | const struct sctp_association *asoc, | 4505 | const struct sctp_association *asoc, |
4466 | const sctp_subtype_t type, | 4506 | const sctp_subtype_t type, |
@@ -4469,7 +4509,7 @@ static sctp_disposition_t sctp_sf_violation_ctsn( | |||
4469 | { | 4509 | { |
4470 | static const char err_str[]="The cumulative tsn ack beyond the max tsn currently sent:"; | 4510 | static const char err_str[]="The cumulative tsn ack beyond the max tsn currently sent:"; |
4471 | 4511 | ||
4472 | return sctp_sf_abort_violation(ep, asoc, arg, commands, err_str, | 4512 | return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, |
4473 | sizeof(err_str)); | 4513 | sizeof(err_str)); |
4474 | } | 4514 | } |
4475 | 4515 | ||
@@ -4480,6 +4520,7 @@ static sctp_disposition_t sctp_sf_violation_ctsn( | |||
4480 | * on the path and we may not want to continue this communication. | 4520 | * on the path and we may not want to continue this communication. |
4481 | */ | 4521 | */ |
4482 | static sctp_disposition_t sctp_sf_violation_chunk( | 4522 | static sctp_disposition_t sctp_sf_violation_chunk( |
4523 | struct net *net, | ||
4483 | const struct sctp_endpoint *ep, | 4524 | const struct sctp_endpoint *ep, |
4484 | const struct sctp_association *asoc, | 4525 | const struct sctp_association *asoc, |
4485 | const sctp_subtype_t type, | 4526 | const sctp_subtype_t type, |
@@ -4489,9 +4530,9 @@ static sctp_disposition_t sctp_sf_violation_chunk( | |||
4489 | static const char err_str[]="The following chunk violates protocol:"; | 4530 | static const char err_str[]="The following chunk violates protocol:"; |
4490 | 4531 | ||
4491 | if (!asoc) | 4532 | if (!asoc) |
4492 | return sctp_sf_violation(ep, asoc, type, arg, commands); | 4533 | return sctp_sf_violation(net, ep, asoc, type, arg, commands); |
4493 | 4534 | ||
4494 | return sctp_sf_abort_violation(ep, asoc, arg, commands, err_str, | 4535 | return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, |
4495 | sizeof(err_str)); | 4536 | sizeof(err_str)); |
4496 | } | 4537 | } |
4497 | /*************************************************************************** | 4538 | /*************************************************************************** |
@@ -4554,7 +4595,8 @@ static sctp_disposition_t sctp_sf_violation_chunk( | |||
4554 | * | 4595 | * |
4555 | * The return value is a disposition. | 4596 | * The return value is a disposition. |
4556 | */ | 4597 | */ |
4557 | sctp_disposition_t sctp_sf_do_prm_asoc(const struct sctp_endpoint *ep, | 4598 | sctp_disposition_t sctp_sf_do_prm_asoc(struct net *net, |
4599 | const struct sctp_endpoint *ep, | ||
4558 | const struct sctp_association *asoc, | 4600 | const struct sctp_association *asoc, |
4559 | const sctp_subtype_t type, | 4601 | const sctp_subtype_t type, |
4560 | void *arg, | 4602 | void *arg, |
@@ -4665,7 +4707,8 @@ nomem: | |||
4665 | * | 4707 | * |
4666 | * The return value is the disposition. | 4708 | * The return value is the disposition. |
4667 | */ | 4709 | */ |
4668 | sctp_disposition_t sctp_sf_do_prm_send(const struct sctp_endpoint *ep, | 4710 | sctp_disposition_t sctp_sf_do_prm_send(struct net *net, |
4711 | const struct sctp_endpoint *ep, | ||
4669 | const struct sctp_association *asoc, | 4712 | const struct sctp_association *asoc, |
4670 | const sctp_subtype_t type, | 4713 | const sctp_subtype_t type, |
4671 | void *arg, | 4714 | void *arg, |
@@ -4704,6 +4747,7 @@ sctp_disposition_t sctp_sf_do_prm_send(const struct sctp_endpoint *ep, | |||
4704 | * The return value is the disposition. | 4747 | * The return value is the disposition. |
4705 | */ | 4748 | */ |
4706 | sctp_disposition_t sctp_sf_do_9_2_prm_shutdown( | 4749 | sctp_disposition_t sctp_sf_do_9_2_prm_shutdown( |
4750 | struct net *net, | ||
4707 | const struct sctp_endpoint *ep, | 4751 | const struct sctp_endpoint *ep, |
4708 | const struct sctp_association *asoc, | 4752 | const struct sctp_association *asoc, |
4709 | const sctp_subtype_t type, | 4753 | const sctp_subtype_t type, |
@@ -4725,7 +4769,7 @@ sctp_disposition_t sctp_sf_do_9_2_prm_shutdown( | |||
4725 | 4769 | ||
4726 | disposition = SCTP_DISPOSITION_CONSUME; | 4770 | disposition = SCTP_DISPOSITION_CONSUME; |
4727 | if (sctp_outq_is_empty(&asoc->outqueue)) { | 4771 | if (sctp_outq_is_empty(&asoc->outqueue)) { |
4728 | disposition = sctp_sf_do_9_2_start_shutdown(ep, asoc, type, | 4772 | disposition = sctp_sf_do_9_2_start_shutdown(net, ep, asoc, type, |
4729 | arg, commands); | 4773 | arg, commands); |
4730 | } | 4774 | } |
4731 | return disposition; | 4775 | return disposition; |
@@ -4759,6 +4803,7 @@ sctp_disposition_t sctp_sf_do_9_2_prm_shutdown( | |||
4759 | * The return value is the disposition. | 4803 | * The return value is the disposition. |
4760 | */ | 4804 | */ |
4761 | sctp_disposition_t sctp_sf_do_9_1_prm_abort( | 4805 | sctp_disposition_t sctp_sf_do_9_1_prm_abort( |
4806 | struct net *net, | ||
4762 | const struct sctp_endpoint *ep, | 4807 | const struct sctp_endpoint *ep, |
4763 | const struct sctp_association *asoc, | 4808 | const struct sctp_association *asoc, |
4764 | const sctp_subtype_t type, | 4809 | const sctp_subtype_t type, |
@@ -4775,7 +4820,6 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort( | |||
4775 | */ | 4820 | */ |
4776 | struct sctp_chunk *abort = arg; | 4821 | struct sctp_chunk *abort = arg; |
4777 | sctp_disposition_t retval; | 4822 | sctp_disposition_t retval; |
4778 | struct net *net; | ||
4779 | 4823 | ||
4780 | retval = SCTP_DISPOSITION_CONSUME; | 4824 | retval = SCTP_DISPOSITION_CONSUME; |
4781 | 4825 | ||
@@ -4791,7 +4835,6 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort( | |||
4791 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 4835 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
4792 | SCTP_PERR(SCTP_ERROR_USER_ABORT)); | 4836 | SCTP_PERR(SCTP_ERROR_USER_ABORT)); |
4793 | 4837 | ||
4794 | net = sock_net(asoc->base.sk); | ||
4795 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); | 4838 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
4796 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); | 4839 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
4797 | 4840 | ||
@@ -4799,7 +4842,8 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort( | |||
4799 | } | 4842 | } |
4800 | 4843 | ||
4801 | /* We tried an illegal operation on an association which is closed. */ | 4844 | /* We tried an illegal operation on an association which is closed. */ |
4802 | sctp_disposition_t sctp_sf_error_closed(const struct sctp_endpoint *ep, | 4845 | sctp_disposition_t sctp_sf_error_closed(struct net *net, |
4846 | const struct sctp_endpoint *ep, | ||
4803 | const struct sctp_association *asoc, | 4847 | const struct sctp_association *asoc, |
4804 | const sctp_subtype_t type, | 4848 | const sctp_subtype_t type, |
4805 | void *arg, | 4849 | void *arg, |
@@ -4812,7 +4856,8 @@ sctp_disposition_t sctp_sf_error_closed(const struct sctp_endpoint *ep, | |||
4812 | /* We tried an illegal operation on an association which is shutting | 4856 | /* We tried an illegal operation on an association which is shutting |
4813 | * down. | 4857 | * down. |
4814 | */ | 4858 | */ |
4815 | sctp_disposition_t sctp_sf_error_shutdown(const struct sctp_endpoint *ep, | 4859 | sctp_disposition_t sctp_sf_error_shutdown(struct net *net, |
4860 | const struct sctp_endpoint *ep, | ||
4816 | const struct sctp_association *asoc, | 4861 | const struct sctp_association *asoc, |
4817 | const sctp_subtype_t type, | 4862 | const sctp_subtype_t type, |
4818 | void *arg, | 4863 | void *arg, |
@@ -4838,14 +4883,13 @@ sctp_disposition_t sctp_sf_error_shutdown(const struct sctp_endpoint *ep, | |||
4838 | * (timers) | 4883 | * (timers) |
4839 | */ | 4884 | */ |
4840 | sctp_disposition_t sctp_sf_cookie_wait_prm_shutdown( | 4885 | sctp_disposition_t sctp_sf_cookie_wait_prm_shutdown( |
4886 | struct net *net, | ||
4841 | const struct sctp_endpoint *ep, | 4887 | const struct sctp_endpoint *ep, |
4842 | const struct sctp_association *asoc, | 4888 | const struct sctp_association *asoc, |
4843 | const sctp_subtype_t type, | 4889 | const sctp_subtype_t type, |
4844 | void *arg, | 4890 | void *arg, |
4845 | sctp_cmd_seq_t *commands) | 4891 | sctp_cmd_seq_t *commands) |
4846 | { | 4892 | { |
4847 | struct net *net = sock_net(asoc->base.sk); | ||
4848 | |||
4849 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 4893 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
4850 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); | 4894 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); |
4851 | 4895 | ||
@@ -4874,6 +4918,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_shutdown( | |||
4874 | * (timers) | 4918 | * (timers) |
4875 | */ | 4919 | */ |
4876 | sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown( | 4920 | sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown( |
4921 | struct net *net, | ||
4877 | const struct sctp_endpoint *ep, | 4922 | const struct sctp_endpoint *ep, |
4878 | const struct sctp_association *asoc, | 4923 | const struct sctp_association *asoc, |
4879 | const sctp_subtype_t type, | 4924 | const sctp_subtype_t type, |
@@ -4882,7 +4927,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown( | |||
4882 | /* There is a single T1 timer, so we should be able to use | 4927 | /* There is a single T1 timer, so we should be able to use |
4883 | * common function with the COOKIE-WAIT state. | 4928 | * common function with the COOKIE-WAIT state. |
4884 | */ | 4929 | */ |
4885 | return sctp_sf_cookie_wait_prm_shutdown(ep, asoc, type, arg, commands); | 4930 | return sctp_sf_cookie_wait_prm_shutdown(net, ep, asoc, type, arg, commands); |
4886 | } | 4931 | } |
4887 | 4932 | ||
4888 | /* | 4933 | /* |
@@ -4900,6 +4945,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown( | |||
4900 | * (timers) | 4945 | * (timers) |
4901 | */ | 4946 | */ |
4902 | sctp_disposition_t sctp_sf_cookie_wait_prm_abort( | 4947 | sctp_disposition_t sctp_sf_cookie_wait_prm_abort( |
4948 | struct net *net, | ||
4903 | const struct sctp_endpoint *ep, | 4949 | const struct sctp_endpoint *ep, |
4904 | const struct sctp_association *asoc, | 4950 | const struct sctp_association *asoc, |
4905 | const sctp_subtype_t type, | 4951 | const sctp_subtype_t type, |
@@ -4908,7 +4954,6 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort( | |||
4908 | { | 4954 | { |
4909 | struct sctp_chunk *abort = arg; | 4955 | struct sctp_chunk *abort = arg; |
4910 | sctp_disposition_t retval; | 4956 | sctp_disposition_t retval; |
4911 | struct net *net = sock_net(asoc->base.sk); | ||
4912 | 4957 | ||
4913 | /* Stop T1-init timer */ | 4958 | /* Stop T1-init timer */ |
4914 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 4959 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
@@ -4950,6 +4995,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort( | |||
4950 | * (timers) | 4995 | * (timers) |
4951 | */ | 4996 | */ |
4952 | sctp_disposition_t sctp_sf_cookie_echoed_prm_abort( | 4997 | sctp_disposition_t sctp_sf_cookie_echoed_prm_abort( |
4998 | struct net *net, | ||
4953 | const struct sctp_endpoint *ep, | 4999 | const struct sctp_endpoint *ep, |
4954 | const struct sctp_association *asoc, | 5000 | const struct sctp_association *asoc, |
4955 | const sctp_subtype_t type, | 5001 | const sctp_subtype_t type, |
@@ -4959,7 +5005,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_prm_abort( | |||
4959 | /* There is a single T1 timer, so we should be able to use | 5005 | /* There is a single T1 timer, so we should be able to use |
4960 | * common function with the COOKIE-WAIT state. | 5006 | * common function with the COOKIE-WAIT state. |
4961 | */ | 5007 | */ |
4962 | return sctp_sf_cookie_wait_prm_abort(ep, asoc, type, arg, commands); | 5008 | return sctp_sf_cookie_wait_prm_abort(net, ep, asoc, type, arg, commands); |
4963 | } | 5009 | } |
4964 | 5010 | ||
4965 | /* | 5011 | /* |
@@ -4975,6 +5021,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_prm_abort( | |||
4975 | * (timers) | 5021 | * (timers) |
4976 | */ | 5022 | */ |
4977 | sctp_disposition_t sctp_sf_shutdown_pending_prm_abort( | 5023 | sctp_disposition_t sctp_sf_shutdown_pending_prm_abort( |
5024 | struct net *net, | ||
4978 | const struct sctp_endpoint *ep, | 5025 | const struct sctp_endpoint *ep, |
4979 | const struct sctp_association *asoc, | 5026 | const struct sctp_association *asoc, |
4980 | const sctp_subtype_t type, | 5027 | const sctp_subtype_t type, |
@@ -4985,7 +5032,7 @@ sctp_disposition_t sctp_sf_shutdown_pending_prm_abort( | |||
4985 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 5032 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
4986 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); | 5033 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); |
4987 | 5034 | ||
4988 | return sctp_sf_do_9_1_prm_abort(ep, asoc, type, arg, commands); | 5035 | return sctp_sf_do_9_1_prm_abort(net, ep, asoc, type, arg, commands); |
4989 | } | 5036 | } |
4990 | 5037 | ||
4991 | /* | 5038 | /* |
@@ -5001,6 +5048,7 @@ sctp_disposition_t sctp_sf_shutdown_pending_prm_abort( | |||
5001 | * (timers) | 5048 | * (timers) |
5002 | */ | 5049 | */ |
5003 | sctp_disposition_t sctp_sf_shutdown_sent_prm_abort( | 5050 | sctp_disposition_t sctp_sf_shutdown_sent_prm_abort( |
5051 | struct net *net, | ||
5004 | const struct sctp_endpoint *ep, | 5052 | const struct sctp_endpoint *ep, |
5005 | const struct sctp_association *asoc, | 5053 | const struct sctp_association *asoc, |
5006 | const sctp_subtype_t type, | 5054 | const sctp_subtype_t type, |
@@ -5015,7 +5063,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_prm_abort( | |||
5015 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 5063 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
5016 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); | 5064 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); |
5017 | 5065 | ||
5018 | return sctp_sf_do_9_1_prm_abort(ep, asoc, type, arg, commands); | 5066 | return sctp_sf_do_9_1_prm_abort(net, ep, asoc, type, arg, commands); |
5019 | } | 5067 | } |
5020 | 5068 | ||
5021 | /* | 5069 | /* |
@@ -5031,6 +5079,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_prm_abort( | |||
5031 | * (timers) | 5079 | * (timers) |
5032 | */ | 5080 | */ |
5033 | sctp_disposition_t sctp_sf_shutdown_ack_sent_prm_abort( | 5081 | sctp_disposition_t sctp_sf_shutdown_ack_sent_prm_abort( |
5082 | struct net *net, | ||
5034 | const struct sctp_endpoint *ep, | 5083 | const struct sctp_endpoint *ep, |
5035 | const struct sctp_association *asoc, | 5084 | const struct sctp_association *asoc, |
5036 | const sctp_subtype_t type, | 5085 | const sctp_subtype_t type, |
@@ -5040,7 +5089,7 @@ sctp_disposition_t sctp_sf_shutdown_ack_sent_prm_abort( | |||
5040 | /* The same T2 timer, so we should be able to use | 5089 | /* The same T2 timer, so we should be able to use |
5041 | * common function with the SHUTDOWN-SENT state. | 5090 | * common function with the SHUTDOWN-SENT state. |
5042 | */ | 5091 | */ |
5043 | return sctp_sf_shutdown_sent_prm_abort(ep, asoc, type, arg, commands); | 5092 | return sctp_sf_shutdown_sent_prm_abort(net, ep, asoc, type, arg, commands); |
5044 | } | 5093 | } |
5045 | 5094 | ||
5046 | /* | 5095 | /* |
@@ -5066,6 +5115,7 @@ sctp_disposition_t sctp_sf_shutdown_ack_sent_prm_abort( | |||
5066 | * association on which a heartbeat should be issued. | 5115 | * association on which a heartbeat should be issued. |
5067 | */ | 5116 | */ |
5068 | sctp_disposition_t sctp_sf_do_prm_requestheartbeat( | 5117 | sctp_disposition_t sctp_sf_do_prm_requestheartbeat( |
5118 | struct net *net, | ||
5069 | const struct sctp_endpoint *ep, | 5119 | const struct sctp_endpoint *ep, |
5070 | const struct sctp_association *asoc, | 5120 | const struct sctp_association *asoc, |
5071 | const sctp_subtype_t type, | 5121 | const sctp_subtype_t type, |
@@ -5097,7 +5147,8 @@ sctp_disposition_t sctp_sf_do_prm_requestheartbeat( | |||
5097 | * When an endpoint has an ASCONF signaled change to be sent to the | 5147 | * When an endpoint has an ASCONF signaled change to be sent to the |
5098 | * remote endpoint it should do A1 to A9 | 5148 | * remote endpoint it should do A1 to A9 |
5099 | */ | 5149 | */ |
5100 | sctp_disposition_t sctp_sf_do_prm_asconf(const struct sctp_endpoint *ep, | 5150 | sctp_disposition_t sctp_sf_do_prm_asconf(struct net *net, |
5151 | const struct sctp_endpoint *ep, | ||
5101 | const struct sctp_association *asoc, | 5152 | const struct sctp_association *asoc, |
5102 | const sctp_subtype_t type, | 5153 | const sctp_subtype_t type, |
5103 | void *arg, | 5154 | void *arg, |
@@ -5118,6 +5169,7 @@ sctp_disposition_t sctp_sf_do_prm_asconf(const struct sctp_endpoint *ep, | |||
5118 | * The return value is the disposition of the primitive. | 5169 | * The return value is the disposition of the primitive. |
5119 | */ | 5170 | */ |
5120 | sctp_disposition_t sctp_sf_ignore_primitive( | 5171 | sctp_disposition_t sctp_sf_ignore_primitive( |
5172 | struct net *net, | ||
5121 | const struct sctp_endpoint *ep, | 5173 | const struct sctp_endpoint *ep, |
5122 | const struct sctp_association *asoc, | 5174 | const struct sctp_association *asoc, |
5123 | const sctp_subtype_t type, | 5175 | const sctp_subtype_t type, |
@@ -5139,6 +5191,7 @@ sctp_disposition_t sctp_sf_ignore_primitive( | |||
5139 | * retransmit, the stack will immediately send up this notification. | 5191 | * retransmit, the stack will immediately send up this notification. |
5140 | */ | 5192 | */ |
5141 | sctp_disposition_t sctp_sf_do_no_pending_tsn( | 5193 | sctp_disposition_t sctp_sf_do_no_pending_tsn( |
5194 | struct net *net, | ||
5142 | const struct sctp_endpoint *ep, | 5195 | const struct sctp_endpoint *ep, |
5143 | const struct sctp_association *asoc, | 5196 | const struct sctp_association *asoc, |
5144 | const sctp_subtype_t type, | 5197 | const sctp_subtype_t type, |
@@ -5170,6 +5223,7 @@ sctp_disposition_t sctp_sf_do_no_pending_tsn( | |||
5170 | * The return value is the disposition. | 5223 | * The return value is the disposition. |
5171 | */ | 5224 | */ |
5172 | sctp_disposition_t sctp_sf_do_9_2_start_shutdown( | 5225 | sctp_disposition_t sctp_sf_do_9_2_start_shutdown( |
5226 | struct net *net, | ||
5173 | const struct sctp_endpoint *ep, | 5227 | const struct sctp_endpoint *ep, |
5174 | const struct sctp_association *asoc, | 5228 | const struct sctp_association *asoc, |
5175 | const sctp_subtype_t type, | 5229 | const sctp_subtype_t type, |
@@ -5239,6 +5293,7 @@ nomem: | |||
5239 | * The return value is the disposition. | 5293 | * The return value is the disposition. |
5240 | */ | 5294 | */ |
5241 | sctp_disposition_t sctp_sf_do_9_2_shutdown_ack( | 5295 | sctp_disposition_t sctp_sf_do_9_2_shutdown_ack( |
5296 | struct net *net, | ||
5242 | const struct sctp_endpoint *ep, | 5297 | const struct sctp_endpoint *ep, |
5243 | const struct sctp_association *asoc, | 5298 | const struct sctp_association *asoc, |
5244 | const sctp_subtype_t type, | 5299 | const sctp_subtype_t type, |
@@ -5257,11 +5312,11 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown_ack( | |||
5257 | */ | 5312 | */ |
5258 | if (chunk) { | 5313 | if (chunk) { |
5259 | if (!sctp_vtag_verify(chunk, asoc)) | 5314 | if (!sctp_vtag_verify(chunk, asoc)) |
5260 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 5315 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
5261 | 5316 | ||
5262 | /* Make sure that the SHUTDOWN chunk has a valid length. */ | 5317 | /* Make sure that the SHUTDOWN chunk has a valid length. */ |
5263 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk_t))) | 5318 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk_t))) |
5264 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 5319 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
5265 | commands); | 5320 | commands); |
5266 | } | 5321 | } |
5267 | 5322 | ||
@@ -5309,7 +5364,8 @@ nomem: | |||
5309 | * | 5364 | * |
5310 | * The return value is the disposition of the event. | 5365 | * The return value is the disposition of the event. |
5311 | */ | 5366 | */ |
5312 | sctp_disposition_t sctp_sf_ignore_other(const struct sctp_endpoint *ep, | 5367 | sctp_disposition_t sctp_sf_ignore_other(struct net *net, |
5368 | const struct sctp_endpoint *ep, | ||
5313 | const struct sctp_association *asoc, | 5369 | const struct sctp_association *asoc, |
5314 | const sctp_subtype_t type, | 5370 | const sctp_subtype_t type, |
5315 | void *arg, | 5371 | void *arg, |
@@ -5334,14 +5390,14 @@ sctp_disposition_t sctp_sf_ignore_other(const struct sctp_endpoint *ep, | |||
5334 | * | 5390 | * |
5335 | * The return value is the disposition of the chunk. | 5391 | * The return value is the disposition of the chunk. |
5336 | */ | 5392 | */ |
5337 | sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep, | 5393 | sctp_disposition_t sctp_sf_do_6_3_3_rtx(struct net *net, |
5394 | const struct sctp_endpoint *ep, | ||
5338 | const struct sctp_association *asoc, | 5395 | const struct sctp_association *asoc, |
5339 | const sctp_subtype_t type, | 5396 | const sctp_subtype_t type, |
5340 | void *arg, | 5397 | void *arg, |
5341 | sctp_cmd_seq_t *commands) | 5398 | sctp_cmd_seq_t *commands) |
5342 | { | 5399 | { |
5343 | struct sctp_transport *transport = arg; | 5400 | struct sctp_transport *transport = arg; |
5344 | struct net *net = sock_net(asoc->base.sk); | ||
5345 | 5401 | ||
5346 | SCTP_INC_STATS(net, SCTP_MIB_T3_RTX_EXPIREDS); | 5402 | SCTP_INC_STATS(net, SCTP_MIB_T3_RTX_EXPIREDS); |
5347 | 5403 | ||
@@ -5421,13 +5477,13 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep, | |||
5421 | * allow. However, an SCTP transmitter MUST NOT be more aggressive than | 5477 | * allow. However, an SCTP transmitter MUST NOT be more aggressive than |
5422 | * the following algorithms allow. | 5478 | * the following algorithms allow. |
5423 | */ | 5479 | */ |
5424 | sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep, | 5480 | sctp_disposition_t sctp_sf_do_6_2_sack(struct net *net, |
5481 | const struct sctp_endpoint *ep, | ||
5425 | const struct sctp_association *asoc, | 5482 | const struct sctp_association *asoc, |
5426 | const sctp_subtype_t type, | 5483 | const sctp_subtype_t type, |
5427 | void *arg, | 5484 | void *arg, |
5428 | sctp_cmd_seq_t *commands) | 5485 | sctp_cmd_seq_t *commands) |
5429 | { | 5486 | { |
5430 | struct net *net = sock_net(asoc->base.sk); | ||
5431 | SCTP_INC_STATS(net, SCTP_MIB_DELAY_SACK_EXPIREDS); | 5487 | SCTP_INC_STATS(net, SCTP_MIB_DELAY_SACK_EXPIREDS); |
5432 | sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_FORCE()); | 5488 | sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_FORCE()); |
5433 | return SCTP_DISPOSITION_CONSUME; | 5489 | return SCTP_DISPOSITION_CONSUME; |
@@ -5452,7 +5508,8 @@ sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep, | |||
5452 | * (timers, events) | 5508 | * (timers, events) |
5453 | * | 5509 | * |
5454 | */ | 5510 | */ |
5455 | sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep, | 5511 | sctp_disposition_t sctp_sf_t1_init_timer_expire(struct net *net, |
5512 | const struct sctp_endpoint *ep, | ||
5456 | const struct sctp_association *asoc, | 5513 | const struct sctp_association *asoc, |
5457 | const sctp_subtype_t type, | 5514 | const sctp_subtype_t type, |
5458 | void *arg, | 5515 | void *arg, |
@@ -5461,7 +5518,6 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep, | |||
5461 | struct sctp_chunk *repl = NULL; | 5518 | struct sctp_chunk *repl = NULL; |
5462 | struct sctp_bind_addr *bp; | 5519 | struct sctp_bind_addr *bp; |
5463 | int attempts = asoc->init_err_counter + 1; | 5520 | int attempts = asoc->init_err_counter + 1; |
5464 | struct net *net = sock_net(asoc->base.sk); | ||
5465 | 5521 | ||
5466 | SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n"); | 5522 | SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n"); |
5467 | SCTP_INC_STATS(net, SCTP_MIB_T1_INIT_EXPIREDS); | 5523 | SCTP_INC_STATS(net, SCTP_MIB_T1_INIT_EXPIREDS); |
@@ -5514,7 +5570,8 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep, | |||
5514 | * (timers, events) | 5570 | * (timers, events) |
5515 | * | 5571 | * |
5516 | */ | 5572 | */ |
5517 | sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep, | 5573 | sctp_disposition_t sctp_sf_t1_cookie_timer_expire(struct net *net, |
5574 | const struct sctp_endpoint *ep, | ||
5518 | const struct sctp_association *asoc, | 5575 | const struct sctp_association *asoc, |
5519 | const sctp_subtype_t type, | 5576 | const sctp_subtype_t type, |
5520 | void *arg, | 5577 | void *arg, |
@@ -5522,7 +5579,6 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep | |||
5522 | { | 5579 | { |
5523 | struct sctp_chunk *repl = NULL; | 5580 | struct sctp_chunk *repl = NULL; |
5524 | int attempts = asoc->init_err_counter + 1; | 5581 | int attempts = asoc->init_err_counter + 1; |
5525 | struct net *net = sock_net(asoc->base.sk); | ||
5526 | 5582 | ||
5527 | SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n"); | 5583 | SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n"); |
5528 | SCTP_INC_STATS(net, SCTP_MIB_T1_COOKIE_EXPIREDS); | 5584 | SCTP_INC_STATS(net, SCTP_MIB_T1_COOKIE_EXPIREDS); |
@@ -5563,14 +5619,14 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep | |||
5563 | * the T2-Shutdown timer, giving its peer ample opportunity to transmit | 5619 | * the T2-Shutdown timer, giving its peer ample opportunity to transmit |
5564 | * all of its queued DATA chunks that have not yet been sent. | 5620 | * all of its queued DATA chunks that have not yet been sent. |
5565 | */ | 5621 | */ |
5566 | sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep, | 5622 | sctp_disposition_t sctp_sf_t2_timer_expire(struct net *net, |
5623 | const struct sctp_endpoint *ep, | ||
5567 | const struct sctp_association *asoc, | 5624 | const struct sctp_association *asoc, |
5568 | const sctp_subtype_t type, | 5625 | const sctp_subtype_t type, |
5569 | void *arg, | 5626 | void *arg, |
5570 | sctp_cmd_seq_t *commands) | 5627 | sctp_cmd_seq_t *commands) |
5571 | { | 5628 | { |
5572 | struct sctp_chunk *reply = NULL; | 5629 | struct sctp_chunk *reply = NULL; |
5573 | struct net *net = sock_net(asoc->base.sk); | ||
5574 | 5630 | ||
5575 | SCTP_DEBUG_PRINTK("Timer T2 expired.\n"); | 5631 | SCTP_DEBUG_PRINTK("Timer T2 expired.\n"); |
5576 | SCTP_INC_STATS(net, SCTP_MIB_T2_SHUTDOWN_EXPIREDS); | 5632 | SCTP_INC_STATS(net, SCTP_MIB_T2_SHUTDOWN_EXPIREDS); |
@@ -5633,6 +5689,7 @@ nomem: | |||
5633 | * If the T4 RTO timer expires the endpoint should do B1 to B5 | 5689 | * If the T4 RTO timer expires the endpoint should do B1 to B5 |
5634 | */ | 5690 | */ |
5635 | sctp_disposition_t sctp_sf_t4_timer_expire( | 5691 | sctp_disposition_t sctp_sf_t4_timer_expire( |
5692 | struct net *net, | ||
5636 | const struct sctp_endpoint *ep, | 5693 | const struct sctp_endpoint *ep, |
5637 | const struct sctp_association *asoc, | 5694 | const struct sctp_association *asoc, |
5638 | const sctp_subtype_t type, | 5695 | const sctp_subtype_t type, |
@@ -5641,7 +5698,6 @@ sctp_disposition_t sctp_sf_t4_timer_expire( | |||
5641 | { | 5698 | { |
5642 | struct sctp_chunk *chunk = asoc->addip_last_asconf; | 5699 | struct sctp_chunk *chunk = asoc->addip_last_asconf; |
5643 | struct sctp_transport *transport = chunk->transport; | 5700 | struct sctp_transport *transport = chunk->transport; |
5644 | struct net *net = sock_net(asoc->base.sk); | ||
5645 | 5701 | ||
5646 | SCTP_INC_STATS(net, SCTP_MIB_T4_RTO_EXPIREDS); | 5702 | SCTP_INC_STATS(net, SCTP_MIB_T4_RTO_EXPIREDS); |
5647 | 5703 | ||
@@ -5704,14 +5760,14 @@ sctp_disposition_t sctp_sf_t4_timer_expire( | |||
5704 | * At the expiration of this timer the sender SHOULD abort the association | 5760 | * At the expiration of this timer the sender SHOULD abort the association |
5705 | * by sending an ABORT chunk. | 5761 | * by sending an ABORT chunk. |
5706 | */ | 5762 | */ |
5707 | sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep, | 5763 | sctp_disposition_t sctp_sf_t5_timer_expire(struct net *net, |
5764 | const struct sctp_endpoint *ep, | ||
5708 | const struct sctp_association *asoc, | 5765 | const struct sctp_association *asoc, |
5709 | const sctp_subtype_t type, | 5766 | const sctp_subtype_t type, |
5710 | void *arg, | 5767 | void *arg, |
5711 | sctp_cmd_seq_t *commands) | 5768 | sctp_cmd_seq_t *commands) |
5712 | { | 5769 | { |
5713 | struct sctp_chunk *reply = NULL; | 5770 | struct sctp_chunk *reply = NULL; |
5714 | struct net *net = sock_net(asoc->base.sk); | ||
5715 | 5771 | ||
5716 | SCTP_DEBUG_PRINTK("Timer T5 expired.\n"); | 5772 | SCTP_DEBUG_PRINTK("Timer T5 expired.\n"); |
5717 | SCTP_INC_STATS(net, SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS); | 5773 | SCTP_INC_STATS(net, SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS); |
@@ -5740,13 +5796,13 @@ nomem: | |||
5740 | * the user. So this routine looks same as sctp_sf_do_9_2_prm_shutdown(). | 5796 | * the user. So this routine looks same as sctp_sf_do_9_2_prm_shutdown(). |
5741 | */ | 5797 | */ |
5742 | sctp_disposition_t sctp_sf_autoclose_timer_expire( | 5798 | sctp_disposition_t sctp_sf_autoclose_timer_expire( |
5799 | struct net *net, | ||
5743 | const struct sctp_endpoint *ep, | 5800 | const struct sctp_endpoint *ep, |
5744 | const struct sctp_association *asoc, | 5801 | const struct sctp_association *asoc, |
5745 | const sctp_subtype_t type, | 5802 | const sctp_subtype_t type, |
5746 | void *arg, | 5803 | void *arg, |
5747 | sctp_cmd_seq_t *commands) | 5804 | sctp_cmd_seq_t *commands) |
5748 | { | 5805 | { |
5749 | struct net *net = sock_net(asoc->base.sk); | ||
5750 | int disposition; | 5806 | int disposition; |
5751 | 5807 | ||
5752 | SCTP_INC_STATS(net, SCTP_MIB_AUTOCLOSE_EXPIREDS); | 5808 | SCTP_INC_STATS(net, SCTP_MIB_AUTOCLOSE_EXPIREDS); |
@@ -5764,7 +5820,7 @@ sctp_disposition_t sctp_sf_autoclose_timer_expire( | |||
5764 | 5820 | ||
5765 | disposition = SCTP_DISPOSITION_CONSUME; | 5821 | disposition = SCTP_DISPOSITION_CONSUME; |
5766 | if (sctp_outq_is_empty(&asoc->outqueue)) { | 5822 | if (sctp_outq_is_empty(&asoc->outqueue)) { |
5767 | disposition = sctp_sf_do_9_2_start_shutdown(ep, asoc, type, | 5823 | disposition = sctp_sf_do_9_2_start_shutdown(net, ep, asoc, type, |
5768 | arg, commands); | 5824 | arg, commands); |
5769 | } | 5825 | } |
5770 | return disposition; | 5826 | return disposition; |
@@ -5782,7 +5838,8 @@ sctp_disposition_t sctp_sf_autoclose_timer_expire( | |||
5782 | * | 5838 | * |
5783 | * The return value is the disposition of the chunk. | 5839 | * The return value is the disposition of the chunk. |
5784 | */ | 5840 | */ |
5785 | sctp_disposition_t sctp_sf_not_impl(const struct sctp_endpoint *ep, | 5841 | sctp_disposition_t sctp_sf_not_impl(struct net *net, |
5842 | const struct sctp_endpoint *ep, | ||
5786 | const struct sctp_association *asoc, | 5843 | const struct sctp_association *asoc, |
5787 | const sctp_subtype_t type, | 5844 | const sctp_subtype_t type, |
5788 | void *arg, | 5845 | void *arg, |
@@ -5799,7 +5856,8 @@ sctp_disposition_t sctp_sf_not_impl(const struct sctp_endpoint *ep, | |||
5799 | * | 5856 | * |
5800 | * The return value is the disposition of the chunk. | 5857 | * The return value is the disposition of the chunk. |
5801 | */ | 5858 | */ |
5802 | sctp_disposition_t sctp_sf_bug(const struct sctp_endpoint *ep, | 5859 | sctp_disposition_t sctp_sf_bug(struct net *net, |
5860 | const struct sctp_endpoint *ep, | ||
5803 | const struct sctp_association *asoc, | 5861 | const struct sctp_association *asoc, |
5804 | const sctp_subtype_t type, | 5862 | const sctp_subtype_t type, |
5805 | void *arg, | 5863 | void *arg, |
@@ -5819,7 +5877,8 @@ sctp_disposition_t sctp_sf_bug(const struct sctp_endpoint *ep, | |||
5819 | * | 5877 | * |
5820 | * The return value is the disposition of the chunk. | 5878 | * The return value is the disposition of the chunk. |
5821 | */ | 5879 | */ |
5822 | sctp_disposition_t sctp_sf_timer_ignore(const struct sctp_endpoint *ep, | 5880 | sctp_disposition_t sctp_sf_timer_ignore(struct net *net, |
5881 | const struct sctp_endpoint *ep, | ||
5823 | const struct sctp_association *asoc, | 5882 | const struct sctp_association *asoc, |
5824 | const sctp_subtype_t type, | 5883 | const sctp_subtype_t type, |
5825 | void *arg, | 5884 | void *arg, |
@@ -5861,7 +5920,8 @@ static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk) | |||
5861 | /* Create an ABORT packet to be sent as a response, with the specified | 5920 | /* Create an ABORT packet to be sent as a response, with the specified |
5862 | * error causes. | 5921 | * error causes. |
5863 | */ | 5922 | */ |
5864 | static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | 5923 | static struct sctp_packet *sctp_abort_pkt_new(struct net *net, |
5924 | const struct sctp_endpoint *ep, | ||
5865 | const struct sctp_association *asoc, | 5925 | const struct sctp_association *asoc, |
5866 | struct sctp_chunk *chunk, | 5926 | struct sctp_chunk *chunk, |
5867 | const void *payload, | 5927 | const void *payload, |
@@ -5869,9 +5929,7 @@ static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | |||
5869 | { | 5929 | { |
5870 | struct sctp_packet *packet; | 5930 | struct sctp_packet *packet; |
5871 | struct sctp_chunk *abort; | 5931 | struct sctp_chunk *abort; |
5872 | struct net *net; | ||
5873 | 5932 | ||
5874 | net = sock_net(ep->base.sk); | ||
5875 | packet = sctp_ootb_pkt_new(net, asoc, chunk); | 5933 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
5876 | 5934 | ||
5877 | if (packet) { | 5935 | if (packet) { |
@@ -5984,7 +6042,8 @@ void sctp_ootb_pkt_free(struct sctp_packet *packet) | |||
5984 | } | 6042 | } |
5985 | 6043 | ||
5986 | /* Send a stale cookie error when a invalid COOKIE ECHO chunk is found */ | 6044 | /* Send a stale cookie error when a invalid COOKIE ECHO chunk is found */ |
5987 | static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | 6045 | static void sctp_send_stale_cookie_err(struct net *net, |
6046 | const struct sctp_endpoint *ep, | ||
5988 | const struct sctp_association *asoc, | 6047 | const struct sctp_association *asoc, |
5989 | const struct sctp_chunk *chunk, | 6048 | const struct sctp_chunk *chunk, |
5990 | sctp_cmd_seq_t *commands, | 6049 | sctp_cmd_seq_t *commands, |
@@ -5993,7 +6052,6 @@ static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | |||
5993 | struct sctp_packet *packet; | 6052 | struct sctp_packet *packet; |
5994 | 6053 | ||
5995 | if (err_chunk) { | 6054 | if (err_chunk) { |
5996 | struct net *net = sock_net(ep->base.sk); | ||
5997 | packet = sctp_ootb_pkt_new(net, asoc, chunk); | 6055 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
5998 | if (packet) { | 6056 | if (packet) { |
5999 | struct sctp_signed_cookie *cookie; | 6057 | struct sctp_signed_cookie *cookie; |
@@ -6027,7 +6085,7 @@ static int sctp_eat_data(const struct sctp_association *asoc, | |||
6027 | __u32 tsn; | 6085 | __u32 tsn; |
6028 | struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; | 6086 | struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; |
6029 | struct sock *sk = asoc->base.sk; | 6087 | struct sock *sk = asoc->base.sk; |
6030 | struct net *net; | 6088 | struct net *net = sock_net(sk); |
6031 | u16 ssn; | 6089 | u16 ssn; |
6032 | u16 sid; | 6090 | u16 sid; |
6033 | u8 ordered = 0; | 6091 | u8 ordered = 0; |
@@ -6144,7 +6202,6 @@ static int sctp_eat_data(const struct sctp_association *asoc, | |||
6144 | * No User Data: This error cause is returned to the originator of a | 6202 | * No User Data: This error cause is returned to the originator of a |
6145 | * DATA chunk if a received DATA chunk has no user data. | 6203 | * DATA chunk if a received DATA chunk has no user data. |
6146 | */ | 6204 | */ |
6147 | net = sock_net(sk); | ||
6148 | if (unlikely(0 == datalen)) { | 6205 | if (unlikely(0 == datalen)) { |
6149 | err = sctp_make_abort_no_data(asoc, chunk, tsn); | 6206 | err = sctp_make_abort_no_data(asoc, chunk, tsn); |
6150 | if (err) { | 6207 | if (err) { |