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
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * 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  */
2177c67f2fSkcpoon 
227c478bd9Sstevel@tonic-gate /*
23*bd670b35SErik Nordmark  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <sys/systm.h>
297c478bd9Sstevel@tonic-gate #include <sys/stream.h>
307c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
317c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <netinet/in.h>
347c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <inet/common.h>
377c478bd9Sstevel@tonic-gate #include <inet/ip.h>
387c478bd9Sstevel@tonic-gate #include <inet/mib2.h>
39f4b3ec61Sdh #include <inet/ipclassifier.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;
53f4b3ec61Sdh 	sctp_stack_t	*sctps = sctp->sctp_sctps;
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate 	BUMP_LOCAL(sctp->sctp_ibchunks);
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate 	/* Update the faddr for the src addr */
587c478bd9Sstevel@tonic-gate 	isv4 = (IPH_HDR_VERSION(mp->b_rptr) == IPV4_VERSION);
597c478bd9Sstevel@tonic-gate 	if (isv4) {
607c478bd9Sstevel@tonic-gate 		iniph = (ipha_t *)mp->b_rptr;
617c478bd9Sstevel@tonic-gate 		IN6_IPADDR_TO_V4MAPPED(iniph->ipha_src, &addr);
627c478bd9Sstevel@tonic-gate 	} else {
637c478bd9Sstevel@tonic-gate 		inip6h = (ip6_t *)mp->b_rptr;
647c478bd9Sstevel@tonic-gate 		addr = inip6h->ip6_src;
657c478bd9Sstevel@tonic-gate 	}
667c478bd9Sstevel@tonic-gate 	fp = sctp_lookup_faddr(sctp, &addr);
67*bd670b35SErik Nordmark 	/* If the source address is bogus we silently drop the packet */
68*bd670b35SErik Nordmark 	if (fp == NULL) {
69*bd670b35SErik Nordmark 		dprint(1,
70*bd670b35SErik Nordmark 		    ("sctp_return_heartbeat: %p bogus hb from %x:%x:%x:%x\n",
71*bd670b35SErik Nordmark 		    (void *)sctp, SCTP_PRINTADDR(addr)));
72*bd670b35SErik Nordmark 		SCTP_KSTAT(sctps, sctp_return_hb_failed);
73*bd670b35SErik Nordmark 		return;
74*bd670b35SErik Nordmark 	}
757c478bd9Sstevel@tonic-gate 	dprint(3, ("sctp_return_heartbeat: %p got hb from %x:%x:%x:%x\n",
7645916cd2Sjpk 	    (void *)sctp, SCTP_PRINTADDR(addr)));
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate 	/*
797c478bd9Sstevel@tonic-gate 	 * XXX It's really tempting to reuse the heartbeat mblk. But
807c478bd9Sstevel@tonic-gate 	 * this complicates processing in sctp_dispatch (i.e. it will
817c478bd9Sstevel@tonic-gate 	 * screw up sctp_next_chunk since we will set the chunk
827c478bd9Sstevel@tonic-gate 	 * header's length into network byte-order), and if we ever
837c478bd9Sstevel@tonic-gate 	 * encounter a heartbeat bundled with other chunks...
847c478bd9Sstevel@tonic-gate 	 * So we take the slower-but-safe route.
857c478bd9Sstevel@tonic-gate 	 */
867c478bd9Sstevel@tonic-gate 	len = ntohs(hbcp->sch_len);
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate 	/* Create an IP header, returning to the src addr from the heartbt */
897c478bd9Sstevel@tonic-gate 	smp = sctp_make_mp(sctp, fp, len);
907c478bd9Sstevel@tonic-gate 	if (smp == NULL) {
91f4b3ec61Sdh 		SCTP_KSTAT(sctps, sctp_return_hb_failed);
927c478bd9Sstevel@tonic-gate 		return;
937c478bd9Sstevel@tonic-gate 	}
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 	cp = (sctp_chunk_hdr_t *)smp->b_wptr;
967c478bd9Sstevel@tonic-gate 	cp->sch_id = CHUNK_HEARTBEAT_ACK;
977c478bd9Sstevel@tonic-gate 	cp->sch_flags = 0;
987c478bd9Sstevel@tonic-gate 	cp->sch_len = htons(len);
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	/* Copy the information field from the heartbeat */
1017c478bd9Sstevel@tonic-gate 	bcopy((void *)(hbcp + 1), (void *)(cp + 1), len - sizeof (*cp));
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	smp->b_wptr += len;
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate 	BUMP_LOCAL(sctp->sctp_obchunks);
106*bd670b35SErik Nordmark 
107*bd670b35SErik Nordmark 	sctp_set_iplen(sctp, smp, fp->ixa);
108*bd670b35SErik Nordmark 	(void) conn_ip_output(smp, fp->ixa);
109*bd670b35SErik Nordmark 	BUMP_LOCAL(sctp->sctp_opkts);
1107c478bd9Sstevel@tonic-gate }
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate  * The data section of the heartbeat contains a time field (lbolt64),
1147c478bd9Sstevel@tonic-gate  * a 64 bit secret, followed by the v6 (possible a v4mapped) address this
1157c478bd9Sstevel@tonic-gate  * heartbeat was sent to.  No byte-ordering is done, since the heartbeat
1167c478bd9Sstevel@tonic-gate  * is not interpreted by the peer.
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate void
1197c478bd9Sstevel@tonic-gate sctp_send_heartbeat(sctp_t *sctp, sctp_faddr_t *fp)
1207c478bd9Sstevel@tonic-gate {
1217c478bd9Sstevel@tonic-gate 	sctp_chunk_hdr_t *cp;
1227c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t *hpp;
1237c478bd9Sstevel@tonic-gate 	int64_t *t;
1247c478bd9Sstevel@tonic-gate 	int64_t now;
1257c478bd9Sstevel@tonic-gate 	in6_addr_t *a;
1267c478bd9Sstevel@tonic-gate 	mblk_t *hbmp;
1277c478bd9Sstevel@tonic-gate 	size_t hblen;
128f4b3ec61Sdh 	sctp_stack_t	*sctps = sctp->sctp_sctps;
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	dprint(3, ("sctp_send_heartbeat: to %x:%x:%x:%x from %x:%x:%x:%x\n",
1317c478bd9Sstevel@tonic-gate 	    SCTP_PRINTADDR(fp->faddr), SCTP_PRINTADDR(fp->saddr)));
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 	hblen = sizeof (*cp) +
134*bd670b35SErik Nordmark 	    sizeof (*hpp) +
135*bd670b35SErik Nordmark 	    sizeof (*t) +
136*bd670b35SErik Nordmark 	    sizeof (fp->hb_secret) +
137*bd670b35SErik Nordmark 	    sizeof (fp->faddr);
1387c478bd9Sstevel@tonic-gate 	hbmp = sctp_make_mp(sctp, fp, hblen);
13977c67f2fSkcpoon 	if (hbmp == NULL) {
140f4b3ec61Sdh 		SCTP_KSTAT(sctps, sctp_send_hb_failed);
1417c478bd9Sstevel@tonic-gate 		return;
14277c67f2fSkcpoon 	}
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate 	cp = (sctp_chunk_hdr_t *)hbmp->b_wptr;
1457c478bd9Sstevel@tonic-gate 	cp->sch_id = CHUNK_HEARTBEAT;
1467c478bd9Sstevel@tonic-gate 	cp->sch_flags = 0;
1477c478bd9Sstevel@tonic-gate 	cp->sch_len = hblen;
1487c478bd9Sstevel@tonic-gate 	cp->sch_len = htons(cp->sch_len);
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate 	hpp = (sctp_parm_hdr_t *)(cp + 1);
1517c478bd9Sstevel@tonic-gate 	hpp->sph_type = htons(PARM_HBINFO);
1527c478bd9Sstevel@tonic-gate 	hpp->sph_len = hblen - sizeof (*cp);
1537c478bd9Sstevel@tonic-gate 	hpp->sph_len = htons(hpp->sph_len);
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate 	/*
1567c478bd9Sstevel@tonic-gate 	 * Timestamp
1577c478bd9Sstevel@tonic-gate 	 *
1587c478bd9Sstevel@tonic-gate 	 * Copy the current time to the heartbeat and we can use it to
1597c478bd9Sstevel@tonic-gate 	 * calculate the RTT when we get it back in the heartbeat ACK.
1607c478bd9Sstevel@tonic-gate 	 */
1617c478bd9Sstevel@tonic-gate 	now = lbolt64;
1627c478bd9Sstevel@tonic-gate 	t = (int64_t *)(hpp + 1);
1637c478bd9Sstevel@tonic-gate 	bcopy(&now, t, sizeof (now));
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 	/*
1667c478bd9Sstevel@tonic-gate 	 * Secret
1677c478bd9Sstevel@tonic-gate 	 *
1687c478bd9Sstevel@tonic-gate 	 * The per peer address secret is used to make sure that the heartbeat
1697c478bd9Sstevel@tonic-gate 	 * ack is really in response to our heartbeat.  This prevents blind
1707c478bd9Sstevel@tonic-gate 	 * spoofing of heartbeat ack to fake the validity of an address.
1717c478bd9Sstevel@tonic-gate 	 */
1727c478bd9Sstevel@tonic-gate 	t++;
1737c478bd9Sstevel@tonic-gate 	bcopy(&fp->hb_secret, t, sizeof (uint64_t));
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 	/*
1767c478bd9Sstevel@tonic-gate 	 * Peer address
1777c478bd9Sstevel@tonic-gate 	 *
1787c478bd9Sstevel@tonic-gate 	 * The peer address is used to associate the heartbeat ack with
1797c478bd9Sstevel@tonic-gate 	 * the correct peer address.  The reason is that the peer is
1807c478bd9Sstevel@tonic-gate 	 * multihomed so that it may not use the same address as source
1817c478bd9Sstevel@tonic-gate 	 * in response to our heartbeat.
1827c478bd9Sstevel@tonic-gate 	 */
1837c478bd9Sstevel@tonic-gate 	a = (in6_addr_t *)(t + 1);
1847c478bd9Sstevel@tonic-gate 	bcopy(&fp->faddr, a, sizeof (*a));
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate 	hbmp->b_wptr += hblen;
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate 	/* Update the faddr's info */
1897c478bd9Sstevel@tonic-gate 	fp->lastactive = now;
1907c478bd9Sstevel@tonic-gate 	fp->hb_pending = B_TRUE;
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 	BUMP_LOCAL(sctp->sctp_obchunks);
193f4b3ec61Sdh 	BUMP_MIB(&sctps->sctps_mib, sctpTimHeartBeatProbe);
1947c478bd9Sstevel@tonic-gate 
195*bd670b35SErik Nordmark 	sctp_set_iplen(sctp, hbmp, fp->ixa);
196*bd670b35SErik Nordmark 	(void) conn_ip_output(hbmp, fp->ixa);
197*bd670b35SErik Nordmark 	BUMP_LOCAL(sctp->sctp_opkts);
1987c478bd9Sstevel@tonic-gate }
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * Call right after any address change to validate peer addresses.
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate void
2047c478bd9Sstevel@tonic-gate sctp_validate_peer(sctp_t *sctp)
2057c478bd9Sstevel@tonic-gate {
2067c478bd9Sstevel@tonic-gate 	sctp_faddr_t	*fp;
2077c478bd9Sstevel@tonic-gate 	int		cnt;
2087c478bd9Sstevel@tonic-gate 	int64_t		now;
2097c478bd9Sstevel@tonic-gate 	int64_t		earliest_expiry;
210f4b3ec61Sdh 	sctp_stack_t	*sctps = sctp->sctp_sctps;
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate 	now = lbolt64;
2137c478bd9Sstevel@tonic-gate 	earliest_expiry = 0;
214f4b3ec61Sdh 	cnt = sctps->sctps_maxburst;
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate 	/*
2177c478bd9Sstevel@tonic-gate 	 * Loop thru the list looking for unconfirmed addresses and
2187c478bd9Sstevel@tonic-gate 	 * send a heartbeat.  But we should only send at most sctp_maxburst
2197c478bd9Sstevel@tonic-gate 	 * heartbeats.
2207c478bd9Sstevel@tonic-gate 	 */
2217c478bd9Sstevel@tonic-gate 	for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) {
2227c478bd9Sstevel@tonic-gate 		/* No need to validate unreachable address. */
2237c478bd9Sstevel@tonic-gate 		if (fp->state == SCTP_FADDRS_UNREACH)
2247c478bd9Sstevel@tonic-gate 			continue;
2257c478bd9Sstevel@tonic-gate 		if (fp->state == SCTP_FADDRS_UNCONFIRMED) {
2267c478bd9Sstevel@tonic-gate 			if (cnt-- > 0) {
2277c478bd9Sstevel@tonic-gate 				fp->hb_expiry = now + fp->rto;
2287c478bd9Sstevel@tonic-gate 				sctp_send_heartbeat(sctp, fp);
2297c478bd9Sstevel@tonic-gate 			} else {
2307c478bd9Sstevel@tonic-gate 				/*
2317c478bd9Sstevel@tonic-gate 				 * If we cannot send now, be more aggressive
2327c478bd9Sstevel@tonic-gate 				 * and try again about half of RTO.  Note that
2337c478bd9Sstevel@tonic-gate 				 * all the unsent probes are set to expire at
2347c478bd9Sstevel@tonic-gate 				 * the same time.
2357c478bd9Sstevel@tonic-gate 				 */
2367c478bd9Sstevel@tonic-gate 				fp->hb_expiry = now +
2377c478bd9Sstevel@tonic-gate 				    (sctp->sctp_rto_initial >> 1);
2387c478bd9Sstevel@tonic-gate 			}
2397c478bd9Sstevel@tonic-gate 		}
2407c478bd9Sstevel@tonic-gate 		/* Find the earliest heartbeat expiry time for ALL fps. */
2417c478bd9Sstevel@tonic-gate 		if (fp->hb_interval != 0 && (earliest_expiry == 0 ||
2427c478bd9Sstevel@tonic-gate 		    fp->hb_expiry < earliest_expiry)) {
2437c478bd9Sstevel@tonic-gate 			earliest_expiry = fp->hb_expiry;
2447c478bd9Sstevel@tonic-gate 		}
2457c478bd9Sstevel@tonic-gate 	}
2467c478bd9Sstevel@tonic-gate 	/* We use heartbeat timer for autoclose. */
2477c478bd9Sstevel@tonic-gate 	if (sctp->sctp_autoclose != 0) {
2487c478bd9Sstevel@tonic-gate 		int64_t expire;
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 		expire = sctp->sctp_active + sctp->sctp_autoclose;
2517c478bd9Sstevel@tonic-gate 		if (earliest_expiry == 0 || expire < earliest_expiry)
2527c478bd9Sstevel@tonic-gate 			earliest_expiry = expire;
2537c478bd9Sstevel@tonic-gate 	}
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate 	/*
2567c478bd9Sstevel@tonic-gate 	 * Set the timer to fire for the earliest heartbeat unless
2577c478bd9Sstevel@tonic-gate 	 * heartbeat is disabled for all addresses.
2587c478bd9Sstevel@tonic-gate 	 */
2597c478bd9Sstevel@tonic-gate 	if (earliest_expiry != 0) {
2607c478bd9Sstevel@tonic-gate 		earliest_expiry -= now;
2617c478bd9Sstevel@tonic-gate 		if (earliest_expiry < 0)
2627c478bd9Sstevel@tonic-gate 			earliest_expiry = 1;
2637c478bd9Sstevel@tonic-gate 		sctp_timer(sctp, sctp->sctp_heartbeat_mp, earliest_expiry);
2647c478bd9Sstevel@tonic-gate 	}
2657c478bd9Sstevel@tonic-gate }
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /*
2687c478bd9Sstevel@tonic-gate  * Process an incoming heartbeat ack.  When sending a heartbeat, we
2697c478bd9Sstevel@tonic-gate  * put the timestamp, a secret and the peer address the heartbeat is
2707c478bd9Sstevel@tonic-gate  * sent in the data part of the heartbeat.  We will extract this info
2717c478bd9Sstevel@tonic-gate  * and verify that this heartbeat ack is valid.
2727c478bd9Sstevel@tonic-gate  */
2737c478bd9Sstevel@tonic-gate void
2747c478bd9Sstevel@tonic-gate sctp_process_heartbeat(sctp_t *sctp, sctp_chunk_hdr_t *cp)
2757c478bd9Sstevel@tonic-gate {
2767c478bd9Sstevel@tonic-gate 	int64_t *sentp, sent;
2777c478bd9Sstevel@tonic-gate 	uint64_t secret;
2787c478bd9Sstevel@tonic-gate 	in6_addr_t addr;
2797c478bd9Sstevel@tonic-gate 	sctp_faddr_t *fp;
2807c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t *hpp;
2817c478bd9Sstevel@tonic-gate 	int64_t now;
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate 	BUMP_LOCAL(sctp->sctp_ibchunks);
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate 	/* Sanity checks */
2867c478bd9Sstevel@tonic-gate 	ASSERT(OK_32PTR(cp));
2877c478bd9Sstevel@tonic-gate 	if (ntohs(cp->sch_len) < (sizeof (*cp) + sizeof (*hpp) +
2887c478bd9Sstevel@tonic-gate 	    sizeof (sent) + sizeof (secret) + sizeof (addr))) {
2897c478bd9Sstevel@tonic-gate 		/* drop it */
2907c478bd9Sstevel@tonic-gate 		dprint(2, ("sctp_process_heartbeat: malformed ack %p\n",
29145916cd2Sjpk 		    (void *)sctp));
2927c478bd9Sstevel@tonic-gate 		return;
2937c478bd9Sstevel@tonic-gate 	}
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate 	hpp = (sctp_parm_hdr_t *)(cp + 1);
2967c478bd9Sstevel@tonic-gate 	if (ntohs(hpp->sph_type) != PARM_HBINFO ||
2977c478bd9Sstevel@tonic-gate 	    ntohs(hpp->sph_len) != (ntohs(cp->sch_len) - sizeof (*cp))) {
2987c478bd9Sstevel@tonic-gate 		dprint(2,
2997c478bd9Sstevel@tonic-gate 		    ("sctp_process_heartbeat: malformed param in ack %p\n",
30045916cd2Sjpk 		    (void *)sctp));
3017c478bd9Sstevel@tonic-gate 		return;
3027c478bd9Sstevel@tonic-gate 	}
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate 	/*
3057c478bd9Sstevel@tonic-gate 	 * Pull out the time sent from the ack.
3067c478bd9Sstevel@tonic-gate 	 * SCTP is 32-bit aligned, so copy 64 bit quantity.  Since we
3077c478bd9Sstevel@tonic-gate 	 * put it in, it should be in our byte order.
3087c478bd9Sstevel@tonic-gate 	 */
3097c478bd9Sstevel@tonic-gate 	sentp = (int64_t *)(hpp + 1);
3107c478bd9Sstevel@tonic-gate 	bcopy(sentp, &sent, sizeof (sent));
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	/* Grab the secret to make sure that this heartbeat is valid */
3137c478bd9Sstevel@tonic-gate 	bcopy(++sentp, &secret, sizeof (secret));
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate 	/* Next, verify the address to make sure that it is the right one. */
3167c478bd9Sstevel@tonic-gate 	bcopy(++sentp, &addr, sizeof (addr));
3177c478bd9Sstevel@tonic-gate 	fp = sctp_lookup_faddr(sctp, &addr);
3187c478bd9Sstevel@tonic-gate 	if (fp == NULL) {
3197c478bd9Sstevel@tonic-gate 		dprint(2, ("sctp_process_heartbeat: invalid faddr (sctp=%p)\n",
32045916cd2Sjpk 		    (void *)sctp));
3217c478bd9Sstevel@tonic-gate 		return;
3227c478bd9Sstevel@tonic-gate 	}
3237c478bd9Sstevel@tonic-gate 	if (secret != fp->hb_secret) {
3247c478bd9Sstevel@tonic-gate 		dprint(2,
3257c478bd9Sstevel@tonic-gate 		    ("sctp_process_heartbeat: invalid secret in ack %p\n",
32645916cd2Sjpk 		    (void *)sctp));
3277c478bd9Sstevel@tonic-gate 		return;
3287c478bd9Sstevel@tonic-gate 	}
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate 	/* This address is now confirmed and alive. */
3317c478bd9Sstevel@tonic-gate 	sctp_faddr_alive(sctp, fp);
3327c478bd9Sstevel@tonic-gate 	now = lbolt64;
3337c478bd9Sstevel@tonic-gate 	sctp_update_rtt(sctp, fp, now - sent);
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate 	/*
3367c478bd9Sstevel@tonic-gate 	 * Note that the heartbeat timer should still be running, we don't
3377c478bd9Sstevel@tonic-gate 	 * reset it to avoid going through the whole list of peer addresses
3387c478bd9Sstevel@tonic-gate 	 * for each heartbeat ack as we probably are in interrupt context.
3397c478bd9Sstevel@tonic-gate 	 */
3407c478bd9Sstevel@tonic-gate 	fp->hb_expiry = now + SET_HB_INTVL(fp);
3417c478bd9Sstevel@tonic-gate }
342