]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/tcp_output.c
ide: IDE_AFLAG_WP -> IDE_DFLAG_WP
[linux-2.6-omap-h63xx.git] / net / ipv4 / tcp_output.c
index 8f9793a37b618540d27ec965b5489a3d1ff7a171..990a584932355bd8689f976b79bbe76dfaf3674e 100644 (file)
@@ -345,6 +345,11 @@ static void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u8 flags)
        TCP_SKB_CB(skb)->end_seq = seq;
 }
 
+static inline int tcp_urg_mode(const struct tcp_sock *tp)
+{
+       return tp->snd_una != tp->snd_up;
+}
+
 #define OPTION_SACK_ADVERTISE  (1 << 0)
 #define OPTION_TS              (1 << 1)
 #define OPTION_MD5             (1 << 2)
@@ -646,7 +651,8 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
        th->check               = 0;
        th->urg_ptr             = 0;
 
-       if (unlikely(tp->urg_mode &&
+       /* The urg_mode check is necessary during a below snd_una win probe */
+       if (unlikely(tcp_urg_mode(tp) &&
                     between(tp->snd_up, tcb->seq + 1, tcb->seq + 0xFFFF))) {
                th->urg_ptr             = htons(tp->snd_up - tcb->seq);
                th->urg                 = 1;
@@ -1012,7 +1018,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
 /* Compute the current effective MSS, taking SACKs and IP options,
  * and even PMTU discovery events into account.
  *
- * LARGESEND note: !urg_mode is overkill, only frames up to snd_up
+ * LARGESEND note: !tcp_urg_mode is overkill, only frames up to snd_up
  * cannot be large. However, taking into account rare use of URG, this
  * is not a big flaw.
  */
@@ -1029,7 +1035,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed)
 
        mss_now = tp->mss_cache;
 
-       if (large_allowed && sk_can_gso(sk) && !tp->urg_mode)
+       if (large_allowed && sk_can_gso(sk) && !tcp_urg_mode(tp))
                doing_tso = 1;
 
        if (dst) {
@@ -1193,7 +1199,7 @@ static inline int tcp_nagle_test(struct tcp_sock *tp, struct sk_buff *skb,
        /* Don't use the nagle rule for urgent data (or for the final FIN).
         * Nagle can be ignored during F-RTO too (see RFC4138).
         */
-       if (tp->urg_mode || (tp->frto_counter == 2) ||
+       if (tcp_urg_mode(tp) || (tp->frto_counter == 2) ||
            (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN))
                return 1;
 
@@ -1932,8 +1938,8 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
        /* Collapse two adjacent packets if worthwhile and we can. */
        if (!(TCP_SKB_CB(skb)->flags & TCPCB_FLAG_SYN) &&
            (skb->len < (cur_mss >> 1)) &&
-           (tcp_write_queue_next(sk, skb) != tcp_send_head(sk)) &&
            (!tcp_skb_is_last(sk, skb)) &&
+           (tcp_write_queue_next(sk, skb) != tcp_send_head(sk)) &&
            (skb_shinfo(skb)->nr_frags == 0 &&
             skb_shinfo(tcp_write_queue_next(sk, skb))->nr_frags == 0) &&
            (tcp_skb_pcount(skb) == 1 &&
@@ -2232,6 +2238,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
        struct sk_buff *skb;
        struct tcp_md5sig_key *md5;
        __u8 *md5_hash_location;
+       int mss;
 
        skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC);
        if (skb == NULL)
@@ -2242,13 +2249,17 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
 
        skb->dst = dst_clone(dst);
 
+       mss = dst_metric(dst, RTAX_ADVMSS);
+       if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < mss)
+               mss = tp->rx_opt.user_mss;
+
        if (req->rcv_wnd == 0) { /* ignored for retransmitted syns */
                __u8 rcv_wscale;
                /* Set this up on the first call only */
                req->window_clamp = tp->window_clamp ? : dst_metric(dst, RTAX_WINDOW);
                /* tcp_full_space because it is guaranteed to be the first packet */
                tcp_select_initial_window(tcp_full_space(sk),
-                       dst_metric(dst, RTAX_ADVMSS) - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0),
+                       mss - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0),
                        &req->rcv_wnd,
                        &req->window_clamp,
                        ireq->wscale_ok,
@@ -2258,8 +2269,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
 
        memset(&opts, 0, sizeof(opts));
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
-       tcp_header_size = tcp_synack_options(sk, req,
-                                            dst_metric(dst, RTAX_ADVMSS),
+       tcp_header_size = tcp_synack_options(sk, req, mss,
                                             skb, &opts, &md5) +
                          sizeof(struct tcphdr);
 
@@ -2271,7 +2281,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
        th->syn = 1;
        th->ack = 1;
        TCP_ECN_make_synack(req, th);
-       th->source = inet_sk(sk)->sport;
+       th->source = ireq->loc_port;
        th->dest = ireq->rmt_port;
        /* Setting of flags are superfluous here for callers (and ECE is
         * not even correctly set)
@@ -2333,6 +2343,9 @@ static void tcp_connect_init(struct sock *sk)
        if (!tp->window_clamp)
                tp->window_clamp = dst_metric(dst, RTAX_WINDOW);
        tp->advmss = dst_metric(dst, RTAX_ADVMSS);
+       if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < tp->advmss)
+               tp->advmss = tp->rx_opt.user_mss;
+
        tcp_initialize_rcv_mss(sk);
 
        tcp_select_initial_window(tcp_full_space(sk),
@@ -2351,6 +2364,7 @@ static void tcp_connect_init(struct sock *sk)
        tcp_init_wl(tp, tp->write_seq, 0);
        tp->snd_una = tp->write_seq;
        tp->snd_sml = tp->write_seq;
+       tp->snd_up = tp->write_seq;
        tp->rcv_nxt = 0;
        tp->rcv_wup = 0;
        tp->copied_seq = 0;
@@ -2560,8 +2574,7 @@ int tcp_write_wakeup(struct sock *sk)
                        tcp_event_new_data_sent(sk, skb);
                return err;
        } else {
-               if (tp->urg_mode &&
-                   between(tp->snd_up, tp->snd_una + 1, tp->snd_una + 0xFFFF))
+               if (between(tp->snd_up, tp->snd_una + 1, tp->snd_una + 0xFFFF))
                        tcp_xmit_probe_skb(sk, 1);
                return tcp_xmit_probe_skb(sk, 0);
        }