10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51676Sjpk * Common Development and Distribution License (the "License"). 61676Sjpk * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211735Skcpoon 220Sstevel@tonic-gate /* 2310212SGeorge.Shepherd@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #include <sys/types.h> 280Sstevel@tonic-gate #include <sys/systm.h> 290Sstevel@tonic-gate #include <sys/stream.h> 300Sstevel@tonic-gate #include <sys/cmn_err.h> 310Sstevel@tonic-gate #include <sys/strsubr.h> 320Sstevel@tonic-gate #include <sys/strsun.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <netinet/in.h> 350Sstevel@tonic-gate #include <netinet/ip6.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate #include <inet/common.h> 380Sstevel@tonic-gate #include <inet/ip.h> 390Sstevel@tonic-gate #include <inet/mib2.h> 400Sstevel@tonic-gate #include <inet/ipclassifier.h> 410Sstevel@tonic-gate #include "sctp_impl.h" 420Sstevel@tonic-gate #include "sctp_asconf.h" 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* Timer block states. */ 450Sstevel@tonic-gate typedef enum { 460Sstevel@tonic-gate SCTP_TB_RUNNING = 1, 470Sstevel@tonic-gate SCTP_TB_IDLE, 480Sstevel@tonic-gate /* Could not stop/free before mblk got queued */ 490Sstevel@tonic-gate SCTP_TB_RESCHED, /* sctp_tb_time_left contains tick count */ 500Sstevel@tonic-gate SCTP_TB_CANCELLED, 510Sstevel@tonic-gate SCTP_TB_TO_BE_FREED 520Sstevel@tonic-gate } timer_block_state; 530Sstevel@tonic-gate 540Sstevel@tonic-gate typedef struct sctp_tb_s { 550Sstevel@tonic-gate timer_block_state sctp_tb_state; 560Sstevel@tonic-gate timeout_id_t sctp_tb_tid; 570Sstevel@tonic-gate mblk_t *sctp_tb_mp; 580Sstevel@tonic-gate clock_t sctp_tb_time_left; 590Sstevel@tonic-gate } sctp_tb_t; 600Sstevel@tonic-gate 610Sstevel@tonic-gate static void sctp_timer_fire(sctp_tb_t *); 620Sstevel@tonic-gate 630Sstevel@tonic-gate /* 640Sstevel@tonic-gate * sctp_timer mechanism. 650Sstevel@tonic-gate * 660Sstevel@tonic-gate * Each timer is represented by a timer mblk. When the 670Sstevel@tonic-gate * timer fires, and the sctp_t is busy, the timer mblk will be put on 680Sstevel@tonic-gate * the associated sctp_t timer queue so that it can be executed when 690Sstevel@tonic-gate * the thread holding the lock on the sctp_t is done with its job. 700Sstevel@tonic-gate * 710Sstevel@tonic-gate * Note that there is no lock to protect the timer mblk state. The reason 720Sstevel@tonic-gate * is that the timer state can only be changed by a thread holding the 730Sstevel@tonic-gate * lock on the sctp_t. 740Sstevel@tonic-gate * 750Sstevel@tonic-gate * The interface consists of 4 entry points: 760Sstevel@tonic-gate * sctp_timer_alloc - create a timer mblk 770Sstevel@tonic-gate * sctp_timer_free - free a timer mblk 780Sstevel@tonic-gate * sctp_timer - start, restart, stop the timer 790Sstevel@tonic-gate * sctp_timer_valid - called by sctp_process_recvq to verify that 800Sstevel@tonic-gate * the timer did indeed fire. 810Sstevel@tonic-gate */ 820Sstevel@tonic-gate 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * Start, restart, stop the timer. 860Sstevel@tonic-gate * If "tim" is -1 the timer is stopped. 870Sstevel@tonic-gate * Otherwise, the timer is stopped if it is already running, and 880Sstevel@tonic-gate * set to fire tim clock ticks from now. 890Sstevel@tonic-gate */ 900Sstevel@tonic-gate void 910Sstevel@tonic-gate sctp_timer(sctp_t *sctp, mblk_t *mp, clock_t tim) 920Sstevel@tonic-gate { 930Sstevel@tonic-gate sctp_tb_t *sctp_tb; 940Sstevel@tonic-gate int state; 950Sstevel@tonic-gate 960Sstevel@tonic-gate ASSERT(sctp != NULL && mp != NULL); 970Sstevel@tonic-gate ASSERT((mp->b_rptr - mp->b_datap->db_base) == sizeof (sctp_tb_t)); 980Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 990Sstevel@tonic-gate 1000Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)mp->b_datap->db_base; 1010Sstevel@tonic-gate if (tim >= 0) { 1020Sstevel@tonic-gate state = sctp_tb->sctp_tb_state; 1030Sstevel@tonic-gate sctp_tb->sctp_tb_time_left = tim; 1040Sstevel@tonic-gate if (state == SCTP_TB_RUNNING) { 1050Sstevel@tonic-gate if (untimeout(sctp_tb->sctp_tb_tid) < 0) { 1060Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_RESCHED; 1070Sstevel@tonic-gate /* sctp_timer_valid will start timer */ 1080Sstevel@tonic-gate return; 1090Sstevel@tonic-gate } 1100Sstevel@tonic-gate } else if (state != SCTP_TB_IDLE) { 1110Sstevel@tonic-gate ASSERT(state != SCTP_TB_TO_BE_FREED); 1120Sstevel@tonic-gate if (state == SCTP_TB_CANCELLED) { 1130Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_RESCHED; 1140Sstevel@tonic-gate /* sctp_timer_valid will start timer */ 1150Sstevel@tonic-gate return; 1160Sstevel@tonic-gate } 1170Sstevel@tonic-gate if (state == SCTP_TB_RESCHED) { 1180Sstevel@tonic-gate /* sctp_timer_valid will start timer */ 1190Sstevel@tonic-gate return; 1200Sstevel@tonic-gate } 1210Sstevel@tonic-gate } else { 1220Sstevel@tonic-gate SCTP_REFHOLD(sctp); 1230Sstevel@tonic-gate } 1240Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_RUNNING; 1250Sstevel@tonic-gate sctp_tb->sctp_tb_tid = 1260Sstevel@tonic-gate timeout((pfv_t)sctp_timer_fire, sctp_tb, tim); 1270Sstevel@tonic-gate return; 1280Sstevel@tonic-gate } 1290Sstevel@tonic-gate switch (tim) { 1300Sstevel@tonic-gate case -1: 1310Sstevel@tonic-gate sctp_timer_stop(mp); 1320Sstevel@tonic-gate break; 1330Sstevel@tonic-gate default: 1340Sstevel@tonic-gate ASSERT(0); 1350Sstevel@tonic-gate break; 1360Sstevel@tonic-gate } 1370Sstevel@tonic-gate } 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate /* 1400Sstevel@tonic-gate * sctp_timer_alloc is called by sctp_init to allocate and initialize a 1410Sstevel@tonic-gate * sctp timer. 1420Sstevel@tonic-gate * 1430Sstevel@tonic-gate * Allocate an M_PCSIG timer message. The space between db_base and 1440Sstevel@tonic-gate * b_rptr is used by the sctp_timer mechanism, and after b_rptr there is 1450Sstevel@tonic-gate * space for sctpt_t. 1460Sstevel@tonic-gate */ 1470Sstevel@tonic-gate mblk_t * 1484691Skcpoon sctp_timer_alloc(sctp_t *sctp, pfv_t func, int sleep) 1490Sstevel@tonic-gate { 1500Sstevel@tonic-gate mblk_t *mp; 1510Sstevel@tonic-gate sctp_tb_t *sctp_tb; 1520Sstevel@tonic-gate sctpt_t *sctpt; 1533448Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps; 1540Sstevel@tonic-gate 1554691Skcpoon if (sleep == KM_SLEEP) { 1564691Skcpoon mp = allocb_wait(sizeof (sctp_t) + sizeof (sctp_tb_t), BPRI_HI, 1574691Skcpoon STR_NOSIG, NULL); 1584691Skcpoon } else { 1594691Skcpoon mp = allocb(sizeof (sctp_t) + sizeof (sctp_tb_t), BPRI_HI); 1604691Skcpoon } 1614691Skcpoon if (mp != NULL) { 1620Sstevel@tonic-gate mp->b_datap->db_type = M_PCSIG; 1630Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)mp->b_datap->db_base; 1640Sstevel@tonic-gate mp->b_rptr = (uchar_t *)&sctp_tb[1]; 1650Sstevel@tonic-gate mp->b_wptr = mp->b_rptr + sizeof (sctpt_t); 1660Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_IDLE; 1670Sstevel@tonic-gate sctp_tb->sctp_tb_mp = mp; 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 1700Sstevel@tonic-gate sctpt->sctpt_sctp = sctp; 1710Sstevel@tonic-gate sctpt->sctpt_faddr = NULL; /* set when starting timer */ 1720Sstevel@tonic-gate sctpt->sctpt_pfv = func; 1730Sstevel@tonic-gate return (mp); 1740Sstevel@tonic-gate } 1753448Sdh155122 SCTP_KSTAT(sctps, sctp_add_timer); 1760Sstevel@tonic-gate return (NULL); 1770Sstevel@tonic-gate } 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate /* 1800Sstevel@tonic-gate * timeout() callback function. 1810Sstevel@tonic-gate * Put the message on the process control block's queue. 1820Sstevel@tonic-gate * If the timer is stopped or freed after 1830Sstevel@tonic-gate * it has fired then sctp_timer() and sctp_timer_valid() will clean 1840Sstevel@tonic-gate * things up. 1850Sstevel@tonic-gate */ 1860Sstevel@tonic-gate static void 1870Sstevel@tonic-gate sctp_timer_fire(sctp_tb_t *sctp_tb) 1880Sstevel@tonic-gate { 1890Sstevel@tonic-gate mblk_t *mp; 1900Sstevel@tonic-gate sctp_t *sctp; 1910Sstevel@tonic-gate sctpt_t *sctpt; 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate mp = sctp_tb->sctp_tb_mp; 1940Sstevel@tonic-gate ASSERT(sctp_tb == (sctp_tb_t *)mp->b_datap->db_base); 1950Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 1980Sstevel@tonic-gate sctp = sctpt->sctpt_sctp; 1990Sstevel@tonic-gate ASSERT(sctp != NULL); 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate mutex_enter(&sctp->sctp_lock); 2020Sstevel@tonic-gate if (sctp->sctp_running) { 2030Sstevel@tonic-gate /* 2040Sstevel@tonic-gate * Put the timer mblk to the special sctp_timer_mp list. 2050Sstevel@tonic-gate * This timer will be handled when the thread using this 2060Sstevel@tonic-gate * SCTP is done with its job. 2070Sstevel@tonic-gate */ 2080Sstevel@tonic-gate if (sctp->sctp_timer_mp == NULL) { 2090Sstevel@tonic-gate SCTP_REFHOLD(sctp); 2100Sstevel@tonic-gate sctp->sctp_timer_mp = mp; 2110Sstevel@tonic-gate } else { 2120Sstevel@tonic-gate linkb(sctp->sctp_timer_mp, mp); 2130Sstevel@tonic-gate } 2140Sstevel@tonic-gate mp->b_cont = NULL; 2150Sstevel@tonic-gate mutex_exit(&sctp->sctp_lock); 2160Sstevel@tonic-gate } else { 2170Sstevel@tonic-gate sctp->sctp_running = B_TRUE; 2180Sstevel@tonic-gate mutex_exit(&sctp->sctp_lock); 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate sctp_timer_call(sctp, mp); 2210Sstevel@tonic-gate WAKE_SCTP(sctp); 2220Sstevel@tonic-gate } 2230Sstevel@tonic-gate SCTP_REFRELE(sctp); 2240Sstevel@tonic-gate } 2250Sstevel@tonic-gate 2260Sstevel@tonic-gate /* 2270Sstevel@tonic-gate * Logically free a timer mblk (that might have a pending timeout().) 2280Sstevel@tonic-gate * If the timer has fired and the mblk has been put on the queue then 2290Sstevel@tonic-gate * sctp_timer_valid will free the mblk. 2300Sstevel@tonic-gate */ 2310Sstevel@tonic-gate void 2320Sstevel@tonic-gate sctp_timer_free(mblk_t *mp) 2330Sstevel@tonic-gate { 2340Sstevel@tonic-gate sctp_tb_t *sctp_tb; 2350Sstevel@tonic-gate int state; 2360Sstevel@tonic-gate sctpt_t *sctpt; 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate ASSERT(mp != NULL); 2390Sstevel@tonic-gate ASSERT((mp->b_rptr - mp->b_datap->db_base) == sizeof (sctp_tb_t)); 2400Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)mp->b_datap->db_base; 2430Sstevel@tonic-gate state = sctp_tb->sctp_tb_state; 2440Sstevel@tonic-gate 2451676Sjpk dprint(5, ("sctp_timer_free %p state %d\n", (void *)mp, state)); 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate if (state == SCTP_TB_RUNNING) { 2480Sstevel@tonic-gate if (untimeout(sctp_tb->sctp_tb_tid) < 0) { 2490Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_TO_BE_FREED; 2500Sstevel@tonic-gate /* sctp_timer_valid will free the mblk */ 2510Sstevel@tonic-gate return; 2520Sstevel@tonic-gate } 2530Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 2540Sstevel@tonic-gate SCTP_REFRELE(sctpt->sctpt_sctp); 2550Sstevel@tonic-gate } else if (state != SCTP_TB_IDLE) { 2560Sstevel@tonic-gate ASSERT(state != SCTP_TB_TO_BE_FREED); 2570Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_TO_BE_FREED; 2580Sstevel@tonic-gate /* sctp_timer_valid will free the mblk */ 2590Sstevel@tonic-gate return; 2600Sstevel@tonic-gate } 2610Sstevel@tonic-gate freeb(mp); 2620Sstevel@tonic-gate } 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate /* 2650Sstevel@tonic-gate * Called from sctp_timer(,,-1) 2660Sstevel@tonic-gate */ 2670Sstevel@tonic-gate void 2680Sstevel@tonic-gate sctp_timer_stop(mblk_t *mp) 2690Sstevel@tonic-gate { 2700Sstevel@tonic-gate sctp_tb_t *sctp_tb; 2710Sstevel@tonic-gate int state; 2720Sstevel@tonic-gate sctpt_t *sctpt; 2730Sstevel@tonic-gate 2740Sstevel@tonic-gate ASSERT(mp != NULL); 2750Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 2760Sstevel@tonic-gate 2770Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)mp->b_datap->db_base; 2780Sstevel@tonic-gate state = sctp_tb->sctp_tb_state; 2790Sstevel@tonic-gate 2801676Sjpk dprint(5, ("sctp_timer_stop %p %d\n", (void *)mp, state)); 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate if (state == SCTP_TB_RUNNING) { 2830Sstevel@tonic-gate if (untimeout(sctp_tb->sctp_tb_tid) < 0) { 2840Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_CANCELLED; 2850Sstevel@tonic-gate } else { 2860Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_IDLE; 2870Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 2880Sstevel@tonic-gate SCTP_REFRELE(sctpt->sctpt_sctp); 2890Sstevel@tonic-gate } 2900Sstevel@tonic-gate } else if (state == SCTP_TB_RESCHED) { 2910Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_CANCELLED; 2920Sstevel@tonic-gate } 2930Sstevel@tonic-gate } 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate /* 2960Sstevel@tonic-gate * The user of the sctp_timer mechanism is required to call 2970Sstevel@tonic-gate * sctp_timer_valid() for each M_PCSIG message processed in the 2980Sstevel@tonic-gate * service procedures. 2990Sstevel@tonic-gate * sctp_timer_valid will return "true" if the timer actually did fire. 3000Sstevel@tonic-gate */ 3010Sstevel@tonic-gate 3020Sstevel@tonic-gate static boolean_t 3030Sstevel@tonic-gate sctp_timer_valid(mblk_t *mp) 3040Sstevel@tonic-gate { 3050Sstevel@tonic-gate sctp_tb_t *sctp_tb; 3060Sstevel@tonic-gate int state; 3070Sstevel@tonic-gate sctpt_t *sctpt; 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate ASSERT(mp != NULL); 3100Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)DB_BASE(mp); 3130Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 3140Sstevel@tonic-gate state = sctp_tb->sctp_tb_state; 3150Sstevel@tonic-gate if (state != SCTP_TB_RUNNING) { 3160Sstevel@tonic-gate ASSERT(state != SCTP_TB_IDLE); 3170Sstevel@tonic-gate if (state == SCTP_TB_TO_BE_FREED) { 3180Sstevel@tonic-gate /* 3190Sstevel@tonic-gate * sctp_timer_free was called after the message 3200Sstevel@tonic-gate * was putq'ed. 3210Sstevel@tonic-gate */ 3220Sstevel@tonic-gate freeb(mp); 3230Sstevel@tonic-gate return (B_FALSE); 3240Sstevel@tonic-gate } 3250Sstevel@tonic-gate if (state == SCTP_TB_CANCELLED) { 3260Sstevel@tonic-gate /* The timer was stopped after the mblk was putq'ed */ 3270Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_IDLE; 3280Sstevel@tonic-gate return (B_FALSE); 3290Sstevel@tonic-gate } 3300Sstevel@tonic-gate if (state == SCTP_TB_RESCHED) { 3310Sstevel@tonic-gate /* 3320Sstevel@tonic-gate * The timer was stopped and then restarted after 3330Sstevel@tonic-gate * the mblk was putq'ed. 3340Sstevel@tonic-gate * sctp_tb_time_left contains the number of ticks that 3350Sstevel@tonic-gate * the timer was restarted with. 3360Sstevel@tonic-gate * The sctp will not be disapper between the time 3370Sstevel@tonic-gate * the sctpt_t is marked SCTP_TB_RESCHED and when 3380Sstevel@tonic-gate * we get here as sctp_add_recvq() does a refhold. 3390Sstevel@tonic-gate */ 3400Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_RUNNING; 3410Sstevel@tonic-gate sctp_tb->sctp_tb_tid = timeout((pfv_t)sctp_timer_fire, 3420Sstevel@tonic-gate sctp_tb, sctp_tb->sctp_tb_time_left); 3430Sstevel@tonic-gate SCTP_REFHOLD(sctpt->sctpt_sctp); 3440Sstevel@tonic-gate return (B_FALSE); 3450Sstevel@tonic-gate } 3460Sstevel@tonic-gate } 3470Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_IDLE; 3480Sstevel@tonic-gate return (B_TRUE); 3490Sstevel@tonic-gate } 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate /* 3520Sstevel@tonic-gate * The SCTP timer call. Calls sctp_timer_valid() to verify whether 3530Sstevel@tonic-gate * timer was cancelled or not. 3540Sstevel@tonic-gate */ 3550Sstevel@tonic-gate void 3560Sstevel@tonic-gate sctp_timer_call(sctp_t *sctp, mblk_t *mp) 3570Sstevel@tonic-gate { 3580Sstevel@tonic-gate sctpt_t *sctpt = (sctpt_t *)mp->b_rptr; 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate if (sctp_timer_valid(mp)) { 3610Sstevel@tonic-gate (*sctpt->sctpt_pfv)(sctp, sctpt->sctpt_faddr); 3620Sstevel@tonic-gate } 3630Sstevel@tonic-gate } 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate /* 3660Sstevel@tonic-gate * Delayed ack 3670Sstevel@tonic-gate */ 3680Sstevel@tonic-gate void 3690Sstevel@tonic-gate sctp_ack_timer(sctp_t *sctp) 3700Sstevel@tonic-gate { 3713448Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps; 3723448Sdh155122 3730Sstevel@tonic-gate sctp->sctp_ack_timer_running = 0; 3743448Sdh155122 sctp->sctp_sack_toggle = sctps->sctps_deferred_acks_max; 3753448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpOutAckDelayed); 3764964Skcpoon (void) sctp_sack(sctp, NULL); 3770Sstevel@tonic-gate } 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate /* 3800Sstevel@tonic-gate * Peer address heartbeat timer handler 3810Sstevel@tonic-gate */ 3820Sstevel@tonic-gate void 3830Sstevel@tonic-gate sctp_heartbeat_timer(sctp_t *sctp) 3840Sstevel@tonic-gate { 3850Sstevel@tonic-gate sctp_faddr_t *fp; 3860Sstevel@tonic-gate int64_t now; 3870Sstevel@tonic-gate int64_t earliest_expiry; 3880Sstevel@tonic-gate int cnt; 3893448Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps; 3900Sstevel@tonic-gate 3910Sstevel@tonic-gate if (sctp->sctp_strikes >= sctp->sctp_pa_max_rxt) { 3920Sstevel@tonic-gate /* 3930Sstevel@tonic-gate * If there is a peer address with no strikes, 3940Sstevel@tonic-gate * don't give up yet. If enough other peer 3950Sstevel@tonic-gate * address are down, we could otherwise fail 3960Sstevel@tonic-gate * the association prematurely. This is a 3970Sstevel@tonic-gate * byproduct of our aggressive probe approach 3980Sstevel@tonic-gate * when a heartbeat fails to connect. We may 3990Sstevel@tonic-gate * wish to revisit this... 4000Sstevel@tonic-gate */ 4010Sstevel@tonic-gate if (!sctp_is_a_faddr_clean(sctp)) { 4020Sstevel@tonic-gate /* time to give up */ 4033448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpAborted); 4043448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimHeartBeatDrop); 4050Sstevel@tonic-gate sctp_assoc_event(sctp, SCTP_COMM_LOST, 0, NULL); 4060Sstevel@tonic-gate sctp_clean_death(sctp, sctp->sctp_client_errno ? 4070Sstevel@tonic-gate sctp->sctp_client_errno : ETIMEDOUT); 4080Sstevel@tonic-gate return; 4090Sstevel@tonic-gate } 4100Sstevel@tonic-gate } 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate /* Only send heartbeats in the established state */ 4130Sstevel@tonic-gate if (sctp->sctp_state != SCTPS_ESTABLISHED) { 4140Sstevel@tonic-gate dprint(5, ("sctp_heartbeat_timer: not in ESTABLISHED\n")); 4150Sstevel@tonic-gate return; 4160Sstevel@tonic-gate } 4170Sstevel@tonic-gate 418*11066Srafael.vanoni@sun.com now = ddi_get_lbolt64(); 4190Sstevel@tonic-gate earliest_expiry = 0; 4203448Sdh155122 cnt = sctps->sctps_maxburst; 4210Sstevel@tonic-gate 4220Sstevel@tonic-gate /* 4230Sstevel@tonic-gate * Walk through all faddrs. Since the timer should run infrequently 4240Sstevel@tonic-gate * and the number of peer addresses should not be big, this should 4250Sstevel@tonic-gate * be OK. 4260Sstevel@tonic-gate */ 4270Sstevel@tonic-gate for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) { 4280Sstevel@tonic-gate /* 4294818Skcpoon * If the peer is unreachable because there is no available 43011042SErik.Nordmark@Sun.COM * source address, call sctp_get_dest() to see if it is 4314818Skcpoon * reachable now. If it is OK, the state will become 4324818Skcpoon * unconfirmed. And the following code to handle unconfirmed 4334818Skcpoon * address will be executed. If it is still not OK, 4344818Skcpoon * re-schedule. If heartbeat is enabled, only try this 4354818Skcpoon * up to the normal heartbeat max times. But if heartbeat 4364818Skcpoon * is disable, this retry may go on forever. 4370Sstevel@tonic-gate */ 4384818Skcpoon if (fp->state == SCTP_FADDRS_UNREACH) { 43911042SErik.Nordmark@Sun.COM sctp_get_dest(sctp, fp); 4404818Skcpoon if (fp->state == SCTP_FADDRS_UNREACH) { 4414818Skcpoon if (fp->hb_enabled && 4424818Skcpoon ++fp->strikes > fp->max_retr && 4434818Skcpoon sctp_faddr_dead(sctp, fp, 4444818Skcpoon SCTP_FADDRS_DOWN) == -1) { 4454818Skcpoon /* Assoc is dead */ 4464818Skcpoon return; 4474818Skcpoon } 4484818Skcpoon fp->hb_expiry = now + SET_HB_INTVL(fp); 4494818Skcpoon goto set_expiry; 4504818Skcpoon } else { 4514818Skcpoon /* Send a heartbeat immediately. */ 4524818Skcpoon fp->hb_expiry = now; 4534818Skcpoon } 4544818Skcpoon } 4554818Skcpoon /* 4564818Skcpoon * Don't send heartbeat to this address if it is not 4574818Skcpoon * hb_enabled and the address has been confirmed. 4584818Skcpoon */ 4594818Skcpoon if (!fp->hb_enabled && fp->state != SCTP_FADDRS_UNCONFIRMED) { 4600Sstevel@tonic-gate continue; 4610Sstevel@tonic-gate } 4620Sstevel@tonic-gate 4630Sstevel@tonic-gate /* 4640Sstevel@tonic-gate * The heartbeat timer is expired. If the address is dead, 4650Sstevel@tonic-gate * we still send heartbeat to it in case it becomes alive 4664818Skcpoon * again. But we will only send once in a while, calculated 4674818Skcpoon * by SET_HB_INTVL(). 4680Sstevel@tonic-gate * 4690Sstevel@tonic-gate * If the address is alive and there is a hearbeat pending, 4700Sstevel@tonic-gate * resend the heartbeat and start exponential backoff on the 4710Sstevel@tonic-gate * heartbeat timeout value. If there is no heartbeat pending, 4720Sstevel@tonic-gate * just send out one. 4730Sstevel@tonic-gate */ 4740Sstevel@tonic-gate if (now >= fp->hb_expiry) { 4750Sstevel@tonic-gate if (fp->hb_pending) { 4760Sstevel@tonic-gate /* 4770Sstevel@tonic-gate * If an address is not confirmed, no need 4780Sstevel@tonic-gate * to bump the overall counter as it doesn't 4790Sstevel@tonic-gate * matter as we will not use it to send data 4800Sstevel@tonic-gate * and it should not affect the association. 4810Sstevel@tonic-gate */ 4820Sstevel@tonic-gate switch (fp->state) { 4830Sstevel@tonic-gate case SCTP_FADDRS_ALIVE: 4840Sstevel@tonic-gate sctp->sctp_strikes++; 4850Sstevel@tonic-gate /* FALLTHRU */ 4860Sstevel@tonic-gate case SCTP_FADDRS_UNCONFIRMED: 4870Sstevel@tonic-gate /* 4880Sstevel@tonic-gate * Retransmission implies that RTO 4890Sstevel@tonic-gate * is probably not correct. 4900Sstevel@tonic-gate */ 4910Sstevel@tonic-gate fp->rtt_updates = 0; 4920Sstevel@tonic-gate fp->strikes++; 4930Sstevel@tonic-gate if (fp->strikes > fp->max_retr) { 4940Sstevel@tonic-gate if (sctp_faddr_dead(sctp, fp, 4950Sstevel@tonic-gate SCTP_FADDRS_DOWN) == -1) { 4960Sstevel@tonic-gate /* Assoc is dead */ 4970Sstevel@tonic-gate return; 4980Sstevel@tonic-gate } 4990Sstevel@tonic-gate /* 5000Sstevel@tonic-gate * Addr is down; keep initial 5010Sstevel@tonic-gate * RTO 5020Sstevel@tonic-gate */ 5030Sstevel@tonic-gate fp->rto = 5040Sstevel@tonic-gate sctp->sctp_rto_initial; 5050Sstevel@tonic-gate goto dead_addr; 5060Sstevel@tonic-gate } else { 50710212SGeorge.Shepherd@Sun.COM SCTP_CALC_RXT(sctp, fp); 5080Sstevel@tonic-gate fp->hb_expiry = now + fp->rto; 5090Sstevel@tonic-gate } 5100Sstevel@tonic-gate break; 5110Sstevel@tonic-gate case SCTP_FADDRS_DOWN: 5120Sstevel@tonic-gate dead_addr: 5130Sstevel@tonic-gate fp->hb_expiry = now + SET_HB_INTVL(fp); 5140Sstevel@tonic-gate break; 5150Sstevel@tonic-gate default: 5160Sstevel@tonic-gate continue; 5170Sstevel@tonic-gate } 5180Sstevel@tonic-gate } else { 5194818Skcpoon /* 5204818Skcpoon * If there is unack'ed data, no need to 5214818Skcpoon * send a heart beat. 5224818Skcpoon */ 5234818Skcpoon if (fp->suna > 0) { 5244818Skcpoon fp->hb_expiry = now + SET_HB_INTVL(fp); 5254818Skcpoon goto set_expiry; 5264818Skcpoon } else { 5274818Skcpoon fp->hb_expiry = now + fp->rto; 5284818Skcpoon } 5290Sstevel@tonic-gate } 5300Sstevel@tonic-gate /* 5310Sstevel@tonic-gate * Note that the total number of heartbeat we can send 5320Sstevel@tonic-gate * out simultaneously is limited by sctp_maxburst. If 5330Sstevel@tonic-gate * the limit is exceeded, we need to wait for the next 5340Sstevel@tonic-gate * timeout to send them. This should only happen if 5350Sstevel@tonic-gate * there is unconfirmed address. Note that hb_pending 5360Sstevel@tonic-gate * is set in sctp_send_heartbeat(). So if a heartbeat 5370Sstevel@tonic-gate * is not sent, it will not affect the state of the 5380Sstevel@tonic-gate * peer address. 5390Sstevel@tonic-gate */ 5400Sstevel@tonic-gate if (fp->state != SCTP_FADDRS_UNCONFIRMED || cnt-- > 0) 5410Sstevel@tonic-gate sctp_send_heartbeat(sctp, fp); 5420Sstevel@tonic-gate } 5434818Skcpoon set_expiry: 5440Sstevel@tonic-gate if (fp->hb_expiry < earliest_expiry || earliest_expiry == 0) 5450Sstevel@tonic-gate earliest_expiry = fp->hb_expiry; 5460Sstevel@tonic-gate } 5470Sstevel@tonic-gate if (sctp->sctp_autoclose != 0) { 5480Sstevel@tonic-gate int64_t expire; 5490Sstevel@tonic-gate 5500Sstevel@tonic-gate expire = sctp->sctp_active + sctp->sctp_autoclose; 5510Sstevel@tonic-gate 5520Sstevel@tonic-gate if (expire <= now) { 5530Sstevel@tonic-gate dprint(3, ("sctp_heartbeat_timer: autoclosing\n")); 5540Sstevel@tonic-gate sctp_send_shutdown(sctp, 0); 5550Sstevel@tonic-gate return; 5560Sstevel@tonic-gate } 5570Sstevel@tonic-gate if (expire < earliest_expiry || earliest_expiry == 0) 5580Sstevel@tonic-gate earliest_expiry = expire; 5590Sstevel@tonic-gate } 5600Sstevel@tonic-gate 5610Sstevel@tonic-gate earliest_expiry -= now; 5620Sstevel@tonic-gate if (earliest_expiry < 0) 5630Sstevel@tonic-gate earliest_expiry = 1; 5640Sstevel@tonic-gate sctp_timer(sctp, sctp->sctp_heartbeat_mp, earliest_expiry); 5650Sstevel@tonic-gate } 5660Sstevel@tonic-gate 5670Sstevel@tonic-gate void 5680Sstevel@tonic-gate sctp_rexmit_timer(sctp_t *sctp, sctp_faddr_t *fp) 5690Sstevel@tonic-gate { 5700Sstevel@tonic-gate mblk_t *mp; 5713448Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps; 5720Sstevel@tonic-gate 5730Sstevel@tonic-gate ASSERT(fp != NULL); 5740Sstevel@tonic-gate 5750Sstevel@tonic-gate dprint(3, ("sctp_timer: faddr=%x:%x:%x:%x\n", 5760Sstevel@tonic-gate SCTP_PRINTADDR(fp->faddr))); 5770Sstevel@tonic-gate 5780Sstevel@tonic-gate fp->timer_running = 0; 5790Sstevel@tonic-gate 5800Sstevel@tonic-gate /* Check is we've reached the max for retries */ 5810Sstevel@tonic-gate if (sctp->sctp_state < SCTPS_ESTABLISHED) { 5820Sstevel@tonic-gate if (fp->strikes >= sctp->sctp_max_init_rxt) { 5830Sstevel@tonic-gate /* time to give up */ 5843448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpAborted); 5853448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetransDrop); 5860Sstevel@tonic-gate sctp_assoc_event(sctp, SCTP_CANT_STR_ASSOC, 0, NULL); 5870Sstevel@tonic-gate sctp_clean_death(sctp, sctp->sctp_client_errno ? 5880Sstevel@tonic-gate sctp->sctp_client_errno : ETIMEDOUT); 5890Sstevel@tonic-gate return; 5900Sstevel@tonic-gate } 5910Sstevel@tonic-gate } else if (sctp->sctp_state >= SCTPS_ESTABLISHED) { 5920Sstevel@tonic-gate if (sctp->sctp_strikes >= sctp->sctp_pa_max_rxt) { 5930Sstevel@tonic-gate /* time to give up */ 5943448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpAborted); 5953448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetransDrop); 5960Sstevel@tonic-gate sctp_assoc_event(sctp, SCTP_COMM_LOST, 0, NULL); 5970Sstevel@tonic-gate sctp_clean_death(sctp, sctp->sctp_client_errno ? 5980Sstevel@tonic-gate sctp->sctp_client_errno : ETIMEDOUT); 5990Sstevel@tonic-gate return; 6000Sstevel@tonic-gate } 6010Sstevel@tonic-gate } 6020Sstevel@tonic-gate 6030Sstevel@tonic-gate if (fp->strikes >= fp->max_retr) { 6040Sstevel@tonic-gate if (sctp_faddr_dead(sctp, fp, SCTP_FADDRS_DOWN) == -1) { 6050Sstevel@tonic-gate return; 6060Sstevel@tonic-gate } 6070Sstevel@tonic-gate } 6080Sstevel@tonic-gate 6090Sstevel@tonic-gate switch (sctp->sctp_state) { 6104818Skcpoon case SCTPS_SHUTDOWN_RECEIVED: 6114818Skcpoon (void) sctp_shutdown_received(sctp, NULL, B_FALSE, B_TRUE, 6124818Skcpoon NULL); 6130Sstevel@tonic-gate 6140Sstevel@tonic-gate /* FALLTHRU */ 6154818Skcpoon case SCTPS_ESTABLISHED: 6160Sstevel@tonic-gate case SCTPS_SHUTDOWN_PENDING: 6170Sstevel@tonic-gate if (sctp->sctp_xmit_head == NULL && 6180Sstevel@tonic-gate sctp->sctp_xmit_unsent == NULL) { 6190Sstevel@tonic-gate /* Nothing to retransmit */ 6200Sstevel@tonic-gate if (sctp->sctp_state == SCTPS_SHUTDOWN_PENDING) { 6210Sstevel@tonic-gate sctp_send_shutdown(sctp, 1); 6220Sstevel@tonic-gate } 6230Sstevel@tonic-gate return; 6240Sstevel@tonic-gate } 6250Sstevel@tonic-gate 6263448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6270Sstevel@tonic-gate 6280Sstevel@tonic-gate sctp_rexmit(sctp, fp); 6290Sstevel@tonic-gate /* 6300Sstevel@tonic-gate * sctp_rexmit() will increase the strikes and restart the 6310Sstevel@tonic-gate * timer, so return here. 6320Sstevel@tonic-gate */ 6330Sstevel@tonic-gate return; 6340Sstevel@tonic-gate case SCTPS_COOKIE_WAIT: 6350Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_T1expire); 6360Sstevel@tonic-gate rxmit_init: 6370Sstevel@tonic-gate /* retransmit init */ 638432Svi117747 /* 639432Svi117747 * We don't take the conn hash lock here since the source 640432Svi117747 * address list won't be modified (it would have been done 641432Svi117747 * the first time around). 642432Svi117747 */ 64311042SErik.Nordmark@Sun.COM mp = sctp_init_mp(sctp, fp); 6440Sstevel@tonic-gate if (mp != NULL) { 6453448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 64611042SErik.Nordmark@Sun.COM (void) conn_ip_output(mp, fp->ixa); 64711042SErik.Nordmark@Sun.COM BUMP_LOCAL(sctp->sctp_opkts); 6480Sstevel@tonic-gate } 6490Sstevel@tonic-gate break; 65011042SErik.Nordmark@Sun.COM case SCTPS_COOKIE_ECHOED: 6510Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_T1expire); 6520Sstevel@tonic-gate if (sctp->sctp_cookie_mp == NULL) { 6530Sstevel@tonic-gate sctp->sctp_state = SCTPS_COOKIE_WAIT; 6540Sstevel@tonic-gate goto rxmit_init; 6550Sstevel@tonic-gate } 6560Sstevel@tonic-gate mp = dupmsg(sctp->sctp_cookie_mp); 6570Sstevel@tonic-gate if (mp == NULL) 6580Sstevel@tonic-gate break; 65911042SErik.Nordmark@Sun.COM (void) conn_ip_output(mp, fp->ixa); 66011042SErik.Nordmark@Sun.COM BUMP_LOCAL(sctp->sctp_opkts); 6613448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6620Sstevel@tonic-gate break; 6630Sstevel@tonic-gate case SCTPS_SHUTDOWN_SENT: 6640Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_T2expire); 6650Sstevel@tonic-gate sctp_send_shutdown(sctp, 1); 6663448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6670Sstevel@tonic-gate break; 6680Sstevel@tonic-gate case SCTPS_SHUTDOWN_ACK_SENT: 6690Sstevel@tonic-gate /* We shouldn't have any more outstanding data */ 6700Sstevel@tonic-gate ASSERT(sctp->sctp_xmit_head == NULL); 6710Sstevel@tonic-gate ASSERT(sctp->sctp_xmit_unsent == NULL); 6720Sstevel@tonic-gate 6730Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_T2expire); 6741735Skcpoon (void) sctp_shutdown_received(sctp, NULL, B_FALSE, B_TRUE, 6751735Skcpoon NULL); 6763448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6770Sstevel@tonic-gate break; 6780Sstevel@tonic-gate default: 6790Sstevel@tonic-gate ASSERT(0); 6800Sstevel@tonic-gate break; 6810Sstevel@tonic-gate } 6820Sstevel@tonic-gate 6830Sstevel@tonic-gate fp->strikes++; 6840Sstevel@tonic-gate sctp->sctp_strikes++; 68510212SGeorge.Shepherd@Sun.COM SCTP_CALC_RXT(sctp, fp); 6860Sstevel@tonic-gate 6870Sstevel@tonic-gate SCTP_FADDR_TIMER_RESTART(sctp, fp, fp->rto); 6880Sstevel@tonic-gate } 6890Sstevel@tonic-gate 6900Sstevel@tonic-gate /* 6910Sstevel@tonic-gate * RTO calculation. timesent and now are both in ms. 6920Sstevel@tonic-gate */ 6930Sstevel@tonic-gate void 6940Sstevel@tonic-gate sctp_update_rtt(sctp_t *sctp, sctp_faddr_t *fp, clock_t delta) 6950Sstevel@tonic-gate { 6960Sstevel@tonic-gate int rtt; 6970Sstevel@tonic-gate 6980Sstevel@tonic-gate /* Calculate the RTT in ms */ 6990Sstevel@tonic-gate rtt = (int)delta; 7000Sstevel@tonic-gate rtt = rtt > 0 ? rtt : 1; 7010Sstevel@tonic-gate 7021676Sjpk dprint(5, ("sctp_update_rtt: fp = %p, rtt = %d\n", (void *)fp, rtt)); 7030Sstevel@tonic-gate 7040Sstevel@tonic-gate /* Is this the first RTT measurement? */ 7050Sstevel@tonic-gate if (fp->srtt == -1) { 7060Sstevel@tonic-gate fp->srtt = rtt; 7070Sstevel@tonic-gate fp->rttvar = rtt / 2; 7080Sstevel@tonic-gate fp->rto = 3 * rtt; /* == rtt + 4 * rttvar ( == rtt / 2) */ 7090Sstevel@tonic-gate } else { 7100Sstevel@tonic-gate int abs; 7110Sstevel@tonic-gate /* 7120Sstevel@tonic-gate * Versions of the RTO equations that use fixed-point math. 7130Sstevel@tonic-gate * alpha and beta are NOT tunable in this implementation, 7140Sstevel@tonic-gate * and so are hard-coded in. alpha = 1/8, beta = 1/4. 7150Sstevel@tonic-gate */ 7160Sstevel@tonic-gate abs = fp->srtt - rtt; 7170Sstevel@tonic-gate abs = abs >= 0 ? abs : -abs; 7180Sstevel@tonic-gate fp->rttvar = (3 * fp->rttvar + abs) >> 2; 7190Sstevel@tonic-gate fp->rttvar = fp->rttvar != 0 ? fp->rttvar : 1; 7200Sstevel@tonic-gate 7210Sstevel@tonic-gate fp->srtt = (7 * fp->srtt + rtt) >> 3; 7220Sstevel@tonic-gate fp->rto = fp->srtt + 4 * fp->rttvar; 7230Sstevel@tonic-gate } 7240Sstevel@tonic-gate 7250Sstevel@tonic-gate dprint(5, ("sctp_update_rtt: srtt = %d, rttvar = %d, rto = %d\n", 7260Sstevel@tonic-gate fp->srtt, fp->rttvar, fp->rto)); 7270Sstevel@tonic-gate 7280Sstevel@tonic-gate /* Bound the RTO by configured min and max values */ 7290Sstevel@tonic-gate if (fp->rto < sctp->sctp_rto_min) { 7300Sstevel@tonic-gate fp->rto = sctp->sctp_rto_min; 7310Sstevel@tonic-gate } 7320Sstevel@tonic-gate if (fp->rto > sctp->sctp_rto_max) { 7330Sstevel@tonic-gate fp->rto = sctp->sctp_rto_max; 7340Sstevel@tonic-gate } 7350Sstevel@tonic-gate 73610212SGeorge.Shepherd@Sun.COM SCTP_MAX_RTO(sctp, fp); 7370Sstevel@tonic-gate fp->rtt_updates++; 7380Sstevel@tonic-gate } 7390Sstevel@tonic-gate 7400Sstevel@tonic-gate void 7410Sstevel@tonic-gate sctp_free_faddr_timers(sctp_t *sctp) 7420Sstevel@tonic-gate { 7430Sstevel@tonic-gate sctp_faddr_t *fp; 7440Sstevel@tonic-gate 7450Sstevel@tonic-gate for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) { 7460Sstevel@tonic-gate if (fp->timer_mp != NULL) { 7470Sstevel@tonic-gate sctp_timer_free(fp->timer_mp); 7480Sstevel@tonic-gate fp->timer_mp = NULL; 7490Sstevel@tonic-gate fp->timer_running = 0; 7500Sstevel@tonic-gate } 7510Sstevel@tonic-gate if (fp->rc_timer_mp != NULL) { 7520Sstevel@tonic-gate sctp_timer_free(fp->rc_timer_mp); 7530Sstevel@tonic-gate fp->rc_timer_mp = NULL; 7540Sstevel@tonic-gate fp->rc_timer_running = 0; 7550Sstevel@tonic-gate } 7560Sstevel@tonic-gate } 7570Sstevel@tonic-gate } 7580Sstevel@tonic-gate 7590Sstevel@tonic-gate void 7600Sstevel@tonic-gate sctp_stop_faddr_timers(sctp_t *sctp) 7610Sstevel@tonic-gate { 7620Sstevel@tonic-gate sctp_faddr_t *fp; 7630Sstevel@tonic-gate 7640Sstevel@tonic-gate for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) { 7650Sstevel@tonic-gate SCTP_FADDR_TIMER_STOP(fp); 7660Sstevel@tonic-gate SCTP_FADDR_RC_TIMER_STOP(fp); 7670Sstevel@tonic-gate } 7680Sstevel@tonic-gate } 7690Sstevel@tonic-gate 7700Sstevel@tonic-gate void 7710Sstevel@tonic-gate sctp_process_timer(sctp_t *sctp) 7720Sstevel@tonic-gate { 7730Sstevel@tonic-gate mblk_t *mp; 7740Sstevel@tonic-gate 7750Sstevel@tonic-gate ASSERT(sctp->sctp_running); 7760Sstevel@tonic-gate ASSERT(MUTEX_HELD(&sctp->sctp_lock)); 7770Sstevel@tonic-gate while ((mp = sctp->sctp_timer_mp) != NULL) { 7780Sstevel@tonic-gate ASSERT(DB_TYPE(mp) == M_PCSIG); 7790Sstevel@tonic-gate /* 7800Sstevel@tonic-gate * Since the timer mblk can be freed in sctp_timer_call(), 7810Sstevel@tonic-gate * we need to grab the b_cont before that. 7820Sstevel@tonic-gate */ 7830Sstevel@tonic-gate sctp->sctp_timer_mp = mp->b_cont; 7840Sstevel@tonic-gate mp->b_cont = NULL; 7857444SGeorge.Shepherd@Sun.COM /* 7867444SGeorge.Shepherd@Sun.COM * We have a reference on the sctp, the lock must be 7877444SGeorge.Shepherd@Sun.COM * dropped to avoid deadlocks with functions potentially 7887444SGeorge.Shepherd@Sun.COM * called in this context which in turn call untimeout(). 7897444SGeorge.Shepherd@Sun.COM */ 7907444SGeorge.Shepherd@Sun.COM mutex_exit(&sctp->sctp_lock); 7910Sstevel@tonic-gate sctp_timer_call(sctp, mp); 7927444SGeorge.Shepherd@Sun.COM mutex_enter(&sctp->sctp_lock); 7930Sstevel@tonic-gate } 7940Sstevel@tonic-gate SCTP_REFRELE(sctp); 7950Sstevel@tonic-gate } 796