]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/tcp_output.c
Merge ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
[linux-2.6-omap-h63xx.git] / net / ipv4 / tcp_output.c
index 029c70dfb585f74e74383faf40c1816b4e6d410d..a7623ead39a8b6a91fe34b81afd5193d9ed6cce3 100644 (file)
@@ -51,8 +51,8 @@ int sysctl_tcp_retrans_collapse = 1;
  */
 int sysctl_tcp_tso_win_divisor = 3;
 
  */
 int sysctl_tcp_tso_win_divisor = 3;
 
-static inline void update_send_head(struct sock *sk, struct tcp_sock *tp,
-                                   struct sk_buff *skb)
+static void update_send_head(struct sock *sk, struct tcp_sock *tp,
+                            struct sk_buff *skb)
 {
        sk->sk_send_head = skb->next;
        if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue)
 {
        sk->sk_send_head = skb->next;
        if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue)
@@ -124,8 +124,8 @@ static void tcp_cwnd_restart(struct sock *sk, struct dst_entry *dst)
        tp->snd_cwnd_used = 0;
 }
 
        tp->snd_cwnd_used = 0;
 }
 
-static inline void tcp_event_data_sent(struct tcp_sock *tp,
-                                      struct sk_buff *skb, struct sock *sk)
+static void tcp_event_data_sent(struct tcp_sock *tp,
+                               struct sk_buff *skb, struct sock *sk)
 {
        struct inet_connection_sock *icsk = inet_csk(sk);
        const u32 now = tcp_time_stamp;
 {
        struct inet_connection_sock *icsk = inet_csk(sk);
        const u32 now = tcp_time_stamp;
@@ -142,7 +142,7 @@ static inline void tcp_event_data_sent(struct tcp_sock *tp,
                icsk->icsk_ack.pingpong = 1;
 }
 
                icsk->icsk_ack.pingpong = 1;
 }
 
-static __inline__ void tcp_event_ack_sent(struct sock *sk, unsigned int pkts)
+static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts)
 {
        tcp_dec_quickack_mode(sk, pkts);
        inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
 {
        tcp_dec_quickack_mode(sk, pkts);
        inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
@@ -212,7 +212,7 @@ void tcp_select_initial_window(int __space, __u32 mss,
  * value can be stuffed directly into th->window for an outgoing
  * frame.
  */
  * value can be stuffed directly into th->window for an outgoing
  * frame.
  */
-static __inline__ u16 tcp_select_window(struct sock *sk)
+static u16 tcp_select_window(struct sock *sk)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        u32 cur_win = tcp_receive_window(tp);
 {
        struct tcp_sock *tp = tcp_sk(sk);
        u32 cur_win = tcp_receive_window(tp);
@@ -250,6 +250,75 @@ static __inline__ u16 tcp_select_window(struct sock *sk)
        return new_win;
 }
 
        return new_win;
 }
 
+static void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp,
+                                        __u32 tstamp)
+{
+       if (tp->rx_opt.tstamp_ok) {
+               *ptr++ = __constant_htonl((TCPOPT_NOP << 24) |
+                                         (TCPOPT_NOP << 16) |
+                                         (TCPOPT_TIMESTAMP << 8) |
+                                         TCPOLEN_TIMESTAMP);
+               *ptr++ = htonl(tstamp);
+               *ptr++ = htonl(tp->rx_opt.ts_recent);
+       }
+       if (tp->rx_opt.eff_sacks) {
+               struct tcp_sack_block *sp = tp->rx_opt.dsack ? tp->duplicate_sack : tp->selective_acks;
+               int this_sack;
+
+               *ptr++ = htonl((TCPOPT_NOP  << 24) |
+                              (TCPOPT_NOP  << 16) |
+                              (TCPOPT_SACK <<  8) |
+                              (TCPOLEN_SACK_BASE + (tp->rx_opt.eff_sacks *
+                                                    TCPOLEN_SACK_PERBLOCK)));
+               for(this_sack = 0; this_sack < tp->rx_opt.eff_sacks; this_sack++) {
+                       *ptr++ = htonl(sp[this_sack].start_seq);
+                       *ptr++ = htonl(sp[this_sack].end_seq);
+               }
+               if (tp->rx_opt.dsack) {
+                       tp->rx_opt.dsack = 0;
+                       tp->rx_opt.eff_sacks--;
+               }
+       }
+}
+
+/* Construct a tcp options header for a SYN or SYN_ACK packet.
+ * If this is every changed make sure to change the definition of
+ * MAX_SYN_SIZE to match the new maximum number of options that you
+ * can generate.
+ */
+static void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sack,
+                                 int offer_wscale, int wscale, __u32 tstamp,
+                                 __u32 ts_recent)
+{
+       /* We always get an MSS option.
+        * The option bytes which will be seen in normal data
+        * packets should timestamps be used, must be in the MSS
+        * advertised.  But we subtract them from tp->mss_cache so
+        * that calculations in tcp_sendmsg are simpler etc.
+        * So account for this fact here if necessary.  If we
+        * don't do this correctly, as a receiver we won't
+        * recognize data packets as being full sized when we
+        * should, and thus we won't abide by the delayed ACK
+        * rules correctly.
+        * SACKs don't matter, we never delay an ACK when we
+        * have any of those going out.
+        */
+       *ptr++ = htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) | mss);
+       if (ts) {
+               if(sack)
+                       *ptr++ = __constant_htonl((TCPOPT_SACK_PERM << 24) | (TCPOLEN_SACK_PERM << 16) |
+                                                 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
+               else
+                       *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
+                                                 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
+               *ptr++ = htonl(tstamp);         /* TSVAL */
+               *ptr++ = htonl(ts_recent);      /* TSECR */
+       } else if(sack)
+               *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
+                                         (TCPOPT_SACK_PERM << 8) | TCPOLEN_SACK_PERM);
+       if (offer_wscale)
+               *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_WINDOW << 16) | (TCPOLEN_WINDOW << 8) | (wscale));
+}
 
 /* This routine actually transmits TCP packets queued in by
  * tcp_do_sendmsg().  This is used by both the initial
 
 /* This routine actually transmits TCP packets queued in by
  * tcp_do_sendmsg().  This is used by both the initial
@@ -262,122 +331,139 @@ static __inline__ u16 tcp_select_window(struct sock *sk)
  * We are working here with either a clone of the original
  * SKB, or a fresh unique copy made by the retransmit engine.
  */
  * We are working here with either a clone of the original
  * SKB, or a fresh unique copy made by the retransmit engine.
  */
