PERFORCE change 165539 for review

Andre Oppermann andre at FreeBSD.org
Thu Jul 2 11:18:48 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=165539

Change 165539 by andre at andre_flirtbox on 2009/07/02 11:18:45

	Fix up function prototypes, add variables, comment out gone
	or currently unresolved stuff, hackery...
	
	Makes tcp_new syntactically correct enough to compile but
	not functional or useable yet.

Affected files ...

.. //depot/projects/tcp_new/modules/Makefile#3 edit
.. //depot/projects/tcp_new/netinet/tcp.h#4 edit
.. //depot/projects/tcp_new/netinet/tcp_input.c#12 edit
.. //depot/projects/tcp_new/netinet/tcp_output.c#10 edit
.. //depot/projects/tcp_new/netinet/tcp_reass.c#2 edit
.. //depot/projects/tcp_new/netinet/tcp_sack.c#2 edit
.. //depot/projects/tcp_new/netinet/tcp_seq.h#2 edit
.. //depot/projects/tcp_new/netinet/tcp_subr.c#5 edit
.. //depot/projects/tcp_new/netinet/tcp_syncache.c#5 edit
.. //depot/projects/tcp_new/netinet/tcp_syncache.h#2 edit
.. //depot/projects/tcp_new/netinet/tcp_timer.c#3 edit
.. //depot/projects/tcp_new/netinet/tcp_timewait.c#2 edit
.. //depot/projects/tcp_new/netinet/tcp_usrreq.c#4 edit
.. //depot/projects/tcp_new/netinet/tcp_var.h#10 edit

Differences ...

==== //depot/projects/tcp_new/modules/Makefile#3 (text+ko) ====

@@ -64,7 +64,6 @@
 	${_ctau} \
 	cue \
 	${_cx} \
-	cxgb \
 	dc \
 	dcons \
 	dcons_crom \

==== //depot/projects/tcp_new/netinet/tcp.h#4 (text+ko) ====


==== //depot/projects/tcp_new/netinet/tcp_input.c#12 (text+ko) ====

@@ -128,10 +128,10 @@
     &tcp_do_rfc3390, 0,
     "Enable RFC 3390 (Increasing TCP's Initial Congestion Window)");
 
-static int tcp_insecure_rst = 0;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_RW,
-    &tcp_insecure_rst, 0,
-    "Follow the old (insecure) criteria for accepting RST packets");
+static int tcp_secure_rst = 0;
+SYSCTL_INT(_net_inet_tcp, OID_AUTO, secure_rst, CTLFLAG_RW,
+    &tcp_secure_rst, 0,
+    "Follow the new (secure) criteria for accepting RST packets");
 
 int	tcp_do_autorcvbuf = 1;
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, recvbuf_auto, CTLFLAG_RW,
@@ -150,21 +150,25 @@
 #define	tcb6	tcb  /* for KAME src sync over BSD*'s */
 struct inpcbinfo tcbinfo;
 
-static void	 tcp_dooptions(struct tcpopt *, u_char *, int, int);
+static void	 tcp_do_options(struct tcpopt *, u_char *, int, int);
+static void	 tcp_do_ack(struct tcpcb *tp, struct tcphdr *th, int tiwin,
+		     int acked, int tlen, int sacked);
+static int	 tcp_do_rto(struct tcpcb *tp, int rtt);
 static void	 tcp_do_segment(struct mbuf *, struct tcphdr *,
 		     struct socket *, struct tcpcb *, int, int);
 static void	 tcp_do_time(struct tcpcb *tp, struct tcphdr *th,
-		     struct tcpopt *to, int acked, int tlen);
-static void	 tcp_do_urg(struct tcpcb *tp, struct tcphdr *th, int tlen);
-static void	 tcp_do_wu(struct tcpcb *tp, struct tcphdr *th,
+		     struct tcpopt *to, int acked, int tlen, int sacked);
+static void	 tcp_do_urg(struct tcpcb *tp, struct socket *so,
+		     struct tcphdr *th, int *tlen);
+static int	 tcp_do_wu(struct tcpcb *tp, struct tcphdr *th,
 		     struct tcpopt *to, int tiwin, int acked, int tlen,
 		     int sacked);
 static void	 tcp_dropwithreset(struct mbuf *, struct tcphdr *,
 		     struct tcpcb *, int, int);
+int		 tcp_init_cwnd(struct tcpcb *tp);
+static void	 tcp_init_values(struct tcpcb *tp);
 static void	 tcp_pulloutofband(struct socket *,
 		     struct tcphdr *, struct mbuf *, int);
-static void	 tcp_xmit_timer(struct tcpcb *, int);
-static void	 tcp_newreno_partial_ack(struct tcpcb *, struct tcphdr *);
 
 /* Neighbor Discovery, Neighbor Unreachability Detection Upper layer hint. */
 #ifdef INET6
