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