-static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb)
+static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, gfp_t gfp_mask)
 {
 {
-       if (skb != NULL) {
-               const struct inet_connection_sock *icsk = inet_csk(sk);
-               struct inet_sock *inet = inet_sk(sk);
-               struct tcp_sock *tp = tcp_sk(sk);
-               struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
-               int tcp_header_size = tp->tcp_header_len;
-               struct tcphdr *th;
-               int sysctl_flags;
-               int err;
+       const struct inet_connection_sock *icsk = inet_csk(sk);
+       struct inet_sock *inet;
+       struct tcp_sock *tp;
+       struct tcp_skb_cb *tcb;
+       int tcp_header_size;
+       struct tcphdr *th;
+       int sysctl_flags;
+       int err;
+
+       BUG_ON(!skb || !tcp_skb_pcount(skb));
+
+       /* If congestion control is doing timestamping, we must
+        * take such a timestamp before we potentially clone/copy.
+        */
+       if (icsk->icsk_ca_ops->rtt_sample)
+               __net_timestamp(skb);
+
+       if (likely(clone_it)) {
+               if (unlikely(skb_cloned(skb)))
+                       skb = pskb_copy(skb, gfp_mask);
+               else
+                       skb = skb_clone(skb, gfp_mask);
+               if (unlikely(!skb))
+                       return -ENOBUFS;
+       }
 
 
-               BUG_ON(!tcp_skb_pcount(skb));
+       inet = inet_sk(sk);
+       tp = tcp_sk(sk);
+       tcb = TCP_SKB_CB(skb);
+       tcp_header_size = tp->tcp_header_len;
 
 #define SYSCTL_FLAG_TSTAMPS    0x1
 #define SYSCTL_FLAG_WSCALE     0x2
 #define SYSCTL_FLAG_SACK       0x4
 
 
 #define SYSCTL_FLAG_TSTAMPS    0x1
 #define SYSCTL_FLAG_WSCALE     0x2
 #define SYSCTL_FLAG_SACK       0x4
 
-               /* If congestion control is doing timestamping */
-               if (icsk->icsk_ca_ops->rtt_sample)
-                       __net_timestamp(skb);
-
-               sysctl_flags = 0;
-               if (tcb->flags & TCPCB_FLAG_SYN) {
-                       tcp_header_size = sizeof(struct tcphdr) + TCPOLEN_MSS;
-                       if(sysctl_tcp_timestamps) {
-                               tcp_header_size += TCPOLEN_TSTAMP_ALIGNED;
-                               sysctl_flags |= SYSCTL_FLAG_TSTAMPS;
-                       }
-                       if(sysctl_tcp_window_scaling) {
-                               tcp_header_size += TCPOLEN_WSCALE_ALIGNED;
-                               sysctl_flags |= SYSCTL_FLAG_WSCALE;
-                       }
-                       if(sysctl_tcp_sack) {
-                               sysctl_flags |= SYSCTL_FLAG_SACK;
-                               if(!(sysctl_flags & SYSCTL_FLAG_TSTAMPS))
-                                       tcp_header_size += TCPOLEN_SACKPERM_ALIGNED;
-                       }
-               } else if (tp->rx_opt.eff_sacks) {
-                       /* A SACK is 2 pad bytes, a 2 byte header, plus
-                        * 2 32-bit sequence numbers for each SACK block.
-                        */
-                       tcp_header_size += (TCPOLEN_SACK_BASE_ALIGNED +
-                                           (tp->rx_opt.eff_sacks * TCPOLEN_SACK_PERBLOCK));
+       sysctl_flags = 0;
+       if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) {
+               tcp_header_size = sizeof(struct tcphdr) + TCPOLEN_MSS;
+               if(sysctl_tcp_timestamps) {
+                       tcp_header_size += TCPOLEN_TSTAMP_ALIGNED;
+                       sysctl_flags |= SYSCTL_FLAG_TSTAMPS;
                }
                }
-               
-               if (tcp_packets_in_flight(tp) == 0)
-                       tcp_ca_event(sk, CA_EVENT_TX_START);
-
-               th = (struct tcphdr *) skb_push(skb, tcp_header_size);
-               skb->h.th = th;
-               skb_set_owner_w(skb, sk);
-
-               /* Build TCP header and checksum it. */
-               th->source              = inet->sport;
-               th->dest                = inet->dport;
-               th->seq                 = htonl(tcb->seq);
-               th->ack_seq             = htonl(tp->rcv_nxt);
-               *(((__u16 *)th) + 6)    = htons(((tcp_header_size >> 2) << 12) | tcb->flags);
-               if (tcb->flags & TCPCB_FLAG_SYN) {
-                       /* RFC1323: The window in SYN & SYN/ACK segments
-                        * is never scaled.
-                        */
-                       th->window      = htons(tp->rcv_wnd);
-               } else {
-                       th->window      = htons(tcp_select_window(sk));
+               if (sysctl_tcp_window_scaling) {
+                       tcp_header_size += TCPOLEN_WSCALE_ALIGNED;
+                       sysctl_flags |= SYSCTL_FLAG_WSCALE;
                }
                }
-               th->check               = 0;
-               th->urg_ptr             = 0;
-
-               if (tp->urg_mode &&
-                   between(tp->snd_up, tcb->seq+1, tcb->seq+0xFFFF)) {
-                       th->urg_ptr             = htons(tp->snd_up-tcb->seq);
-                       th->urg                 = 1;
+               if (sysctl_tcp_sack) {
+                       sysctl_flags |= SYSCTL_FLAG_SACK;
+                       if (!(sysctl_flags & SYSCTL_FLAG_TSTAMPS))
+                               tcp_header_size += TCPOLEN_SACKPERM_ALIGNED;
                }
                }
+       } else if (unlikely(tp->rx_opt.eff_sacks)) {
+               /* A SACK is 2 pad bytes, a 2 byte header, plus
+                * 2 32-bit sequence numbers for each SACK block.
+                */
+               tcp_header_size += (TCPOLEN_SACK_BASE_ALIGNED +
+                                   (tp->rx_opt.eff_sacks *
+                                    TCPOLEN_SACK_PERBLOCK));
+       }
+               
+       if (tcp_packets_in_flight(tp) == 0)
+               tcp_ca_event(sk, CA_EVENT_TX_START);
+
+       th = (struct tcphdr *) skb_push(skb, tcp_header_size);
+       skb->h.th = th;
+       skb_set_owner_w(skb, sk);
+
+       /* Build TCP header and checksum it. */
+       th->source              = inet->sport;
+       th->dest                = inet->dport;
+       th->seq                 = htonl(tcb->seq);
+       th->ack_seq             = htonl(tp->rcv_nxt);
+       *(((__u16 *)th) + 6)    = htons(((tcp_header_size >> 2) << 12) |
+                                       tcb->flags);
+
+       if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) {
+               /* RFC1323: The window in SYN & SYN/ACK segments
+                * is never scaled.
+                */
+               th->window      = htons(tp->rcv_wnd);
+       } else {
+               th->window      = htons(tcp_select_window(sk));
+       }
+       th->check               = 0;
+       th->urg_ptr             = 0;
 
 
-               if (tcb->flags & TCPCB_FLAG_SYN) {
-                       tcp_syn_build_options((__u32 *)(th + 1),
-                                             tcp_advertise_mss(sk),
-                                             (sysctl_flags & SYSCTL_FLAG_TSTAMPS),
-                                             (sysctl_flags & SYSCTL_FLAG_SACK),
-                                             (sysctl_flags & SYSCTL_FLAG_WSCALE),
-                                             tp->rx_opt.rcv_wscale,
-                                             tcb->when,
-                                             tp->rx_opt.ts_recent);
-               } else {
-                       tcp_build_and_update_options((__u32 *)(th + 1),
-                                                    tp, tcb->when);
+       if (unlikely(tp->urg_mode &&
+                    between(tp->snd_up, tcb->seq+1, tcb->seq+0xFFFF))) {
+               th->urg_ptr             = htons(tp->snd_up-tcb->seq);
+               th->urg                 = 1;
+       }
 
 
-                       TCP_ECN_send(sk, tp, skb, tcp_header_size);
-               }
-               tp->af_specific->send_check(sk, th, skb->len, skb);
+       if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) {
+               tcp_syn_build_options((__u32 *)(th + 1),
+                                     tcp_advertise_mss(sk),
+                                     (sysctl_flags & SYSCTL_FLAG_TSTAMPS),
+                                     (sysctl_flags & SYSCTL_FLAG_SACK),
+                                     (sysctl_flags & SYSCTL_FLAG_WSCALE),
+                                     tp->rx_opt.rcv_wscale,
+                                     tcb->when,
+                                     tp->rx_opt.ts_recent);
+       } else {
+               tcp_build_and_update_options((__u32 *)(th + 1),
+                                            tp, tcb->when);
+               TCP_ECN_send(sk, tp, skb, tcp_header_size);
+       }
 
 
-               if (tcb->flags & TCPCB_FLAG_ACK)
-                       tcp_event_ack_sent(sk, tcp_skb_pcount(skb));
+       icsk->icsk_af_ops->send_check(sk, skb->len, skb);
 
 
-               if (skb->len != tcp_header_size)
-                       tcp_event_data_sent(tp, skb, sk);
+       if (likely(tcb->flags & TCPCB_FLAG_ACK))
+               tcp_event_ack_sent(sk, tcp_skb_pcount(skb));
 
 
-               TCP_INC_STATS(TCP_MIB_OUTSEGS);
+       if (skb->len != tcp_header_size)
+               tcp_event_data_sent(tp, skb, sk);
 
 
-               err = tp->af_specific->queue_xmit(skb, 0);
-               if (err <= 0)
-                       return err;
+       TCP_INC_STATS(TCP_MIB_OUTSEGS);
 
 
-               tcp_enter_cwr(sk);
+       err = icsk->icsk_af_ops->queue_xmit(skb, 0);
+       if (unlikely(err <= 0))
+               return err;
+
+       tcp_enter_cwr(sk);
+
+       /* NET_XMIT_CN is special. It does not guarantee,
+        * that this packet is lost. It tells that device
+        * is about to start to drop packets or already
+        * drops some packets of the same priority and
+        * invokes us to send less aggressively.
+        */
+       return err == NET_XMIT_CN ? 0 : err;
 
 
-               /* NET_XMIT_CN is special. It does not guarantee,
-                * that this packet is lost. It tells that device
-                * is about to start to drop packets or already
-                * drops some packets of the same priority and
-                * invokes us to send less aggressively.
-                */
-               return err == NET_XMIT_CN ? 0 : err;
-       }
-       return -ENOBUFS;
 #undef SYSCTL_FLAG_TSTAMPS
 #undef SYSCTL_FLAG_WSCALE
 #undef SYSCTL_FLAG_SACK
 #undef SYSCTL_FLAG_TSTAMPS
 #undef SYSCTL_FLAG_WSCALE
 #undef SYSCTL_FLAG_SACK
