Deleted Added
sdiff udiff text old ( 179157 ) new ( 179783 )
full compact
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 $");
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
63 sctp_pcb_init();
64
65
66 if ((nmbclusters / 8) > SCTP_ASOC_MAX_CHUNKS_ON_QUEUE)
67 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));
73 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 */
80 sctp_recvspace = sctp_sendspace;
81
82}
83
84
85
86/*
87 * cleanup of the sctppcbinfo structure.
88 * Assumes that the sctppcbinfo lock is held.
89 */
90void
91sctp_pcbinfo_cleanup(void)
92{
93 /* 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);
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;
137 if (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? */
296 if (sctp_cmt_on_off && 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 }
524 error = SCTP_SORESERVE(so, sctp_sendspace, 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);
1677 if (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);
2743 if (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 {
3702 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EDOM);
3703 error = EDOM;
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 {
3725 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EDOM);
3726 error = EDOM;
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
4193 if (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 ---