Module Name:    src
Committed By:   riz
Date:           Tue Mar 29 20:13:34 UTC 2011

Modified Files:
        src/sys/netinet [netbsd-5-0]: tcp_output.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1586):
        sys/netinet/tcp_output.c: revision 1.170
Clean up setting ECN bit in TOS.  Fixes PR 44742


To generate a diff of this commit:
cvs rdiff -u -r1.167 -r1.167.16.1 src/sys/netinet/tcp_output.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/tcp_output.c
diff -u src/sys/netinet/tcp_output.c:1.167 src/sys/netinet/tcp_output.c:1.167.16.1
--- src/sys/netinet/tcp_output.c:1.167	Mon Apr 28 20:24:09 2008
+++ src/sys/netinet/tcp_output.c	Tue Mar 29 20:13:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_output.c,v 1.167 2008/04/28 20:24:09 martin Exp $	*/
+/*	$NetBSD: tcp_output.c,v 1.167.16.1 2011/03/29 20:13:34 riz Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -135,7 +135,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.167 2008/04/28 20:24:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.167.16.1 2011/03/29 20:13:34 riz Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -573,6 +573,7 @@
 	bool alwaysfrag;
 	int sack_rxmit;
 	int sack_bytes_rxmt;
+	int ecn_tos;
 	struct sackhole *p;
 #ifdef TCP_SIGNATURE
 	int sigoff = 0;
@@ -698,6 +699,7 @@
 
 	txsegsize_nosack = txsegsize;
 again:
+	ecn_tos = 0;
 	use_tso = has_tso;
 	if ((tp->t_flags & (TF_ECN_SND_CWR|TF_ECN_SND_ECE)) != 0) {
 		/* don't duplicate CWR/ECE. */
@@ -1344,18 +1346,7 @@
 		 */
 		if (len > 0 && SEQ_GEQ(tp->snd_nxt, tp->snd_max) &&
 		    !(tp->t_force && len == 1)) {
-			switch (af) {
-#ifdef INET
-			case AF_INET:
-				tp->t_inpcb->inp_ip.ip_tos |= IPTOS_ECN_ECT0;
-				break;
-#endif
-#ifdef INET6
-			case AF_INET6:
-				ip6->ip6_flow |= htonl(IPTOS_ECN_ECT0 << 20);
-				break;
-#endif
-			}
+			ecn_tos = IPTOS_ECN_ECT0;
 			TCP_STATINC(TCP_STAT_ECN_ECT);
 		}
 
@@ -1569,12 +1560,12 @@
 		packetlen = m->m_pkthdr.len;
 		if (tp->t_inpcb) {
 			ip->ip_ttl = tp->t_inpcb->inp_ip.ip_ttl;
-			ip->ip_tos = tp->t_inpcb->inp_ip.ip_tos;
+			ip->ip_tos = tp->t_inpcb->inp_ip.ip_tos | ecn_tos;
 		}
 #ifdef INET6
 		else if (tp->t_in6pcb) {
 			ip->ip_ttl = in6_selecthlim(tp->t_in6pcb, NULL); /*XXX*/
-			ip->ip_tos = 0;	/*XXX*/
+			ip->ip_tos = ecn_tos;	/*XXX*/
 		}
 #endif
 		break;
@@ -1594,7 +1585,8 @@
 				(rt = rtcache_validate(ro)) != NULL ? rt->rt_ifp
 				                                    : NULL);
 		}
-		/* ip6->ip6_flow = ??? */
+		ip6->ip6_flow |= htonl(ecn_tos << 20);
+		/* ip6->ip6_flow = ??? (from template) */
 		/* ip6_plen will be filled in ip6_output(). */
 		break;
 #endif

Reply via email to