@@ -604,7 +690,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
    It is minimum of user_mss and mss received with SYN.
    It also does not include TCP options.
 
    It is minimum of user_mss and mss received with SYN.
    It also does not include TCP options.
 
-   tp->pmtu_cookie is last pmtu, seen by this function.
+   inet_csk(sk)->icsk_pmtu_cookie is last pmtu, seen by this function.
 
    tp->mss_cache is current effective sending mss, including
    all tcp options except for SACKs. It is evaluated,
 
    tp->mss_cache is current effective sending mss, including
    all tcp options except for SACKs. It is evaluated,
@@ -614,26 +700,26 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
    NOTE1. rfc1122 clearly states that advertised MSS
    DOES NOT include either tcp or ip options.
 
    NOTE1. rfc1122 clearly states that advertised MSS
    DOES NOT include either tcp or ip options.
 
-   NOTE2. tp->pmtu_cookie and tp->mss_cache are READ ONLY outside
-   this function.                      --ANK (980731)
+   NOTE2. inet_csk(sk)->icsk_pmtu_cookie and tp->mss_cache
+   are READ ONLY outside this function.                --ANK (980731)
  */
 
 unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
 {
        struct tcp_sock *tp = tcp_sk(sk);
  */
 
 unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
 {
        struct tcp_sock *tp = tcp_sk(sk);
-       int mss_now;
-
+       struct inet_connection_sock *icsk = inet_csk(sk);
        /* Calculate base mss without TCP options:
           It is MMS_S - sizeof(tcphdr) of rfc1122
         */
        /* Calculate base mss without TCP options:
           It is MMS_S - sizeof(tcphdr) of rfc1122
         */
-       mss_now = pmtu - tp->af_specific->net_header_len - sizeof(struct tcphdr);
+       int mss_now = (pmtu - icsk->icsk_af_ops->net_header_len -
+                      sizeof(struct tcphdr));
 
        /* Clamp it (mss_clamp does not include tcp options) */
        if (mss_now > tp->rx_opt.mss_clamp)
                mss_now = tp->rx_opt.mss_clamp;
 
        /* Now subtract optional transport overhead */
 
        /* Clamp it (mss_clamp does not include tcp options) */
        if (mss_now > tp->rx_opt.mss_clamp)
                mss_now = tp->rx_opt.mss_clamp;
 
        /* Now subtract optional transport overhead */
-       mss_now -= tp->ext_header_len;
+       mss_now -= icsk->icsk_ext_hdr_len;
 
        /* Then reserve room for full set of TCP options and 8 bytes of data */
        if (mss_now < 48)
 
        /* Then reserve room for full set of TCP options and 8 bytes of data */
        if (mss_now < 48)
@@ -647,7 +733,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
                mss_now = max((tp->max_window>>1), 68U - tp->tcp_header_len);
 
        /* And store cached results */
                mss_now = max((tp->max_window>>1), 68U - tp->tcp_header_len);
 
        /* And store cached results */
-       tp->pmtu_cookie = pmtu;
+       icsk->icsk_pmtu_cookie = pmtu;
        tp->mss_cache = mss_now;
 
        return mss_now;
        tp->mss_cache = mss_now;
 
        return mss_now;
@@ -677,7 +763,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed)
 
        if (dst) {
                u32 mtu = dst_mtu(dst);
 
        if (dst) {
                u32 mtu = dst_mtu(dst);
-               if (mtu != tp->pmtu_cookie)
+               if (mtu != inet_csk(sk)->icsk_pmtu_cookie)
                        mss_now = tcp_sync_mss(sk, mtu);
        }
 
                        mss_now = tcp_sync_mss(sk, mtu);
        }
 
@@ -688,9 +774,10 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed)
        xmit_size_goal = mss_now;
 
        if (doing_tso) {
        xmit_size_goal = mss_now;
 
        if (doing_tso) {
-               xmit_size_goal = 65535 -
-                       tp->af_specific->net_header_len -
-                       tp->ext_header_len - tp->tcp_header_len;
+               xmit_size_goal = (65535 -
+                                 inet_csk(sk)->icsk_af_ops->net_header_len -
+                                 inet_csk(sk)->icsk_ext_hdr_len -
+                                 tp->tcp_header_len);
 
                if (tp->max_window &&
                    (xmit_size_goal > (tp->max_window >> 1)))
 
                if (tp->max_window &&
                    (xmit_size_goal > (tp->max_window >> 1)))
@@ -706,7 +793,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed)
 
 /* Congestion window validation. (RFC2861) */
 
 
 /* Congestion window validation. (RFC2861) */
 
-static inline void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp)
+static void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp)
 {
        __u32 packets_out = tp->packets_out;
 
 {
        __u32 packets_out = tp->packets_out;
 
@@ -755,7 +842,7 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, struct sk_buff *sk
 /* This must be invoked the first time we consider transmitting
  * SKB onto the wire.
  */
 /* This must be invoked the first time we consider transmitting
  * SKB onto the wire.
  */
-static inline int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now)
+static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now)
 {
        int tso_segs = tcp_skb_pcount(skb);
 
 {
        int tso_segs = tcp_skb_pcount(skb);
 
@@ -1036,7 +1123,7 @@ static int tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle)
 
                TCP_SKB_CB(skb)->when = tcp_time_stamp;
 
 
                TCP_SKB_CB(skb)->when = tcp_time_stamp;
 
-               if (unlikely(tcp_transmit_skb(sk, skb_clone(skb, GFP_ATOMIC))))
+               if (unlikely(tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC)))
                        break;
 
                /* Advance the send_head.  This one is sent out.
                        break;
 
                /* Advance the send_head.  This one is sent out.
@@ -1109,7 +1196,7 @@ void tcp_push_one(struct sock *sk, unsigned int mss_now)
                /* Send it out now. */
                TCP_SKB_CB(skb)->when = tcp_time_stamp;
 
                /* Send it out now. */
                TCP_SKB_CB(skb)->when = tcp_time_stamp;
 
