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 /* 233430Skcpoon * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <sys/types.h> 300Sstevel@tonic-gate #include <sys/systm.h> 310Sstevel@tonic-gate #include <sys/stream.h> 320Sstevel@tonic-gate #include <sys/cmn_err.h> 330Sstevel@tonic-gate #include <sys/strsubr.h> 340Sstevel@tonic-gate #include <sys/strsun.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <netinet/in.h> 370Sstevel@tonic-gate #include <netinet/ip6.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include <inet/common.h> 400Sstevel@tonic-gate #include <inet/ip.h> 410Sstevel@tonic-gate #include <inet/mib2.h> 420Sstevel@tonic-gate #include <inet/ipclassifier.h> 430Sstevel@tonic-gate #include "sctp_impl.h" 440Sstevel@tonic-gate #include "sctp_asconf.h" 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* Timer block states. */ 470Sstevel@tonic-gate typedef enum { 480Sstevel@tonic-gate SCTP_TB_RUNNING = 1, 490Sstevel@tonic-gate SCTP_TB_IDLE, 500Sstevel@tonic-gate /* Could not stop/free before mblk got queued */ 510Sstevel@tonic-gate SCTP_TB_RESCHED, /* sctp_tb_time_left contains tick count */ 520Sstevel@tonic-gate SCTP_TB_CANCELLED, 530Sstevel@tonic-gate SCTP_TB_TO_BE_FREED 540Sstevel@tonic-gate } timer_block_state; 550Sstevel@tonic-gate 560Sstevel@tonic-gate typedef struct sctp_tb_s { 570Sstevel@tonic-gate timer_block_state sctp_tb_state; 580Sstevel@tonic-gate timeout_id_t sctp_tb_tid; 590Sstevel@tonic-gate mblk_t *sctp_tb_mp; 600Sstevel@tonic-gate clock_t sctp_tb_time_left; 610Sstevel@tonic-gate } sctp_tb_t; 620Sstevel@tonic-gate 630Sstevel@tonic-gate static void sctp_timer_fire(sctp_tb_t *); 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * sctp_timer mechanism. 670Sstevel@tonic-gate * 680Sstevel@tonic-gate * Each timer is represented by a timer mblk. When the 690Sstevel@tonic-gate * timer fires, and the sctp_t is busy, the timer mblk will be put on 700Sstevel@tonic-gate * the associated sctp_t timer queue so that it can be executed when 710Sstevel@tonic-gate * the thread holding the lock on the sctp_t is done with its job. 720Sstevel@tonic-gate * 730Sstevel@tonic-gate * Note that there is no lock to protect the timer mblk state. The reason 740Sstevel@tonic-gate * is that the timer state can only be changed by a thread holding the 750Sstevel@tonic-gate * lock on the sctp_t. 760Sstevel@tonic-gate * 770Sstevel@tonic-gate * The interface consists of 4 entry points: 780Sstevel@tonic-gate * sctp_timer_alloc - create a timer mblk 790Sstevel@tonic-gate * sctp_timer_free - free a timer mblk 800Sstevel@tonic-gate * sctp_timer - start, restart, stop the timer 810Sstevel@tonic-gate * sctp_timer_valid - called by sctp_process_recvq to verify that 820Sstevel@tonic-gate * the timer did indeed fire. 830Sstevel@tonic-gate */ 840Sstevel@tonic-gate 850Sstevel@tonic-gate 860Sstevel@tonic-gate /* 870Sstevel@tonic-gate * Start, restart, stop the timer. 880Sstevel@tonic-gate * If "tim" is -1 the timer is stopped. 890Sstevel@tonic-gate * Otherwise, the timer is stopped if it is already running, and 900Sstevel@tonic-gate * set to fire tim clock ticks from now. 910Sstevel@tonic-gate */ 920Sstevel@tonic-gate void 930Sstevel@tonic-gate sctp_timer(sctp_t *sctp, mblk_t *mp, clock_t tim) 940Sstevel@tonic-gate { 950Sstevel@tonic-gate sctp_tb_t *sctp_tb; 960Sstevel@tonic-gate int state; 970Sstevel@tonic-gate 980Sstevel@tonic-gate ASSERT(sctp != NULL && mp != NULL); 990Sstevel@tonic-gate ASSERT((mp->b_rptr - mp->b_datap->db_base) == sizeof (sctp_tb_t)); 1000Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)mp->b_datap->db_base; 1030Sstevel@tonic-gate if (tim >= 0) { 1040Sstevel@tonic-gate state = sctp_tb->sctp_tb_state; 1050Sstevel@tonic-gate sctp_tb->sctp_tb_time_left = tim; 1060Sstevel@tonic-gate if (state == SCTP_TB_RUNNING) { 1070Sstevel@tonic-gate if (untimeout(sctp_tb->sctp_tb_tid) < 0) { 1080Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_RESCHED; 1090Sstevel@tonic-gate /* sctp_timer_valid will start timer */ 1100Sstevel@tonic-gate return; 1110Sstevel@tonic-gate } 1120Sstevel@tonic-gate } else if (state != SCTP_TB_IDLE) { 1130Sstevel@tonic-gate ASSERT(state != SCTP_TB_TO_BE_FREED); 1140Sstevel@tonic-gate if (state == SCTP_TB_CANCELLED) { 1150Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_RESCHED; 1160Sstevel@tonic-gate /* sctp_timer_valid will start timer */ 1170Sstevel@tonic-gate return; 1180Sstevel@tonic-gate } 1190Sstevel@tonic-gate if (state == SCTP_TB_RESCHED) { 1200Sstevel@tonic-gate /* sctp_timer_valid will start timer */ 1210Sstevel@tonic-gate return; 1220Sstevel@tonic-gate } 1230Sstevel@tonic-gate } else { 1240Sstevel@tonic-gate SCTP_REFHOLD(sctp); 1250Sstevel@tonic-gate } 1260Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_RUNNING; 1270Sstevel@tonic-gate sctp_tb->sctp_tb_tid = 1280Sstevel@tonic-gate timeout((pfv_t)sctp_timer_fire, sctp_tb, tim); 1290Sstevel@tonic-gate return; 1300Sstevel@tonic-gate } 1310Sstevel@tonic-gate switch (tim) { 1320Sstevel@tonic-gate case -1: 1330Sstevel@tonic-gate sctp_timer_stop(mp); 1340Sstevel@tonic-gate break; 1350Sstevel@tonic-gate default: 1360Sstevel@tonic-gate ASSERT(0); 1370Sstevel@tonic-gate break; 1380Sstevel@tonic-gate } 1390Sstevel@tonic-gate } 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* 1420Sstevel@tonic-gate * sctp_timer_alloc is called by sctp_init to allocate and initialize a 1430Sstevel@tonic-gate * sctp timer. 1440Sstevel@tonic-gate * 1450Sstevel@tonic-gate * Allocate an M_PCSIG timer message. The space between db_base and 1460Sstevel@tonic-gate * b_rptr is used by the sctp_timer mechanism, and after b_rptr there is 1470Sstevel@tonic-gate * space for sctpt_t. 1480Sstevel@tonic-gate */ 1490Sstevel@tonic-gate mblk_t * 150*4691Skcpoon sctp_timer_alloc(sctp_t *sctp, pfv_t func, int sleep) 1510Sstevel@tonic-gate { 1520Sstevel@tonic-gate mblk_t *mp; 1530Sstevel@tonic-gate sctp_tb_t *sctp_tb; 1540Sstevel@tonic-gate sctpt_t *sctpt; 1553448Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps; 1560Sstevel@tonic-gate 157*4691Skcpoon if (sleep == KM_SLEEP) { 158*4691Skcpoon mp = allocb_wait(sizeof (sctp_t) + sizeof (sctp_tb_t), BPRI_HI, 159*4691Skcpoon STR_NOSIG, NULL); 160*4691Skcpoon } else { 161*4691Skcpoon mp = allocb(sizeof (sctp_t) + sizeof (sctp_tb_t), BPRI_HI); 162*4691Skcpoon } 163*4691Skcpoon if (mp != NULL) { 1640Sstevel@tonic-gate mp->b_datap->db_type = M_PCSIG; 1650Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)mp->b_datap->db_base; 1660Sstevel@tonic-gate mp->b_rptr = (uchar_t *)&sctp_tb[1]; 1670Sstevel@tonic-gate mp->b_wptr = mp->b_rptr + sizeof (sctpt_t); 1680Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_IDLE; 1690Sstevel@tonic-gate sctp_tb->sctp_tb_mp = mp; 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 1720Sstevel@tonic-gate sctpt->sctpt_sctp = sctp; 1730Sstevel@tonic-gate sctpt->sctpt_faddr = NULL; /* set when starting timer */ 1740Sstevel@tonic-gate sctpt->sctpt_pfv = func; 1750Sstevel@tonic-gate return (mp); 1760Sstevel@tonic-gate } 1773448Sdh155122 SCTP_KSTAT(sctps, sctp_add_timer); 1780Sstevel@tonic-gate return (NULL); 1790Sstevel@tonic-gate } 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate /* 1820Sstevel@tonic-gate * timeout() callback function. 1830Sstevel@tonic-gate * Put the message on the process control block's queue. 1840Sstevel@tonic-gate * If the timer is stopped or freed after 1850Sstevel@tonic-gate * it has fired then sctp_timer() and sctp_timer_valid() will clean 1860Sstevel@tonic-gate * things up. 1870Sstevel@tonic-gate */ 1880Sstevel@tonic-gate static void 1890Sstevel@tonic-gate sctp_timer_fire(sctp_tb_t *sctp_tb) 1900Sstevel@tonic-gate { 1910Sstevel@tonic-gate mblk_t *mp; 1920Sstevel@tonic-gate sctp_t *sctp; 1930Sstevel@tonic-gate sctpt_t *sctpt; 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate mp = sctp_tb->sctp_tb_mp; 1960Sstevel@tonic-gate ASSERT(sctp_tb == (sctp_tb_t *)mp->b_datap->db_base); 1970Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 2000Sstevel@tonic-gate sctp = sctpt->sctpt_sctp; 2010Sstevel@tonic-gate ASSERT(sctp != NULL); 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate mutex_enter(&sctp->sctp_lock); 2040Sstevel@tonic-gate if (sctp->sctp_running) { 2050Sstevel@tonic-gate /* 2060Sstevel@tonic-gate * Put the timer mblk to the special sctp_timer_mp list. 2070Sstevel@tonic-gate * This timer will be handled when the thread using this 2080Sstevel@tonic-gate * SCTP is done with its job. 2090Sstevel@tonic-gate */ 2100Sstevel@tonic-gate if (sctp->sctp_timer_mp == NULL) { 2110Sstevel@tonic-gate SCTP_REFHOLD(sctp); 2120Sstevel@tonic-gate sctp->sctp_timer_mp = mp; 2130Sstevel@tonic-gate } else { 2140Sstevel@tonic-gate linkb(sctp->sctp_timer_mp, mp); 2150Sstevel@tonic-gate } 2160Sstevel@tonic-gate mp->b_cont = NULL; 2170Sstevel@tonic-gate mutex_exit(&sctp->sctp_lock); 2180Sstevel@tonic-gate } else { 2190Sstevel@tonic-gate sctp->sctp_running = B_TRUE; 2200Sstevel@tonic-gate mutex_exit(&sctp->sctp_lock); 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate sctp_timer_call(sctp, mp); 2230Sstevel@tonic-gate WAKE_SCTP(sctp); 2240Sstevel@tonic-gate sctp_process_sendq(sctp); 2250Sstevel@tonic-gate } 2260Sstevel@tonic-gate SCTP_REFRELE(sctp); 2270Sstevel@tonic-gate } 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate /* 2300Sstevel@tonic-gate * Logically free a timer mblk (that might have a pending timeout().) 2310Sstevel@tonic-gate * If the timer has fired and the mblk has been put on the queue then 2320Sstevel@tonic-gate * sctp_timer_valid will free the mblk. 2330Sstevel@tonic-gate */ 2340Sstevel@tonic-gate void 2350Sstevel@tonic-gate sctp_timer_free(mblk_t *mp) 2360Sstevel@tonic-gate { 2370Sstevel@tonic-gate sctp_tb_t *sctp_tb; 2380Sstevel@tonic-gate int state; 2390Sstevel@tonic-gate sctpt_t *sctpt; 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate ASSERT(mp != NULL); 2420Sstevel@tonic-gate ASSERT((mp->b_rptr - mp->b_datap->db_base) == sizeof (sctp_tb_t)); 2430Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 2440Sstevel@tonic-gate 2450Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)mp->b_datap->db_base; 2460Sstevel@tonic-gate state = sctp_tb->sctp_tb_state; 2470Sstevel@tonic-gate 2481676Sjpk dprint(5, ("sctp_timer_free %p state %d\n", (void *)mp, state)); 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate if (state == SCTP_TB_RUNNING) { 2510Sstevel@tonic-gate if (untimeout(sctp_tb->sctp_tb_tid) < 0) { 2520Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_TO_BE_FREED; 2530Sstevel@tonic-gate /* sctp_timer_valid will free the mblk */ 2540Sstevel@tonic-gate return; 2550Sstevel@tonic-gate } 2560Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 2570Sstevel@tonic-gate SCTP_REFRELE(sctpt->sctpt_sctp); 2580Sstevel@tonic-gate } else if (state != SCTP_TB_IDLE) { 2590Sstevel@tonic-gate ASSERT(state != SCTP_TB_TO_BE_FREED); 2600Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_TO_BE_FREED; 2610Sstevel@tonic-gate /* sctp_timer_valid will free the mblk */ 2620Sstevel@tonic-gate return; 2630Sstevel@tonic-gate } 2640Sstevel@tonic-gate freeb(mp); 2650Sstevel@tonic-gate } 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate /* 2680Sstevel@tonic-gate * Called from sctp_timer(,,-1) 2690Sstevel@tonic-gate */ 2700Sstevel@tonic-gate void 2710Sstevel@tonic-gate sctp_timer_stop(mblk_t *mp) 2720Sstevel@tonic-gate { 2730Sstevel@tonic-gate sctp_tb_t *sctp_tb; 2740Sstevel@tonic-gate int state; 2750Sstevel@tonic-gate sctpt_t *sctpt; 2760Sstevel@tonic-gate 2770Sstevel@tonic-gate ASSERT(mp != NULL); 2780Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)mp->b_datap->db_base; 2810Sstevel@tonic-gate state = sctp_tb->sctp_tb_state; 2820Sstevel@tonic-gate 2831676Sjpk dprint(5, ("sctp_timer_stop %p %d\n", (void *)mp, state)); 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate if (state == SCTP_TB_RUNNING) { 2860Sstevel@tonic-gate if (untimeout(sctp_tb->sctp_tb_tid) < 0) { 2870Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_CANCELLED; 2880Sstevel@tonic-gate } else { 2890Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_IDLE; 2900Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 2910Sstevel@tonic-gate SCTP_REFRELE(sctpt->sctpt_sctp); 2920Sstevel@tonic-gate } 2930Sstevel@tonic-gate } else if (state == SCTP_TB_RESCHED) { 2940Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_CANCELLED; 2950Sstevel@tonic-gate } 2960Sstevel@tonic-gate } 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate /* 2990Sstevel@tonic-gate * The user of the sctp_timer mechanism is required to call 3000Sstevel@tonic-gate * sctp_timer_valid() for each M_PCSIG message processed in the 3010Sstevel@tonic-gate * service procedures. 3020Sstevel@tonic-gate * sctp_timer_valid will return "true" if the timer actually did fire. 3030Sstevel@tonic-gate */ 3040Sstevel@tonic-gate 3050Sstevel@tonic-gate static boolean_t 3060Sstevel@tonic-gate sctp_timer_valid(mblk_t *mp) 3070Sstevel@tonic-gate { 3080Sstevel@tonic-gate sctp_tb_t *sctp_tb; 3090Sstevel@tonic-gate int state; 3100Sstevel@tonic-gate sctpt_t *sctpt; 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate ASSERT(mp != NULL); 3130Sstevel@tonic-gate ASSERT(mp->b_datap->db_type == M_PCSIG); 3140Sstevel@tonic-gate 3150Sstevel@tonic-gate sctp_tb = (sctp_tb_t *)DB_BASE(mp); 3160Sstevel@tonic-gate sctpt = (sctpt_t *)mp->b_rptr; 3170Sstevel@tonic-gate state = sctp_tb->sctp_tb_state; 3180Sstevel@tonic-gate if (state != SCTP_TB_RUNNING) { 3190Sstevel@tonic-gate ASSERT(state != SCTP_TB_IDLE); 3200Sstevel@tonic-gate if (state == SCTP_TB_TO_BE_FREED) { 3210Sstevel@tonic-gate /* 3220Sstevel@tonic-gate * sctp_timer_free was called after the message 3230Sstevel@tonic-gate * was putq'ed. 3240Sstevel@tonic-gate */ 3250Sstevel@tonic-gate freeb(mp); 3260Sstevel@tonic-gate return (B_FALSE); 3270Sstevel@tonic-gate } 3280Sstevel@tonic-gate if (state == SCTP_TB_CANCELLED) { 3290Sstevel@tonic-gate /* The timer was stopped after the mblk was putq'ed */ 3300Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_IDLE; 3310Sstevel@tonic-gate return (B_FALSE); 3320Sstevel@tonic-gate } 3330Sstevel@tonic-gate if (state == SCTP_TB_RESCHED) { 3340Sstevel@tonic-gate /* 3350Sstevel@tonic-gate * The timer was stopped and then restarted after 3360Sstevel@tonic-gate * the mblk was putq'ed. 3370Sstevel@tonic-gate * sctp_tb_time_left contains the number of ticks that 3380Sstevel@tonic-gate * the timer was restarted with. 3390Sstevel@tonic-gate * The sctp will not be disapper between the time 3400Sstevel@tonic-gate * the sctpt_t is marked SCTP_TB_RESCHED and when 3410Sstevel@tonic-gate * we get here as sctp_add_recvq() does a refhold. 3420Sstevel@tonic-gate */ 3430Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_RUNNING; 3440Sstevel@tonic-gate sctp_tb->sctp_tb_tid = timeout((pfv_t)sctp_timer_fire, 3450Sstevel@tonic-gate sctp_tb, sctp_tb->sctp_tb_time_left); 3460Sstevel@tonic-gate SCTP_REFHOLD(sctpt->sctpt_sctp); 3470Sstevel@tonic-gate return (B_FALSE); 3480Sstevel@tonic-gate } 3490Sstevel@tonic-gate } 3500Sstevel@tonic-gate sctp_tb->sctp_tb_state = SCTP_TB_IDLE; 3510Sstevel@tonic-gate return (B_TRUE); 3520Sstevel@tonic-gate } 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate /* 3550Sstevel@tonic-gate * The SCTP timer call. Calls sctp_timer_valid() to verify whether 3560Sstevel@tonic-gate * timer was cancelled or not. 3570Sstevel@tonic-gate */ 3580Sstevel@tonic-gate void 3590Sstevel@tonic-gate sctp_timer_call(sctp_t *sctp, mblk_t *mp) 3600Sstevel@tonic-gate { 3610Sstevel@tonic-gate sctpt_t *sctpt = (sctpt_t *)mp->b_rptr; 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate if (sctp_timer_valid(mp)) { 3640Sstevel@tonic-gate (*sctpt->sctpt_pfv)(sctp, sctpt->sctpt_faddr); 3650Sstevel@tonic-gate } 3660Sstevel@tonic-gate } 3670Sstevel@tonic-gate 3680Sstevel@tonic-gate /* 3690Sstevel@tonic-gate * Delayed ack 3700Sstevel@tonic-gate */ 3710Sstevel@tonic-gate void 3720Sstevel@tonic-gate sctp_ack_timer(sctp_t *sctp) 3730Sstevel@tonic-gate { 3743448Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps; 3753448Sdh155122 3760Sstevel@tonic-gate sctp->sctp_ack_timer_running = 0; 3773448Sdh155122 sctp->sctp_sack_toggle = sctps->sctps_deferred_acks_max; 3783448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpOutAckDelayed); 3790Sstevel@tonic-gate sctp_sack(sctp, NULL); 3800Sstevel@tonic-gate } 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate /* 3830Sstevel@tonic-gate * Peer address heartbeat timer handler 3840Sstevel@tonic-gate */ 3850Sstevel@tonic-gate void 3860Sstevel@tonic-gate sctp_heartbeat_timer(sctp_t *sctp) 3870Sstevel@tonic-gate { 3880Sstevel@tonic-gate sctp_faddr_t *fp; 3890Sstevel@tonic-gate int64_t now; 3900Sstevel@tonic-gate int64_t earliest_expiry; 3910Sstevel@tonic-gate int cnt; 3923448Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps; 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate if (sctp->sctp_strikes >= sctp->sctp_pa_max_rxt) { 3950Sstevel@tonic-gate /* 3960Sstevel@tonic-gate * If there is a peer address with no strikes, 3970Sstevel@tonic-gate * don't give up yet. If enough other peer 3980Sstevel@tonic-gate * address are down, we could otherwise fail 3990Sstevel@tonic-gate * the association prematurely. This is a 4000Sstevel@tonic-gate * byproduct of our aggressive probe approach 4010Sstevel@tonic-gate * when a heartbeat fails to connect. We may 4020Sstevel@tonic-gate * wish to revisit this... 4030Sstevel@tonic-gate */ 4040Sstevel@tonic-gate if (!sctp_is_a_faddr_clean(sctp)) { 4050Sstevel@tonic-gate /* time to give up */ 4063448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpAborted); 4073448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimHeartBeatDrop); 4080Sstevel@tonic-gate sctp_assoc_event(sctp, SCTP_COMM_LOST, 0, NULL); 4090Sstevel@tonic-gate sctp_clean_death(sctp, sctp->sctp_client_errno ? 4100Sstevel@tonic-gate sctp->sctp_client_errno : ETIMEDOUT); 4110Sstevel@tonic-gate return; 4120Sstevel@tonic-gate } 4130Sstevel@tonic-gate } 4140Sstevel@tonic-gate 4150Sstevel@tonic-gate /* Only send heartbeats in the established state */ 4160Sstevel@tonic-gate if (sctp->sctp_state != SCTPS_ESTABLISHED) { 4170Sstevel@tonic-gate dprint(5, ("sctp_heartbeat_timer: not in ESTABLISHED\n")); 4180Sstevel@tonic-gate return; 4190Sstevel@tonic-gate } 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate now = lbolt64; 4220Sstevel@tonic-gate earliest_expiry = 0; 4233448Sdh155122 cnt = sctps->sctps_maxburst; 4240Sstevel@tonic-gate 4250Sstevel@tonic-gate /* 4260Sstevel@tonic-gate * Walk through all faddrs. Since the timer should run infrequently 4270Sstevel@tonic-gate * and the number of peer addresses should not be big, this should 4280Sstevel@tonic-gate * be OK. 4290Sstevel@tonic-gate */ 4300Sstevel@tonic-gate for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) { 4310Sstevel@tonic-gate /* 4320Sstevel@tonic-gate * Don't send heartbeat to this address if 4330Sstevel@tonic-gate * 1. it is not reachable OR 4340Sstevel@tonic-gate * 2. hb_interval == 0 and the address has been confirmed. 4350Sstevel@tonic-gate */ 4360Sstevel@tonic-gate if (fp->state == SCTP_FADDRS_UNREACH || 4370Sstevel@tonic-gate (fp->hb_interval == 0 && 4380Sstevel@tonic-gate fp->state != SCTP_FADDRS_UNCONFIRMED)) { 4390Sstevel@tonic-gate continue; 4400Sstevel@tonic-gate } 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate /* 4430Sstevel@tonic-gate * The heartbeat timer is expired. If the address is dead, 4440Sstevel@tonic-gate * we still send heartbeat to it in case it becomes alive 4450Sstevel@tonic-gate * again. But we will only send once every hb_interval. 4460Sstevel@tonic-gate * 4470Sstevel@tonic-gate * If the address is alive and there is a hearbeat pending, 4480Sstevel@tonic-gate * resend the heartbeat and start exponential backoff on the 4490Sstevel@tonic-gate * heartbeat timeout value. If there is no heartbeat pending, 4500Sstevel@tonic-gate * just send out one. 4510Sstevel@tonic-gate */ 4520Sstevel@tonic-gate if (now >= fp->hb_expiry) { 4530Sstevel@tonic-gate if (fp->hb_pending) { 4540Sstevel@tonic-gate /* 4550Sstevel@tonic-gate * If an address is not confirmed, no need 4560Sstevel@tonic-gate * to bump the overall counter as it doesn't 4570Sstevel@tonic-gate * matter as we will not use it to send data 4580Sstevel@tonic-gate * and it should not affect the association. 4590Sstevel@tonic-gate */ 4600Sstevel@tonic-gate switch (fp->state) { 4610Sstevel@tonic-gate case SCTP_FADDRS_ALIVE: 4620Sstevel@tonic-gate sctp->sctp_strikes++; 4630Sstevel@tonic-gate /* FALLTHRU */ 4640Sstevel@tonic-gate case SCTP_FADDRS_UNCONFIRMED: 4650Sstevel@tonic-gate /* 4660Sstevel@tonic-gate * Retransmission implies that RTO 4670Sstevel@tonic-gate * is probably not correct. 4680Sstevel@tonic-gate */ 4690Sstevel@tonic-gate fp->rtt_updates = 0; 4700Sstevel@tonic-gate fp->strikes++; 4710Sstevel@tonic-gate if (fp->strikes > fp->max_retr) { 4720Sstevel@tonic-gate if (sctp_faddr_dead(sctp, fp, 4730Sstevel@tonic-gate SCTP_FADDRS_DOWN) == -1) { 4740Sstevel@tonic-gate /* Assoc is dead */ 4750Sstevel@tonic-gate return; 4760Sstevel@tonic-gate } 4770Sstevel@tonic-gate /* 4780Sstevel@tonic-gate * Addr is down; keep initial 4790Sstevel@tonic-gate * RTO 4800Sstevel@tonic-gate */ 4810Sstevel@tonic-gate fp->rto = 4820Sstevel@tonic-gate sctp->sctp_rto_initial; 4830Sstevel@tonic-gate goto dead_addr; 4840Sstevel@tonic-gate } else { 4850Sstevel@tonic-gate SCTP_CALC_RXT(fp, 4860Sstevel@tonic-gate sctp->sctp_rto_max); 4870Sstevel@tonic-gate fp->hb_expiry = now + fp->rto; 4880Sstevel@tonic-gate } 4890Sstevel@tonic-gate break; 4900Sstevel@tonic-gate case SCTP_FADDRS_DOWN: 4910Sstevel@tonic-gate dead_addr: 4920Sstevel@tonic-gate fp->hb_expiry = now + SET_HB_INTVL(fp); 4930Sstevel@tonic-gate break; 4940Sstevel@tonic-gate default: 4950Sstevel@tonic-gate continue; 4960Sstevel@tonic-gate } 4970Sstevel@tonic-gate } else { 4980Sstevel@tonic-gate fp->hb_expiry = now + fp->rto; 4990Sstevel@tonic-gate } 5000Sstevel@tonic-gate /* 5010Sstevel@tonic-gate * Note that the total number of heartbeat we can send 5020Sstevel@tonic-gate * out simultaneously is limited by sctp_maxburst. If 5030Sstevel@tonic-gate * the limit is exceeded, we need to wait for the next 5040Sstevel@tonic-gate * timeout to send them. This should only happen if 5050Sstevel@tonic-gate * there is unconfirmed address. Note that hb_pending 5060Sstevel@tonic-gate * is set in sctp_send_heartbeat(). So if a heartbeat 5070Sstevel@tonic-gate * is not sent, it will not affect the state of the 5080Sstevel@tonic-gate * peer address. 5090Sstevel@tonic-gate */ 5100Sstevel@tonic-gate if (fp->state != SCTP_FADDRS_UNCONFIRMED || cnt-- > 0) 5110Sstevel@tonic-gate sctp_send_heartbeat(sctp, fp); 5120Sstevel@tonic-gate } 5130Sstevel@tonic-gate if (fp->hb_expiry < earliest_expiry || earliest_expiry == 0) 5140Sstevel@tonic-gate earliest_expiry = fp->hb_expiry; 5150Sstevel@tonic-gate } 5160Sstevel@tonic-gate if (sctp->sctp_autoclose != 0) { 5170Sstevel@tonic-gate int64_t expire; 5180Sstevel@tonic-gate 5190Sstevel@tonic-gate expire = sctp->sctp_active + sctp->sctp_autoclose; 5200Sstevel@tonic-gate 5210Sstevel@tonic-gate if (expire <= now) { 5220Sstevel@tonic-gate dprint(3, ("sctp_heartbeat_timer: autoclosing\n")); 5230Sstevel@tonic-gate sctp_send_shutdown(sctp, 0); 5240Sstevel@tonic-gate return; 5250Sstevel@tonic-gate } 5260Sstevel@tonic-gate if (expire < earliest_expiry || earliest_expiry == 0) 5270Sstevel@tonic-gate earliest_expiry = expire; 5280Sstevel@tonic-gate } 5290Sstevel@tonic-gate 5300Sstevel@tonic-gate earliest_expiry -= now; 5310Sstevel@tonic-gate if (earliest_expiry < 0) 5320Sstevel@tonic-gate earliest_expiry = 1; 5330Sstevel@tonic-gate sctp_timer(sctp, sctp->sctp_heartbeat_mp, earliest_expiry); 5340Sstevel@tonic-gate } 5350Sstevel@tonic-gate 5360Sstevel@tonic-gate void 5370Sstevel@tonic-gate sctp_rexmit_timer(sctp_t *sctp, sctp_faddr_t *fp) 5380Sstevel@tonic-gate { 5390Sstevel@tonic-gate mblk_t *mp; 5400Sstevel@tonic-gate uint32_t rto_max = sctp->sctp_rto_max; 5413448Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps; 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate ASSERT(fp != NULL); 5440Sstevel@tonic-gate 5450Sstevel@tonic-gate dprint(3, ("sctp_timer: faddr=%x:%x:%x:%x\n", 5460Sstevel@tonic-gate SCTP_PRINTADDR(fp->faddr))); 5470Sstevel@tonic-gate 5480Sstevel@tonic-gate fp->timer_running = 0; 5490Sstevel@tonic-gate 5500Sstevel@tonic-gate /* Check is we've reached the max for retries */ 5510Sstevel@tonic-gate if (sctp->sctp_state < SCTPS_ESTABLISHED) { 5520Sstevel@tonic-gate if (fp->strikes >= sctp->sctp_max_init_rxt) { 5530Sstevel@tonic-gate /* time to give up */ 5543448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpAborted); 5553448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetransDrop); 5560Sstevel@tonic-gate sctp_assoc_event(sctp, SCTP_CANT_STR_ASSOC, 0, NULL); 5570Sstevel@tonic-gate sctp_clean_death(sctp, sctp->sctp_client_errno ? 5580Sstevel@tonic-gate sctp->sctp_client_errno : ETIMEDOUT); 5590Sstevel@tonic-gate return; 5600Sstevel@tonic-gate } 5610Sstevel@tonic-gate } else if (sctp->sctp_state >= SCTPS_ESTABLISHED) { 5620Sstevel@tonic-gate if (sctp->sctp_strikes >= sctp->sctp_pa_max_rxt) { 5630Sstevel@tonic-gate /* time to give up */ 5643448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpAborted); 5653448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetransDrop); 5660Sstevel@tonic-gate sctp_assoc_event(sctp, SCTP_COMM_LOST, 0, NULL); 5670Sstevel@tonic-gate sctp_clean_death(sctp, sctp->sctp_client_errno ? 5680Sstevel@tonic-gate sctp->sctp_client_errno : ETIMEDOUT); 5690Sstevel@tonic-gate return; 5700Sstevel@tonic-gate } 5710Sstevel@tonic-gate } 5720Sstevel@tonic-gate 5730Sstevel@tonic-gate if (fp->strikes >= fp->max_retr) { 5740Sstevel@tonic-gate if (sctp_faddr_dead(sctp, fp, SCTP_FADDRS_DOWN) == -1) { 5750Sstevel@tonic-gate return; 5760Sstevel@tonic-gate } 5770Sstevel@tonic-gate } 5780Sstevel@tonic-gate 5790Sstevel@tonic-gate switch (sctp->sctp_state) { 5800Sstevel@tonic-gate case SCTPS_ESTABLISHED: 5810Sstevel@tonic-gate /* 5820Sstevel@tonic-gate * Reset the heartbeat expiry time. We don't need a heartbeat 5830Sstevel@tonic-gate * timer running if we are retransmitting. Otherwise, the drop 5840Sstevel@tonic-gate * of heartbeat may just make this peer address to be marked 5850Sstevel@tonic-gate * dead faster as fp->strikes is also increased for heartbeat. 5860Sstevel@tonic-gate */ 5870Sstevel@tonic-gate fp->hb_expiry = lbolt64 + SET_HB_INTVL(fp); 5880Sstevel@tonic-gate fp->hb_pending = B_FALSE; 5890Sstevel@tonic-gate 5900Sstevel@tonic-gate /* FALLTHRU */ 5910Sstevel@tonic-gate case SCTPS_SHUTDOWN_PENDING: 5920Sstevel@tonic-gate case SCTPS_SHUTDOWN_RECEIVED: 5930Sstevel@tonic-gate if (sctp->sctp_state == SCTPS_SHUTDOWN_RECEIVED) { 5941735Skcpoon (void) sctp_shutdown_received(sctp, NULL, B_FALSE, 5951735Skcpoon B_TRUE, NULL); 5960Sstevel@tonic-gate } 5970Sstevel@tonic-gate 5980Sstevel@tonic-gate if (sctp->sctp_xmit_head == NULL && 5990Sstevel@tonic-gate sctp->sctp_xmit_unsent == NULL) { 6000Sstevel@tonic-gate /* Nothing to retransmit */ 6010Sstevel@tonic-gate if (sctp->sctp_state == SCTPS_SHUTDOWN_PENDING) { 6020Sstevel@tonic-gate sctp_send_shutdown(sctp, 1); 6030Sstevel@tonic-gate } 6040Sstevel@tonic-gate return; 6050Sstevel@tonic-gate } 6060Sstevel@tonic-gate 6073448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6080Sstevel@tonic-gate 6090Sstevel@tonic-gate sctp_rexmit(sctp, fp); 6100Sstevel@tonic-gate /* 6110Sstevel@tonic-gate * sctp_rexmit() will increase the strikes and restart the 6120Sstevel@tonic-gate * timer, so return here. 6130Sstevel@tonic-gate */ 6140Sstevel@tonic-gate return; 6150Sstevel@tonic-gate case SCTPS_COOKIE_WAIT: 6160Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_T1expire); 6170Sstevel@tonic-gate rxmit_init: 6180Sstevel@tonic-gate /* retransmit init */ 619432Svi117747 /* 620432Svi117747 * We don't take the conn hash lock here since the source 621432Svi117747 * address list won't be modified (it would have been done 622432Svi117747 * the first time around). 623432Svi117747 */ 6240Sstevel@tonic-gate mp = sctp_init_mp(sctp); 6250Sstevel@tonic-gate if (mp != NULL) { 6263448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6270Sstevel@tonic-gate sctp_add_sendq(sctp, mp); 6280Sstevel@tonic-gate } 6290Sstevel@tonic-gate rto_max = sctp->sctp_init_rto_max; 6300Sstevel@tonic-gate break; 6310Sstevel@tonic-gate case SCTPS_COOKIE_ECHOED: { 6320Sstevel@tonic-gate ipha_t *iph; 6330Sstevel@tonic-gate 6340Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_T1expire); 6350Sstevel@tonic-gate if (sctp->sctp_cookie_mp == NULL) { 6360Sstevel@tonic-gate sctp->sctp_state = SCTPS_COOKIE_WAIT; 6370Sstevel@tonic-gate goto rxmit_init; 6380Sstevel@tonic-gate } 6390Sstevel@tonic-gate mp = dupmsg(sctp->sctp_cookie_mp); 6400Sstevel@tonic-gate if (mp == NULL) 6410Sstevel@tonic-gate break; 6420Sstevel@tonic-gate iph = (ipha_t *)mp->b_rptr; 6430Sstevel@tonic-gate /* Reset the IP ident. */ 6440Sstevel@tonic-gate if (IPH_HDR_VERSION(iph) == IPV4_VERSION) 6450Sstevel@tonic-gate iph->ipha_ident = 0; 6460Sstevel@tonic-gate sctp_add_sendq(sctp, mp); 6473448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6480Sstevel@tonic-gate rto_max = sctp->sctp_init_rto_max; 6490Sstevel@tonic-gate break; 6500Sstevel@tonic-gate } 6510Sstevel@tonic-gate case SCTPS_SHUTDOWN_SENT: 6520Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_T2expire); 6530Sstevel@tonic-gate sctp_send_shutdown(sctp, 1); 6543448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6550Sstevel@tonic-gate break; 6560Sstevel@tonic-gate case SCTPS_SHUTDOWN_ACK_SENT: 6570Sstevel@tonic-gate /* We shouldn't have any more outstanding data */ 6580Sstevel@tonic-gate ASSERT(sctp->sctp_xmit_head == NULL); 6590Sstevel@tonic-gate ASSERT(sctp->sctp_xmit_unsent == NULL); 6600Sstevel@tonic-gate 6610Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_T2expire); 6621735Skcpoon (void) sctp_shutdown_received(sctp, NULL, B_FALSE, B_TRUE, 6631735Skcpoon NULL); 6643448Sdh155122 BUMP_MIB(&sctps->sctps_mib, sctpTimRetrans); 6650Sstevel@tonic-gate break; 6660Sstevel@tonic-gate default: 6670Sstevel@tonic-gate ASSERT(0); 6680Sstevel@tonic-gate break; 6690Sstevel@tonic-gate } 6700Sstevel@tonic-gate 6710Sstevel@tonic-gate fp->strikes++; 6720Sstevel@tonic-gate sctp->sctp_strikes++; 6730Sstevel@tonic-gate SCTP_CALC_RXT(fp, rto_max); 6740Sstevel@tonic-gate 6750Sstevel@tonic-gate SCTP_FADDR_TIMER_RESTART(sctp, fp, fp->rto); 6760Sstevel@tonic-gate } 6770Sstevel@tonic-gate 6780Sstevel@tonic-gate /* 6790Sstevel@tonic-gate * RTO calculation. timesent and now are both in ms. 6800Sstevel@tonic-gate */ 6810Sstevel@tonic-gate void 6820Sstevel@tonic-gate sctp_update_rtt(sctp_t *sctp, sctp_faddr_t *fp, clock_t delta) 6830Sstevel@tonic-gate { 6840Sstevel@tonic-gate int rtt; 6850Sstevel@tonic-gate 6860Sstevel@tonic-gate /* Calculate the RTT in ms */ 6870Sstevel@tonic-gate rtt = (int)delta; 6880Sstevel@tonic-gate rtt = rtt > 0 ? rtt : 1; 6890Sstevel@tonic-gate 6901676Sjpk dprint(5, ("sctp_update_rtt: fp = %p, rtt = %d\n", (void *)fp, rtt)); 6910Sstevel@tonic-gate 6920Sstevel@tonic-gate /* Is this the first RTT measurement? */ 6930Sstevel@tonic-gate if (fp->srtt == -1) { 6940Sstevel@tonic-gate fp->srtt = rtt; 6950Sstevel@tonic-gate fp->rttvar = rtt / 2; 6960Sstevel@tonic-gate fp->rto = 3 * rtt; /* == rtt + 4 * rttvar ( == rtt / 2) */ 6970Sstevel@tonic-gate } else { 6980Sstevel@tonic-gate int abs; 6990Sstevel@tonic-gate /* 7000Sstevel@tonic-gate * Versions of the RTO equations that use fixed-point math. 7010Sstevel@tonic-gate * alpha and beta are NOT tunable in this implementation, 7020Sstevel@tonic-gate * and so are hard-coded in. alpha = 1/8, beta = 1/4. 7030Sstevel@tonic-gate */ 7040Sstevel@tonic-gate abs = fp->srtt - rtt; 7050Sstevel@tonic-gate abs = abs >= 0 ? abs : -abs; 7060Sstevel@tonic-gate fp->rttvar = (3 * fp->rttvar + abs) >> 2; 7070Sstevel@tonic-gate fp->rttvar = fp->rttvar != 0 ? fp->rttvar : 1; 7080Sstevel@tonic-gate 7090Sstevel@tonic-gate fp->srtt = (7 * fp->srtt + rtt) >> 3; 7100Sstevel@tonic-gate fp->rto = fp->srtt + 4 * fp->rttvar; 7110Sstevel@tonic-gate } 7120Sstevel@tonic-gate 7130Sstevel@tonic-gate dprint(5, ("sctp_update_rtt: srtt = %d, rttvar = %d, rto = %d\n", 7140Sstevel@tonic-gate fp->srtt, fp->rttvar, fp->rto)); 7150Sstevel@tonic-gate 7160Sstevel@tonic-gate /* Bound the RTO by configured min and max values */ 7170Sstevel@tonic-gate if (fp->rto < sctp->sctp_rto_min) { 7180Sstevel@tonic-gate fp->rto = sctp->sctp_rto_min; 7190Sstevel@tonic-gate } 7200Sstevel@tonic-gate if (fp->rto > sctp->sctp_rto_max) { 7210Sstevel@tonic-gate fp->rto = sctp->sctp_rto_max; 7220Sstevel@tonic-gate } 7230Sstevel@tonic-gate 7240Sstevel@tonic-gate fp->rtt_updates++; 7250Sstevel@tonic-gate } 7260Sstevel@tonic-gate 7270Sstevel@tonic-gate void 7280Sstevel@tonic-gate sctp_free_faddr_timers(sctp_t *sctp) 7290Sstevel@tonic-gate { 7300Sstevel@tonic-gate sctp_faddr_t *fp; 7310Sstevel@tonic-gate 7320Sstevel@tonic-gate for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) { 7330Sstevel@tonic-gate if (fp->timer_mp != NULL) { 7340Sstevel@tonic-gate sctp_timer_free(fp->timer_mp); 7350Sstevel@tonic-gate fp->timer_mp = NULL; 7360Sstevel@tonic-gate fp->timer_running = 0; 7370Sstevel@tonic-gate } 7380Sstevel@tonic-gate if (fp->rc_timer_mp != NULL) { 7390Sstevel@tonic-gate sctp_timer_free(fp->rc_timer_mp); 7400Sstevel@tonic-gate fp->rc_timer_mp = NULL; 7410Sstevel@tonic-gate fp->rc_timer_running = 0; 7420Sstevel@tonic-gate } 7430Sstevel@tonic-gate } 7440Sstevel@tonic-gate } 7450Sstevel@tonic-gate 7460Sstevel@tonic-gate void 7470Sstevel@tonic-gate sctp_stop_faddr_timers(sctp_t *sctp) 7480Sstevel@tonic-gate { 7490Sstevel@tonic-gate sctp_faddr_t *fp; 7500Sstevel@tonic-gate 7510Sstevel@tonic-gate for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) { 7520Sstevel@tonic-gate SCTP_FADDR_TIMER_STOP(fp); 7530Sstevel@tonic-gate SCTP_FADDR_RC_TIMER_STOP(fp); 7540Sstevel@tonic-gate } 7550Sstevel@tonic-gate } 7560Sstevel@tonic-gate 7570Sstevel@tonic-gate void 7580Sstevel@tonic-gate sctp_process_timer(sctp_t *sctp) 7590Sstevel@tonic-gate { 7600Sstevel@tonic-gate mblk_t *mp; 7610Sstevel@tonic-gate 7620Sstevel@tonic-gate ASSERT(sctp->sctp_running); 7630Sstevel@tonic-gate ASSERT(MUTEX_HELD(&sctp->sctp_lock)); 7640Sstevel@tonic-gate while ((mp = sctp->sctp_timer_mp) != NULL) { 7650Sstevel@tonic-gate ASSERT(DB_TYPE(mp) == M_PCSIG); 7660Sstevel@tonic-gate /* 7670Sstevel@tonic-gate * Since the timer mblk can be freed in sctp_timer_call(), 7680Sstevel@tonic-gate * we need to grab the b_cont before that. 7690Sstevel@tonic-gate */ 7700Sstevel@tonic-gate sctp->sctp_timer_mp = mp->b_cont; 7710Sstevel@tonic-gate mp->b_cont = NULL; 7720Sstevel@tonic-gate sctp_timer_call(sctp, mp); 7730Sstevel@tonic-gate } 7740Sstevel@tonic-gate SCTP_REFRELE(sctp); 7750Sstevel@tonic-gate } 776