[Midnightbsd-cvs] src: sys/netinet: Revert to previous code for 0.2 branch.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed Jun 18 15:44:15 EDT 2008


Log Message:
-----------
Revert to previous code for 0.2 branch.

Tags:
----
RELENG_0_2

Modified Files:
--------------
    src/sys/netinet:
        ip_output.c (r1.6 -> r1.6.2.1)
        ip_var.h (r1.2 -> r1.2.2.1)
        tcp_syncache.c (r1.8 -> r1.8.2.1)
        tcp_usrreq.c (r1.7 -> r1.7.2.1)

-------------- next part --------------
Index: tcp_usrreq.c
===================================================================
RCS file: /home/cvs/src/sys/netinet/tcp_usrreq.c,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -L sys/netinet/tcp_usrreq.c -L sys/netinet/tcp_usrreq.c -u -r1.7 -r1.7.2.1
--- sys/netinet/tcp_usrreq.c
+++ sys/netinet/tcp_usrreq.c
@@ -30,9 +30,6 @@
  * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.124.2.2 2005/11/04 20:26:14 ume Exp $
  */
 
-#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
-
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_tcpdebug.h"
@@ -83,9 +80,7 @@
 /*
  * TCP protocol interface to socket abstraction.
  */
-#ifdef TCPDEBUG
 extern	char *tcpstates[];	/* XXX ??? */
-#endif
 
 static int	tcp_attach(struct socket *);
 static int	tcp_connect(struct tcpcb *, struct sockaddr *,
@@ -121,8 +116,10 @@
 	int error;
 	struct inpcb *inp;
 	struct tcpcb *tp = 0;
+	TCPDEBUG0;
 
 	INP_INFO_WLOCK(&tcbinfo);
+	TCPDEBUG1();
 	inp = sotoinpcb(so);
 	if (inp) {
 		error = EISCONN;
@@ -139,6 +136,7 @@
 	inp = sotoinpcb(so);
 	tp = intotcpcb(inp);
 out:
+	TCPDEBUG2(PRU_ATTACH);
 	INP_INFO_WUNLOCK(&tcbinfo);
 	return error;
 }
@@ -851,7 +849,10 @@
  * Initialize connection parameters and enter SYN-SENT state.
  */
 static int
-tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
+tcp_connect(tp, nam, td)
+	register struct tcpcb *tp;
+	struct sockaddr *nam;
+	struct thread *td;
 {
 	struct inpcb *inp = tp->t_inpcb, *oinp;
 	struct socket *so = inp->inp_socket;
@@ -887,7 +888,7 @@
 	 * XXX: This should be moved to tcp_output().
 	 */
 	while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
-	    (TCP_MAXWIN << tp->request_r_scale) < sb_max)       /* XXX */
+	    (0x1 << tp->request_r_scale) < tcp_minmss)       /* XXX */
 		tp->request_r_scale++;
 
 	soisconnecting(so);
@@ -903,7 +904,10 @@
 
 #ifdef INET6
 static int
-tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
+tcp6_connect(tp, nam, td)
+	register struct tcpcb *tp;
+	struct sockaddr *nam;
+	struct thread *td;
 {
 	struct inpcb *inp = tp->t_inpcb, *oinp;
 	struct socket *so = inp->inp_socket;
@@ -970,7 +974,9 @@
  * from Linux.
  */
 static void
-tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti)
+tcp_fill_info(tp, ti)
+	struct tcpcb *tp;
+	struct tcp_info *ti;
 {
 
 	INP_LOCK_ASSERT(tp->t_inpcb);
@@ -1008,7 +1014,9 @@
  * the inpcb lock.
  */
 int
-tcp_ctloutput(struct socket *so, struct sockopt *sopt)
+tcp_ctloutput(so, sopt)
+	struct socket *so;
+	struct sockopt *sopt;
 {
 	int	error, opt, optval;
 	struct	inpcb *inp;
@@ -1031,7 +1039,7 @@
 			error = ip6_ctloutput(so, sopt);
 		else
 #endif /* INET6 */
-		error = ip_ctloutput_pcbinfo(so, sopt, &tcbinfo);
+		error = ip_ctloutput(so, sopt);
 		return (error);
 	}
 	tp = intotcpcb(inp);
@@ -1170,9 +1178,10 @@
  * bufer space, and entering LISTEN state if to accept connections.
  */
 static int
-tcp_attach(struct socket *so)
+tcp_attach(so)
+	struct socket *so;
 {
-	struct tcpcb *tp;
+	register struct tcpcb *tp;
 	struct inpcb *inp;
 	int error;
 #ifdef INET6
@@ -1229,7 +1238,8 @@
  * send segment to peer (with FIN).
  */
 static struct tcpcb *
-tcp_disconnect(struct tcpcb *tp)
+tcp_disconnect(tp)
+	register struct tcpcb *tp;
 {
 	struct inpcb *inp = tp->t_inpcb;
 	struct socket *so = inp->inp_socket;
@@ -1262,13 +1272,15 @@
  * We can let the user exit from the close as soon as the FIN is acked.
  */
 static struct tcpcb *
-tcp_usrclosed(struct tcpcb *tp)
+tcp_usrclosed(tp)
+	register struct tcpcb *tp;
 {
 
 	INP_INFO_WLOCK_ASSERT(&tcbinfo);
 	INP_LOCK_ASSERT(tp->t_inpcb);
 
 	switch (tp->t_state) {
+
 	case TCPS_CLOSED:
 	case TCPS_LISTEN:
 		tp->t_state = TCPS_CLOSED;
@@ -1288,9 +1300,9 @@
 		tp->t_state = TCPS_LAST_ACK;
 		break;
 	}
-	if (tp->t_state >= TCPS_FIN_WAIT_2) {
+	if (tp && tp->t_state >= TCPS_FIN_WAIT_2) {
 		soisdisconnected(tp->t_inpcb->inp_socket);
-		/* Prevent the connection hanging in FIN_WAIT_2 forever. */
+		/* To prevent the connection hanging in FIN_WAIT_2 forever. */
 		if (tp->t_state == TCPS_FIN_WAIT_2)
 			callout_reset(tp->tt_2msl, tcp_maxidle,
 				      tcp_timer_2msl, tp);
Index: ip_var.h
===================================================================
RCS file: /home/cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -L sys/netinet/ip_var.h -L sys/netinet/ip_var.h -u -r1.2 -r1.2.2.1
--- sys/netinet/ip_var.h
+++ sys/netinet/ip_var.h
@@ -144,7 +144,6 @@
 
 struct ip;
 struct inpcb;
-struct inpcbinfo;
 struct route;
 struct sockopt;
 
@@ -165,8 +164,6 @@
 extern struct	pr_usrreqs rip_usrreqs;
 
 int	 ip_ctloutput(struct socket *, struct sockopt *sopt);
-int	 ip_ctloutput_pcbinfo(struct socket *, struct sockopt *sopt,
-	    struct inpcbinfo *pcbinfo);
 void	 ip_drain(void);
 void	 ip_fini(void *xtp);
 int	 ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
Index: tcp_syncache.c
===================================================================
RCS file: /home/cvs/src/sys/netinet/tcp_syncache.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -L sys/netinet/tcp_syncache.c -L sys/netinet/tcp_syncache.c -u -r1.8 -r1.8.2.1
--- sys/netinet/tcp_syncache.c
+++ sys/netinet/tcp_syncache.c
@@ -31,9 +31,6 @@
  * $FreeBSD: src/sys/netinet/tcp_syncache.c,v 1.74.2.5 2006/02/16 01:06:22 qingli Exp $
  */
 
-#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
-
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_ipsec.h"
@@ -237,7 +234,7 @@
 	/* Allocate the hash table. */
 	MALLOC(tcp_syncache.hashbase, struct syncache_head *,
 	    tcp_syncache.hashsize * sizeof(struct syncache_head),
-	    M_SYNCACHE, M_WAITOK | M_ZERO);
+	    M_SYNCACHE, M_WAITOK);
 
 	/* Initialize the hash buckets. */
 	for (i = 0; i < tcp_syncache.hashsize; i++) {
@@ -734,7 +731,11 @@
  * the SYN-RECEIVED state.
  */
 int
-syncache_expand(struct in_conninfo *inc, struct tcphdr *th, struct socket **sop, struct mbuf *m)
+syncache_expand(inc, th, sop, m)
+	struct in_conninfo *inc;
+	struct tcphdr *th;
+	struct socket **sop;
+	struct mbuf *m;
 {
 	struct syncache *sc;
 	struct syncache_head *sch;
@@ -965,28 +966,14 @@
 			int wscale = 0;
 
 			/*
-			 * Pick the smallest possible scaling factor that
-			 * will still allow us to scale up to sb_max, aka
-			 * kern.ipc.maxsockbuf.
-			 *
-			 * We do this because there are broken firewalls that
-			 * will corrupt the window scale option, leading to
-			 * the other endpoint believing that our advertised
-			 * window is unscaled.  At scale factors larger than
-			 * 5 the unscaled window will drop below 1500 bytes,
-			 * leading to serious problems when traversing these
-			 * broken firewalls.
-			 *
-			 * With the default maxsockbuf of 256K, a scale factor
-			 * of 3 will be chosen by this algorithm.  Those who
-			 * choose a larger maxsockbuf should watch out
-			 * for the compatiblity problems mentioned above.
- 			 *
- 			 * RFC1323: The Window field in a SYN (i.e., a <SYN>
- 			 * or <SYN,ACK>) segment itself is never scaled.
+			 * Compute proper scaling value from buffer space:
+			 * Place window scale into sweet spot where it is
+			 * about one fourth of the MSS.  This allows us to
+			 * scale the receive buffer over a wide range while
+			 * not losing any efficiency or fine granularity.
 			 */
 			while (wscale < TCP_MAX_WINSHIFT &&
-			    (TCP_MAXWIN << wscale) < sb_max)
+			    (0x1 << wscale) < tcp_minmss)
 				wscale++;
 			sc->sc_request_r_scale = wscale;
 			sc->sc_requested_s_scale = to->to_requested_s_scale;
@@ -1274,6 +1261,8 @@
 
 static int tcp_msstab[] = { 0, 536, 1460, 8960 };
 
+static MD5_CTX syn_ctx;
+
 #define MD5Add(v)	MD5Update(&syn_ctx, (u_char *)&v, sizeof(v))
 
 struct md5_add {
@@ -1303,7 +1292,6 @@
 	u_int32_t data;
 	int idx, i;
 	struct md5_add add;
-	MD5_CTX syn_ctx;
 
 	/* NB: single threaded; could add INP_INFO_WLOCK_ASSERT(&tcbinfo) */
 
@@ -1341,7 +1329,6 @@
 	MD5Final((u_char *)&md5_buffer, &syn_ctx);
 	data ^= (md5_buffer[0] & ~SYNCOOKIE_WNDMASK);
 	*flowid = md5_buffer[1];
-	tcpstat.tcps_sc_sendcookie++;
 	return (data);
 }
 
@@ -1356,7 +1343,6 @@
 	u_int32_t data;
 	int wnd, idx;
 	struct md5_add add;
-	MD5_CTX syn_ctx;
 
 	/* NB: single threaded; could add INP_INFO_WLOCK_ASSERT(&tcbinfo) */
 
Index: ip_output.c
===================================================================
RCS file: /home/cvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -L sys/netinet/ip_output.c -L sys/netinet/ip_output.c -u -r1.6 -r1.6.2.1
--- sys/netinet/ip_output.c
+++ sys/netinet/ip_output.c
@@ -28,7 +28,6 @@
  *
  *	@(#)ip_output.c	8.3 (Berkeley) 1/21/94
  * $FreeBSD: src/sys/netinet/ip_output.c,v 1.242.2.8 2006/01/31 16:06:05 andre Exp $
- * $MidnightBSD$
  */
 
 #include "opt_ipfw.h"
@@ -169,7 +168,7 @@
 	 * will wrap around in less than 10 seconds at 100 Mbit/s on a
 	 * medium with MTU 1500.  See Steven M. Bellovin, "A Technique
 	 * for Counting NATted Hosts", Proc. IMW'02, available at
-	 * <http://www.cs.columbia.edu/~smb/papers/fnat.pdf>.
+	 * <http://www.research.att.com/~smb/papers/fnat.pdf>.
 	 */
 	if ((flags & (IP_FORWARDING|IP_RAWOUTPUT)) == 0) {
 		ip->ip_v = IPVERSION;
@@ -1149,37 +1148,20 @@
 
 /*
  * IP socket option processing.
- *
- * There are two versions of this call in order to work around a race
- * condition in TCP in FreeBSD 6.x.  In the TCP implementation, so->so_pcb
- * can become NULL if the pcb or pcbinfo lock isn't held.  However, when
- * entering ip_ctloutput(), neither lock is held, and finding the pointer to
- * either lock requires follow so->so_pcb, which may be NULL.
- * ip_ctloutput_pcbinfo() accepts the pcbinfo pointer so that the lock can be
- * safely acquired.  This is not required in FreeBSD 7.x because the
- * invariants on so->so_pcb are much stronger, so it cannot become NULL
- * while the socket is in use.
  */
 int
-ip_ctloutput_pcbinfo(so, sopt, pcbinfo)
+ip_ctloutput(so, sopt)
 	struct socket *so;
 	struct sockopt *sopt;
-	struct inpcbinfo *pcbinfo;
 {
 	struct	inpcb *inp = sotoinpcb(so);
 	int	error, optval;
 
-	if (pcbinfo == NULL)
-		pcbinfo = inp->inp_pcbinfo;
-
 	error = optval = 0;
 	if (sopt->sopt_level != IPPROTO_IP) {
 		return (EINVAL);
 	}
 
-	if (inp == NULL)
-		return (EINVAL);
-
 	switch (sopt->sopt_dir) {
 	case SOPT_SET:
 		switch (sopt->sopt_name) {
@@ -1201,19 +1183,7 @@
 			m->m_len = sopt->sopt_valsize;
 			error = sooptcopyin(sopt, mtod(m, char *), m->m_len,
 					    m->m_len);
-			if (error) {
-				m_free(m);
-				break;
-			}
-			INP_INFO_WLOCK(pcbinfo);
-			if (so->so_pcb == NULL) {
-				INP_INFO_WUNLOCK(pcbinfo);
-				m_free(m);
-				error = EINVAL;
-				break;
-			}
 			INP_LOCK(inp);
-			INP_INFO_WUNLOCK(pcbinfo);
 			error = ip_pcbopts(inp, sopt->sopt_name, m);
 			INP_UNLOCK(inp);
 			return (error);
@@ -1234,14 +1204,7 @@
 					    sizeof optval);
 			if (error)
 				break;
-			INP_INFO_WLOCK(pcbinfo);
-			if (so->so_pcb == NULL) {
-				INP_INFO_WUNLOCK(pcbinfo);
-				 error = EINVAL;
-				 break;
-			}
-			INP_LOCK(inp);
-			INP_INFO_WUNLOCK(pcbinfo);
+
 			switch (sopt->sopt_name) {
 			case IP_TOS:
 				inp->inp_ip_tos = optval;
@@ -1298,7 +1261,6 @@
 				OPTSET(INP_DONTFRAG);
 				break;
 			}
-			INP_UNLOCK(inp);
 			break;
 #undef OPTSET
 
@@ -1317,14 +1279,7 @@
 			if (error)
 				break;
 
-			INP_INFO_WLOCK(pcbinfo);
-			if (so->so_pcb == NULL) {
-				INP_INFO_WUNLOCK(pcbinfo);
-				error = EINVAL;
-				break;
-			}
 			INP_LOCK(inp);
-			INP_INFO_WUNLOCK(pcbinfo);
 			switch (optval) {
 			case IP_PORTRANGE_DEFAULT:
 				inp->inp_flags &= ~(INP_LOWPORT);
@@ -1366,11 +1321,6 @@
 			req = mtod(m, caddr_t);
 			len = m->m_len;
 			optname = sopt->sopt_name;
-			 if (so->so_pcb == NULL) {
-				m_free(m);
-				error = EINVAL;
-				break;
-			}
 			error = ipsec4_set_policy(inp, optname, req, len, priv);
 			m_freem(m);
 			break;
@@ -1505,12 +1455,6 @@
 	return (error);
 }
 
-int
-ip_ctloutput(struct socket *so, struct sockopt *sopt)
-{
-	return (ip_ctloutput_pcbinfo(so, sopt, NULL));
-}
-
 /*
  * Set up IP options in pcb for insertion in output packets.
  * Store in mbuf with pointer in pcbopt, adding pseudo-option


More information about the Midnightbsd-cvs mailing list