-               if (likely(!tcp_transmit_skb(sk, skb_clone(skb, sk->sk_allocation)))) {
+               if (likely(!tcp_transmit_skb(sk, skb, 1, sk->sk_allocation))) {
                        update_send_head(sk, tp, skb);
                        tcp_cwnd_validate(sk, tp);
                        return;
                        update_send_head(sk, tp, skb);
                        tcp_cwnd_validate(sk, tp);
                        return;
@@ -1405,7 +1492,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
           (sysctl_tcp_retrans_collapse != 0))
                tcp_retrans_try_collapse(sk, skb, cur_mss);
 
           (sysctl_tcp_retrans_collapse != 0))
                tcp_retrans_try_collapse(sk, skb, cur_mss);
 
-       if(tp->af_specific->rebuild_header(sk))
+       if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk))
                return -EHOSTUNREACH; /* Routing failure or similar. */
 
        /* Some Solaris stacks overoptimize and ignore the FIN on a
                return -EHOSTUNREACH; /* Routing failure or similar. */
 
        /* Some Solaris stacks overoptimize and ignore the FIN on a
@@ -1429,9 +1516,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
         */
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
 
         */
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
 
-       err = tcp_transmit_skb(sk, (skb_cloned(skb) ?
-                                   pskb_copy(skb, GFP_ATOMIC):
-                                   skb_clone(skb, GFP_ATOMIC)));
+       err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
 
        if (err == 0) {
                /* Update global TCP statistics. */
 
        if (err == 0) {
                /* Update global TCP statistics. */
@@ -1665,7 +1750,7 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority)
        TCP_SKB_CB(skb)->seq = tcp_acceptable_seq(sk, tp);
        TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq;
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
        TCP_SKB_CB(skb)->seq = tcp_acceptable_seq(sk, tp);
        TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq;
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
-       if (tcp_transmit_skb(sk, skb))
+       if (tcp_transmit_skb(sk, skb, 0, priority))
                NET_INC_STATS(LINUX_MIB_TCPABORTFAILED);
 }
 
                NET_INC_STATS(LINUX_MIB_TCPABORTFAILED);
 }
 
