diff options
Diffstat (limited to 'net/ipv4/tcp_output.c')
| -rw-r--r-- | net/ipv4/tcp_output.c | 87 |
1 files changed, 78 insertions, 9 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 3a0a914de917..a7623ead39a8 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
| @@ -51,8 +51,8 @@ int sysctl_tcp_retrans_collapse = 1; | |||
| 51 | */ | 51 | */ |
| 52 | int sysctl_tcp_tso_win_divisor = 3; | 52 | int sysctl_tcp_tso_win_divisor = 3; |
| 53 | 53 | ||
| 54 | static inline void update_send_head(struct sock *sk, struct tcp_sock *tp, | 54 | static void update_send_head(struct sock *sk, struct tcp_sock *tp, |
| 55 | struct sk_buff *skb) | 55 | struct sk_buff *skb) |
| 56 | { | 56 | { |
| 57 | sk->sk_send_head = skb->next; | 57 | sk->sk_send_head = skb->next; |
| 58 | if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue) | 58 | 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) | |||
| 124 | tp->snd_cwnd_used = 0; | 124 | tp->snd_cwnd_used = 0; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | static inline void tcp_event_data_sent(struct tcp_sock *tp, | 127 | static void tcp_event_data_sent(struct tcp_sock *tp, |
| 128 | struct sk_buff *skb, struct sock *sk) | 128 | struct sk_buff *skb, struct sock *sk) |
| 129 | { | 129 | { |
| 130 | struct inet_connection_sock *icsk = inet_csk(sk); | 130 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 131 | const u32 now = tcp_time_stamp; | 131 | const u32 now = tcp_time_stamp; |
| @@ -142,7 +142,7 @@ static inline void tcp_event_data_sent(struct tcp_sock *tp, | |||
| 142 | icsk->icsk_ack.pingpong = 1; | 142 | icsk->icsk_ack.pingpong = 1; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | static __inline__ void tcp_event_ack_sent(struct sock *sk, unsigned int pkts) | 145 | static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts) |
| 146 | { | 146 | { |
| 147 | tcp_dec_quickack_mode(sk, pkts); | 147 | tcp_dec_quickack_mode(sk, pkts); |
| 148 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); | 148 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); |
| @@ -212,7 +212,7 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
| 212 | * value can be stuffed directly into th->window for an outgoing | 212 | * value can be stuffed directly into th->window for an outgoing |
| 213 | * frame. | 213 | * frame. |
| 214 | */ | 214 | */ |
| 215 | static __inline__ u16 tcp_select_window(struct sock *sk) | 215 | static u16 tcp_select_window(struct sock *sk) |
| 216 | { | 216 | { |
| 217 | struct tcp_sock *tp = tcp_sk(sk); | 217 | struct tcp_sock *tp = tcp_sk(sk); |
| 218 | u32 cur_win = tcp_receive_window(tp); | 218 | u32 cur_win = tcp_receive_window(tp); |
| @@ -250,6 +250,75 @@ static __inline__ u16 tcp_select_window(struct sock *sk) | |||
| 250 | return new_win; | 250 | return new_win; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | static void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp, | ||
| 254 | __u32 tstamp) | ||
| 255 | { | ||
| 256 | if (tp->rx_opt.tstamp_ok) { | ||
| 257 | *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | | ||
| 258 | (TCPOPT_NOP << 16) | | ||
| 259 | (TCPOPT_TIMESTAMP << 8) | | ||
| 260 | TCPOLEN_TIMESTAMP); | ||
| 261 | *ptr++ = htonl(tstamp); | ||
| 262 | *ptr++ = htonl(tp->rx_opt.ts_recent); | ||
| 263 | } | ||
| 264 | if (tp->rx_opt.eff_sacks) { | ||
| 265 | struct tcp_sack_block *sp = tp->rx_opt.dsack ? tp->duplicate_sack : tp->selective_acks; | ||
| 266 | int this_sack; | ||
| 267 | |||
| 268 | *ptr++ = htonl((TCPOPT_NOP << 24) | | ||
| 269 | (TCPOPT_NOP << 16) | | ||
| 270 | (TCPOPT_SACK << 8) | | ||
| 271 | (TCPOLEN_SACK_BASE + (tp->rx_opt.eff_sacks * | ||
| 272 | TCPOLEN_SACK_PERBLOCK))); | ||
| 273 | for(this_sack = 0; this_sack < tp->rx_opt.eff_sacks; this_sack++) { | ||
| 274 | *ptr++ = htonl(sp[this_sack].start_seq); | ||
| 275 | *ptr++ = htonl(sp[this_sack].end_seq); | ||
| 276 | } | ||
| 277 | if (tp->rx_opt.dsack) { | ||
| 278 | tp->rx_opt.dsack = 0; | ||
| 279 | tp->rx_opt.eff_sacks--; | ||
| 280 | } | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 284 | /* Construct a tcp options header for a SYN or SYN_ACK packet. | ||
| 285 | * If this is every changed make sure to change the definition of | ||
| 286 | * MAX_SYN_SIZE to match the new maximum number of options that you | ||
| 287 | * can generate. | ||
| 288 | */ | ||
| 289 | static void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sack, | ||
| 290 | int offer_wscale, int wscale, __u32 tstamp, | ||
| 291 | __u32 ts_recent) | ||
| 292 | { | ||
| 293 | /* We always get an MSS option. | ||
| 294 | * The option bytes which will be seen in normal data | ||
| 295 | * packets should timestamps be used, must be in the MSS | ||
| 296 | * advertised. But we subtract them from tp->mss_cache so | ||
| 297 | * that calculations in tcp_sendmsg are simpler etc. | ||
| 298 | * So account for this fact here if necessary. If we | ||
| 299 | * don't do this correctly, as a receiver we won't | ||
| 300 | * recognize data packets as being full sized when we | ||
| 301 | * should, and thus we won't abide by the delayed ACK | ||
| 302 | * rules correctly. | ||
| 303 | * SACKs don't matter, we never delay an ACK when we | ||
| 304 | * have any of those going out. | ||
| 305 | */ | ||
| 306 | *ptr++ = htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) | mss); | ||
| 307 | if (ts) { | ||
| 308 | if(sack) | ||
| 309 | *ptr++ = __constant_htonl((TCPOPT_SACK_PERM << 24) | (TCPOLEN_SACK_PERM << 16) | | ||
| 310 | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); | ||
| 311 | else | ||
| 312 | *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | | ||
| 313 | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); | ||
| 314 | *ptr++ = htonl(tstamp); /* TSVAL */ | ||
| 315 | *ptr++ = htonl(ts_recent); /* TSECR */ | ||
| 316 | } else if(sack) | ||
| 317 | *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | | ||
| 318 | (TCPOPT_SACK_PERM << 8) | TCPOLEN_SACK_PERM); | ||
| 319 | if (offer_wscale) | ||
| 320 | *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_WINDOW << 16) | (TCPOLEN_WINDOW << 8) | (wscale)); | ||
| 321 | } | ||
| 253 | 322 | ||
| 254 | /* This routine actually transmits TCP packets queued in by | 323 | /* This routine actually transmits TCP packets queued in by |
| 255 | * tcp_do_sendmsg(). This is used by both the initial | 324 | * tcp_do_sendmsg(). This is used by both the initial |
| @@ -724,7 +793,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) | |||
| 724 | 793 | ||
| 725 | /* Congestion window validation. (RFC2861) */ | 794 | /* Congestion window validation. (RFC2861) */ |
| 726 | 795 | ||
| 727 | static inline void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp) | 796 | static void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp) |
| 728 | { | 797 | { |
| 729 | __u32 packets_out = tp->packets_out; | 798 | __u32 packets_out = tp->packets_out; |
| 730 | 799 | ||
| @@ -773,7 +842,7 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, struct sk_buff *sk | |||
| 773 | /* This must be invoked the first time we consider transmitting | 842 | /* This must be invoked the first time we consider transmitting |
| 774 | * SKB onto the wire. | 843 | * SKB onto the wire. |
| 775 | */ | 844 | */ |
| 776 | static inline int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now) | 845 | static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now) |
| 777 | { | 846 | { |
| 778 | int tso_segs = tcp_skb_pcount(skb); | 847 | int tso_segs = tcp_skb_pcount(skb); |
| 779 | 848 | ||
| @@ -1794,7 +1863,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, | |||
| 1794 | /* | 1863 | /* |
| 1795 | * Do all connect socket setups that can be done AF independent. | 1864 | * Do all connect socket setups that can be done AF independent. |
| 1796 | */ | 1865 | */ |
| 1797 | static inline void tcp_connect_init(struct sock *sk) | 1866 | static void tcp_connect_init(struct sock *sk) |
| 1798 | { | 1867 | { |
| 1799 | struct dst_entry *dst = __sk_dst_get(sk); | 1868 | struct dst_entry *dst = __sk_dst_get(sk); |
| 1800 | struct tcp_sock *tp = tcp_sk(sk); | 1869 | struct tcp_sock *tp = tcp_sk(sk); |
