vserver 2.0 rc7
[linux-2.6.git] / net / ipv4 / tcp_input.c
index 4819cb6..5bad504 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Version:    $Id: tcp_input.c,v 1.243 2002/02/01 22:01:04 davem Exp $
  *
- * Authors:    Ross Biro, <bir7@leland.Stanford.Edu>
+ * Authors:    Ross Biro
  *             Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  *             Mark Evans, <evansmp@uhura.aston.ac.uk>
  *             Corey Minyard <wf-rch!minyard@relay.EU.net>
@@ -71,6 +71,7 @@
 #include <net/tcp.h>
 #include <net/inet_common.h>
 #include <linux/ipsec.h>
+#include <asm/unaligned.h>
 
 int sysctl_tcp_timestamps = 1;
 int sysctl_tcp_window_scaling = 1;
@@ -977,7 +978,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
         * Not good, but alternative is to resegment the queue. */
        if (sk->sk_route_caps & NETIF_F_TSO) {
                sk->sk_route_caps &= ~NETIF_F_TSO;
-               sk->sk_no_largesend = 1;
+               sock_set_flag(sk, SOCK_NO_LARGESEND);
                tp->mss_cache = tp->mss_cache_std;
        }
 
@@ -3010,7 +3011,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                                switch(opcode) {
                                case TCPOPT_MSS:
                                        if(opsize==TCPOLEN_MSS && th->syn && !estab) {
-                                               u16 in_mss = ntohs(*(__u16 *)ptr);
+                                               u16 in_mss = ntohs(get_unaligned((__u16 *)ptr));
                                                if (in_mss) {
                                                        if (opt_rx->user_mss && opt_rx->user_mss < in_mss)
                                                                in_mss = opt_rx->user_mss;
@@ -3021,15 +3022,16 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                                case TCPOPT_WINDOW:
                                        if(opsize==TCPOLEN_WINDOW && th->syn && !estab)
                                                if (sysctl_tcp_window_scaling) {
+                                                       __u8 snd_wscale = *(__u8 *) ptr;
                                                        opt_rx->wscale_ok = 1;
-                                                       opt_rx->snd_wscale = *(__u8 *)ptr;
-                                                       if(opt_rx->snd_wscale > 14) {
+                                                       if (snd_wscale > 14) {
                                                                if(net_ratelimit())
                                                                        printk(KERN_INFO "tcp_parse_options: Illegal window "
                                                                               "scaling value %d >14 received.\n",
-                                                                              opt_rx->snd_wscale);
-                                                               opt_rx->snd_wscale = 14;
+                                                                              snd_wscale);
+                                                               snd_wscale = 14;
                                                        }
+                                                       opt_rx->snd_wscale = snd_wscale;
                                                }
                                        break;
                                case TCPOPT_TIMESTAMP:
@@ -3037,8 +3039,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                                                if ((estab && opt_rx->tstamp_ok) ||
                                                    (!estab && sysctl_tcp_timestamps)) {
                                                        opt_rx->saw_tstamp = 1;
-                                                       opt_rx->rcv_tsval = ntohl(*(__u32 *)ptr);
-                                                       opt_rx->rcv_tsecr = ntohl(*(__u32 *)(ptr+4));
+                                                       opt_rx->rcv_tsval = ntohl(get_unaligned((__u32 *)ptr));
+                                                       opt_rx->rcv_tsecr = ntohl(get_unaligned((__u32 *)(ptr+4)));
                                                }
                                        }
                                        break;
@@ -3515,7 +3517,6 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
        if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq)
                goto drop;
 
-       th = skb->h.th;
        __skb_pull(skb, th->doff*4);
 
        TCP_ECN_accept_cwr(tp, skb);
@@ -3938,7 +3939,7 @@ void tcp_cwnd_application_limited(struct sock *sk)
 
 
 /* When incoming ACK allowed to free some skb from write_queue,
- * we remember this event in flag sk->sk_queue_shrunk and wake up socket
+ * we remember this event in flag SOCK_QUEUE_SHRUNK and wake up socket
  * on the exit from tcp input handler.
  *
  * PROBLEM: sndbuf expansion does not work well with largesend.
@@ -3966,8 +3967,8 @@ static void tcp_new_space(struct sock *sk)
 
 static inline void tcp_check_space(struct sock *sk)
 {
-       if (sk->sk_queue_shrunk) {
-               sk->sk_queue_shrunk = 0;
+       if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) {
+               sock_reset_flag(sk, SOCK_QUEUE_SHRUNK);
                if (sk->sk_socket &&
                    test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
                        tcp_new_space(sk);
@@ -4354,16 +4355,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
                                        goto no_ack;
                        }
 
-                       if (eaten) {
-                               if (tcp_in_quickack_mode(tp)) {
-                                       tcp_send_ack(sk);
-                               } else {
-                                       tcp_send_delayed_ack(sk);
-                               }
-                       } else {
-                               __tcp_ack_snd_check(sk, 0);
-                       }
-
+                       __tcp_ack_snd_check(sk, 0);
 no_ack:
                        if (eaten)
                                __kfree_skb(skb);
@@ -4510,7 +4502,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
 
                TCP_ECN_rcv_synack(tp, th);
                if (tp->ecn_flags&TCP_ECN_OK)
-                       sk->sk_no_largesend = 1;
+                       sock_set_flag(sk, SOCK_NO_LARGESEND);
 
                tp->snd_wl1 = TCP_SKB_CB(skb)->seq;
                tcp_ack(sk, skb, FLAG_SLOWPATH);
@@ -4648,7 +4640,7 @@ discard:
 
                TCP_ECN_rcv_syn(tp, th);
                if (tp->ecn_flags&TCP_ECN_OK)
-                       sk->sk_no_largesend = 1;
+                       sock_set_flag(sk, SOCK_NO_LARGESEND);
 
                tcp_sync_mss(sk, tp->pmtu_cookie);
                tcp_initialize_rcv_mss(sk);