tcp_timewait.c revision 32752
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *	This product includes software developed by the University of
16 *	California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 *    may be used to endorse or promote products derived from this software
19 *    without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 *	@(#)tcp_subr.c	8.2 (Berkeley) 5/24/95
34 *	$Id: tcp_subr.c,v 1.40 1997/12/19 03:36:14 julian Exp $
35 */
36
37#include "opt_compat.h"
38#include "opt_tcpdebug.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>
43#include <sys/sysctl.h>
44#include <sys/malloc.h>
45#include <sys/mbuf.h>
46#include <sys/socket.h>
47#include <sys/socketvar.h>
48#include <sys/protosw.h>
49
50#include <net/route.h>
51#include <net/if.h>
52
53#define _IP_VHL
54#include <netinet/in.h>
55#include <netinet/in_systm.h>
56#include <netinet/ip.h>
57#include <netinet/in_pcb.h>
58#include <netinet/in_var.h>
59#include <netinet/ip_var.h>
60#include <netinet/tcp.h>
61#include <netinet/tcp_fsm.h>
62#include <netinet/tcp_seq.h>
63#include <netinet/tcp_timer.h>
64#include <netinet/tcp_var.h>
65#include <netinet/tcpip.h>
66#ifdef TCPDEBUG
67#include <netinet/tcp_debug.h>
68#endif
69
70int 	tcp_mssdflt = TCP_MSS;
71SYSCTL_INT(_net_inet_tcp, TCPCTL_MSSDFLT, mssdflt,
72	CTLFLAG_RW, &tcp_mssdflt , 0, "");
73
74static int 	tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
75SYSCTL_INT(_net_inet_tcp, TCPCTL_RTTDFLT, rttdflt,
76	CTLFLAG_RW, &tcp_rttdflt , 0, "");
77
78static int	tcp_do_rfc1323 = 1;
79SYSCTL_INT(_net_inet_tcp, TCPCTL_DO_RFC1323, rfc1323,
80	CTLFLAG_RW, &tcp_do_rfc1323 , 0, "");
81
82static int	tcp_do_rfc1644 = 1;
83SYSCTL_INT(_net_inet_tcp, TCPCTL_DO_RFC1644, rfc1644,
84	CTLFLAG_RW, &tcp_do_rfc1644 , 0, "");
85
86static void	tcp_cleartaocache __P((void));
87static void	tcp_notify __P((struct inpcb *, int));
88
89/*
90 * Target size of TCP PCB hash table. Will be rounded down to a prime
91 * number.
92 */
93#ifndef TCBHASHSIZE
94#define TCBHASHSIZE	128
95#endif
96
97/*
98 * Tcp initialization
99 */
100void
101tcp_init()
102{
103
104	tcp_iss = random();	/* wrong, but better than a constant */
105	tcp_ccgen = 1;
106	tcp_cleartaocache();
107	LIST_INIT(&tcb);
108	tcbinfo.listhead = &tcb;
109	tcbinfo.hashbase = hashinit(TCBHASHSIZE, M_PCB, &tcbinfo.hashmask);
110	if (max_protohdr < sizeof(struct tcpiphdr))
111		max_protohdr = sizeof(struct tcpiphdr);
112	if (max_linkhdr + sizeof(struct tcpiphdr) > MHLEN)
113		panic("tcp_init");
114}
115
116/*
117 * Create template to be used to send tcp packets on a connection.
118 * Call after host entry created, allocates an mbuf and fills
119 * in a skeletal tcp/ip header, minimizing the amount of work
120 * necessary when the connection is used.
121 */
122struct tcpiphdr *
123tcp_template(tp)
124	struct tcpcb *tp;
125{
126	register struct inpcb *inp = tp->t_inpcb;
127	register struct mbuf *m;
128	register struct tcpiphdr *n;
129
130	if ((n = tp->t_template) == 0) {
131		m = m_get(M_DONTWAIT, MT_HEADER);
132		if (m == NULL)
133			return (0);
134		m->m_len = sizeof (struct tcpiphdr);
135		n = mtod(m, struct tcpiphdr *);
136	}
137	n->ti_next = n->ti_prev = 0;
138	n->ti_x1 = 0;
139	n->ti_pr = IPPROTO_TCP;
140	n->ti_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));
141	n->ti_src = inp->inp_laddr;
142	n->ti_dst = inp->inp_faddr;
143	n->ti_sport = inp->inp_lport;
144	n->ti_dport = inp->inp_fport;
145	n->ti_seq = 0;
146	n->ti_ack = 0;
147	n->ti_x2 = 0;
148	n->ti_off = 5;
149	n->ti_flags = 0;
150	n->ti_win = 0;
151	n->ti_sum = 0;
152	n->ti_urp = 0;
153	return (n);
154}
155
156/*
157 * Send a single message to the TCP at address specified by
158 * the given TCP/IP header.  If m == 0, then we make a copy
159 * of the tcpiphdr at ti and send directly to the addressed host.
160 * This is used to force keep alive messages out using the TCP
161 * template for a connection tp->t_template.  If flags are given
162 * then we send a message back to the TCP which originated the
163 * segment ti, and discard the mbuf containing it and any other
164 * attached mbufs.
165 *
166 * In any case the ack and sequence number of the transmitted
167 * segment are as specified by the parameters.
168 *
169 * NOTE: If m != NULL, then ti must point to *inside* the mbuf.
170 */
171void
172tcp_respond(tp, ti, m, ack, seq, flags)
173	struct tcpcb *tp;
174	register struct tcpiphdr *ti;
175	register struct mbuf *m;
176	tcp_seq ack, seq;
177	int flags;
178{
179	register int tlen;
180	int win = 0;
181	struct route *ro = 0;
182	struct route sro;
183
184	if (tp) {
185		win = sbspace(&tp->t_inpcb->inp_socket->so_rcv);
186		ro = &tp->t_inpcb->inp_route;
187	} else {
188		ro = &sro;
189		bzero(ro, sizeof *ro);
190	}
191	if (m == 0) {
192		m = m_gethdr(M_DONTWAIT, MT_HEADER);
193		if (m == NULL)
194			return;
195#ifdef TCP_COMPAT_42
196		tlen = 1;
197#else
198		tlen = 0;
199#endif
200		m->m_data += max_linkhdr;
201		*mtod(m, struct tcpiphdr *) = *ti;
202		ti = mtod(m, struct tcpiphdr *);
203		flags = TH_ACK;
204	} else {
205		m_freem(m->m_next);
206		m->m_next = 0;
207		m->m_data = (caddr_t)ti;
208		m->m_len = sizeof (struct tcpiphdr);
209		tlen = 0;
210#define xchg(a,b,type) { type t; t=a; a=b; b=t; }
211		xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, u_long);
212		xchg(ti->ti_dport, ti->ti_sport, u_short);
213#undef xchg
214	}
215	ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
216	tlen += sizeof (struct tcpiphdr);
217	m->m_len = tlen;
218	m->m_pkthdr.len = tlen;
219	m->m_pkthdr.rcvif = (struct ifnet *) 0;
220	ti->ti_next = ti->ti_prev = 0;
221	ti->ti_x1 = 0;
222	ti->ti_seq = htonl(seq);
223	ti->ti_ack = htonl(ack);
224	ti->ti_x2 = 0;
225	ti->ti_off = sizeof (struct tcphdr) >> 2;
226	ti->ti_flags = flags;
227	if (tp)
228		ti->ti_win = htons((u_short) (win >> tp->rcv_scale));
229	else
230		ti->ti_win = htons((u_short)win);
231	ti->ti_urp = 0;
232	ti->ti_sum = 0;
233	ti->ti_sum = in_cksum(m, tlen);
234	((struct ip *)ti)->ip_len = tlen;
235	((struct ip *)ti)->ip_ttl = ip_defttl;
236#ifdef TCPDEBUG
237	if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
238		tcp_trace(TA_OUTPUT, 0, tp, ti, 0);
239#endif
240	(void) ip_output(m, NULL, ro, 0, NULL);
241	if (ro == &sro && ro->ro_rt) {
242		RTFREE(ro->ro_rt);
243	}
244}
245
246/*
247 * Create a new TCP control block, making an
248 * empty reassembly queue and hooking it to the argument
249 * protocol control block.
250 */
251struct tcpcb *
252tcp_newtcpcb(inp)
253	struct inpcb *inp;
254{
255	register struct tcpcb *tp;
256
257	tp = malloc(sizeof(*tp), M_PCB, M_NOWAIT);
258	if (tp == NULL)
259		return ((struct tcpcb *)0);
260	bzero((char *) tp, sizeof(struct tcpcb));
261	tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
262	tp->t_maxseg = tp->t_maxopd = tcp_mssdflt;
263
264	if (tcp_do_rfc1323)
265		tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP);
266	if (tcp_do_rfc1644)
267		tp->t_flags |= TF_REQ_CC;
268	tp->t_inpcb = inp;
269	/*
270	 * Init srtt to TCPTV_SRTTBASE (0), so we can tell that we have no
271	 * rtt estimate.  Set rttvar so that srtt + 4 * rttvar gives
272	 * reasonable initial retransmit time.
273	 */
274	tp->t_srtt = TCPTV_SRTTBASE;
275	tp->t_rttvar = ((TCPTV_RTOBASE - TCPTV_SRTTBASE) << TCP_RTTVAR_SHIFT) / 4;
276	tp->t_rttmin = TCPTV_MIN;
277	tp->t_rxtcur = TCPTV_RTOBASE;
278	tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
279	tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
280	inp->inp_ip_ttl = ip_defttl;
281	inp->inp_ppcb = (caddr_t)tp;
282	return (tp);
283}
284
285/*
286 * Drop a TCP connection, reporting
287 * the specified error.  If connection is synchronized,
288 * then send a RST to peer.
289 */
290struct tcpcb *
291tcp_drop(tp, errno)
292	register struct tcpcb *tp;
293	int errno;
294{
295	struct socket *so = tp->t_inpcb->inp_socket;
296
297	if (TCPS_HAVERCVDSYN(tp->t_state)) {
298		tp->t_state = TCPS_CLOSED;
299		(void) tcp_output(tp);
300		tcpstat.tcps_drops++;
301	} else
302		tcpstat.tcps_conndrops++;
303	if (errno == ETIMEDOUT && tp->t_softerror)
304		errno = tp->t_softerror;
305	so->so_error = errno;
306	return (tcp_close(tp));
307}
308
309/*
310 * Close a TCP control block:
311 *	discard all space held by the tcp
312 *	discard internet protocol block
313 *	wake up any sleepers
314 */
315struct tcpcb *
316tcp_close(tp)
317	register struct tcpcb *tp;
318{
319	register struct tcpiphdr *t;
320	struct inpcb *inp = tp->t_inpcb;
321	struct socket *so = inp->inp_socket;
322	register struct mbuf *m;
323	register struct rtentry *rt;
324	int dosavessthresh;
325
326	/*
327	 * If we got enough samples through the srtt filter,
328	 * save the rtt and rttvar in the routing entry.
329	 * 'Enough' is arbitrarily defined as the 16 samples.
330	 * 16 samples is enough for the srtt filter to converge
331	 * to within 5% of the correct value; fewer samples and
332	 * we could save a very bogus rtt.
333	 *
334	 * Don't update the default route's characteristics and don't
335	 * update anything that the user "locked".
336	 */
337	if (tp->t_rttupdated >= 16 &&
338	    (rt = inp->inp_route.ro_rt) &&
339	    ((struct sockaddr_in *)rt_key(rt))->sin_addr.s_addr != INADDR_ANY) {
340		register u_long i = 0;
341
342		if ((rt->rt_rmx.rmx_locks & RTV_RTT) == 0) {
343			i = tp->t_srtt *
344			    (RTM_RTTUNIT / (PR_SLOWHZ * TCP_RTT_SCALE));
345			if (rt->rt_rmx.rmx_rtt && i)
346				/*
347				 * filter this update to half the old & half
348				 * the new values, converting scale.
349				 * See route.h and tcp_var.h for a
350				 * description of the scaling constants.
351				 */
352				rt->rt_rmx.rmx_rtt =
353				    (rt->rt_rmx.rmx_rtt + i) / 2;
354			else
355				rt->rt_rmx.rmx_rtt = i;
356			tcpstat.tcps_cachedrtt++;
357		}
358		if ((rt->rt_rmx.rmx_locks & RTV_RTTVAR) == 0) {
359			i = tp->t_rttvar *
360			    (RTM_RTTUNIT / (PR_SLOWHZ * TCP_RTTVAR_SCALE));
361			if (rt->rt_rmx.rmx_rttvar && i)
362				rt->rt_rmx.rmx_rttvar =
363				    (rt->rt_rmx.rmx_rttvar + i) / 2;
364			else
365				rt->rt_rmx.rmx_rttvar = i;
366			tcpstat.tcps_cachedrttvar++;
367		}
368		/*
369		 * The old comment here said:
370		 * update the pipelimit (ssthresh) if it has been updated
371		 * already or if a pipesize was specified & the threshhold
372		 * got below half the pipesize.  I.e., wait for bad news
373		 * before we start updating, then update on both good
374		 * and bad news.
375		 *
376		 * But we want to save the ssthresh even if no pipesize is
377		 * specified explicitly in the route, because such
378		 * connections still have an implicit pipesize specified
379		 * by the global tcp_sendspace.  In the absence of a reliable
380		 * way to calculate the pipesize, it will have to do.
381		 */
382		i = tp->snd_ssthresh;
383#if 1
384		if (rt->rt_rmx.rmx_sendpipe != 0)
385			dosavessthresh = (i < rt->rt_rmx.rmx_sendpipe / 2);
386		else
387			dosavessthresh = (i < so->so_snd.sb_hiwat / 2);
388#else
389		dosavessthresh = (i < rt->rt_rmx.rmx_sendpipe / 2);
390#endif
391		if (((rt->rt_rmx.rmx_locks & RTV_SSTHRESH) == 0 &&
392		     i != 0 && rt->rt_rmx.rmx_ssthresh != 0)
393		    || dosavessthresh) {
394			/*
395			 * convert the limit from user data bytes to
396			 * packets then to packet data bytes.
397			 */
398			i = (i + tp->t_maxseg / 2) / tp->t_maxseg;
399			if (i < 2)
400				i = 2;
401			i *= (u_long)(tp->t_maxseg + sizeof (struct tcpiphdr));
402			if (rt->rt_rmx.rmx_ssthresh)
403				rt->rt_rmx.rmx_ssthresh =
404				    (rt->rt_rmx.rmx_ssthresh + i) / 2;
405			else
406				rt->rt_rmx.rmx_ssthresh = i;
407			tcpstat.tcps_cachedssthresh++;
408		}
409	}
410	/* free the reassembly queue, if any */
411	t = tp->seg_next;
412	while (t != (struct tcpiphdr *)tp) {
413		t = (struct tcpiphdr *)t->ti_next;
414		m = REASS_MBUF((struct tcpiphdr *)t->ti_prev);
415		remque(t->ti_prev);
416		m_freem(m);
417	}
418	if (tp->t_template)
419		(void) m_free(dtom(tp->t_template));
420	free(tp, M_PCB);
421	inp->inp_ppcb = 0;
422	soisdisconnected(so);
423	in_pcbdetach(inp);
424	tcpstat.tcps_closed++;
425	return ((struct tcpcb *)0);
426}
427
428void
429tcp_drain()
430{
431
432}
433
434/*
435 * Notify a tcp user of an asynchronous error;
436 * store error as soft error, but wake up user
437 * (for now, won't do anything until can select for soft error).
438 */
439static void
440tcp_notify(inp, error)
441	struct inpcb *inp;
442	int error;
443{
444	register struct tcpcb *tp = (struct tcpcb *)inp->inp_ppcb;
445	register struct socket *so = inp->inp_socket;
446
447	/*
448	 * Ignore some errors if we are hooked up.
449	 * If connection hasn't completed, has retransmitted several times,
450	 * and receives a second error, give up now.  This is better
451	 * than waiting a long time to establish a connection that
452	 * can never complete.
453	 */
454	if (tp->t_state == TCPS_ESTABLISHED &&
455	     (error == EHOSTUNREACH || error == ENETUNREACH ||
456	      error == EHOSTDOWN)) {
457		return;
458	} else if (tp->t_state < TCPS_ESTABLISHED && tp->t_rxtshift > 3 &&
459	    tp->t_softerror)
460		so->so_error = error;
461	else
462		tp->t_softerror = error;
463	wakeup((caddr_t) &so->so_timeo);
464	sorwakeup(so);
465	sowwakeup(so);
466}
467
468void
469tcp_ctlinput(cmd, sa, vip)
470	int cmd;
471	struct sockaddr *sa;
472	void *vip;
473{
474	register struct ip *ip = vip;
475	register struct tcphdr *th;
476	void (*notify) __P((struct inpcb *, int)) = tcp_notify;
477
478	if (cmd == PRC_QUENCH)
479		notify = tcp_quench;
480#if 1
481	else if (cmd == PRC_MSGSIZE)
482		notify = tcp_mtudisc;
483#endif
484	else if (!PRC_IS_REDIRECT(cmd) &&
485		 ((unsigned)cmd > PRC_NCMDS || inetctlerrmap[cmd] == 0))
486		return;
487	if (ip) {
488		th = (struct tcphdr *)((caddr_t)ip
489				       + (IP_VHL_HL(ip->ip_vhl) << 2));
490		in_pcbnotify(&tcb, sa, th->th_dport, ip->ip_src, th->th_sport,
491			cmd, notify);
492	} else
493		in_pcbnotify(&tcb, sa, 0, zeroin_addr, 0, cmd, notify);
494}
495
496/*
497 * When a source quench is received, close congestion window
498 * to one segment.  We will gradually open it again as we proceed.
499 */
500void
501tcp_quench(inp, errno)
502	struct inpcb *inp;
503	int errno;
504{
505	struct tcpcb *tp = intotcpcb(inp);
506
507	if (tp)
508		tp->snd_cwnd = tp->t_maxseg;
509}
510
511#if 1
512/*
513 * When `need fragmentation' ICMP is received, update our idea of the MSS
514 * based on the new value in the route.  Also nudge TCP to send something,
515 * since we know the packet we just sent was dropped.
516 * This duplicates some code in the tcp_mss() function in tcp_input.c.
517 */
518void
519tcp_mtudisc(inp, errno)
520	struct inpcb *inp;
521	int errno;
522{
523	struct tcpcb *tp = intotcpcb(inp);
524	struct rtentry *rt;
525	struct rmxp_tao *taop;
526	struct socket *so = inp->inp_socket;
527	int offered;
528	int mss;
529
530	if (tp) {
531		rt = tcp_rtlookup(inp);
532		if (!rt || !rt->rt_rmx.rmx_mtu) {
533			tp->t_maxopd = tp->t_maxseg = tcp_mssdflt;
534			return;
535		}
536		taop = rmx_taop(rt->rt_rmx);
537		offered = taop->tao_mssopt;
538		mss = rt->rt_rmx.rmx_mtu - sizeof(struct tcpiphdr);
539		if (offered)
540			mss = min(mss, offered);
541		/*
542		 * XXX - The above conditional probably violates the TCP
543		 * spec.  The problem is that, since we don't know the
544		 * other end's MSS, we are supposed to use a conservative
545		 * default.  But, if we do that, then MTU discovery will
546		 * never actually take place, because the conservative
547		 * default is much less than the MTUs typically seen
548		 * on the Internet today.  For the moment, we'll sweep
549		 * this under the carpet.
550		 *
551		 * The conservative default might not actually be a problem
552		 * if the only case this occurs is when sending an initial
553		 * SYN with options and data to a host we've never talked
554		 * to before.  Then, they will reply with an MSS value which
555		 * will get recorded and the new parameters should get
556		 * recomputed.  For Further Study.
557		 */
558		if (tp->t_maxopd <= mss)
559			return;
560		tp->t_maxopd = mss;
561
562		if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
563		    (tp->t_flags & TF_RCVD_TSTMP) == TF_RCVD_TSTMP)
564			mss -= TCPOLEN_TSTAMP_APPA;
565		if ((tp->t_flags & (TF_REQ_CC|TF_NOOPT)) == TF_REQ_CC &&
566		    (tp->t_flags & TF_RCVD_CC) == TF_RCVD_CC)
567			mss -= TCPOLEN_CC_APPA;
568#if	(MCLBYTES & (MCLBYTES - 1)) == 0
569		if (mss > MCLBYTES)
570			mss &= ~(MCLBYTES-1);
571#else
572		if (mss > MCLBYTES)
573			mss = mss / MCLBYTES * MCLBYTES;
574#endif
575		if (so->so_snd.sb_hiwat < mss)
576			mss = so->so_snd.sb_hiwat;
577
578		tp->t_maxseg = mss;
579
580		tcpstat.tcps_mturesent++;
581		tp->t_rtt = 0;
582		tp->snd_nxt = tp->snd_una;
583		tcp_output(tp);
584	}
585}
586#endif
587
588/*
589 * Look-up the routing entry to the peer of this inpcb.  If no route
590 * is found and it cannot be allocated the return NULL.  This routine
591 * is called by TCP routines that access the rmx structure and by tcp_mss
592 * to get the interface MTU.
593 */
594struct rtentry *
595tcp_rtlookup(inp)
596	struct inpcb *inp;
597{
598	struct route *ro;
599	struct rtentry *rt;
600
601	ro = &inp->inp_route;
602	rt = ro->ro_rt;
603	if (rt == NULL || !(rt->rt_flags & RTF_UP)) {
604		/* No route yet, so try to acquire one */
605		if (inp->inp_faddr.s_addr != INADDR_ANY) {
606			ro->ro_dst.sa_family = AF_INET;
607			ro->ro_dst.sa_len = sizeof(ro->ro_dst);
608			((struct sockaddr_in *) &ro->ro_dst)->sin_addr =
609				inp->inp_faddr;
610			rtalloc(ro);
611			rt = ro->ro_rt;
612		}
613	}
614	return rt;
615}
616
617/*
618 * Return a pointer to the cached information about the remote host.
619 * The cached information is stored in the protocol specific part of
620 * the route metrics.
621 */
622struct rmxp_tao *
623tcp_gettaocache(inp)
624	struct inpcb *inp;
625{
626	struct rtentry *rt = tcp_rtlookup(inp);
627
628	/* Make sure this is a host route and is up. */
629	if (rt == NULL ||
630	    (rt->rt_flags & (RTF_UP|RTF_HOST)) != (RTF_UP|RTF_HOST))
631		return NULL;
632
633	return rmx_taop(rt->rt_rmx);
634}
635
636/*
637 * Clear all the TAO cache entries, called from tcp_init.
638 *
639 * XXX
640 * This routine is just an empty one, because we assume that the routing
641 * routing tables are initialized at the same time when TCP, so there is
642 * nothing in the cache left over.
643 */
644static void
645tcp_cleartaocache()
646{
647}
648