sctputil.c (170428) | sctputil.c (170462) |
---|---|
1/*- 2 * Copyright (c) 2001-2007, by 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: sctputil.c,v 1.37 2005/03/07 23:26:09 itojun Exp $ */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2007, by 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: sctputil.c,v 1.37 2005/03/07 23:26:09 itojun Exp $ */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 170428 2007-06-08 10:57:11Z rrs $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 170462 2007-06-09 13:46:57Z rrs $"); |
35 36#include <netinet/sctp_os.h> 37#include <netinet/sctp_pcb.h> 38#include <netinet/sctputil.h> 39#include <netinet/sctp_var.h> 40#include <netinet/sctp_sysctl.h> 41#ifdef INET6 42#include <netinet6/sctp6_var.h> --- 2877 unchanged lines hidden (view full) --- 2920 ssf->ssf_type = SCTP_SEND_FAILED; 2921 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT) 2922 ssf->ssf_flags = SCTP_DATA_UNSENT; 2923 else 2924 ssf->ssf_flags = SCTP_DATA_SENT; 2925 ssf->ssf_length = length; 2926 ssf->ssf_error = error; 2927 /* not exactly what the user sent in, but should be close :) */ | 35 36#include <netinet/sctp_os.h> 37#include <netinet/sctp_pcb.h> 38#include <netinet/sctputil.h> 39#include <netinet/sctp_var.h> 40#include <netinet/sctp_sysctl.h> 41#ifdef INET6 42#include <netinet6/sctp6_var.h> --- 2877 unchanged lines hidden (view full) --- 2920 ssf->ssf_type = SCTP_SEND_FAILED; 2921 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT) 2922 ssf->ssf_flags = SCTP_DATA_UNSENT; 2923 else 2924 ssf->ssf_flags = SCTP_DATA_SENT; 2925 ssf->ssf_length = length; 2926 ssf->ssf_error = error; 2927 /* not exactly what the user sent in, but should be close :) */ |
2928 bzero(&ssf->ssf_info, sizeof(ssf->ssf_info)); |
|
2928 ssf->ssf_info.sinfo_stream = chk->rec.data.stream_number; 2929 ssf->ssf_info.sinfo_ssn = chk->rec.data.stream_seq; 2930 ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags; 2931 ssf->ssf_info.sinfo_ppid = chk->rec.data.payloadtype; 2932 ssf->ssf_info.sinfo_context = chk->rec.data.context; 2933 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); 2934 ssf->ssf_assoc_id = sctp_get_associd(stcb); 2935 SCTP_BUF_NEXT(m_notify) = chk->data; --- 35 unchanged lines hidden (view full) --- 2971 struct sctp_queued_to_read *control; 2972 int length; 2973 2974 if ((stcb == NULL) || (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_RECVSENDFAILEVNT))) 2975 /* event not enabled */ 2976 return; 2977 2978 length = sizeof(struct sctp_send_failed) + sp->length; | 2929 ssf->ssf_info.sinfo_stream = chk->rec.data.stream_number; 2930 ssf->ssf_info.sinfo_ssn = chk->rec.data.stream_seq; 2931 ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags; 2932 ssf->ssf_info.sinfo_ppid = chk->rec.data.payloadtype; 2933 ssf->ssf_info.sinfo_context = chk->rec.data.context; 2934 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); 2935 ssf->ssf_assoc_id = sctp_get_associd(stcb); 2936 SCTP_BUF_NEXT(m_notify) = chk->data; --- 35 unchanged lines hidden (view full) --- 2972 struct sctp_queued_to_read *control; 2973 int length; 2974 2975 if ((stcb == NULL) || (sctp_is_feature_off(stcb->sctp_ep, SCTP_PCB_FLAGS_RECVSENDFAILEVNT))) 2976 /* event not enabled */ 2977 return; 2978 2979 length = sizeof(struct sctp_send_failed) + sp->length; |
2979 m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_adaption_event), 0, M_DONTWAIT, 1, MT_DATA); | 2980 m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_send_failed), 0, M_DONTWAIT, 1, MT_DATA); |
2980 if (m_notify == NULL) 2981 /* no space left */ 2982 return; 2983 SCTP_BUF_LEN(m_notify) = 0; 2984 ssf = mtod(m_notify, struct sctp_send_failed *); 2985 ssf->ssf_type = SCTP_SEND_FAILED; 2986 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT) 2987 ssf->ssf_flags = SCTP_DATA_UNSENT; 2988 else 2989 ssf->ssf_flags = SCTP_DATA_SENT; 2990 ssf->ssf_length = length; 2991 ssf->ssf_error = error; 2992 /* not exactly what the user sent in, but should be close :) */ | 2981 if (m_notify == NULL) 2982 /* no space left */ 2983 return; 2984 SCTP_BUF_LEN(m_notify) = 0; 2985 ssf = mtod(m_notify, struct sctp_send_failed *); 2986 ssf->ssf_type = SCTP_SEND_FAILED; 2987 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT) 2988 ssf->ssf_flags = SCTP_DATA_UNSENT; 2989 else 2990 ssf->ssf_flags = SCTP_DATA_SENT; 2991 ssf->ssf_length = length; 2992 ssf->ssf_error = error; 2993 /* not exactly what the user sent in, but should be close :) */ |
2994 bzero(&ssf->ssf_info, sizeof(ssf->ssf_info)); |
|
2993 ssf->ssf_info.sinfo_stream = sp->stream; 2994 ssf->ssf_info.sinfo_ssn = sp->strseq; 2995 ssf->ssf_info.sinfo_flags = sp->sinfo_flags; 2996 ssf->ssf_info.sinfo_ppid = sp->ppid; 2997 ssf->ssf_info.sinfo_context = sp->context; 2998 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); 2999 ssf->ssf_assoc_id = sctp_get_associd(stcb); 3000 SCTP_BUF_NEXT(m_notify) = sp->data; --- 452 unchanged lines hidden (view full) --- 3453 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || 3454 (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) { 3455 return; 3456 } 3457 /* now through all the gunk freeing chunks */ 3458 if (holds_lock == 0) { 3459 SCTP_TCB_SEND_LOCK(stcb); 3460 } | 2995 ssf->ssf_info.sinfo_stream = sp->stream; 2996 ssf->ssf_info.sinfo_ssn = sp->strseq; 2997 ssf->ssf_info.sinfo_flags = sp->sinfo_flags; 2998 ssf->ssf_info.sinfo_ppid = sp->ppid; 2999 ssf->ssf_info.sinfo_context = sp->context; 3000 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); 3001 ssf->ssf_assoc_id = sctp_get_associd(stcb); 3002 SCTP_BUF_NEXT(m_notify) = sp->data; --- 452 unchanged lines hidden (view full) --- 3455 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || 3456 (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) { 3457 return; 3458 } 3459 /* now through all the gunk freeing chunks */ 3460 if (holds_lock == 0) { 3461 SCTP_TCB_SEND_LOCK(stcb); 3462 } |
3461 for (i = 0; i < stcb->asoc.streamoutcnt; i++) { 3462 /* For each stream */ 3463 outs = &stcb->asoc.strmout[i]; 3464 /* clean up any sends there */ 3465 stcb->asoc.locked_on_sending = NULL; 3466 sp = TAILQ_FIRST(&outs->outqueue); 3467 while (sp) { 3468 stcb->asoc.stream_queue_cnt--; 3469 TAILQ_REMOVE(&outs->outqueue, sp, next); 3470 sctp_free_spbufspace(stcb, asoc, sp); 3471 sctp_ulp_notify(SCTP_NOTIFY_SPECIAL_SP_FAIL, stcb, 3472 SCTP_NOTIFY_DATAGRAM_UNSENT, (void *)sp); 3473 if (sp->data) { 3474 sctp_m_freem(sp->data); 3475 sp->data = NULL; 3476 } 3477 if (sp->net) 3478 sctp_free_remote_addr(sp->net); 3479 sp->net = NULL; 3480 /* Free the chunk */ 3481 sctp_free_a_strmoq(stcb, sp); 3482 /* sa_ignore FREED_MEMORY */ 3483 sp = TAILQ_FIRST(&outs->outqueue); 3484 } 3485 } 3486 3487 /* pending send queue SHOULD be empty */ 3488 if (!TAILQ_EMPTY(&asoc->send_queue)) { 3489 chk = TAILQ_FIRST(&asoc->send_queue); | 3463 /* sent queue SHOULD be empty */ 3464 if (!TAILQ_EMPTY(&asoc->sent_queue)) { 3465 chk = TAILQ_FIRST(&asoc->sent_queue); |
3490 while (chk) { | 3466 while (chk) { |
3491 TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next); 3492 asoc->send_queue_cnt--; | 3467 TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); 3468 asoc->sent_queue_cnt--; |
3493 if (chk->data) { 3494 /* 3495 * trim off the sctp chunk header(it should 3496 * be there) 3497 */ 3498 if (chk->send_size >= sizeof(struct sctp_data_chunk)) { 3499 m_adj(chk->data, sizeof(struct sctp_data_chunk)); 3500 sctp_mbuf_crush(chk->data); | 3469 if (chk->data) { 3470 /* 3471 * trim off the sctp chunk header(it should 3472 * be there) 3473 */ 3474 if (chk->send_size >= sizeof(struct sctp_data_chunk)) { 3475 m_adj(chk->data, sizeof(struct sctp_data_chunk)); 3476 sctp_mbuf_crush(chk->data); |
3477 chk->send_size -= sizeof(struct sctp_data_chunk); |
|
3501 } 3502 } 3503 sctp_free_bufspace(stcb, asoc, chk, 1); | 3478 } 3479 } 3480 sctp_free_bufspace(stcb, asoc, chk, 1); |
3504 sctp_ulp_notify(SCTP_NOTIFY_DG_FAIL, stcb, SCTP_NOTIFY_DATAGRAM_UNSENT, chk); | 3481 sctp_ulp_notify(SCTP_NOTIFY_DG_FAIL, stcb, 3482 SCTP_NOTIFY_DATAGRAM_SENT, chk); |
3505 if (chk->data) { 3506 sctp_m_freem(chk->data); 3507 chk->data = NULL; 3508 } 3509 if (chk->whoTo) 3510 sctp_free_remote_addr(chk->whoTo); 3511 chk->whoTo = NULL; 3512 sctp_free_a_chunk(stcb, chk); 3513 /* sa_ignore FREED_MEMORY */ | 3483 if (chk->data) { 3484 sctp_m_freem(chk->data); 3485 chk->data = NULL; 3486 } 3487 if (chk->whoTo) 3488 sctp_free_remote_addr(chk->whoTo); 3489 chk->whoTo = NULL; 3490 sctp_free_a_chunk(stcb, chk); 3491 /* sa_ignore FREED_MEMORY */ |
3514 chk = TAILQ_FIRST(&asoc->send_queue); | 3492 chk = TAILQ_FIRST(&asoc->sent_queue); |
3515 } 3516 } | 3493 } 3494 } |
3517 /* sent queue SHOULD be empty */ 3518 if (!TAILQ_EMPTY(&asoc->sent_queue)) { 3519 chk = TAILQ_FIRST(&asoc->sent_queue); | 3495 /* pending send queue SHOULD be empty */ 3496 if (!TAILQ_EMPTY(&asoc->send_queue)) { 3497 chk = TAILQ_FIRST(&asoc->send_queue); |
3520 while (chk) { | 3498 while (chk) { |
3521 TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); 3522 asoc->sent_queue_cnt--; | 3499 TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next); 3500 asoc->send_queue_cnt--; |
3523 if (chk->data) { 3524 /* 3525 * trim off the sctp chunk header(it should 3526 * be there) 3527 */ 3528 if (chk->send_size >= sizeof(struct sctp_data_chunk)) { 3529 m_adj(chk->data, sizeof(struct sctp_data_chunk)); 3530 sctp_mbuf_crush(chk->data); | 3501 if (chk->data) { 3502 /* 3503 * trim off the sctp chunk header(it should 3504 * be there) 3505 */ 3506 if (chk->send_size >= sizeof(struct sctp_data_chunk)) { 3507 m_adj(chk->data, sizeof(struct sctp_data_chunk)); 3508 sctp_mbuf_crush(chk->data); |
3509 chk->send_size -= sizeof(struct sctp_data_chunk); |
|
3531 } 3532 } 3533 sctp_free_bufspace(stcb, asoc, chk, 1); | 3510 } 3511 } 3512 sctp_free_bufspace(stcb, asoc, chk, 1); |
3534 sctp_ulp_notify(SCTP_NOTIFY_DG_FAIL, stcb, 3535 SCTP_NOTIFY_DATAGRAM_SENT, chk); | 3513 sctp_ulp_notify(SCTP_NOTIFY_DG_FAIL, stcb, SCTP_NOTIFY_DATAGRAM_UNSENT, chk); |
3536 if (chk->data) { 3537 sctp_m_freem(chk->data); 3538 chk->data = NULL; 3539 } 3540 if (chk->whoTo) 3541 sctp_free_remote_addr(chk->whoTo); 3542 chk->whoTo = NULL; 3543 sctp_free_a_chunk(stcb, chk); 3544 /* sa_ignore FREED_MEMORY */ | 3514 if (chk->data) { 3515 sctp_m_freem(chk->data); 3516 chk->data = NULL; 3517 } 3518 if (chk->whoTo) 3519 sctp_free_remote_addr(chk->whoTo); 3520 chk->whoTo = NULL; 3521 sctp_free_a_chunk(stcb, chk); 3522 /* sa_ignore FREED_MEMORY */ |
3545 chk = TAILQ_FIRST(&asoc->sent_queue); | 3523 chk = TAILQ_FIRST(&asoc->send_queue); |
3546 } 3547 } | 3524 } 3525 } |
3526 for (i = 0; i < stcb->asoc.streamoutcnt; i++) { 3527 /* For each stream */ 3528 outs = &stcb->asoc.strmout[i]; 3529 /* clean up any sends there */ 3530 stcb->asoc.locked_on_sending = NULL; 3531 sp = TAILQ_FIRST(&outs->outqueue); 3532 while (sp) { 3533 stcb->asoc.stream_queue_cnt--; 3534 TAILQ_REMOVE(&outs->outqueue, sp, next); 3535 sctp_free_spbufspace(stcb, asoc, sp); 3536 sctp_ulp_notify(SCTP_NOTIFY_SPECIAL_SP_FAIL, stcb, 3537 SCTP_NOTIFY_DATAGRAM_UNSENT, (void *)sp); 3538 if (sp->data) { 3539 sctp_m_freem(sp->data); 3540 sp->data = NULL; 3541 } 3542 if (sp->net) 3543 sctp_free_remote_addr(sp->net); 3544 sp->net = NULL; 3545 /* Free the chunk */ 3546 sctp_free_a_strmoq(stcb, sp); 3547 /* sa_ignore FREED_MEMORY */ 3548 sp = TAILQ_FIRST(&outs->outqueue); 3549 } 3550 } 3551 |
|
3548 if (holds_lock == 0) { 3549 SCTP_TCB_SEND_UNLOCK(stcb); 3550 } 3551} 3552 3553void 3554sctp_abort_notification(struct sctp_tcb *stcb, int error) 3555{ --- 2320 unchanged lines hidden --- | 3552 if (holds_lock == 0) { 3553 SCTP_TCB_SEND_UNLOCK(stcb); 3554 } 3555} 3556 3557void 3558sctp_abort_notification(struct sctp_tcb *stcb, int error) 3559{ --- 2320 unchanged lines hidden --- |