@@ -504,7 +508,7 @@
 	 */
 	if (inp->inp_vflag & INP_TIMEWAIT) {
 		if (thflags & TH_SYN)
-			tcp_dooptions(&to, optp, optlen, TO_SYN);
+			tcp_do_options(&to, optp, optlen, TO_SYN);
 		/*
 		 * NB: tcp_twcheck unlocks the INP and frees the mbuf.
 		 */
@@ -580,7 +584,7 @@
 			 * syncookies need access to the reflected
 			 * timestamp.
 			 */
-			tcp_dooptions(&to, optp, optlen, 0);
+			tcp_do_options(&to, optp, optlen, 0);
 			/*
 			 * NB: syncache_expand() doesn't unlock
 			 * inp and tcpinfo locks.
@@ -819,7 +823,7 @@
 			tcp_trace(TA_INPUT, ostate, tp,
 			    (void *)tcp_saveipgen, &tcp_savetcp, 0);
 #endif
-		tcp_dooptions(&to, optp, optlen, TO_SYN);
+		tcp_do_options(&to, optp, optlen, TO_SYN);
 		syncache_add(&inc, &to, th, inp, &so, m);
 		/*
 		 * Entry added to syncache and mbuf consumed.
@@ -856,7 +860,7 @@
 	return;
 }
 
-#define	tcplog	(s = tcp_log_addrs(tcpcbtoinc(tp), th, NULL, NULL))
+#define	tcplog(x)  (s = tcp_log_addrs(&tp->t_inpcb->inp_inc, th, NULL, NULL))
 
 static void
 tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
@@ -898,7 +902,7 @@
 	 *  RFC1122: section 4.2.2.5
 	 */
 	if ((th->th_off << 2) != sizeof(struct tcphdr))
-		tcp_dooptions(&to, (u_char *)(th + 1),
+		tcp_do_options(&to, (u_char *)(th + 1),
 		    (th->th_off << 2) - sizeof(struct tcphdr),
 		    (thflags & TH_SYN) ? TO_SYN : 0);
 	else
@@ -1021,9 +1025,9 @@
 		 * SYN and once when get back the SYN-ACK.
 		 */
 		if (to.to_flags & TOF_MSS)
-			tp->snd_mss = tcp_mss(tptoinpinc(tp), to.to_mss, 0);
+			tp->snd_mss = tcp_mss(tcpcbtoinc(tp), to.to_mss, 0);
 		else
-			tp->snd_mss = tcp_mss(tptoinpinc(tp), 0, 0);
+			tp->snd_mss = tcp_mss(tcpcbtoinc(tp), 0, 0);
 
 		/*
 		 * Do window scaling on this connection?
@@ -1048,7 +1052,7 @@
 			 */
 			tcplog("Window Scaling Option unexpected, "
 			    "connection aborted");
-			tp->t_error = ENETRESET;	/* XXXAO: Correct error? */
+			tp->t_softerror = ENETRESET;	/* XXXAO: Correct error? */
 			tp = tcp_close(tp);
 			rstreason = BANDLIM_UNLIMITED;
 			goto dropwithreset;
@@ -1070,7 +1074,7 @@
 			 */
 			tcplog("Timestamp Option unexpected, "
 			    "connection aborted");
-			tp->t_error = ENETRESET;
+			tp->t_softerror = ENETRESET;
 			tp = tcp_close(tp);
 			rstreason = BANDLIM_UNLIMITED;
 			goto dropwithreset;
@@ -1092,7 +1096,7 @@
 			 */
 			tcplog("SACK Permitted unexpected, "
 			    "connection aborted");
-			tp->t_error = ENETRESET;
+			tp->t_softerror = ENETRESET;
 			tp = tcp_close(tp);
 			rstreason = BANDLIM_UNLIMITED;
 			goto dropwithreset;
@@ -1102,13 +1106,12 @@
 		 * Initialize receive structure.
 		 * XXXAO: TODO
 		 */
-		tp->rcv_adv += rwin;	/* XXX */
-		tp->irs = th->th_seq;
+		tp->rcv_advwin += rwin;	/* XXX */
 		tp->rcv_up = th->th_seq;
-		tcp_rcvseqinit(tp);
 
-		tcp_init_rcv(tp, seq);	/* XXXAO */
-		tcp_init_snd(tp, ack);	/* XXXAO */
+		//tcp_init_rcv(tp, seq);	/* XXXAO */
+		//tcp_init_snd(tp, ack);	/* XXXAO */
+		tcp_init_values(tp);
 
 		/*
 		 * Process SYN and integrate sequence number.
@@ -1132,8 +1135,8 @@
 		 * Otherwise go into idle mode and wait for
 		 * either side to start transmitting data.
 		 */
-		if (tp->snd_una != snd_nxt) {
-			tcp_timer_activate(tp, TT_RXMIT, );  /* XXXAO */
+		if (tp->snd_una != tp->snd_nxt) {
+			tcp_timer_activate(tp, TT_REXMT, 1);  /* XXXAO */
 			nudgeoutput = 1;
 		} else {
 			tcp_timer_activate(tp, TT_KEEP, tcp_keepidle);	/* XXXAO */
@@ -1191,7 +1194,7 @@
 		 *  RFC2018: section 1, page 2, last paragraph
 		 */
 		if ((to.to_flags & TOF_SACK) &&
-		    !(tp->t_flags & TF_SACK_PERM)) {
+		    !(tp->t_flags & TF_SACK_PERMIT)) {
 			tcplog("SACK unexpected, segment ignored");
 			goto drop;
 		}
@@ -1214,21 +1217,21 @@
 		 * Linux 2.6.25, net/ipv4/tcp_input.c, tcp_disordered_ack()
 		 */
 		if (to.to_flags & TOF_TS) {
-			time_t uptime = tcp_uptime();
+			time_t uptime = (time_t)ticks;		/* XXXAO */
 
 			if (uptime - tp->t_rcvtime < ((tcp_ts)0x0 - 1) / (hz * 2)) {
-				if (TSTMP_LT(to.to_tsval, tp->snd_tsecr) {
+				if (TSTMP_LT(to.to_tsval, tp->snd_tsecr)) {
 					tcplog("Timestamp too old, "
 					    "sending challenge ack");
 					goto dropafterack;
 				}
-				if (TSTMP_GT(to.to_tsecr, tp->snd_tsval) {
+				if (TSTMP_GT(to.to_tsecr, tp->snd_tslast)) {
 					tcplog("Timestamp too new, "
 					    "sending challenge ack");
 					goto dropafterack;
 				}
 			} else
-				to->to_flags &= ~TOF_TS;
+				to.to_flags &= ~TOF_TS;
 		}
 
 		/*
@@ -1276,7 +1279,7 @@
 			if (th->th_seq == tp->rcv_nxt - 1 &&
 			    th->th_ack == tp->snd_nxt &&
 			    tlen <= 1 && !(thflags & TH_URG) &&
-			    !TCPS_HAVERCVDFIN(tp)) {
+			    !TCPS_HAVERCVDFIN(tp->t_state)) {
 				/*
 				 * The connection is idle and this
 				 * is a keepalive.  Force an ACK and
@@ -1293,9 +1296,9 @@
 					thflags &= ~TH_FIN;
 				}
 				tp->t_flags |= TF_ACKNOW;
-				tcps.tcps_rcv_keepalive++;
+				//tcpstat.tcps_rcv_keepalive++;
 			} else if (th->th_seq == tp->rcv_nxt - 1 &&
-			    TCPS_HAVERCVDFIN(tp) && (thflags & TH_FIN)) {
+			    TCPS_HAVERCVDFIN(tp->t_state) && (thflags & TH_FIN)) {
 				/*
 				 * Continue with duplicate FIN.
 				 * When we received the orginal FIN
@@ -1309,7 +1312,7 @@
 				 */
 				tp->t_flags |= TF_ACKNOW;
 			} else if (th->th_seq == tp->rcv_nxt && tlen > 0 &&
-			    (thflags & TH_URG) && th->th_urg > 0) {
+			    (thflags & TH_URG) && th->th_urp > 0) {
 				/*
 				 * We must accept urgent data even when
 				 * the window is closed.  Continue
@@ -1355,7 +1358,7 @@
 		 * XXXAO: Informal.  Not part of any RFC.
 		 */
 		if (SEQ_GT(th->th_seq, tp->snd_lastack) &&
-		    SEQ_LT(th->th_seq, tp->rcv_nxt) {
+		    SEQ_LT(th->th_seq, tp->rcv_nxt)) {
 			tcplog("Received retransmit before we sent delayed ACK,"
 			    " no action");
 		}
@@ -1433,7 +1436,7 @@
 			 * a SYN.
 			 */
 			if (th->th_ack != tp->snd_una ||
-			    th->th_ack != th->snd_nxt) {
+			    th->th_ack != tp->snd_nxt) {
 				tcplog("RST does not match, segment ignored");
 				tcpstat.tcps_badrst++;
 				goto drop;
@@ -1476,14 +1479,14 @@
 			 */
 			if (tcp_secure_rst &&
 			    (SEQ_DELTA(th->th_seq, tp->rcv_nxt) > 1 ||
-			     SEQ_DELTA(th->th_seq, tp->snd_last_ack) > 1) ||
-			     SEQ_DELTA(th->th_seq, tp->snd_last_ack + rwin) > 1) {
+			     SEQ_DELTA(th->th_seq, tp->snd_lastack) > 1 ||
+			     SEQ_DELTA(th->th_seq, tp->snd_lastack + rwin) > 1)) {
 				tcplog("RST does not match (secure), segment ignored");
 				tcpstat.tcps_badrst++;
 				goto drop;
 			} else if (!tcp_secure_rst &&
-			    (SEQ_LT(th->th_seq, tp->snd_last_ack - 1) ||
-			     SEQ_GT(th->th_seq, tp->snd_last_ack + rwin))) {
+			    (SEQ_LT(th->th_seq, tp->snd_lastack - 1) ||
+			     SEQ_GT(th->th_seq, tp->snd_lastack + rwin))) {
 				tcplog("RST does not match (insecure), segment ignored");
 				tcpstat.tcps_badrst++;
 				goto drop;
@@ -1646,11 +1649,11 @@
 	 * drop trailing data (and PUSH and FIN);
 	 * if nothing left, just ACK.
 	 */
-	todrop = th->th_seq + tlen, tp->rcv_nxt + rwin;
+	todrop = SEQ_DELTA(th->th_seq + tlen, tp->rcv_nxt + rwin);
 	if (todrop > 0) {
 		KASSERT(todrop <= tlen,
 		    ("%s: right todrop > tlen", __func__));
-		KASSERT(!TCPS_HAVERCVDFIN(tp),
+		KASSERT(!TCPS_HAVERCVDFIN(tp->t_state),
 		    ("%s: FIN received, todrop > 0", __func__));
 
 		/*
@@ -1760,7 +1763,7 @@
 	/*
 	 * Update congestion control information.
 	 */
-	tcp_cc_ack(tp, th, tiwin, acked, tlen, sacked);
+	//tcp_cc_ack(tp, th, tiwin, acked, tlen, sacked);
 	KASSERT(tp->snd_cwnd > tp->snd_mss,
 	    ("%s: cwnd < 1*mss after congestion control function", __func__));
 
@@ -1768,14 +1771,14 @@
 	 * Drop acknowledged data from send socket buffer.
 	 *  RFC793: section 3.9, page 72, fifth check
 	 */
-	if (acked > 0)
+	if (acked > 0) {
 		SOCKBUF_LOCK(&so->so_snd);
 
 		KASSERT(SEQ_GT(th->th_ack, tp->snd_nxt),
 		    ("%s: more acked than sent", __func__));
 		KASSERT(acked <= so->so_snd.sb_cc + 1,
 		    ("%s: more acked than in send buffer", __func__));
-		KASSERT(!TCPS_HAVERCVDFIN(tp),
+		KASSERT(!TCPS_HAVERCVDFIN(tp->t_state),
 		    ("%s: FIN already processed but acked > 0", __func__));
 
 		/*
@@ -1810,9 +1813,9 @@
 			    ("%s: got ack for FIN but haven't sent FIN yet",
 			    __func__));
 
-			KASSERT(!tcp_timer_active(TT_RXMIT),
+			KASSERT(!tcp_timer_active(tp, TT_REXMT),
 			    ("%s: ourfinisacked but RXMIT still active",
-			    __func__);
+			    __func__));
 
 			/*
 			 * Handle ack'ed FIN according to previous state.
@@ -1903,7 +1906,7 @@
 	 */
 	if (tlen == 0 && (th->th_flags & TH_FIN) == 0 &&
 	    !TCPS_HAVERCVDFIN(tp->t_state)) {
-		INP_INFO_WUNLOCK(&tcpinfo);
+		INP_INFO_WUNLOCK(&tcbinfo);
 		m_freem(m);
 		m = NULL;
 		th = NULL;
@@ -1917,7 +1920,7 @@
 	 */
 	if ((thflags & TH_URG) && th->th_urp > 0 && tlen > 0 &&
 	    !TCPS_HAVERCVDFIN(tp->t_state)) {
-		tcp_do_urg(tp, th, &tlen);
+		tcp_do_urg(tp, so, th, &tlen);
 	} else if (SEQ_GT(tp->rcv_nxt, tp->rcv_up)) {
 		tp->rcv_up = tp->rcv_nxt;
 	}
@@ -1937,7 +1940,7 @@
 	 *  segment with urgent that got pulled and now is zero
 	 */
 	if (!TCPS_HAVERCVDFIN(tp->t_state) &&
-	    (tlen > 0 || (tp->rcv_trq != NULL && (th->th_flags & TH_FIN)))) {
+	    (tlen > 0 || (!TAILQ_EMPTY(&tp->rcv_trq) && (th->th_flags & TH_FIN)))) {
 		int newsize = 0;	/* Rcvbuf autoscaling. */
 
 		/*
@@ -1955,14 +1958,14 @@
 			 * XXXAO: This breaks with reassembly queue and
 			 * tlen == 0 and TH_FIN.
 			 */
-			m_demote(m);
+			m_demote(m, 1);
 			while (m->m_len == 0 && m->m_next != NULL)
 				m = m_free(m);
 			KASSERT(m->m_len > 0,
 			    ("%s: drop_hdrlen too big or mbuf chain broken",
 			    __func__));
 		}
-		KASSERT(tlen == m_length(m),
+		KASSERT(tlen == m_length(m, NULL),
 		    ("%s: tlen != mbuf chain length", __func__));
 
 		/*
@@ -1980,7 +1983,8 @@
 		 *  RFC1122: section 4.2.2.21
 		 */
 		if (th->th_seq != tp->rcv_nxt || !TAILQ_EMPTY(&tp->rcv_trq)) {
-			m = tcp_reass(tp, m, tlen, thflags);
+			//m = tcp_reass(tp, m, tlen, thflags);
+			m = NULL;
 
 			if (m != NULL && (m->m_flags & M_PROTO1))
 				thflags |= TH_FIN;
@@ -2029,7 +2033,7 @@
 		 */
 		if (m != NULL && tcp_do_autorcvbuf && (to.to_flags & TOF_TS) &&
 		    (so->so_rcv.sb_flags & SB_AUTOSIZE)) {
-			if (TS_GT(to.to_tsecr, tp->rfbuf_ts) &&
+			if (TSTMP_GT(to.to_tsecr, tp->rfbuf_ts) &&
 			    to.to_tsecr - tp->rfbuf_ts < hz) {
 				if (tp->rfbuf_cnt > (so->so_rcv.sb_hiwat / 8 * 7) &&
 				    so->so_rcv.sb_hiwat < tcp_autorcvbuf_max) {
@@ -2091,7 +2095,7 @@
 				/*
 				 * Update size of receive window.
 				 */
-				tp->rcv_wnd = sbspace(so->so_rcv);
+				tp->rcv_wnd = (tcp_seq)sbspace(&so->so_rcv);
 
 				/*
 				 * NB: sorwakeup_locked implicitly unlocks.
@@ -2125,10 +2129,10 @@
 			 */
 		}
 	} else {
-		KASSERT(!TCPS_HAVERCVDFIN(tp) || TAILQ_EMPTY(&tp->rcv_trq),
+		KASSERT(!TCPS_HAVERCVDFIN(tp->t_state) || TAILQ_EMPTY(&tp->rcv_trq),
 		    ("%s: FIN received but reassembly queue not empty", __func__));
 		KASSERT(tlen == 0,
-		    ("%s: data unexpected", __func__))
+		    ("%s: data unexpected", __func__));
 
 		/*
 		 * Dispose of segment.  The data was already dropped
@@ -2255,7 +2259,7 @@
 	 * XXXAO: Multi-delack?
 	 * XXXAO: Always call into tcp_output and have it decide what to do.
 	 */
-	(void)tcp_output(tp, TPO_TINPUT);
+	(void)tcp_output(tp);
 #if 0
 	if ((tp->t_flags & TF_ACKNOW) || tp->snd_delack > 1 ||
 	    nudgeoutput || (tp->t_flags & TF_RXWIN0SENT) ||
@@ -2271,7 +2275,7 @@
 	return;
 
 dropafterack:
-	INP_INFO_LOCK_ASSERT(&tcpinfo);
+	INP_INFO_WLOCK_ASSERT(&tcbinfo);
 	INP_LOCK_ASSERT(tp->t_inpcb);
 	KASSERT(!(thflags & TH_RST),
 	    ("%s: dropafterack with RST", __func__));
@@ -2290,12 +2294,12 @@
 	 */
 	tp->t_flags |= TF_ACKNOW;
 	m_freem(m);
-	(void) tcp_output(tp, TPO_TINPUT);
+	(void) tcp_output(tp);
 	INP_UNLOCK(tp->t_inpcb);
 	return;
 
 dropwithreset:
-	INP_INFO_LOCK_ASSERT(&tcpinfo);
+	INP_INFO_WLOCK_ASSERT(&tcbinfo);
 	INP_INFO_WUNLOCK(&tcbinfo);
 	KASSERT(th != NULL,
 	    ("%s: th for tcp_dropwithreset() is NULL", __func__));
@@ -2310,7 +2314,7 @@
 	return;
 
 drop:
-	INP_INFO_LOCK_ASSERT(&tcpinfo);
+	INP_INFO_WLOCK_ASSERT(&tcbinfo);
 	/*
 	 * Drop space held by incoming segment and return.
 	 */
@@ -2489,7 +2493,7 @@
     int acked, int tlen, int sacked)
 {
 	int rtt;
-	tcp_ts tick = tcp_ticks;
+	tcp_ts tick = ticks;
 
 	INP_LOCK_ASSERT(tp->t_inpcb);
 	KASSERT(tp != NULL && th != NULL && to != NULL,
@@ -2500,8 +2504,7 @@
 	 *
 	 * Make note of most recent segment received time.
 	 */
-	tp->t_rcvtime = tcp_uptime();
-	tp->t_rcvticks = tick;
+	tp->t_rcvtime = time_uptime;
 
 	/*
 	 * 2. If timestamps are used decide which to reflect.
@@ -2527,27 +2530,29 @@
 	 * Does this give PAWS problems?
 	 */
 	if (to->to_flags & TOF_TS) {
+#define TCP_RFC1323_BRADEN
 #ifdef TCP_RFC1323_BRADEN
-		if (TS_GEQ(to->to_tsval, tp->snd_tsecr) &&
+		if (TSTMP_GEQ(to->to_tsval, tp->snd_tsecr) &&
 		    SEQ_LEQ(th->th_ack, tp->snd_lastack)) {
 #endif
 #ifdef TCP_RFC1323bis_plusSACK
-		if (TS_GT(to->to_tsval, tp->snd_tsecr) &&
+		if (TSTMP_GT(to->to_tsval, tp->snd_tsecr) &&
 		    ((th->th_seq == tp->rcv_nxt && tp->snd_delack == 0) ||
-		     sacked > 0) {
+		     sacked > 0)) {
 #endif
 			tp->snd_tsecr = to->to_tsval;
-			tp->snd_tsecrts = tcp_ticks;
+			//tp->snd_tsecrts = ticks;
 		}
-		KASSERT(!TS_GT(to->to_secr, tick),
+		KASSERT(!TSTMP_GT(to->to_tsecr, tick),
 		    ("%s: timestamp newer than our time", __func__));
 		/*
 		 * Remember highest most recent reflected TS.
 		 */
 		if (SEQ_LEQ(th->th_seq, tp->snd_lastack) &&
-		    TS_GT(to->to_tsecr > tp->ts_recent))
-			tp->ts_recent = to->to_tsecr;
-			tp->ts_recentts = tick;
+		    TSTMP_GT(to->to_tsecr, tp->tsval_recent)) {
+			tp->tsval_recent = to->to_tsecr;
+			//tp->ts_recentts = tick;
+		}
 	}
 
 	/*
@@ -2557,7 +2562,7 @@
 		rtt = tick - to->to_tsecr;
 	} else if (acked > 0 && tp->snd_rtseq != 0 &&
 	    SEQ_GT(th->th_ack, tp->snd_rtseq) &&
-	    TAILQ_EMPTY(tp->rcv_trq) && tp->snd_rtoshift == 0) {
+	    TAILQ_EMPTY(&tp->rcv_trq) /*&& tp->snd_rtoshift == 0*/ ) {
 		rtt = tick - tp->snd_rtts;
 		tp->snd_rtseq = 0;
 	} else
@@ -2587,8 +2592,8 @@
 	 * the time measurement or our estimate will be way off.
 	 */
 	if (tick - tp->snd_tslast > tp->snd_rto) {
-		if (tp->t_rtseq != 0)
-			tp->t_rtseq = 0;
+		if (tp->snd_rtseq != 0)
+			tp->snd_rtseq = 0;
 		return;
 	}
 
@@ -2878,8 +2883,8 @@
 #endif
 #ifdef TCP_WU_BSDNEW
 	if (((to->to_flags & TOF_TS) &&
-	     TS_GT(to->to_tsecr, tp->ts_reflected_last) ||
-	     TS_GT(to->to_tsval, tp->ts_recent)) ||
+	     (TSTMP_GT(to->to_tsecr, tp->snd_tsecr) ||
+	      TSTMP_GT(to->to_tsval, tp->snd_tslast))) ||
 	    acked > 0 ||
 	    (SEQ_GT(th->th_seq, tp->snd_wu_seq) && acked >= 0) ||
 	    (th->th_seq == tp->snd_wu_seq && th->th_ack == tp->snd_una &&
@@ -2898,8 +2903,9 @@
 		 *  RFC793: section 3.7, page 42-44, "Managing the Window"
 		 *  RFC1122: section 4.2.2.16
 		 */
-		if (SEQ_DELTA(tp->snd_nxt, tp->snd_una + acked) + tiwin < tp->snd_wnd)
-			tcplog("peer shrank the window");
+		if (SEQ_DELTA(tp->snd_nxt, tp->snd_una + acked) + tiwin < tp->snd_wnd) {
+			//tcplog("peer shrank the window");
+		}
 
 		/*
 		 * Update the window and keep track of this update.
@@ -2920,7 +2926,8 @@
 }
 
 static void
-tcp_do_ack(tp, th, tiwin, acked, tlen, sacked)
+tcp_do_ack(struct tcpcb *tp, struct tcphdr *th, int tiwin, int acked,
+    int tlen, int sacked)
 {
 	/*
 	 * Without SACK detecting a duplicate ACK is based on an
@@ -2959,8 +2966,8 @@
 	if (acked > 0)
 		tp->snd_una += acked;
 
-	KASSERT(tp->snd_una == tp->snd_nxt || tcp_timer_active(TT_RXMIT),
-	    ("%s: outstanding data but RXMIT timer not active", __func__));
+	KASSERT(tp->snd_una == tp->snd_nxt || tcp_timer_active(tp, TT_REXMT),
+	    ("%s: outstanding data but REXMT timer not active", __func__));
 
 	/*
 	 * Stop the retransmit timer if all data we sent has been
@@ -2970,9 +2977,9 @@
 	 * XXXAO: Handle backoff on multiple retransmits.
 	 */
 	if (acked > 0 && tp->snd_una == tp->snd_nxt)
-		tcp_timer_activate(TT_RXMIT, 0);
+		tcp_timer_activate(tp, TT_REXMT, 0);
 	else if (acked > 0)
-		tcp_timer_activate(TT_RXMIT, tp->snd_rto);
+		tcp_timer_activate(tp, TT_REXMT, tp->snd_rto);
 
 }
 
@@ -2983,14 +2990,16 @@
  *  Finish this function and validate against all relevant RFCs.
  */
 void
-tcp_do_urg(struct tcpcb *tp, struct tcphdr *th, int tlen)
+tcp_do_urg(struct tcpcb *tp, struct socket *so, struct tcphdr *th, int *tlen)
 {
+	struct mbuf *m = NULL;
+	int drop_hdrlen = 0;
 
 	KASSERT(tp != NULL && th != NULL,
 	    ("%s: ", __func__));
 	KASSERT(tlen > 0,
 	    ("%s: ", __func__));
-	KASSERT(!HAVERCVDFIN(tp),
+	KASSERT(!TCPS_HAVERCVDFIN(tp->t_state),
 	    ("%s: ", __func__));
 	INP_LOCK_ASSERT(tp->t_inpcb);
 
@@ -3003,7 +3012,7 @@
 	SOCKBUF_LOCK(&so->so_rcv);
 	if (th->th_urp + so->so_rcv.sb_cc > sb_max) {
 		th->th_urp = 0;			/* XXX */
-		thflags &= ~TH_URG;		/* XXX */
+		//thflags &= ~TH_URG;		/* XXX */
 		SOCKBUF_UNLOCK(&so->so_rcv);	/* XXX */
 		return;				/* XXX */
 	}
@@ -3110,13 +3119,13 @@
 #ifdef INET6
 	if (isipv6) {
 		mss = tcp_v6mssdflt;
-		maxmtu = tcp_maxmtu6(inc, mtuflags);
+		maxmtu = tcp_maxmtu6(inc, &mtuflags);
 		min_protoh = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
 	} else
 #endif
 	{
 		mss = tcp_mssdflt;
-		maxmtu = tcp_maxmtu(inc, mtuflags);
+		maxmtu = tcp_maxmtu(inc, &mtuflags);
 		min_protoh = sizeof(struct tcpiphdr);
 	}
 	thcmtu = tcp_hc_getmtu(inc);	/* IPv4 and IPv6 */
@@ -3173,14 +3182,8 @@
 
 	if (tcp_do_rfc3390)
 		cwnd = min(4 * tp->snd_mss, max(2 * tp->snd_mss, 4380));
-#ifdef INET6
-	else if (isipv6 && in6_localaddr(&inp->in6p_faddr))
-		cwnd = tp->snd_mss * ss_fltsz_local;
-#endif
-	else if (in_localaddr(inp->inp_faddr))
-		cwnd = tp->snd_mss * ss_fltsz_local;
 	else
-		cwnd = tp->snd_mss * ss_fltsz;
+		cwnd = tp->snd_mss;
 
 	return (cwnd);
 }
@@ -3194,13 +3197,8 @@
 	struct inpcb *inp = tp->t_inpcb;
 	struct socket *so = inp->inp_socket;
 	u_long bufsize;
-	u_long maxmtu;
-	int rtt, mss;
-	int origoffer = offer;
+	int rtt, mss = 0;
 	int mtuflags = 0;
-#ifdef INET6
-	int isipv6 = ((inp->inp_vflag & INP_IPV6) != 0) ? 1 : 0;
-#endif
 	struct hc_metrics_lite metrics;
 
 	/*
@@ -3255,7 +3253,7 @@
 			(void)sbreserve_locked(&so->so_snd, bufsize, so, NULL);
 	}
 	SOCKBUF_UNLOCK(&so->so_snd);
-	tp->t_maxseg = mss;
+	//tp->t_maxseg = mss;
 
 	SOCKBUF_LOCK(&so->so_rcv);
 	if ((so->so_rcv.sb_hiwat == tcp_recvspace) && metrics.rmx_recvpipe)
@@ -3276,7 +3274,7 @@
 	 */
 	if (tp->t_srtt == 0 && (rtt = metrics.rmx_rtt)) {
 		tp->t_srtt = rtt;
-		tp->t_rttbest = tp->t_srtt + TCP_RTT_SCALE;
+		//tp->t_rttbest = tp->t_srtt + TCP_RTT_SCALE;
 		tcpstat.tcps_usedrtt++;
 		if (metrics.rmx_rttvar) {
 			tp->t_rttvar = metrics.rmx_rttvar;
@@ -3286,9 +3284,9 @@
 			tp->t_rttvar =
 			    tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE;
 		}
-		TCPT_RANGESET(tp->t_rxtcur,
-			      ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
-			      tp->t_rttmin, TCPTV_REXMTMAX);
+		//TCPT_RANGESET(tp->t_rxtcur,
+		//	      ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
+		//	      tp->t_rttmin, TCPTV_REXMTMAX);
 	}
 	if (metrics.rmx_ssthresh) {
 		/*

==== //depot/projects/tcp_new/netinet/tcp_output.c#10 (text+ko) ====

@@ -80,6 +80,7 @@
 
 #include <security/mac/mac_framework.h>
 
+int	path_mtu_discovery = 1;		/* XXXAO: old style */
 int 	tcp_do_pmtud = 1;
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, path_mtu_discovery, CTLFLAG_RW,
     &tcp_do_pmtud, 1, "Enable Path MTU Discovery");
@@ -100,19 +101,21 @@
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, sendbuf_max, CTLFLAG_RW,
     &tcp_autosndbuf_max, 0, "Max size of automatic send buffer");
 
-static int
-tcp_send(struct tcpcb *tp, struct tcpopt *to, int len, int rwin, int flags);
-static int
-tcp_retransmit(struct tcpcb *tp, int *len);
-static int
-tcp_send_segments(struct tcpcb *tp, struct tcphdr *ths, struct tcpopt *opt,
-    int off, int *olen, int optlen);
-static u_int
-tcp_rcv_wnd(struct tcpcb *tp, struct socket *so);
-static void
-tcp_snd_pace(struct tcpcp *tp);
-static void
-tcp_options(struct tcpcb *tp, struct tcpopt *to, int flags);
+static int	ip_optlen(struct inpcb *inp);
+static int	tcp_send(struct tcpcb *tp, struct socket *so,
+		    struct tcpopt *to, u_char *opt, int len,
+		    int optlen, int rwin, int flags);
+static int	tcp_retransmit(struct tcpcb *tp, struct socket *so,
+		    struct tcpopt *to, u_char *opt, int *len,
+		    int optlen, int rwin, int flags);
+static int	tcp_send_segments(struct tcpcb *tp, struct tcphdr *ths,
+		    u_char *opt, int off, int *olen, int optlen);
+static u_int	tcp_rcv_wnd(struct tcpcb *tp, struct socket *so);
+static int	tcp_snd_pace(struct tcpcb *tp, int len);
+static void	tcp_snd_autoscale(struct tcpcb *tp, struct socket *so,
+		    int swin);
+static int	tcp_options(struct tcpcb *tp, struct socket *so,
+		    struct tcpopt *to, u_char *opt, int flags);
 
 /*
  * Tcp output routine: figure out what should be sent and send it.
@@ -139,13 +142,14 @@
  * 7. Send based on flags
  */
 int
-tcp_output(struct tcpcb *tp, int reason)
+tcp_output(struct tcpcb *tp)
 {
-	int off, flags, error, optlen;
-	tcp_win len, recwin, swin;
+	int flags, error, optlen = 0;
+	tcp_win len;
+	int duna, swnd, cwnd, dlen, inflight, rwin;
+	int tcp_min_idle = 1;		/* XXXAO */
 	struct inpcb *inp = tp->t_inpcb;
 	struct socket *so = inp->inp_socket;
-	struct tcphdr ths;
 	struct tcpopt to;
 	u_char opt[TCP_MAXOLEN];
 #ifdef TCP_SIGNATURE
@@ -159,10 +163,10 @@
 	KASSERT(tp->t_state < TCPS_TIME_WAIT,
 	    ("%s: TCPS_TIME_WAIT invalid", __func__));
 
-	KASSERT(SEQ_GEQ(tp->snd_rxmit, tp->snd_una),
-	    ("%s: snd_rxmit < snd_una", __func__))
-	KASSERT(SEQ_LEQ(tp->snd_rxmit, tp->snd_nxt),
-	    ("%s: snd_rxmit > snd_nxt", __func__))
+	//KASSERT(SEQ_GEQ(tp->snd_rxmit, tp->snd_una),
+	//    ("%s: snd_rxmit < snd_una", __func__));
+	//KASSERT(SEQ_LEQ(tp->snd_rxmit, tp->snd_nxt),
+	//    ("%s: snd_rxmit > snd_nxt", __func__));
 
 	/*
 	 * Get standard flags.  Removal of inappropriate flags for a
@@ -251,15 +255,15 @@
 		 */
 		if (tp->snd_nxt == tp->snd_una &&
 		    (ticks - tp->t_rcvtime) >= max(tp->t_rxtcur, tcp_min_idle)) {
-			tp->snd_cwnd = tcp_init_cwnd(tp);
+			tp->snd_cwnd = tp->snd_mss /*tcp_init_cwnd(tp)*/;
 		}
 		break;
 	case TP_SENDING:
 		break;
 	case TP_LOSSRECOV:
 	case TP_REXMT:
-		tcp_retransmit(tp, &len);
-		if (len = 0)
+		error = tcp_retransmit(tp, so, &to, &opt[0], &len, optlen, rwin, flags);
+		if (len == 0)
 			return (0);
 		break;
 	case TP_PERSIST:
@@ -478,13 +482,21 @@
 	return (0);
 
 send:
-	tcp_options(tp, &to, flags);
-	return (tcp_send(tp, &to, flags));
+	optlen = tcp_options(tp, so, &to, &opt[0], flags);
+	error = tcp_send(tp, so, &to, &opt[0], len, optlen, rwin, flags);
+
+	if (!error)
+		tcp_snd_autoscale(tp, so, swnd);
+
+	return (error);
 }
 
 static int
-tcp_send(struct tcpcb *tp, struct tcpopt *to, int len, int rwin, int flags)
+tcp_send(struct tcpcb *tp, struct socket *so, struct tcpopt *to,
+    u_char *opt, int len, int optlen, int rwin, int flags)
 {
+	int off, error;
+	struct tcphdr ths, *th = &ths;
 
 	KASSERT((flags & TH_SYN) || (tp->t_flags & TF_SENTSYN),
 	    ("%s: retransmitting SYN", __func__));
@@ -552,7 +564,7 @@
 		/*
 		 * Integrate FIN into sequence space.
 		 */
-		if ((flags & TH_FIN) && !(tp-t_flags & TF_SENTFIN)) {
+		if ((flags & TH_FIN) && !(tp->t_flags & TF_SENTFIN)) {
 			tp->snd_nxt++;
 			tp->t_flags |= TF_SENTFIN;
 		}
@@ -584,7 +596,7 @@
 		 * Clear related flags and disarm the delayed ACK timer.
 		 */
 		tp->t_flags &= ~(TF_ACKNOW | TF_DELACK);
-		if (SEQ_LT(tp->snd_lastack, tp->rcv_nxt)
+		if (SEQ_LT(tp->snd_lastack, tp->rcv_nxt))
 			tp->snd_lastack = tp->rcv_nxt;
 		if (tcp_timer_active(tp, TT_DELACK))
 			tcp_timer_activate(tp, TT_DELACK, 0);
@@ -620,9 +632,9 @@
 		 * Time this transmission if not a retransmission and
 		 * not currently timing anything.
 		 */
-		if (tp->t_rtttime == 0) {
-			tp->t_rtttime = ticks;
-			tp->t_rtseq = startseq;
+		if (tp->snd_rtts == 0) {
+			tp->snd_rtts = ticks;
+			tp->snd_rtseq = tp->snd_nxt - len;	/* XXXAO */
 			tcpstat.tcps_segstimed++;
 		}
 
@@ -635,7 +647,7 @@
 		 * of retransmit time.
 		 */
 		if (!tcp_timer_active(tp, TT_REXMT) &&
-		     (tp->snd_nxt != tp->snd_una))) {
+		     (tp->snd_nxt != tp->snd_una)) {
 			if (tcp_timer_active(tp, TT_PERSIST)) {
 				tcp_timer_activate(tp, TT_PERSIST, 0);
 				tp->t_rxtshift = 0;
@@ -667,7 +679,7 @@
 		if (!tcp_timer_active(tp, TT_REXMT) &&
 		    !tcp_timer_active(tp, TT_PERSIST))
 			tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur);
-		tp->snd_cwnd = tp->t_maxseg;
+		tp->snd_cwnd = tp->snd_mss;
 		error = 0;
 		break;
 
@@ -687,7 +699,7 @@
 		 * immediatly retry with MSS sized segments generated
 		 * by this function.
 		 */
-		if (tso)
+		if (tp->t_flags & TF_TSO)
 			tp->t_flags &= ~TF_TSO;
 		else
 			tcp_mtudisc(tp->t_inpcb, 0);
@@ -724,11 +736,11 @@
 	 *
 	 * XXXAO: Account for TSO.
 	 */
-	if ((tp->t_flags & TF_FORCEDATA) && len == 1)
+	if ((tp->t_flags & TF_FORCEDATA) && len == 1) {
 		tcpstat.tcps_sndprobe++;
-	else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) {
-		tcpstat.tcps_sndrexmitpack++;
-		tcpstat.tcps_sndrexmitbyte += len;
+	//} else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) {
+	//	tcpstat.tcps_sndrexmitpack++;
+	//	tcpstat.tcps_sndrexmitbyte += len;
 	} else {
 		tcpstat.tcps_sndpack++;
 		tcpstat.tcps_sndbyte += len;
@@ -752,9 +764,11 @@
  * from the normal transmit case as the logic is quite a bit different.
  */
 static int
-tcp_retransmit(struct tcpcb *tp, int *len)
+tcp_retransmit(struct tcpcb *tp, struct socket *so, struct tcpopt *to,
+    u_char *opt, int *len, int optlen, int rwin, int flags)
 {
-	struct tcphdr ths, *th;
+	int error, off, rlen = 0;
+	struct tcphdr ths, *th = &ths;
 
 	/*
 	 * Retransmit over the SACK holes.
@@ -780,12 +794,12 @@
 
 	/* Limited transmit */
 	if (tp->snd_dupack < 3)
-		*len = min(len, tp->snd_mss); /* one mss */
+		*len = min(*len, tp->snd_mss);		/* one mss */
 	else
 		*len = 0;
 
 	if (tp->snd_dupack < 3)
-		return;
+		return (0);
 
 	/*
 	 * XXXAO: Temporary.
@@ -811,10 +825,10 @@
 	
 	SOCKBUF_LOCK(&so->so_snd);
 	off = min(tp->snd_rxmit - tp->snd_una, so->so_snd.sb_cc);
-	error = tcp_send_segments(tp, &ths, opt, off, olen, optlen);
+	error = tcp_send_segments(tp, &ths, opt, off, &rlen, optlen);
 	SOCKBUF_UNLOCK(&so->so_snd);
 
-	return;
+	return (error);
 }
 
 /*
@@ -824,17 +838,18 @@
  * XXXAO: We may leave some left-overs if we can't drain the whole send buffer.
  */
 static int
-tcp_send_segments(struct tcpcb *tp, struct tcphdr *ths, struct tcpopt *opt,
+tcp_send_segments(struct tcpcb *tp, struct tcphdr *ths, u_char *opt,
     int off, int *olen, int optlen)
 {
-	int len, slen, hdrs, hdrlen, linkhdr, optlen, ipoptlen;
+	int len, slen, hdrs, hdrlen, linkhdr, ipoptlen;
 	int error = 0;
+	struct mbuf *m;
 	struct tcphdr *th;
-	struct ip *ip;
+	struct ip *ip = NULL;
 	struct inpcb *inp = tp->t_inpcb;
 	struct socket *so = inp->inp_socket;
 #ifdef INET6
-	struct ip6_hdr *ip6;
+	struct ip6_hdr *ip6 = NULL;
 	int isipv6 = (inp->inp_vflag & INP_IPV6) != 0;
 #endif
 	INP_LOCK_ASSERT(tp->t_inpcb);
@@ -905,7 +920,7 @@
 		 * is already reflected in the MSS.
 		 */
 		if (tp->t_flags & TF_TSO) {
-			if (len > TCP_MAXWIN - (hdrs + linkhdr) {
+			if (len > TCP_MAXWIN - (hdrs + linkhdr)) {
 				slen = TCP_MAXWIN - (hdrs + linkhdr);
 				slen -= slen % (tp->snd_mss - optlen);
 			} else
@@ -975,7 +990,7 @@
 			 * trailing space is available, or we attach an mbuf chain
 			 * with references to the mbuf storage in the socket buffer.
 			 */
-			if (slen <= M_TAILINGSPACE(m)) {

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list