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