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