patch-2.1.92 linux/net/ipv4/tcp_ipv4.c

Next file: linux/net/ipv4/tcp_output.c
Previous file: linux/net/ipv4/tcp_input.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.91/linux/net/ipv4/tcp_ipv4.c linux/net/ipv4/tcp_ipv4.c
@@ -5,7 +5,7 @@
  *
  *		Implementation of the Transmission Control Protocol(TCP).
  *
- * Version:	$Id: tcp_ipv4.c,v 1.119 1998/03/22 19:14:47 davem Exp $
+ * Version:	$Id: tcp_ipv4.c,v 1.127 1998/03/30 08:41:25 davem Exp $
  *
  *		IPv4 specific functions
  *
@@ -347,7 +347,9 @@
 					   u32 saddr, u16 sport,
 					   u32 daddr, u16 dport, int dif)
 {
-	unsigned short hnum = ntohs(dport);
+	TCP_V4_ADDR_COOKIE(acookie, saddr, daddr)
+	__u16 hnum = ntohs(dport);
+	__u32 ports = TCP_COMBINED_PORTS(sport, hnum);
 	struct sock *sk;
 	int hash;
 
@@ -359,12 +361,7 @@
 
 	/* Check TCP register quick cache first. */
 	sk = TCP_RHASH(sport);
-	if(sk						&&
-	   sk->daddr		== saddr		&& /* remote address */
-	   sk->dport		== sport		&& /* remote port    */
-	   sk->num		== hnum			&& /* local port     */
-	   sk->rcv_saddr	== daddr		&& /* local address  */
-	   (!sk->bound_dev_if || sk->bound_dev_if == dif))
+	if(sk && TCP_IPV4_MATCH(sk, acookie, saddr, daddr, ports, dif))
 		goto hit;
 
 	/* Optimize here for direct hit, only listening connections can
@@ -372,25 +369,16 @@
 	 */
 	hash = tcp_hashfn(daddr, hnum, saddr, sport);
 	for(sk = tcp_established_hash[hash]; sk; sk = sk->next) {
-		if(sk->daddr		== saddr		&& /* remote address */
-		   sk->dport		== sport		&& /* remote port    */
-		   sk->num		== hnum			&& /* local port     */
-		   sk->rcv_saddr	== daddr		&& /* local address  */
-		   (!sk->bound_dev_if || sk->bound_dev_if == dif)) {
+		if(TCP_IPV4_MATCH(sk, acookie, saddr, daddr, ports, dif)) {
 			if (sk->state == TCP_ESTABLISHED)
 				TCP_RHASH(sport) = sk;
 			goto hit; /* You sunk my battleship! */
 		}
 	}
 	/* Must check for a TIME_WAIT'er before going to listener hash. */
-	for(sk = tcp_established_hash[hash+(TCP_HTABLE_SIZE/2)]; sk; sk = sk->next) {
-		if(sk->daddr		== saddr		&& /* remote address */
-		   sk->dport		== sport		&& /* remote port    */
-		   sk->num		== hnum			&& /* local port     */
-		   sk->rcv_saddr	== daddr		&& /* local address  */
-		   (!sk->bound_dev_if || sk->bound_dev_if == dif))
+	for(sk = tcp_established_hash[hash+(TCP_HTABLE_SIZE/2)]; sk; sk = sk->next)
+		if(TCP_IPV4_MATCH(sk, acookie, saddr, daddr, ports, dif))
 			goto hit;
-	}
 #ifdef USE_QUICKSYNS
 listener_shortcut:
 #endif
@@ -601,8 +589,6 @@
 		sk->mtu = 64;	/* Sanity limit */
 
 	mss = sk->mtu - sizeof(struct iphdr);
-	if (sk->opt)
-		mss -= sk->opt->optlen;
 
 	tp->write_seq = secure_tcp_sequence_number(sk->saddr, sk->daddr,
 						   sk->sport, usin->sin_port);
@@ -773,8 +759,8 @@
 	switch (type) {
 	case ICMP_SOURCE_QUENCH:
 #ifndef OLD_SOURCE_QUENCH /* This is deprecated */
-		tp->snd_ssthresh = max(tp->snd_cwnd >> 1, 2);
-		tp->snd_cwnd = tp->snd_ssthresh;
+		tp->snd_ssthresh = max(tp->snd_cwnd >> (1 + TCP_CWND_SHIFT), 2);
+		tp->snd_cwnd = (tp->snd_ssthresh << TCP_CWND_SHIFT);
 		tp->high_seq = tp->snd_nxt;
 #endif
 		return;
@@ -971,8 +957,6 @@
 	}
 
 	mss = (rt->u.dst.pmtu - sizeof(struct iphdr) - sizeof(struct tcphdr));
-	if (opt)
-		mss -= opt->optlen;
 
 	skb = tcp_make_synack(sk, &rt->u.dst, req, mss);
 	if (skb) {
@@ -1098,7 +1082,7 @@
 
 	req->rcv_wnd = 0;		/* So that tcp_send_synack() knows! */
 
-	req->rcv_isn = skb->seq;
+	req->rcv_isn = TCP_SKB_CB(skb)->seq;
  	tp.tstamp_ok = tp.sack_ok = tp.wscale_ok = tp.snd_wscale = 0;
 	tp.in_mss = 536;
 	tcp_parse_options(NULL, th, &tp, want_cookie);
@@ -1207,12 +1191,13 @@
 		newtp->last_ack_sent = req->rcv_isn + 1;
 		newtp->backoff = 0;
 		newtp->mdev = TCP_TIMEOUT_INIT;
-		newtp->snd_cwnd = 1;
+		newtp->snd_cwnd = (1 << TCP_CWND_SHIFT);
 		newtp->rto = TCP_TIMEOUT_INIT;
 		newtp->packets_out = 0;
+		newtp->fackets_out = 0;
+		newtp->retrans_out = 0;
 		newtp->high_seq = 0;
 		newtp->snd_ssthresh = 0x7fffffff;
-		newtp->snd_cwnd_cnt = 0;
 		newtp->dup_acks = 0;
 		newtp->delayed_acks = 0;
 		init_timer(&newtp->retransmit_timer);
@@ -1317,8 +1302,6 @@
 	if (mtu < 68)
 		mtu = 68;
 	snd_mss = mtu - sizeof(struct iphdr);
-	if (opt)
-		snd_mss -= opt->optlen;
 
 	newsk = tcp_create_openreq_child(sk, req, skb, snd_mss);
 	if (!newsk) 
@@ -1337,8 +1320,7 @@
 	newsk->opt = req->af.v4_req.opt;
 	newsk->mtu = mtu;
 
-	/* Must use the af_specific ops here for the case of IPv6 mapped. */
-	newsk->prot->hash(newsk);
+	tcp_v4_hash(newsk);
 	add_to_prot_sklist(newsk);
 
 	return newsk;
@@ -1357,7 +1339,8 @@
 	if (!req)
 		return;
 	/* Sequence number check required by RFC793 */
-	if (before(skb->seq, req->snt_isn) || after(skb->seq, req->snt_isn+1))
+	if (before(TCP_SKB_CB(skb)->seq, req->snt_isn) ||
+	    after(TCP_SKB_CB(skb)->seq, req->snt_isn+1))
 		return;
 	tcp_synq_unlink(tp, req, prev);
 	req->class->destructor(req);
@@ -1509,9 +1492,10 @@
 	if(!ipsec_sk_policy(sk,skb))
 		goto discard_it;
 
-	skb->seq = ntohl(th->seq);
-	skb->end_seq = skb->seq + th->syn + th->fin + len - th->doff*4;
-	skb->ack_seq = ntohl(th->ack_seq);
+	TCP_SKB_CB(skb)->seq = ntohl(th->seq);
+	TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
+				    len - th->doff*4);
+	TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
 
 	skb->used = 0;
 
@@ -1662,7 +1646,7 @@
 	/* See draft-stevens-tcpca-spec-01 for discussion of the
 	 * initialization of these values.
 	 */
-	tp->snd_cwnd = 1;
+	tp->snd_cwnd = (1 << TCP_CWND_SHIFT);
 	tp->snd_ssthresh = 0x7fffffff;	/* Infinity */
 
 	sk->priority = 1;
@@ -1690,11 +1674,11 @@
 		tcp_dec_slow_timer(TCP_SLT_KEEPALIVE);
 
 	/* Cleanup up the write buffer. */
-  	while((skb = skb_dequeue(&sk->write_queue)) != NULL)
+  	while((skb = __skb_dequeue(&sk->write_queue)) != NULL)
 		kfree_skb(skb);
 
 	/* Cleans up our, hopefuly empty, out_of_order_queue. */
-  	while((skb = skb_dequeue(&tp->out_of_order_queue)) != NULL)
+  	while((skb = __skb_dequeue(&tp->out_of_order_queue)) != NULL)
 		kfree_skb(skb);
 
 	/* Clean up a locked TCP bind bucket, this only happens if a

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov