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 /*
235dd46ab5SKacheong Poon * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #include <sys/types.h>
277c478bd9Sstevel@tonic-gate #include <sys/systm.h>
287c478bd9Sstevel@tonic-gate #include <sys/stream.h>
297c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
307c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate #include <netinet/in.h>
337c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate #include <inet/common.h>
367c478bd9Sstevel@tonic-gate #include <inet/ip.h>
377c478bd9Sstevel@tonic-gate #include <inet/mib2.h>
38f4b3ec61Sdh155122 #include <inet/ipclassifier.h>
397c478bd9Sstevel@tonic-gate #include "sctp_impl.h"
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gate void
sctp_return_heartbeat(sctp_t * sctp,sctp_chunk_hdr_t * hbcp,mblk_t * mp)427c478bd9Sstevel@tonic-gate sctp_return_heartbeat(sctp_t *sctp, sctp_chunk_hdr_t *hbcp, mblk_t *mp)
437c478bd9Sstevel@tonic-gate {
447c478bd9Sstevel@tonic-gate mblk_t *smp;
457c478bd9Sstevel@tonic-gate sctp_chunk_hdr_t *cp;
467c478bd9Sstevel@tonic-gate ipha_t *iniph;
477c478bd9Sstevel@tonic-gate ip6_t *inip6h;
487c478bd9Sstevel@tonic-gate int isv4;
497c478bd9Sstevel@tonic-gate in6_addr_t addr;
507c478bd9Sstevel@tonic-gate sctp_faddr_t *fp;
517c478bd9Sstevel@tonic-gate uint16_t len;
52f4b3ec61Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps;
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);
66bd670b35SErik Nordmark /* If the source address is bogus we silently drop the packet */
67bd670b35SErik Nordmark if (fp == NULL) {
68bd670b35SErik Nordmark dprint(1,
69bd670b35SErik Nordmark ("sctp_return_heartbeat: %p bogus hb from %x:%x:%x:%x\n",
70bd670b35SErik Nordmark (void *)sctp, SCTP_PRINTADDR(addr)));
71bd670b35SErik Nordmark SCTP_KSTAT(sctps, sctp_return_hb_failed);
72bd670b35SErik Nordmark return;
73bd670b35SErik Nordmark }
747c478bd9Sstevel@tonic-gate dprint(3, ("sctp_return_heartbeat: %p got hb from %x:%x:%x:%x\n",
7545916cd2Sjpk (void *)sctp, SCTP_PRINTADDR(addr)));
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate * XXX It's really tempting to reuse the heartbeat mblk. But
797c478bd9Sstevel@tonic-gate * this complicates processing in sctp_dispatch (i.e. it will
807c478bd9Sstevel@tonic-gate * screw up sctp_next_chunk since we will set the chunk
817c478bd9Sstevel@tonic-gate * header's length into network byte-order), and if we ever
827c478bd9Sstevel@tonic-gate * encounter a heartbeat bundled with other chunks...
837c478bd9Sstevel@tonic-gate * So we take the slower-but-safe route.
847c478bd9Sstevel@tonic-gate */
857c478bd9Sstevel@tonic-gate len = ntohs(hbcp->sch_len);
867c478bd9Sstevel@tonic-gate
877c478bd9Sstevel@tonic-gate /* Create an IP header, returning to the src addr from the heartbt */
887c478bd9Sstevel@tonic-gate smp = sctp_make_mp(sctp, fp, len);
897c478bd9Sstevel@tonic-gate if (smp == NULL) {
90f4b3ec61Sdh155122 SCTP_KSTAT(sctps, sctp_return_hb_failed);
917c478bd9Sstevel@tonic-gate return;
927c478bd9Sstevel@tonic-gate }
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate cp = (sctp_chunk_hdr_t *)smp->b_wptr;
957c478bd9Sstevel@tonic-gate cp->sch_id = CHUNK_HEARTBEAT_ACK;
967c478bd9Sstevel@tonic-gate cp->sch_flags = 0;
977c478bd9Sstevel@tonic-gate cp->sch_len = htons(len);
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate /* Copy the information field from the heartbeat */
1007c478bd9Sstevel@tonic-gate bcopy((void *)(hbcp + 1), (void *)(cp + 1), len - sizeof (*cp));
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate smp->b_wptr += len;
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_obchunks);
105bd670b35SErik Nordmark
106*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sctp_set_iplen(sctp, smp, fp->sf_ixa);
107*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India (void) conn_ip_output(smp, fp->sf_ixa);
108bd670b35SErik Nordmark BUMP_LOCAL(sctp->sctp_opkts);
1097c478bd9Sstevel@tonic-gate }
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate /*
1127c478bd9Sstevel@tonic-gate * The data section of the heartbeat contains a time field (lbolt64),
1137c478bd9Sstevel@tonic-gate * a 64 bit secret, followed by the v6 (possible a v4mapped) address this
1147c478bd9Sstevel@tonic-gate * heartbeat was sent to. No byte-ordering is done, since the heartbeat
1157c478bd9Sstevel@tonic-gate * is not interpreted by the peer.
1167c478bd9Sstevel@tonic-gate */
1177c478bd9Sstevel@tonic-gate void
sctp_send_heartbeat(sctp_t * sctp,sctp_faddr_t * fp)1187c478bd9Sstevel@tonic-gate sctp_send_heartbeat(sctp_t *sctp, sctp_faddr_t *fp)
1197c478bd9Sstevel@tonic-gate {
1207c478bd9Sstevel@tonic-gate sctp_chunk_hdr_t *cp;
1217c478bd9Sstevel@tonic-gate sctp_parm_hdr_t *hpp;
1227c478bd9Sstevel@tonic-gate int64_t *t;
1237c478bd9Sstevel@tonic-gate int64_t now;
1247c478bd9Sstevel@tonic-gate in6_addr_t *a;
1257c478bd9Sstevel@tonic-gate mblk_t *hbmp;
1267c478bd9Sstevel@tonic-gate size_t hblen;
127f4b3ec61Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps;
1287c478bd9Sstevel@tonic-gate
1297c478bd9Sstevel@tonic-gate dprint(3, ("sctp_send_heartbeat: to %x:%x:%x:%x from %x:%x:%x:%x\n",
130*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India SCTP_PRINTADDR(fp->sf_faddr), SCTP_PRINTADDR(fp->sf_saddr)));
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate hblen = sizeof (*cp) +
1337c478bd9Sstevel@tonic-gate sizeof (*hpp) +
1347c478bd9Sstevel@tonic-gate sizeof (*t) +
135*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sizeof (fp->sf_hb_secret) +
136*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sizeof (fp->sf_faddr);
1377c478bd9Sstevel@tonic-gate hbmp = sctp_make_mp(sctp, fp, hblen);
13877c67f2fSkcpoon if (hbmp == NULL) {
139f4b3ec61Sdh155122 SCTP_KSTAT(sctps, sctp_send_hb_failed);
1407c478bd9Sstevel@tonic-gate return;
14177c67f2fSkcpoon }
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate cp = (sctp_chunk_hdr_t *)hbmp->b_wptr;
1447c478bd9Sstevel@tonic-gate cp->sch_id = CHUNK_HEARTBEAT;
1457c478bd9Sstevel@tonic-gate cp->sch_flags = 0;
1467c478bd9Sstevel@tonic-gate cp->sch_len = hblen;
1477c478bd9Sstevel@tonic-gate cp->sch_len = htons(cp->sch_len);
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gate hpp = (sctp_parm_hdr_t *)(cp + 1);
1507c478bd9Sstevel@tonic-gate hpp->sph_type = htons(PARM_HBINFO);
1517c478bd9Sstevel@tonic-gate hpp->sph_len = hblen - sizeof (*cp);
1527c478bd9Sstevel@tonic-gate hpp->sph_len = htons(hpp->sph_len);
1537c478bd9Sstevel@tonic-gate
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate * Timestamp
1567c478bd9Sstevel@tonic-gate *
1577c478bd9Sstevel@tonic-gate * Copy the current time to the heartbeat and we can use it to
1587c478bd9Sstevel@tonic-gate * calculate the RTT when we get it back in the heartbeat ACK.
1597c478bd9Sstevel@tonic-gate */
160d3d50737SRafael Vanoni now = ddi_get_lbolt64();
1617c478bd9Sstevel@tonic-gate t = (int64_t *)(hpp + 1);
1627c478bd9Sstevel@tonic-gate bcopy(&now, t, sizeof (now));
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate * Secret
1667c478bd9Sstevel@tonic-gate *
1677c478bd9Sstevel@tonic-gate * The per peer address secret is used to make sure that the heartbeat
1687c478bd9Sstevel@tonic-gate * ack is really in response to our heartbeat. This prevents blind
1697c478bd9Sstevel@tonic-gate * spoofing of heartbeat ack to fake the validity of an address.
1707c478bd9Sstevel@tonic-gate */
1717c478bd9Sstevel@tonic-gate t++;
172*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India bcopy(&fp->sf_hb_secret, t, sizeof (uint64_t));
1737c478bd9Sstevel@tonic-gate
1747c478bd9Sstevel@tonic-gate /*
1757c478bd9Sstevel@tonic-gate * Peer address
1767c478bd9Sstevel@tonic-gate *
1777c478bd9Sstevel@tonic-gate * The peer address is used to associate the heartbeat ack with
1787c478bd9Sstevel@tonic-gate * the correct peer address. The reason is that the peer is
1797c478bd9Sstevel@tonic-gate * multihomed so that it may not use the same address as source
1807c478bd9Sstevel@tonic-gate * in response to our heartbeat.
1817c478bd9Sstevel@tonic-gate */
1827c478bd9Sstevel@tonic-gate a = (in6_addr_t *)(t + 1);
183*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India bcopy(&fp->sf_faddr, a, sizeof (*a));
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate hbmp->b_wptr += hblen;
1867c478bd9Sstevel@tonic-gate
1877c478bd9Sstevel@tonic-gate /* Update the faddr's info */
188*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_lastactive = now;
189*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_hb_pending = B_TRUE;
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_obchunks);
1925dd46ab5SKacheong Poon SCTPS_BUMP_MIB(sctps, sctpTimHeartBeatProbe);
1937c478bd9Sstevel@tonic-gate
194*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India sctp_set_iplen(sctp, hbmp, fp->sf_ixa);
195*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India (void) conn_ip_output(hbmp, fp->sf_ixa);
196bd670b35SErik Nordmark BUMP_LOCAL(sctp->sctp_opkts);
1977c478bd9Sstevel@tonic-gate }
1987c478bd9Sstevel@tonic-gate
1997c478bd9Sstevel@tonic-gate /*
2007c478bd9Sstevel@tonic-gate * Call right after any address change to validate peer addresses.
2017c478bd9Sstevel@tonic-gate */
2027c478bd9Sstevel@tonic-gate void
sctp_validate_peer(sctp_t * sctp)2037c478bd9Sstevel@tonic-gate sctp_validate_peer(sctp_t *sctp)
2047c478bd9Sstevel@tonic-gate {
2057c478bd9Sstevel@tonic-gate sctp_faddr_t *fp;
2067c478bd9Sstevel@tonic-gate int cnt;
2077c478bd9Sstevel@tonic-gate int64_t now;
2087c478bd9Sstevel@tonic-gate int64_t earliest_expiry;
209f4b3ec61Sdh155122 sctp_stack_t *sctps = sctp->sctp_sctps;
2107c478bd9Sstevel@tonic-gate
211d3d50737SRafael Vanoni now = ddi_get_lbolt64();
2127c478bd9Sstevel@tonic-gate earliest_expiry = 0;
213f4b3ec61Sdh155122 cnt = sctps->sctps_maxburst;
2147c478bd9Sstevel@tonic-gate
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate * Loop thru the list looking for unconfirmed addresses and
2177c478bd9Sstevel@tonic-gate * send a heartbeat. But we should only send at most sctp_maxburst
2187c478bd9Sstevel@tonic-gate * heartbeats.
2197c478bd9Sstevel@tonic-gate */
220*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->sf_next) {
2217c478bd9Sstevel@tonic-gate /* No need to validate unreachable address. */
222*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India if (fp->sf_state == SCTP_FADDRS_UNREACH)
2237c478bd9Sstevel@tonic-gate continue;
224*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India if (fp->sf_state == SCTP_FADDRS_UNCONFIRMED) {
2257c478bd9Sstevel@tonic-gate if (cnt-- > 0) {
226*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_hb_expiry = now + fp->sf_rto;
2277c478bd9Sstevel@tonic-gate sctp_send_heartbeat(sctp, fp);
2287c478bd9Sstevel@tonic-gate } else {
2297c478bd9Sstevel@tonic-gate /*
2307c478bd9Sstevel@tonic-gate * If we cannot send now, be more aggressive
2317c478bd9Sstevel@tonic-gate * and try again about half of RTO. Note that
2327c478bd9Sstevel@tonic-gate * all the unsent probes are set to expire at
2337c478bd9Sstevel@tonic-gate * the same time.
2347c478bd9Sstevel@tonic-gate */
235*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_hb_expiry = now +
2367c478bd9Sstevel@tonic-gate (sctp->sctp_rto_initial >> 1);
2377c478bd9Sstevel@tonic-gate }
2387c478bd9Sstevel@tonic-gate }
2397c478bd9Sstevel@tonic-gate /* Find the earliest heartbeat expiry time for ALL fps. */
240*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India if (fp->sf_hb_interval != 0 && (earliest_expiry == 0 ||
241*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_hb_expiry < earliest_expiry)) {
242*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India earliest_expiry = fp->sf_hb_expiry;
2437c478bd9Sstevel@tonic-gate }
2447c478bd9Sstevel@tonic-gate }
2457c478bd9Sstevel@tonic-gate /* We use heartbeat timer for autoclose. */
2467c478bd9Sstevel@tonic-gate if (sctp->sctp_autoclose != 0) {
2477c478bd9Sstevel@tonic-gate int64_t expire;
2487c478bd9Sstevel@tonic-gate
2497c478bd9Sstevel@tonic-gate expire = sctp->sctp_active + sctp->sctp_autoclose;
2507c478bd9Sstevel@tonic-gate if (earliest_expiry == 0 || expire < earliest_expiry)
2517c478bd9Sstevel@tonic-gate earliest_expiry = expire;
2527c478bd9Sstevel@tonic-gate }
2537c478bd9Sstevel@tonic-gate
2547c478bd9Sstevel@tonic-gate /*
2557c478bd9Sstevel@tonic-gate * Set the timer to fire for the earliest heartbeat unless
2567c478bd9Sstevel@tonic-gate * heartbeat is disabled for all addresses.
2577c478bd9Sstevel@tonic-gate */
2587c478bd9Sstevel@tonic-gate if (earliest_expiry != 0) {
2597c478bd9Sstevel@tonic-gate earliest_expiry -= now;
2607c478bd9Sstevel@tonic-gate if (earliest_expiry < 0)
2617c478bd9Sstevel@tonic-gate earliest_expiry = 1;
2627c478bd9Sstevel@tonic-gate sctp_timer(sctp, sctp->sctp_heartbeat_mp, earliest_expiry);
2637c478bd9Sstevel@tonic-gate }
2647c478bd9Sstevel@tonic-gate }
2657c478bd9Sstevel@tonic-gate
2667c478bd9Sstevel@tonic-gate /*
2677c478bd9Sstevel@tonic-gate * Process an incoming heartbeat ack. When sending a heartbeat, we
2687c478bd9Sstevel@tonic-gate * put the timestamp, a secret and the peer address the heartbeat is
2697c478bd9Sstevel@tonic-gate * sent in the data part of the heartbeat. We will extract this info
2707c478bd9Sstevel@tonic-gate * and verify that this heartbeat ack is valid.
2717c478bd9Sstevel@tonic-gate */
2727c478bd9Sstevel@tonic-gate void
sctp_process_heartbeat(sctp_t * sctp,sctp_chunk_hdr_t * cp)2737c478bd9Sstevel@tonic-gate sctp_process_heartbeat(sctp_t *sctp, sctp_chunk_hdr_t *cp)
2747c478bd9Sstevel@tonic-gate {
2757c478bd9Sstevel@tonic-gate int64_t *sentp, sent;
2767c478bd9Sstevel@tonic-gate uint64_t secret;
2777c478bd9Sstevel@tonic-gate in6_addr_t addr;
2787c478bd9Sstevel@tonic-gate sctp_faddr_t *fp;
2797c478bd9Sstevel@tonic-gate sctp_parm_hdr_t *hpp;
2807c478bd9Sstevel@tonic-gate int64_t now;
2817c478bd9Sstevel@tonic-gate
2827c478bd9Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_ibchunks);
2837c478bd9Sstevel@tonic-gate
2847c478bd9Sstevel@tonic-gate /* Sanity checks */
2857c478bd9Sstevel@tonic-gate ASSERT(OK_32PTR(cp));
2867c478bd9Sstevel@tonic-gate if (ntohs(cp->sch_len) < (sizeof (*cp) + sizeof (*hpp) +
2877c478bd9Sstevel@tonic-gate sizeof (sent) + sizeof (secret) + sizeof (addr))) {
2887c478bd9Sstevel@tonic-gate /* drop it */
2897c478bd9Sstevel@tonic-gate dprint(2, ("sctp_process_heartbeat: malformed ack %p\n",
29045916cd2Sjpk (void *)sctp));
2917c478bd9Sstevel@tonic-gate return;
2927c478bd9Sstevel@tonic-gate }
2937c478bd9Sstevel@tonic-gate
2947c478bd9Sstevel@tonic-gate hpp = (sctp_parm_hdr_t *)(cp + 1);
2957c478bd9Sstevel@tonic-gate if (ntohs(hpp->sph_type) != PARM_HBINFO ||
2967c478bd9Sstevel@tonic-gate ntohs(hpp->sph_len) != (ntohs(cp->sch_len) - sizeof (*cp))) {
2977c478bd9Sstevel@tonic-gate dprint(2,
2987c478bd9Sstevel@tonic-gate ("sctp_process_heartbeat: malformed param in ack %p\n",
29945916cd2Sjpk (void *)sctp));
3007c478bd9Sstevel@tonic-gate return;
3017c478bd9Sstevel@tonic-gate }
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate * Pull out the time sent from the ack.
3057c478bd9Sstevel@tonic-gate * SCTP is 32-bit aligned, so copy 64 bit quantity. Since we
3067c478bd9Sstevel@tonic-gate * put it in, it should be in our byte order.
3077c478bd9Sstevel@tonic-gate */
3087c478bd9Sstevel@tonic-gate sentp = (int64_t *)(hpp + 1);
3097c478bd9Sstevel@tonic-gate bcopy(sentp, &sent, sizeof (sent));
3107c478bd9Sstevel@tonic-gate
3117c478bd9Sstevel@tonic-gate /* Grab the secret to make sure that this heartbeat is valid */
3127c478bd9Sstevel@tonic-gate bcopy(++sentp, &secret, sizeof (secret));
3137c478bd9Sstevel@tonic-gate
3147c478bd9Sstevel@tonic-gate /* Next, verify the address to make sure that it is the right one. */
3157c478bd9Sstevel@tonic-gate bcopy(++sentp, &addr, sizeof (addr));
3167c478bd9Sstevel@tonic-gate fp = sctp_lookup_faddr(sctp, &addr);
3177c478bd9Sstevel@tonic-gate if (fp == NULL) {
3187c478bd9Sstevel@tonic-gate dprint(2, ("sctp_process_heartbeat: invalid faddr (sctp=%p)\n",
31945916cd2Sjpk (void *)sctp));
3207c478bd9Sstevel@tonic-gate return;
3217c478bd9Sstevel@tonic-gate }
322*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India if (secret != fp->sf_hb_secret) {
3237c478bd9Sstevel@tonic-gate dprint(2,
3247c478bd9Sstevel@tonic-gate ("sctp_process_heartbeat: invalid secret in ack %p\n",
32545916cd2Sjpk (void *)sctp));
3267c478bd9Sstevel@tonic-gate return;
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gate /* This address is now confirmed and alive. */
3307c478bd9Sstevel@tonic-gate sctp_faddr_alive(sctp, fp);
331d3d50737SRafael Vanoni now = ddi_get_lbolt64();
3327c478bd9Sstevel@tonic-gate sctp_update_rtt(sctp, fp, now - sent);
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate /*
3357c478bd9Sstevel@tonic-gate * Note that the heartbeat timer should still be running, we don't
3367c478bd9Sstevel@tonic-gate * reset it to avoid going through the whole list of peer addresses
3377c478bd9Sstevel@tonic-gate * for each heartbeat ack as we probably are in interrupt context.
3387c478bd9Sstevel@tonic-gate */
339*6be61d4eSchandrasekar marimuthu - Sun Microsystems - Bangalore India fp->sf_hb_expiry = now + SET_HB_INTVL(fp);
3407c478bd9Sstevel@tonic-gate }
341