@@ -1700,7 +1785,7 @@ int tcp_send_synack(struct sock *sk)
                TCP_ECN_send_synack(tcp_sk(sk), skb);
        }
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
                TCP_ECN_send_synack(tcp_sk(sk), skb);
        }
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
-       return tcp_transmit_skb(sk, skb_clone(skb, GFP_ATOMIC));
+       return tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
 }
 
 /*
 }
 
 /*
@@ -1778,7 +1863,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
 /* 
  * Do all connect socket setups that can be done AF independent.
  */ 
 /* 
  * Do all connect socket setups that can be done AF independent.
  */ 
-static inline void tcp_connect_init(struct sock *sk)
+static void tcp_connect_init(struct sock *sk)
 {
        struct dst_entry *dst = __sk_dst_get(sk);
        struct tcp_sock *tp = tcp_sk(sk);
 {
        struct dst_entry *dst = __sk_dst_get(sk);
        struct tcp_sock *tp = tcp_sk(sk);
@@ -1861,7 +1946,7 @@ int tcp_connect(struct sock *sk)
        __skb_queue_tail(&sk->sk_write_queue, buff);
        sk_charge_skb(sk, buff);
        tp->packets_out += tcp_skb_pcount(buff);
        __skb_queue_tail(&sk->sk_write_queue, buff);
        sk_charge_skb(sk, buff);
        tp->packets_out += tcp_skb_pcount(buff);
-       tcp_transmit_skb(sk, skb_clone(buff, GFP_KERNEL));
+       tcp_transmit_skb(sk, buff, 1, GFP_KERNEL);
        TCP_INC_STATS(TCP_MIB_ACTIVEOPENS);
 
        /* Timer for repeating the SYN until an answer. */
        TCP_INC_STATS(TCP_MIB_ACTIVEOPENS);
 
        /* Timer for repeating the SYN until an answer. */
@@ -1957,7 +2042,7 @@ void tcp_send_ack(struct sock *sk)
                /* Send it off, this clears delayed acks for us. */
                TCP_SKB_CB(buff)->seq = TCP_SKB_CB(buff)->end_seq = tcp_acceptable_seq(sk, tp);
                TCP_SKB_CB(buff)->when = tcp_time_stamp;
                /* Send it off, this clears delayed acks for us. */
                TCP_SKB_CB(buff)->seq = TCP_SKB_CB(buff)->end_seq = tcp_acceptable_seq(sk, tp);
                TCP_SKB_CB(buff)->when = tcp_time_stamp;
-               tcp_transmit_skb(sk, buff);
+               tcp_transmit_skb(sk, buff, 0, GFP_ATOMIC);
        }
 }
 
        }
 }
 
