17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*45916cd2Sjpk  * Common Development and Distribution License (the "License").
6*45916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*45916cd2Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <sys/types.h>
297c478bd9Sstevel@tonic-gate #include <sys/systm.h>
307c478bd9Sstevel@tonic-gate #include <sys/stream.h>
317c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
327c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <netinet/in.h>
357c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <inet/common.h>
387c478bd9Sstevel@tonic-gate #include <inet/ip.h>
397c478bd9Sstevel@tonic-gate #include <inet/mib2.h>
407c478bd9Sstevel@tonic-gate #include "sctp_impl.h"
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate void
437c478bd9Sstevel@tonic-gate sctp_return_heartbeat(sctp_t *sctp, sctp_chunk_hdr_t *hbcp, mblk_t *mp)
447c478bd9Sstevel@tonic-gate {
457c478bd9Sstevel@tonic-gate 	mblk_t *smp;
467c478bd9Sstevel@tonic-gate 	sctp_chunk_hdr_t *cp;
477c478bd9Sstevel@tonic-gate 	ipha_t *iniph;
487c478bd9Sstevel@tonic-gate 	ip6_t *inip6h;
497c478bd9Sstevel@tonic-gate 	int isv4;
507c478bd9Sstevel@tonic-gate 	in6_addr_t addr;
517c478bd9Sstevel@tonic-gate 	sctp_faddr_t *fp;
527c478bd9Sstevel@tonic-gate 	uint16_t len;
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate 	BUMP_LOCAL(sctp->sctp_ibchunks);
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate 	/* Update the faddr for the src addr */
577c478bd9Sstevel@tonic-gate 	isv4 = (IPH_HDR_VERSION(mp->b_rptr) == IPV4_VERSION);
587c478bd9Sstevel@tonic-gate 	if (isv4) {
597c478bd9Sstevel@tonic-gate 		iniph = (ipha_t *)mp->b_rptr;
607c478bd9Sstevel@tonic-gate 		IN6_IPADDR_TO_V4MAPPED(iniph->ipha_src, &addr);
617c478bd9Sstevel@tonic-gate 	} else {
627c478bd9Sstevel@tonic-gate 		inip6h = (ip6_t *)mp->b_rptr;
637c478bd9Sstevel@tonic-gate 		addr = inip6h->ip6_src;
647c478bd9Sstevel@tonic-gate 	}
657c478bd9Sstevel@tonic-gate 	fp = sctp_lookup_faddr(sctp, &addr);
667c478bd9Sstevel@tonic-gate 	ASSERT(fp != NULL);
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	dprint(3, ("sctp_return_heartbeat: %p got hb from %x:%x:%x:%x\n",
69*45916cd2Sjpk 	    (void *)sctp, SCTP_PRINTADDR(addr)));
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 	/*
727c478bd9Sstevel@tonic-gate 	 * XXX It's really tempting to reuse the heartbeat mblk. But
737c478bd9Sstevel@tonic-gate 	 * this complicates processing in sctp_dispatch (i.e. it will
747c478bd9Sstevel@tonic-gate 	 * screw up sctp_next_chunk since we will set the chunk
757c478bd9Sstevel@tonic-gate 	 * header's length into network byte-order), and if we ever
767c478bd9Sstevel@tonic-gate 	 * encounter a heartbeat bundled with other chunks...
777c478bd9Sstevel@tonic-gate 	 * So we take the slower-but-safe route.
787c478bd9Sstevel@tonic-gate 	 */
797c478bd9Sstevel@tonic-gate 	len = ntohs(hbcp->sch_len);
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	/* Create an IP header, returning to the src addr from the heartbt */
827c478bd9Sstevel@tonic-gate 	smp = sctp_make_mp(sctp, fp, len);
837c478bd9Sstevel@tonic-gate 	if (smp == NULL) {
847c478bd9Sstevel@tonic-gate 		return;
857c478bd9Sstevel@tonic-gate 	}
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate 	cp = (sctp_chunk_hdr_t *)smp->b_wptr;
887c478bd9Sstevel@tonic-gate 	cp->sch_id = CHUNK_HEARTBEAT_ACK;
897c478bd9Sstevel@tonic-gate 	cp->sch_flags = 0;
907c478bd9Sstevel@tonic-gate 	cp->sch_len = htons(len);
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 	/* Copy the information field from the heartbeat */
937c478bd9Sstevel@tonic-gate 	bcopy((void *)(hbcp + 1), (void *)(cp + 1), len - sizeof (*cp));
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 	smp->b_wptr += len;
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 	sctp_set_iplen(sctp, smp);
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 	BUMP_LOCAL(sctp->sctp_obchunks);
1007c478bd9Sstevel@tonic-gate 	sctp_add_sendq(sctp, smp);
1017c478bd9Sstevel@tonic-gate }
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /*
1047c478bd9Sstevel@tonic-gate  * The data section of the heartbeat contains a time field (lbolt64),
1057c478bd9Sstevel@tonic-gate  * a 64 bit secret, followed by the v6 (possible a v4mapped) address this
1067c478bd9Sstevel@tonic-gate  * heartbeat was sent to.  No byte-ordering is done, since the heartbeat
1077c478bd9Sstevel@tonic-gate  * is not interpreted by the peer.
1087c478bd9Sstevel@tonic-gate  */
1097c478bd9Sstevel@tonic-gate void
1107c478bd9Sstevel@tonic-gate sctp_send_heartbeat(sctp_t *sctp, sctp_faddr_t *fp)
1117c478bd9Sstevel@tonic-gate {
1127c478bd9Sstevel@tonic-gate 	sctp_chunk_hdr_t *cp;
1137c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t *hpp;
1147c478bd9Sstevel@tonic-gate 	int64_t *t;
1157c478bd9Sstevel@tonic-gate 	int64_t now;
1167c478bd9Sstevel@tonic-gate 	in6_addr_t *a;
1177c478bd9Sstevel@tonic-gate 	mblk_t *hbmp;
1187c478bd9Sstevel@tonic-gate 	size_t hblen;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate 	dprint(3, ("sctp_send_heartbeat: to %x:%x:%x:%x from %x:%x:%x:%x\n",
1217c478bd9Sstevel@tonic-gate 	    SCTP_PRINTADDR(fp->faddr), SCTP_PRINTADDR(fp->saddr)));
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate 	hblen = sizeof (*cp) +
1247c478bd9Sstevel@tonic-gate 		sizeof (*hpp) +
1257c478bd9Sstevel@tonic-gate 		sizeof (*t) +
1267c478bd9Sstevel@tonic-gate 		sizeof (fp->hb_secret) +
1277c478bd9Sstevel@tonic-gate 		sizeof (fp->faddr);
1287c478bd9Sstevel@tonic-gate 	hbmp = sctp_make_mp(sctp, fp, hblen);
1297c478bd9Sstevel@tonic-gate 	if (hbmp == NULL)
1307c478bd9Sstevel@tonic-gate 		return;
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate 	cp = (sctp_chunk_hdr_t *)hbmp->b_wptr;
1337c478bd9Sstevel@tonic-gate 	cp->sch_id = CHUNK_HEARTBEAT;
1347c478bd9Sstevel@tonic-gate 	cp->sch_flags = 0;
1357c478bd9Sstevel@tonic-gate 	cp->sch_len = hblen;
1367c478bd9Sstevel@tonic-gate 	cp->sch_len = htons(cp->sch_len);
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate 	hpp = (sctp_parm_hdr_t *)(cp + 1);
1397c478bd9Sstevel@tonic-gate 	hpp->sph_type = htons(PARM_HBINFO);
1407c478bd9Sstevel@tonic-gate 	hpp->sph_len = hblen - sizeof (*cp);
1417c478bd9Sstevel@tonic-gate 	hpp->sph_len = htons(hpp->sph_len);
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate 	/*
1447c478bd9Sstevel@tonic-gate 	 * Timestamp
1457c478bd9Sstevel@tonic-gate 	 *
1467c478bd9Sstevel@tonic-gate 	 * Copy the current time to the heartbeat and we can use it to
1477c478bd9Sstevel@tonic-gate 	 * calculate the RTT when we get it back in the heartbeat ACK.
1487c478bd9Sstevel@tonic-gate 	 */
1497c478bd9Sstevel@tonic-gate 	now = lbolt64;
1507c478bd9Sstevel@tonic-gate 	t = (int64_t *)(hpp + 1);
1517c478bd9Sstevel@tonic-gate 	bcopy(&now, t, sizeof (now));
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate 	/*
1547c478bd9Sstevel@tonic-gate 	 * Secret
1557c478bd9Sstevel@tonic-gate 	 *
1567c478bd9Sstevel@tonic-gate 	 * The per peer address secret is used to make sure that the heartbeat
1577c478bd9Sstevel@tonic-gate 	 * ack is really in response to our heartbeat.  This prevents blind
1587c478bd9Sstevel@tonic-gate 	 * spoofing of heartbeat ack to fake the validity of an address.
1597c478bd9Sstevel@tonic-gate 	 */
1607c478bd9Sstevel@tonic-gate 	t++;
1617c478bd9Sstevel@tonic-gate 	bcopy(&fp->hb_secret, t, sizeof (uint64_t));
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 	/*
1647c478bd9Sstevel@tonic-gate 	 * Peer address
1657c478bd9Sstevel@tonic-gate 	 *
1667c478bd9Sstevel@tonic-gate 	 * The peer address is used to associate the heartbeat ack with
1677c478bd9Sstevel@tonic-gate 	 * the correct peer address.  The reason is that the peer is
1687c478bd9Sstevel@tonic-gate 	 * multihomed so that it may not use the same address as source
1697c478bd9Sstevel@tonic-gate 	 * in response to our heartbeat.
1707c478bd9Sstevel@tonic-gate 	 */
1717c478bd9Sstevel@tonic-gate 	a = (in6_addr_t *)(t + 1);
1727c478bd9Sstevel@tonic-gate 	bcopy(&fp->faddr, a, sizeof (*a));
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 	hbmp->b_wptr += hblen;
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate 	sctp_set_iplen(sctp, hbmp);
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate 	/* Update the faddr's info */
1797c478bd9Sstevel@tonic-gate 	fp->lastactive = now;
1807c478bd9Sstevel@tonic-gate 	fp->hb_pending = B_TRUE;
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate 	BUMP_LOCAL(sctp->sctp_obchunks);
1837c478bd9Sstevel@tonic-gate 	BUMP_MIB(&sctp_mib, sctpTimHeartBeatProbe);
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate 	sctp_add_sendq(sctp, hbmp);
1867c478bd9Sstevel@tonic-gate }
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate /*
1897c478bd9Sstevel@tonic-gate  * Call right after any address change to validate peer addresses.
1907c478bd9Sstevel@tonic-gate  */
1917c478bd9Sstevel@tonic-gate void
1927c478bd9Sstevel@tonic-gate sctp_validate_peer(sctp_t *sctp)
1937c478bd9Sstevel@tonic-gate {
1947c478bd9Sstevel@tonic-gate 	sctp_faddr_t	*fp;
1957c478bd9Sstevel@tonic-gate 	int		cnt;
1967c478bd9Sstevel@tonic-gate 	int64_t		now;
1977c478bd9Sstevel@tonic-gate 	int64_t		earliest_expiry;
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate 	now = lbolt64;
2007c478bd9Sstevel@tonic-gate 	earliest_expiry = 0;
2017c478bd9Sstevel@tonic-gate 	cnt = sctp_maxburst;
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate 	/*
2047c478bd9Sstevel@tonic-gate 	 * Loop thru the list looking for unconfirmed addresses and
2057c478bd9Sstevel@tonic-gate 	 * send a heartbeat.  But we should only send at most sctp_maxburst
2067c478bd9Sstevel@tonic-gate 	 * heartbeats.
2077c478bd9Sstevel@tonic-gate 	 */
2087c478bd9Sstevel@tonic-gate 	for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) {
2097c478bd9Sstevel@tonic-gate 		/* No need to validate unreachable address. */
2107c478bd9Sstevel@tonic-gate 		if (fp->state == SCTP_FADDRS_UNREACH)
2117c478bd9Sstevel@tonic-gate 			continue;
2127c478bd9Sstevel@tonic-gate 		if (fp->state == SCTP_FADDRS_UNCONFIRMED) {
2137c478bd9Sstevel@tonic-gate 			if (cnt-- > 0) {
2147c478bd9Sstevel@tonic-gate 				fp->hb_expiry = now + fp->rto;
2157c478bd9Sstevel@tonic-gate 				sctp_send_heartbeat(sctp, fp);
2167c478bd9Sstevel@tonic-gate 			} else {
2177c478bd9Sstevel@tonic-gate 				/*
2187c478bd9Sstevel@tonic-gate 				 * If we cannot send now, be more aggressive
2197c478bd9Sstevel@tonic-gate 				 * and try again about half of RTO.  Note that
2207c478bd9Sstevel@tonic-gate 				 * all the unsent probes are set to expire at
2217c478bd9Sstevel@tonic-gate 				 * the same time.
2227c478bd9Sstevel@tonic-gate 				 */
2237c478bd9Sstevel@tonic-gate 				fp->hb_expiry = now +
2247c478bd9Sstevel@tonic-gate 				    (sctp->sctp_rto_initial >> 1);
2257c478bd9Sstevel@tonic-gate 			}
2267c478bd9Sstevel@tonic-gate 		}
2277c478bd9Sstevel@tonic-gate 		/* Find the earliest heartbeat expiry time for ALL fps. */
2287c478bd9Sstevel@tonic-gate 		if (fp->hb_interval != 0 && (earliest_expiry == 0 ||
2297c478bd9Sstevel@tonic-gate 		    fp->hb_expiry < earliest_expiry)) {
2307c478bd9Sstevel@tonic-gate 			earliest_expiry = fp->hb_expiry;
2317c478bd9Sstevel@tonic-gate 		}
2327c478bd9Sstevel@tonic-gate 	}
2337c478bd9Sstevel@tonic-gate 	/* We use heartbeat timer for autoclose. */
2347c478bd9Sstevel@tonic-gate 	if (sctp->sctp_autoclose != 0) {
2357c478bd9Sstevel@tonic-gate 		int64_t expire;
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate 		expire = sctp->sctp_active + sctp->sctp_autoclose;
2387c478bd9Sstevel@tonic-gate 		if (earliest_expiry == 0 || expire < earliest_expiry)
2397c478bd9Sstevel@tonic-gate 			earliest_expiry = expire;
2407c478bd9Sstevel@tonic-gate 	}
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate 	/*
2437c478bd9Sstevel@tonic-gate 	 * Set the timer to fire for the earliest heartbeat unless
2447c478bd9Sstevel@tonic-gate 	 * heartbeat is disabled for all addresses.
2457c478bd9Sstevel@tonic-gate 	 */
2467c478bd9Sstevel@tonic-gate 	if (earliest_expiry != 0) {
2477c478bd9Sstevel@tonic-gate 		earliest_expiry -= now;
2487c478bd9Sstevel@tonic-gate 		if (earliest_expiry < 0)
2497c478bd9Sstevel@tonic-gate 			earliest_expiry = 1;
2507c478bd9Sstevel@tonic-gate 		sctp_timer(sctp, sctp->sctp_heartbeat_mp, earliest_expiry);
2517c478bd9Sstevel@tonic-gate 	}
2527c478bd9Sstevel@tonic-gate }
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate /*
2557c478bd9Sstevel@tonic-gate  * Process an incoming heartbeat ack.  When sending a heartbeat, we
2567c478bd9Sstevel@tonic-gate  * put the timestamp, a secret and the peer address the heartbeat is
2577c478bd9Sstevel@tonic-gate  * sent in the data part of the heartbeat.  We will extract this info
2587c478bd9Sstevel@tonic-gate  * and verify that this heartbeat ack is valid.
2597c478bd9Sstevel@tonic-gate  */
2607c478bd9Sstevel@tonic-gate void
2617c478bd9Sstevel@tonic-gate sctp_process_heartbeat(sctp_t *sctp, sctp_chunk_hdr_t *cp)
2627c478bd9Sstevel@tonic-gate {
2637c478bd9Sstevel@tonic-gate 	int64_t *sentp, sent;
2647c478bd9Sstevel@tonic-gate 	uint64_t secret;
2657c478bd9Sstevel@tonic-gate 	in6_addr_t addr;
2667c478bd9Sstevel@tonic-gate 	sctp_faddr_t *fp;
2677c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t *hpp;
2687c478bd9Sstevel@tonic-gate 	int64_t now;
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate 	BUMP_LOCAL(sctp->sctp_ibchunks);
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate 	/* Sanity checks */
2737c478bd9Sstevel@tonic-gate 	ASSERT(OK_32PTR(cp));
2747c478bd9Sstevel@tonic-gate 	if (ntohs(cp->sch_len) < (sizeof (*cp) + sizeof (*hpp) +
2757c478bd9Sstevel@tonic-gate 	    sizeof (sent) + sizeof (secret) + sizeof (addr))) {
2767c478bd9Sstevel@tonic-gate 		/* drop it */
2777c478bd9Sstevel@tonic-gate 		dprint(2, ("sctp_process_heartbeat: malformed ack %p\n",
278*45916cd2Sjpk 		    (void *)sctp));
2797c478bd9Sstevel@tonic-gate 		return;
2807c478bd9Sstevel@tonic-gate 	}
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate 	hpp = (sctp_parm_hdr_t *)(cp + 1);
2837c478bd9Sstevel@tonic-gate 	if (ntohs(hpp->sph_type) != PARM_HBINFO ||
2847c478bd9Sstevel@tonic-gate 	    ntohs(hpp->sph_len) != (ntohs(cp->sch_len) - sizeof (*cp))) {
2857c478bd9Sstevel@tonic-gate 		dprint(2,
2867c478bd9Sstevel@tonic-gate 		    ("sctp_process_heartbeat: malformed param in ack %p\n",
287*45916cd2Sjpk 		    (void *)sctp));
2887c478bd9Sstevel@tonic-gate 		return;
2897c478bd9Sstevel@tonic-gate 	}
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate 	/*
2927c478bd9Sstevel@tonic-gate 	 * Pull out the time sent from the ack.
2937c478bd9Sstevel@tonic-gate 	 * SCTP is 32-bit aligned, so copy 64 bit quantity.  Since we
2947c478bd9Sstevel@tonic-gate 	 * put it in, it should be in our byte order.
2957c478bd9Sstevel@tonic-gate 	 */
2967c478bd9Sstevel@tonic-gate 	sentp = (int64_t *)(hpp + 1);
2977c478bd9Sstevel@tonic-gate 	bcopy(sentp, &sent, sizeof (sent));
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate 	/* Grab the secret to make sure that this heartbeat is valid */
3007c478bd9Sstevel@tonic-gate 	bcopy(++sentp, &secret, sizeof (secret));
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate 	/* Next, verify the address to make sure that it is the right one. */
3037c478bd9Sstevel@tonic-gate 	bcopy(++sentp, &addr, sizeof (addr));
3047c478bd9Sstevel@tonic-gate 	fp = sctp_lookup_faddr(sctp, &addr);
3057c478bd9Sstevel@tonic-gate 	if (fp == NULL) {
3067c478bd9Sstevel@tonic-gate 		dprint(2, ("sctp_process_heartbeat: invalid faddr (sctp=%p)\n",
307*45916cd2Sjpk 		    (void *)sctp));
3087c478bd9Sstevel@tonic-gate 		return;
3097c478bd9Sstevel@tonic-gate 	}
3107c478bd9Sstevel@tonic-gate 	if (secret != fp->hb_secret) {
3117c478bd9Sstevel@tonic-gate 		dprint(2,
3127c478bd9Sstevel@tonic-gate 		    ("sctp_process_heartbeat: invalid secret in ack %p\n",
313*45916cd2Sjpk 		    (void *)sctp));
3147c478bd9Sstevel@tonic-gate 		return;
3157c478bd9Sstevel@tonic-gate 	}
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate 	/* This address is now confirmed and alive. */
3187c478bd9Sstevel@tonic-gate 	sctp_faddr_alive(sctp, fp);
3197c478bd9Sstevel@tonic-gate 	now = lbolt64;
3207c478bd9Sstevel@tonic-gate 	sctp_update_rtt(sctp, fp, now - sent);
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate 	/*
3237c478bd9Sstevel@tonic-gate 	 * Note that the heartbeat timer should still be running, we don't
3247c478bd9Sstevel@tonic-gate 	 * reset it to avoid going through the whole list of peer addresses
3257c478bd9Sstevel@tonic-gate 	 * for each heartbeat ack as we probably are in interrupt context.
3267c478bd9Sstevel@tonic-gate 	 */
3277c478bd9Sstevel@tonic-gate 	fp->hb_expiry = now + SET_HB_INTVL(fp);
3287c478bd9Sstevel@tonic-gate }
329