sctp_usrreq.c (179157) | sctp_usrreq.c (179783) |
---|---|
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: sctp_usrreq.c,v 1.48 2005/03/07 23:26:08 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: sctp_usrreq.c,v 1.48 2005/03/07 23:26:08 itojun Exp $ */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 179157 2008-05-20 13:47:46Z rrs $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 179783 2008-06-14 07:58:05Z rrs $"); |
35#include <netinet/sctp_os.h> 36#include <sys/proc.h> 37#include <netinet/sctp_pcb.h> 38#include <netinet/sctp_header.h> 39#include <netinet/sctp_var.h> 40#if defined(INET6) 41#include <netinet6/sctp6_var.h> 42#endif --- 9 unchanged lines hidden (view full) --- 52#include <netinet/sctp_cc_functions.h> 53 54 55 56 57void 58sctp_init(void) 59{ | 35#include <netinet/sctp_os.h> 36#include <sys/proc.h> 37#include <netinet/sctp_pcb.h> 38#include <netinet/sctp_header.h> 39#include <netinet/sctp_var.h> 40#if defined(INET6) 41#include <netinet6/sctp6_var.h> 42#endif --- 9 unchanged lines hidden (view full) --- 52#include <netinet/sctp_cc_functions.h> 53 54 55 56 57void 58sctp_init(void) 59{ |
60 /* Init the SCTP pcb in sctp_pcb.c */ | |
61 u_long sb_max_adj; 62 | 60 u_long sb_max_adj; 61 |
63 sctp_pcb_init(); | 62 bzero(&SCTP_BASE_STATS, sizeof(struct sctpstat)); |
64 | 63 |
64 /* Initialize and modify the sysctled variables */ 65 sctp_init_sysctls(); |
|
65 66 if ((nmbclusters / 8) > SCTP_ASOC_MAX_CHUNKS_ON_QUEUE) | 66 67 if ((nmbclusters / 8) > SCTP_ASOC_MAX_CHUNKS_ON_QUEUE) |
67 sctp_max_chunks_on_queue = (nmbclusters / 8); | 68 SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = (nmbclusters / 8); |
68 /* 69 * Allow a user to take no more than 1/2 the number of clusters or 70 * the SB_MAX whichever is smaller for the send window. 71 */ 72 sb_max_adj = (u_long)((u_quad_t) (SB_MAX) * MCLBYTES / (MSIZE + MCLBYTES)); | 69 /* 70 * Allow a user to take no more than 1/2 the number of clusters or 71 * the SB_MAX whichever is smaller for the send window. 72 */ 73 sb_max_adj = (u_long)((u_quad_t) (SB_MAX) * MCLBYTES / (MSIZE + MCLBYTES)); |
73 sctp_sendspace = min(sb_max_adj, | 74 SCTP_BASE_SYSCTL(sctp_sendspace) = min(sb_max_adj, |
74 (((uint32_t) nmbclusters / 2) * SCTP_DEFAULT_MAXSEGMENT)); 75 /* 76 * Now for the recv window, should we take the same amount? or 77 * should I do 1/2 the SB_MAX instead in the SB_MAX min above. For 78 * now I will just copy. 79 */ | 75 (((uint32_t) nmbclusters / 2) * SCTP_DEFAULT_MAXSEGMENT)); 76 /* 77 * Now for the recv window, should we take the same amount? or 78 * should I do 1/2 the SB_MAX instead in the SB_MAX min above. For 79 * now I will just copy. 80 */ |
80 sctp_recvspace = sctp_sendspace; | 81 SCTP_BASE_SYSCTL(sctp_recvspace) = SCTP_BASE_SYSCTL(sctp_sendspace); |
81 | 82 |
82} | 83 SCTP_BASE_VAR(first_time) = 0; 84 SCTP_BASE_VAR(sctp_pcb_initialized) = 0; 85 sctp_pcb_init(); 86#if defined(SCTP_PACKET_LOGGING) 87 SCTP_BASE_VAR(packet_log_writers) = 0; 88 SCTP_BASE_VAR(packet_log_end) = 0; 89 bzero(&SCTP_BASE_VAR(packet_log_buffer), SCTP_PACKET_LOG_SIZE); 90#endif |
83 84 | 91 92 |
93} |
|
85 | 94 |
95void 96sctp_finish(void) 97{ 98 sctp_pcb_finish(); 99} 100 |
|
86/* | 101/* |
87 * cleanup of the sctppcbinfo structure. 88 * Assumes that the sctppcbinfo lock is held. | 102 * cleanup of the SCTP_BASE_INFO() structure. 103 * Assumes that the SCTP_BASE_INFO() lock is held. |
89 */ 90void 91sctp_pcbinfo_cleanup(void) 92{ 93 /* free the hash tables */ | 104 */ 105void 106sctp_pcbinfo_cleanup(void) 107{ 108 /* free the hash tables */ |
94 if (sctppcbinfo.sctp_asochash != NULL) 95 SCTP_HASH_FREE(sctppcbinfo.sctp_asochash, sctppcbinfo.hashasocmark); 96 if (sctppcbinfo.sctp_ephash != NULL) 97 SCTP_HASH_FREE(sctppcbinfo.sctp_ephash, sctppcbinfo.hashmark); 98 if (sctppcbinfo.sctp_tcpephash != NULL) 99 SCTP_HASH_FREE(sctppcbinfo.sctp_tcpephash, sctppcbinfo.hashtcpmark); 100 if (sctppcbinfo.sctp_restarthash != NULL) 101 SCTP_HASH_FREE(sctppcbinfo.sctp_restarthash, sctppcbinfo.hashrestartmark); | 109 if (SCTP_BASE_INFO(sctp_asochash) != NULL) 110 SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_asochash), SCTP_BASE_INFO(hashasocmark)); 111 if (SCTP_BASE_INFO(sctp_ephash) != NULL) 112 SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_ephash), SCTP_BASE_INFO(hashmark)); 113 if (SCTP_BASE_INFO(sctp_tcpephash) != NULL) 114 SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_tcpephash), SCTP_BASE_INFO(hashtcpmark)); 115 if (SCTP_BASE_INFO(sctp_restarthash) != NULL) 116 SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_restarthash), SCTP_BASE_INFO(hashrestartmark)); |
102} 103 104 105void 106sctp_pathmtu_adjustment(struct sctp_inpcb *inp, 107 struct sctp_tcb *stcb, 108 struct sctp_nets *net, 109 uint16_t nxtsz) --- 19 unchanged lines hidden (view full) --- 129 * since we sent to big of chunk 130 */ 131 chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; 132 if (chk->sent != SCTP_DATAGRAM_RESEND) { 133 sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt); 134 } 135 chk->sent = SCTP_DATAGRAM_RESEND; 136 chk->rec.data.doing_fast_retransmit = 0; | 117} 118 119 120void 121sctp_pathmtu_adjustment(struct sctp_inpcb *inp, 122 struct sctp_tcb *stcb, 123 struct sctp_nets *net, 124 uint16_t nxtsz) --- 19 unchanged lines hidden (view full) --- 144 * since we sent to big of chunk 145 */ 146 chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; 147 if (chk->sent != SCTP_DATAGRAM_RESEND) { 148 sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt); 149 } 150 chk->sent = SCTP_DATAGRAM_RESEND; 151 chk->rec.data.doing_fast_retransmit = 0; |
137 if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) { | 152 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FLIGHT_LOGGING_ENABLE) { |
138 sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU, 139 chk->whoTo->flight_size, 140 chk->book_size, 141 (uintptr_t) chk->whoTo, 142 chk->rec.data.TSN_seq); 143 } 144 /* Clear any time so NO RTT is being done */ 145 chk->do_rtt = 0; --- 142 unchanged lines hidden (view full) --- 288 * destination is set to the unreachable state, also 289 * set the destination to the PF state. 290 */ 291 /* 292 * Add debug message here if destination is not in 293 * PF state. 294 */ 295 /* Stop any running T3 timers here? */ | 153 sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU, 154 chk->whoTo->flight_size, 155 chk->book_size, 156 (uintptr_t) chk->whoTo, 157 chk->rec.data.TSN_seq); 158 } 159 /* Clear any time so NO RTT is being done */ 160 chk->do_rtt = 0; --- 142 unchanged lines hidden (view full) --- 303 * destination is set to the unreachable state, also 304 * set the destination to the PF state. 305 */ 306 /* 307 * Add debug message here if destination is not in 308 * PF state. 309 */ 310 /* Stop any running T3 timers here? */ |
296 if (sctp_cmt_on_off && sctp_cmt_pf) { | 311 if (SCTP_BASE_SYSCTL(sctp_cmt_on_off) && SCTP_BASE_SYSCTL(sctp_cmt_pf)) { |
297 net->dest_state &= ~SCTP_ADDR_PF; 298 SCTPDBG(SCTP_DEBUG_TIMER4, "Destination %p moved from PF to unreachable.\n", 299 net); 300 } 301 net->error_count = net->failure_threshold + 1; 302 sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_DOWN, 303 stcb, SCTP_FAILED_THRESHOLD, 304 (void *)net, SCTP_SO_NOT_LOCKED); --- 211 unchanged lines hidden (view full) --- 516 uint32_t flags; 517 518#endif 519 inp = (struct sctp_inpcb *)so->so_pcb; 520 if (inp != 0) { 521 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); 522 return EINVAL; 523 } | 312 net->dest_state &= ~SCTP_ADDR_PF; 313 SCTPDBG(SCTP_DEBUG_TIMER4, "Destination %p moved from PF to unreachable.\n", 314 net); 315 } 316 net->error_count = net->failure_threshold + 1; 317 sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_DOWN, 318 stcb, SCTP_FAILED_THRESHOLD, 319 (void *)net, SCTP_SO_NOT_LOCKED); --- 211 unchanged lines hidden (view full) --- 531 uint32_t flags; 532 533#endif 534 inp = (struct sctp_inpcb *)so->so_pcb; 535 if (inp != 0) { 536 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); 537 return EINVAL; 538 } |
524 error = SCTP_SORESERVE(so, sctp_sendspace, sctp_recvspace); | 539 error = SCTP_SORESERVE(so, SCTP_BASE_SYSCTL(sctp_sendspace), SCTP_BASE_SYSCTL(sctp_recvspace)); |
525 if (error) { 526 return error; 527 } 528 error = sctp_inpcb_alloc(so, vrf_id); 529 if (error) { 530 return error; 531 } 532 inp = (struct sctp_inpcb *)so->so_pcb; --- 1136 unchanged lines hidden (view full) --- 1669 *optsize = sizeof(uint32_t); 1670 } 1671 break; 1672 case SCTP_CMT_ON_OFF: 1673 { 1674 struct sctp_assoc_value *av; 1675 1676 SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, *optsize); | 540 if (error) { 541 return error; 542 } 543 error = sctp_inpcb_alloc(so, vrf_id); 544 if (error) { 545 return error; 546 } 547 inp = (struct sctp_inpcb *)so->so_pcb; --- 1136 unchanged lines hidden (view full) --- 1684 *optsize = sizeof(uint32_t); 1685 } 1686 break; 1687 case SCTP_CMT_ON_OFF: 1688 { 1689 struct sctp_assoc_value *av; 1690 1691 SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, *optsize); |
1677 if (sctp_cmt_on_off) { | 1692 if (SCTP_BASE_SYSCTL(sctp_cmt_on_off)) { |
1678 SCTP_FIND_STCB(inp, stcb, av->assoc_id); 1679 if (stcb) { 1680 av->assoc_value = stcb->asoc.sctp_cmt_on_off; 1681 SCTP_TCB_UNLOCK(stcb); 1682 1683 } else { 1684 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); 1685 error = ENOTCONN; --- 1049 unchanged lines hidden (view full) --- 2735 } 2736 } 2737 break; 2738 case SCTP_CMT_ON_OFF: 2739 { 2740 struct sctp_assoc_value *av; 2741 2742 SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); | 1693 SCTP_FIND_STCB(inp, stcb, av->assoc_id); 1694 if (stcb) { 1695 av->assoc_value = stcb->asoc.sctp_cmt_on_off; 1696 SCTP_TCB_UNLOCK(stcb); 1697 1698 } else { 1699 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); 1700 error = ENOTCONN; --- 1049 unchanged lines hidden (view full) --- 2750 } 2751 } 2752 break; 2753 case SCTP_CMT_ON_OFF: 2754 { 2755 struct sctp_assoc_value *av; 2756 2757 SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); |
2743 if (sctp_cmt_on_off) { | 2758 if (SCTP_BASE_SYSCTL(sctp_cmt_on_off)) { |
2744 SCTP_FIND_STCB(inp, stcb, av->assoc_id); 2745 if (stcb) { 2746 stcb->asoc.sctp_cmt_on_off = (uint8_t) av->assoc_value; 2747 SCTP_TCB_UNLOCK(stcb); 2748 } else { 2749 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); 2750 error = ENOTCONN; 2751 } --- 942 unchanged lines hidden (view full) --- 3694 new_min = srto->srto_min; 3695 else 3696 new_min = stcb->asoc.minrto; 3697 if ((new_min <= new_init) && (new_init <= new_max)) { 3698 stcb->asoc.initial_rto = new_init; 3699 stcb->asoc.maxrto = new_max; 3700 stcb->asoc.minrto = new_min; 3701 } else { | 2759 SCTP_FIND_STCB(inp, stcb, av->assoc_id); 2760 if (stcb) { 2761 stcb->asoc.sctp_cmt_on_off = (uint8_t) av->assoc_value; 2762 SCTP_TCB_UNLOCK(stcb); 2763 } else { 2764 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); 2765 error = ENOTCONN; 2766 } --- 942 unchanged lines hidden (view full) --- 3709 new_min = srto->srto_min; 3710 else 3711 new_min = stcb->asoc.minrto; 3712 if ((new_min <= new_init) && (new_init <= new_max)) { 3713 stcb->asoc.initial_rto = new_init; 3714 stcb->asoc.maxrto = new_max; 3715 stcb->asoc.minrto = new_min; 3716 } else { |
3702 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EDOM); 3703 error = EDOM; | 3717 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); 3718 error = EINVAL; |
3704 } 3705 SCTP_TCB_UNLOCK(stcb); 3706 } else { 3707 SCTP_INP_WLOCK(inp); 3708 if (srto->srto_initial) 3709 new_init = srto->srto_initial; 3710 else 3711 new_init = inp->sctp_ep.initial_rto; --- 5 unchanged lines hidden (view full) --- 3717 new_min = srto->srto_min; 3718 else 3719 new_min = inp->sctp_ep.sctp_minrto; 3720 if ((new_min <= new_init) && (new_init <= new_max)) { 3721 inp->sctp_ep.initial_rto = new_init; 3722 inp->sctp_ep.sctp_maxrto = new_max; 3723 inp->sctp_ep.sctp_minrto = new_min; 3724 } else { | 3719 } 3720 SCTP_TCB_UNLOCK(stcb); 3721 } else { 3722 SCTP_INP_WLOCK(inp); 3723 if (srto->srto_initial) 3724 new_init = srto->srto_initial; 3725 else 3726 new_init = inp->sctp_ep.initial_rto; --- 5 unchanged lines hidden (view full) --- 3732 new_min = srto->srto_min; 3733 else 3734 new_min = inp->sctp_ep.sctp_minrto; 3735 if ((new_min <= new_init) && (new_init <= new_max)) { 3736 inp->sctp_ep.initial_rto = new_init; 3737 inp->sctp_ep.sctp_maxrto = new_max; 3738 inp->sctp_ep.sctp_minrto = new_min; 3739 } else { |
3725 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EDOM); 3726 error = EDOM; | 3740 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); 3741 error = EINVAL; |
3727 } 3728 SCTP_INP_WUNLOCK(inp); 3729 } 3730 } 3731 break; 3732 case SCTP_ASSOCINFO: 3733 { 3734 struct sctp_assocparams *sasoc; --- 450 unchanged lines hidden (view full) --- 4185 inp = (struct sctp_inpcb *)so->so_pcb; 4186 if (inp == 0) { 4187 /* I made the same as TCP since we are not setup? */ 4188 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); 4189 return (ECONNRESET); 4190 } 4191 SCTP_INP_RLOCK(inp); 4192#ifdef SCTP_LOCK_LOGGING | 3742 } 3743 SCTP_INP_WUNLOCK(inp); 3744 } 3745 } 3746 break; 3747 case SCTP_ASSOCINFO: 3748 { 3749 struct sctp_assocparams *sasoc; --- 450 unchanged lines hidden (view full) --- 4200 inp = (struct sctp_inpcb *)so->so_pcb; 4201 if (inp == 0) { 4202 /* I made the same as TCP since we are not setup? */ 4203 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); 4204 return (ECONNRESET); 4205 } 4206 SCTP_INP_RLOCK(inp); 4207#ifdef SCTP_LOCK_LOGGING |
4193 if (sctp_logging_level & SCTP_LOCK_LOGGING_ENABLE) { | 4208 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) { |
4194 sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK); 4195 } 4196#endif 4197 SOCK_LOCK(so); 4198 error = solisten_proto_check(so); 4199 if (error) { 4200 SOCK_UNLOCK(so); 4201 SCTP_INP_RUNLOCK(inp); --- 325 unchanged lines hidden --- | 4209 sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK); 4210 } 4211#endif 4212 SOCK_LOCK(so); 4213 error = solisten_proto_check(so); 4214 if (error) { 4215 SOCK_UNLOCK(so); 4216 SCTP_INP_RUNLOCK(inp); --- 325 unchanged lines hidden --- |