sctp_input.c (164181) | sctp_input.c (164205) |
---|---|
1/*- 2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 17 unchanged lines hidden (view full) --- 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31/* $KAME: sctp_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 17 unchanged lines hidden (view full) --- 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31/* $KAME: sctp_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 164181 2006-11-11 15:59:01Z rrs $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 164205 2006-11-11 22:44:12Z rrs $"); |
35 36#include "opt_ipsec.h" 37#include "opt_compat.h" 38#include "opt_inet6.h" 39#include "opt_inet.h" 40#include "opt_sctp.h" 41 42#include <sys/param.h> --- 653 unchanged lines hidden (view full) --- 696 stcb->asoc.control_pdapi = NULL; 697 SCTP_INP_READ_UNLOCK(stcb->sctp_ep); 698 sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); 699 } 700 /* are the queues empty? */ 701 if (!TAILQ_EMPTY(&asoc->send_queue) || 702 !TAILQ_EMPTY(&asoc->sent_queue) || 703 !TAILQ_EMPTY(&asoc->out_wheel)) { | 35 36#include "opt_ipsec.h" 37#include "opt_compat.h" 38#include "opt_inet6.h" 39#include "opt_inet.h" 40#include "opt_sctp.h" 41 42#include <sys/param.h> --- 653 unchanged lines hidden (view full) --- 696 stcb->asoc.control_pdapi = NULL; 697 SCTP_INP_READ_UNLOCK(stcb->sctp_ep); 698 sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); 699 } 700 /* are the queues empty? */ 701 if (!TAILQ_EMPTY(&asoc->send_queue) || 702 !TAILQ_EMPTY(&asoc->sent_queue) || 703 !TAILQ_EMPTY(&asoc->out_wheel)) { |
704 sctp_report_all_outbound(stcb); | 704 sctp_report_all_outbound(stcb, 0); |
705 } 706 /* stop the timer */ 707 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net); 708 /* send SHUTDOWN-COMPLETE */ 709 sctp_send_shutdown_complete(stcb, net); 710 /* notify upper layer protocol */ 711 if (stcb->sctp_socket) { 712 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL); --- 374 unchanged lines hidden (view full) --- 1087 struct sockaddr *init_src, int *notification, sctp_assoc_t * sac_assoc_id) 1088{ 1089 struct sctp_association *asoc; 1090 struct sctp_init_chunk *init_cp, init_buf; 1091 struct sctp_init_ack_chunk *initack_cp, initack_buf; 1092 int chk_length; 1093 int init_offset, initack_offset; 1094 int retval; | 705 } 706 /* stop the timer */ 707 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net); 708 /* send SHUTDOWN-COMPLETE */ 709 sctp_send_shutdown_complete(stcb, net); 710 /* notify upper layer protocol */ 711 if (stcb->sctp_socket) { 712 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL); --- 374 unchanged lines hidden (view full) --- 1087 struct sockaddr *init_src, int *notification, sctp_assoc_t * sac_assoc_id) 1088{ 1089 struct sctp_association *asoc; 1090 struct sctp_init_chunk *init_cp, init_buf; 1091 struct sctp_init_ack_chunk *initack_cp, initack_buf; 1092 int chk_length; 1093 int init_offset, initack_offset; 1094 int retval; |
1095 int spec_flag = 0; |
|
1095 1096 /* I know that the TCB is non-NULL from the caller */ 1097 asoc = &stcb->asoc; 1098 1099 if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) { 1100 /* SHUTDOWN came in after sending INIT-ACK */ 1101 struct mbuf *op_err; 1102 struct sctp_paramhdr *ph; --- 163 unchanged lines hidden (view full) --- 1266 * things 1267 */ 1268 net->hb_responded = 1; 1269 if (stcb->asoc.sctp_autoclose_ticks && 1270 sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) { 1271 sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, 1272 NULL); 1273 } | 1096 1097 /* I know that the TCB is non-NULL from the caller */ 1098 asoc = &stcb->asoc; 1099 1100 if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) { 1101 /* SHUTDOWN came in after sending INIT-ACK */ 1102 struct mbuf *op_err; 1103 struct sctp_paramhdr *ph; --- 163 unchanged lines hidden (view full) --- 1267 * things 1268 */ 1269 net->hb_responded = 1; 1270 if (stcb->asoc.sctp_autoclose_ticks && 1271 sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) { 1272 sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, 1273 NULL); 1274 } |
1274 /* 1275 * FIX? Should we go out, in this case (if the seq numbers 1276 * changed on the peer) and set any data to RETRANSMIT? 1277 */ | |
1278 asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); | 1275 asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); |
1279 asoc->pre_open_streams = 1280 ntohs(initack_cp->init.num_outbound_streams); | 1276 asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams); 1277 1278 /* Note last_cwr_tsn? where is this used? */ |
1281 asoc->last_cwr_tsn = asoc->init_seq_number - 1; | 1279 asoc->last_cwr_tsn = asoc->init_seq_number - 1; |
1282 asoc->asconf_seq_in = asoc->last_acked_seq = asoc->init_seq_number - 1; 1283 asoc->str_reset_seq_in = asoc->init_seq_number; 1284 asoc->advanced_peer_ack_point = asoc->last_acked_seq; | 1280 if (ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) { 1281 /* 1282 * Ok the peer probably discarded our data (if we 1283 * echoed a cookie+data). So anything on the 1284 * sent_queue should be marked for retransmit, we 1285 * may not get something to kick us so it COULD 1286 * still take a timeout to move these.. but it can't 1287 * hurt to mark them. 1288 */ 1289 struct sctp_tmit_chunk *chk; |
1285 | 1290 |
1291 TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { 1292 if (chk->sent < SCTP_DATAGRAM_RESEND) { 1293 chk->sent = SCTP_DATAGRAM_RESEND; 1294 stcb->asoc.sent_queue_retran_cnt++; 1295 spec_flag++; 1296 } 1297 } 1298 1299 } |
|
1286 /* process the INIT info (peer's info) */ 1287 retval = sctp_process_init(init_cp, stcb, net); 1288 if (retval < 0) { 1289 return (NULL); 1290 } 1291 if (sctp_load_addresses_from_init(stcb, m, iphlen, 1292 init_offset + sizeof(struct sctp_init_chunk), 1293 initack_offset, sh, init_src)) { --- 17 unchanged lines hidden (view full) --- 1311 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 1312 stcb->sctp_ep, stcb, asoc->primary_destination); 1313 1314 } else { 1315 asoc->state = SCTP_STATE_OPEN; 1316 } 1317 sctp_stop_all_cookie_timers(stcb); 1318 sctp_send_cookie_ack(stcb); | 1300 /* process the INIT info (peer's info) */ 1301 retval = sctp_process_init(init_cp, stcb, net); 1302 if (retval < 0) { 1303 return (NULL); 1304 } 1305 if (sctp_load_addresses_from_init(stcb, m, iphlen, 1306 init_offset + sizeof(struct sctp_init_chunk), 1307 initack_offset, sh, init_src)) { --- 17 unchanged lines hidden (view full) --- 1325 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 1326 stcb->sctp_ep, stcb, asoc->primary_destination); 1327 1328 } else { 1329 asoc->state = SCTP_STATE_OPEN; 1330 } 1331 sctp_stop_all_cookie_timers(stcb); 1332 sctp_send_cookie_ack(stcb); |
1333 if (spec_flag) { 1334 /* 1335 * only if we have retrans set do we do this. What 1336 * this call does is get only the COOKIE-ACK out and 1337 * then when we return the normal call to 1338 * sctp_chunk_output will get the retrans out behind 1339 * this. 1340 */ 1341 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_COOKIE_ACK); 1342 } |
|
1319 return (stcb); 1320 } 1321 if ((ntohl(initack_cp->init.initiate_tag) != asoc->my_vtag && 1322 ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) && 1323 cookie->tie_tag_my_vtag == asoc->my_vtag_nonce && 1324 cookie->tie_tag_peer_vtag == asoc->peer_vtag_nonce && 1325 cookie->tie_tag_peer_vtag != 0) { 1326 struct sctpasochead *head; --- 4 unchanged lines hidden (view full) --- 1331 sctp_timer_stop(SCTP_TIMER_TYPE_INIT, inp, stcb, net); 1332 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net); 1333 *sac_assoc_id = sctp_get_associd(stcb); 1334 /* notify upper layer */ 1335 *notification = SCTP_NOTIFY_ASSOC_RESTART; 1336 1337 1338 /* send up all the data */ | 1343 return (stcb); 1344 } 1345 if ((ntohl(initack_cp->init.initiate_tag) != asoc->my_vtag && 1346 ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) && 1347 cookie->tie_tag_my_vtag == asoc->my_vtag_nonce && 1348 cookie->tie_tag_peer_vtag == asoc->peer_vtag_nonce && 1349 cookie->tie_tag_peer_vtag != 0) { 1350 struct sctpasochead *head; --- 4 unchanged lines hidden (view full) --- 1355 sctp_timer_stop(SCTP_TIMER_TYPE_INIT, inp, stcb, net); 1356 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net); 1357 *sac_assoc_id = sctp_get_associd(stcb); 1358 /* notify upper layer */ 1359 *notification = SCTP_NOTIFY_ASSOC_RESTART; 1360 1361 1362 /* send up all the data */ |
1339 sctp_report_all_outbound(stcb); | 1363 SCTP_TCB_SEND_LOCK(stcb); 1364 sctp_report_all_outbound(stcb, 1); |
1340 1341 /* process the INIT-ACK info (my info) */ 1342 asoc->my_vtag = ntohl(initack_cp->init.initiate_tag); 1343 asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); 1344 1345 /* pull from vtag hash */ 1346 LIST_REMOVE(stcb, sctp_asocs); 1347 /* re-insert to new vtag position */ --- 23 unchanged lines hidden (view full) --- 1371 1372 asoc->str_reset_seq_in = asoc->init_seq_number; 1373 1374 asoc->advanced_peer_ack_point = asoc->last_acked_seq; 1375 if (asoc->mapping_array) 1376 memset(asoc->mapping_array, 0, 1377 asoc->mapping_array_size); 1378 /* process the INIT info (peer's info) */ | 1365 1366 /* process the INIT-ACK info (my info) */ 1367 asoc->my_vtag = ntohl(initack_cp->init.initiate_tag); 1368 asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); 1369 1370 /* pull from vtag hash */ 1371 LIST_REMOVE(stcb, sctp_asocs); 1372 /* re-insert to new vtag position */ --- 23 unchanged lines hidden (view full) --- 1396 1397 asoc->str_reset_seq_in = asoc->init_seq_number; 1398 1399 asoc->advanced_peer_ack_point = asoc->last_acked_seq; 1400 if (asoc->mapping_array) 1401 memset(asoc->mapping_array, 0, 1402 asoc->mapping_array_size); 1403 /* process the INIT info (peer's info) */ |
1404 SCTP_TCB_SEND_UNLOCK(stcb); |
|
1379 retval = sctp_process_init(init_cp, stcb, net); 1380 if (retval < 0) { 1381 return (NULL); 1382 } 1383 /* 1384 * since we did not send a HB make sure we don't double 1385 * things 1386 */ --- 964 unchanged lines hidden (view full) --- 2351 } 2352 /* notify upper layer protocol */ 2353 if (stcb->sctp_socket) { 2354 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL); 2355 /* are the queues empty? they should be */ 2356 if (!TAILQ_EMPTY(&asoc->send_queue) || 2357 !TAILQ_EMPTY(&asoc->sent_queue) || 2358 !TAILQ_EMPTY(&asoc->out_wheel)) { | 1405 retval = sctp_process_init(init_cp, stcb, net); 1406 if (retval < 0) { 1407 return (NULL); 1408 } 1409 /* 1410 * since we did not send a HB make sure we don't double 1411 * things 1412 */ --- 964 unchanged lines hidden (view full) --- 2377 } 2378 /* notify upper layer protocol */ 2379 if (stcb->sctp_socket) { 2380 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL); 2381 /* are the queues empty? they should be */ 2382 if (!TAILQ_EMPTY(&asoc->send_queue) || 2383 !TAILQ_EMPTY(&asoc->sent_queue) || 2384 !TAILQ_EMPTY(&asoc->out_wheel)) { |
2359 sctp_report_all_outbound(stcb); | 2385 sctp_report_all_outbound(stcb, 0); |
2360 } 2361 } 2362 /* stop the timer */ 2363 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net); 2364 SCTP_STAT_INCR_COUNTER32(sctps_shutdown); 2365 /* free the TCB */ 2366 sctp_free_assoc(stcb->sctp_ep, stcb, 0); 2367 return; --- 2403 unchanged lines hidden --- | 2386 } 2387 } 2388 /* stop the timer */ 2389 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net); 2390 SCTP_STAT_INCR_COUNTER32(sctps_shutdown); 2391 /* free the TCB */ 2392 sctp_free_assoc(stcb->sctp_ep, stcb, 0); 2393 return; --- 2403 unchanged lines hidden --- |