X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/3b35bf499f76e67f8f24afd8572a953ec82c4c18..795abf1316db53d4abdc5bff180f2b2376c5cfe4:/sys/netinet/tcp_input.c diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 7b07db2f6c..21f9df5138 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)tcp_input.c 7.25 (Berkeley) 6/30/90 - * $Id: tcp_input.c,v 1.3 1993/11/25 01:35:13 wollman Exp $ + * $Id: tcp_input.c,v 1.8 1994/01/30 01:00:28 davidg Exp $ */ #include "param.h" @@ -57,7 +57,9 @@ #include "tcp_timer.h" #include "tcp_var.h" #include "tcpip.h" +#ifdef TCPDEBUG #include "tcp_debug.h" +#endif static void tcp_dooptions(struct tcpcb *, struct mbuf *, struct tcpiphdr *); static void tcp_pulloutofband(struct socket *, struct tcpiphdr *, struct mbuf *); @@ -67,7 +69,9 @@ int tcprexmtthresh = 3; int tcppredack; /* XXX debugging: times hdr predict ok for acks */ int tcppreddat; /* XXX # times header prediction ok for data packets */ int tcppcbcachemiss; +#ifdef TCPDEBUG struct tcpiphdr tcp_saveti; +#endif struct inpcb *tcp_last_inpcb = &tcb; @@ -219,10 +223,12 @@ tcp_input(m, iphlen) register int tiflags; struct socket *so = 0; int todrop, acked, ourfinisacked, needoutput = 0; - short ostate = 0; struct in_addr laddr; int dropsocket = 0; int iss = 0; +#ifdef TCPDEBUG + short ostate = 0; +#endif tcpstat.tcps_rcvtotal++; /* @@ -326,10 +332,12 @@ findpcb: goto drop; so = inp->inp_socket; if (so->so_options & (SO_DEBUG|SO_ACCEPTCONN)) { +#ifdef TCPDEBUG if (so->so_options & SO_DEBUG) { ostate = tp->t_state; tcp_saveti = *ti; } +#endif if (so->so_options & SO_ACCEPTCONN) { so = sonewconn(so, 0); if (so == 0) @@ -448,7 +456,17 @@ findpcb: m->m_len -= sizeof(struct tcpiphdr); sbappend(&so->so_rcv, m); sorwakeup(so); - tp->t_flags |= TF_DELACK; + /* + * If this is a small packet, then ACK now - with Nagel + * congestion avoidance sender won't send more until + * he gets an ACK. + */ + if ((unsigned)ti->ti_len < tp->t_maxseg) { + tp->t_flags |= TF_ACKNOW; + tcp_output(tp); + } else { + tp->t_flags |= TF_DELACK; + } return; } } @@ -1149,8 +1167,18 @@ dodata: /* XXX */ break; } } +#ifdef TCPDEBUG if (so->so_options & SO_DEBUG) tcp_trace(TA_INPUT, ostate, tp, &tcp_saveti, 0); +#endif + + /* + * If this is a small packet, then ACK now - with Nagel + * congestion avoidance sender won't send more until + * he gets an ACK. + */ + if (ti->ti_len && ((unsigned)ti->ti_len < tp->t_maxseg)) + tp->t_flags |= TF_ACKNOW; /* * Return any desired output. @@ -1202,8 +1230,10 @@ drop: /* * Drop space held by incoming segment and return. */ +#ifdef TCPDEBUG if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) tcp_trace(TA_DROP, ostate, tp, &tcp_saveti, 0); +#endif m_freem(m); /* destroy temporarily created socket */ if (dropsocket) @@ -1470,20 +1500,22 @@ tcp_mss(tp, offer) bufsize = so->so_snd.sb_hiwat; if (bufsize < mss) mss = bufsize; - else { + else bufsize = min(bufsize, SB_MAX) / mss * mss; - (void) sbreserve(&so->so_snd, bufsize); - } + + (void) sbreserve(&so->so_snd, bufsize); tp->t_maxseg = mss; #ifdef RTV_RPIPE if ((bufsize = rt->rt_rmx.rmx_recvpipe) == 0) #endif bufsize = so->so_rcv.sb_hiwat; - if (bufsize > mss) { + if (bufsize < mss) + bufsize = mss; + else bufsize = min(bufsize, SB_MAX) / mss * mss; - (void) sbreserve(&so->so_rcv, bufsize); - } + + (void) sbreserve(&so->so_rcv, bufsize); } tp->snd_cwnd = mss;