sctputil.c (170140) | sctputil.c (170181) |
---|---|
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 170140 2007-05-30 22:34:21Z rrs $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 170181 2007-06-01 11:19:54Z 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> --- 907 unchanged lines hidden (view full) --- 950 951 } else { 952 asoc->my_vtag = sctp_select_a_tag(m); 953 } 954 /* Get the nonce tags */ 955 asoc->my_vtag_nonce = sctp_select_a_tag(m); 956 asoc->peer_vtag_nonce = sctp_select_a_tag(m); 957 asoc->vrf_id = vrf_id; | 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> --- 907 unchanged lines hidden (view full) --- 950 951 } else { 952 asoc->my_vtag = sctp_select_a_tag(m); 953 } 954 /* Get the nonce tags */ 955 asoc->my_vtag_nonce = sctp_select_a_tag(m); 956 asoc->peer_vtag_nonce = sctp_select_a_tag(m); 957 asoc->vrf_id = vrf_id; |
958 /* Save the table id as well from the inp */ 959 asoc->table_id = m->def_table_id; | |
960 961 if (sctp_is_feature_on(m, SCTP_PCB_FLAGS_DONOT_HEARTBEAT)) 962 asoc->hb_is_disabled = 1; 963 else 964 asoc->hb_is_disabled = 0; 965 966 asoc->refcnt = 0; 967 asoc->assoc_up_sent = 0; --- 493 unchanged lines hidden (view full) --- 1461 1462 /* call the handler for the appropriate timer type */ 1463 switch (tmr->type) { 1464 case SCTP_TIMER_TYPE_ZERO_COPY: 1465 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE)) { 1466 SCTP_ZERO_COPY_EVENT(inp, inp->sctp_socket); 1467 } 1468 break; | 958 959 if (sctp_is_feature_on(m, SCTP_PCB_FLAGS_DONOT_HEARTBEAT)) 960 asoc->hb_is_disabled = 1; 961 else 962 asoc->hb_is_disabled = 0; 963 964 asoc->refcnt = 0; 965 asoc->assoc_up_sent = 0; --- 493 unchanged lines hidden (view full) --- 1459 1460 /* call the handler for the appropriate timer type */ 1461 switch (tmr->type) { 1462 case SCTP_TIMER_TYPE_ZERO_COPY: 1463 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE)) { 1464 SCTP_ZERO_COPY_EVENT(inp, inp->sctp_socket); 1465 } 1466 break; |
1467 case SCTP_TIMER_TYPE_ZCOPY_SENDQ: 1468 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE)) { 1469 SCTP_ZERO_COPY_SENDQ_EVENT(inp, inp->sctp_socket); 1470 } 1471 break; |
|
1469 case SCTP_TIMER_TYPE_ADDR_WQ: 1470 sctp_handle_addr_wq(); 1471 break; 1472 case SCTP_TIMER_TYPE_ITERATOR: 1473 SCTP_STAT_INCR(sctps_timoiterator); 1474 sctp_iterator_timer(it); 1475 break; 1476 case SCTP_TIMER_TYPE_SEND: --- 306 unchanged lines hidden (view full) --- 1783 if (stcb) { 1784 SCTP_TCB_LOCK_ASSERT(stcb); 1785 } 1786 switch (t_type) { 1787 case SCTP_TIMER_TYPE_ZERO_COPY: 1788 tmr = &inp->sctp_ep.zero_copy_timer; 1789 to_ticks = SCTP_ZERO_COPY_TICK_DELAY; 1790 break; | 1472 case SCTP_TIMER_TYPE_ADDR_WQ: 1473 sctp_handle_addr_wq(); 1474 break; 1475 case SCTP_TIMER_TYPE_ITERATOR: 1476 SCTP_STAT_INCR(sctps_timoiterator); 1477 sctp_iterator_timer(it); 1478 break; 1479 case SCTP_TIMER_TYPE_SEND: --- 306 unchanged lines hidden (view full) --- 1786 if (stcb) { 1787 SCTP_TCB_LOCK_ASSERT(stcb); 1788 } 1789 switch (t_type) { 1790 case SCTP_TIMER_TYPE_ZERO_COPY: 1791 tmr = &inp->sctp_ep.zero_copy_timer; 1792 to_ticks = SCTP_ZERO_COPY_TICK_DELAY; 1793 break; |
1794 case SCTP_TIMER_TYPE_ZCOPY_SENDQ: 1795 tmr = &inp->sctp_ep.zero_copy_sendq_timer; 1796 to_ticks = SCTP_ZERO_COPY_SENDQ_TICK_DELAY; 1797 break; |
|
1791 case SCTP_TIMER_TYPE_ADDR_WQ: 1792 /* Only 1 tick away :-) */ 1793 tmr = &sctppcbinfo.addr_wq_timer; 1794 to_ticks = SCTP_ADDRESS_TICK_DELAY; 1795 break; 1796 case SCTP_TIMER_TYPE_ITERATOR: 1797 { 1798 struct sctp_iterator *it; --- 333 unchanged lines hidden (view full) --- 2132 tmr = NULL; 2133 if (stcb) { 2134 SCTP_TCB_LOCK_ASSERT(stcb); 2135 } 2136 switch (t_type) { 2137 case SCTP_TIMER_TYPE_ZERO_COPY: 2138 tmr = &inp->sctp_ep.zero_copy_timer; 2139 break; | 1798 case SCTP_TIMER_TYPE_ADDR_WQ: 1799 /* Only 1 tick away :-) */ 1800 tmr = &sctppcbinfo.addr_wq_timer; 1801 to_ticks = SCTP_ADDRESS_TICK_DELAY; 1802 break; 1803 case SCTP_TIMER_TYPE_ITERATOR: 1804 { 1805 struct sctp_iterator *it; --- 333 unchanged lines hidden (view full) --- 2139 tmr = NULL; 2140 if (stcb) { 2141 SCTP_TCB_LOCK_ASSERT(stcb); 2142 } 2143 switch (t_type) { 2144 case SCTP_TIMER_TYPE_ZERO_COPY: 2145 tmr = &inp->sctp_ep.zero_copy_timer; 2146 break; |
2140 | 2147 case SCTP_TIMER_TYPE_ZCOPY_SENDQ: 2148 tmr = &inp->sctp_ep.zero_copy_sendq_timer; 2149 break; |
2141 case SCTP_TIMER_TYPE_ADDR_WQ: 2142 tmr = &sctppcbinfo.addr_wq_timer; 2143 break; 2144 case SCTP_TIMER_TYPE_EARLYFR: 2145 if ((stcb == NULL) || (net == NULL)) { 2146 return; 2147 } 2148 tmr = &net->fr_timer; --- 1405 unchanged lines hidden (view full) --- 3554 stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_WAS_ABORTED; 3555 } 3556 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_ABORTED, stcb, error, NULL); 3557} 3558 3559void 3560sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, 3561 struct mbuf *m, int iphlen, struct sctphdr *sh, struct mbuf *op_err, | 2150 case SCTP_TIMER_TYPE_ADDR_WQ: 2151 tmr = &sctppcbinfo.addr_wq_timer; 2152 break; 2153 case SCTP_TIMER_TYPE_EARLYFR: 2154 if ((stcb == NULL) || (net == NULL)) { 2155 return; 2156 } 2157 tmr = &net->fr_timer; --- 1405 unchanged lines hidden (view full) --- 3563 stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_WAS_ABORTED; 3564 } 3565 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_ABORTED, stcb, error, NULL); 3566} 3567 3568void 3569sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, 3570 struct mbuf *m, int iphlen, struct sctphdr *sh, struct mbuf *op_err, |
3562 uint32_t vrf_id, uint32_t table_id) | 3571 uint32_t vrf_id) |
3563{ 3564 uint32_t vtag; 3565 3566 vtag = 0; 3567 if (stcb != NULL) { 3568 /* We have a TCB to abort, send notification too */ 3569 vtag = stcb->asoc.peer_vtag; 3570 sctp_abort_notification(stcb, 0); 3571 /* get the assoc vrf id and table id */ 3572 vrf_id = stcb->asoc.vrf_id; | 3572{ 3573 uint32_t vtag; 3574 3575 vtag = 0; 3576 if (stcb != NULL) { 3577 /* We have a TCB to abort, send notification too */ 3578 vtag = stcb->asoc.peer_vtag; 3579 sctp_abort_notification(stcb, 0); 3580 /* get the assoc vrf id and table id */ 3581 vrf_id = stcb->asoc.vrf_id; |
3573 table_id = stcb->asoc.table_id; | |
3574 } | 3582 } |
3575 sctp_send_abort(m, iphlen, sh, vtag, op_err, vrf_id, table_id); | 3583 sctp_send_abort(m, iphlen, sh, vtag, op_err, vrf_id); |
3576 if (stcb != NULL) { 3577 /* Ok, now lets free it */ 3578 sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_4); 3579 } else { 3580 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { 3581 if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) { 3582 sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, 3583 SCTP_CALLED_DIRECTLY_NOCMPSET); --- 95 unchanged lines hidden (view full) --- 3679#ifdef SCTP_ASOCLOG_OF_TSNS 3680 sctp_print_out_track_log(stcb); 3681#endif 3682 sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_5); 3683} 3684 3685void 3686sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, | 3584 if (stcb != NULL) { 3585 /* Ok, now lets free it */ 3586 sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_4); 3587 } else { 3588 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { 3589 if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) { 3590 sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, 3591 SCTP_CALLED_DIRECTLY_NOCMPSET); --- 95 unchanged lines hidden (view full) --- 3687#ifdef SCTP_ASOCLOG_OF_TSNS 3688 sctp_print_out_track_log(stcb); 3689#endif 3690 sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_5); 3691} 3692 3693void 3694sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, |
3687 struct sctp_inpcb *inp, struct mbuf *op_err, uint32_t vrf_id, 3688 uint32_t table_id) | 3695 struct sctp_inpcb *inp, struct mbuf *op_err, uint32_t vrf_id) |
3689{ 3690 struct sctp_chunkhdr *ch, chunk_buf; 3691 unsigned int chk_length; 3692 3693 SCTP_STAT_INCR_COUNTER32(sctps_outoftheblue); 3694 /* Generate a TO address for future reference */ 3695 if (inp && (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { 3696 if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) { --- 18 unchanged lines hidden (view full) --- 3715 return; 3716 case SCTP_SHUTDOWN_COMPLETE: 3717 /* 3718 * we ignore it since we are not waiting for it and 3719 * peer is gone 3720 */ 3721 return; 3722 case SCTP_SHUTDOWN_ACK: | 3696{ 3697 struct sctp_chunkhdr *ch, chunk_buf; 3698 unsigned int chk_length; 3699 3700 SCTP_STAT_INCR_COUNTER32(sctps_outoftheblue); 3701 /* Generate a TO address for future reference */ 3702 if (inp && (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { 3703 if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) { --- 18 unchanged lines hidden (view full) --- 3722 return; 3723 case SCTP_SHUTDOWN_COMPLETE: 3724 /* 3725 * we ignore it since we are not waiting for it and 3726 * peer is gone 3727 */ 3728 return; 3729 case SCTP_SHUTDOWN_ACK: |
3723 sctp_send_shutdown_complete2(m, iphlen, sh, vrf_id, 3724 table_id); | 3730 sctp_send_shutdown_complete2(m, iphlen, sh, vrf_id); |
3725 return; 3726 default: 3727 break; 3728 } 3729 offset += SCTP_SIZE32(chk_length); 3730 ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset, 3731 sizeof(*ch), (uint8_t *) & chunk_buf); 3732 } | 3731 return; 3732 default: 3733 break; 3734 } 3735 offset += SCTP_SIZE32(chk_length); 3736 ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset, 3737 sizeof(*ch), (uint8_t *) & chunk_buf); 3738 } |
3733 sctp_send_abort(m, iphlen, sh, 0, op_err, vrf_id, table_id); | 3739 sctp_send_abort(m, iphlen, sh, 0, op_err, vrf_id); |
3734} 3735 3736/* 3737 * check the inbound datagram to make sure there is not an abort inside it, 3738 * if there is return 1, else return 0. 3739 */ 3740int 3741sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t * vtagfill) --- 2118 unchanged lines hidden --- | 3740} 3741 3742/* 3743 * check the inbound datagram to make sure there is not an abort inside it, 3744 * if there is return 1, else return 0. 3745 */ 3746int 3747sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t * vtagfill) --- 2118 unchanged lines hidden --- |