@@ -1997,7 +2082,7 @@ static int tcp_xmit_probe_skb(struct sock *sk, int urgent)
        TCP_SKB_CB(skb)->seq = urgent ? tp->snd_una : tp->snd_una - 1;
        TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq;
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
        TCP_SKB_CB(skb)->seq = urgent ? tp->snd_una : tp->snd_una - 1;
        TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq;
        TCP_SKB_CB(skb)->when = tcp_time_stamp;
-       return tcp_transmit_skb(sk, skb);
+       return tcp_transmit_skb(sk, skb, 0, GFP_ATOMIC);
 }
 
 int tcp_write_wakeup(struct sock *sk)
 }
 
 int tcp_write_wakeup(struct sock *sk)
@@ -2030,7 +2115,7 @@ int tcp_write_wakeup(struct sock *sk)
 
                        TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH;
                        TCP_SKB_CB(skb)->when = tcp_time_stamp;
 
                        TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH;
                        TCP_SKB_CB(skb)->when = tcp_time_stamp;
-                       err = tcp_transmit_skb(sk, skb_clone(skb, GFP_ATOMIC));
+                       err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
                        if (!err) {
                                update_send_head(sk, tp, skb);
                        }
                        if (!err) {
                                update_send_head(sk, tp, skb);
                        }