diff options
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 90 |
1 files changed, 61 insertions, 29 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 54053de0bdd7..92049e681258 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <net/snmp.h> | 39 | #include <net/snmp.h> |
40 | #include <net/ip.h> | 40 | #include <net/ip.h> |
41 | #include <net/tcp_states.h> | 41 | #include <net/tcp_states.h> |
42 | #include <net/inet_ecn.h> | ||
42 | 43 | ||
43 | #include <linux/seq_file.h> | 44 | #include <linux/seq_file.h> |
44 | 45 | ||
@@ -330,6 +331,17 @@ static inline void tcp_clear_options(struct tcp_options_received *rx_opt) | |||
330 | rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; | 331 | rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; |
331 | } | 332 | } |
332 | 333 | ||
334 | #define TCP_ECN_OK 1 | ||
335 | #define TCP_ECN_QUEUE_CWR 2 | ||
336 | #define TCP_ECN_DEMAND_CWR 4 | ||
337 | |||
338 | static __inline__ void | ||
339 | TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th) | ||
340 | { | ||
341 | if (sysctl_tcp_ecn && th->ece && th->cwr) | ||
342 | inet_rsk(req)->ecn_ok = 1; | ||
343 | } | ||
344 | |||
333 | enum tcp_tw_status | 345 | enum tcp_tw_status |
334 | { | 346 | { |
335 | TCP_TW_SUCCESS = 0, | 347 | TCP_TW_SUCCESS = 0, |
@@ -573,8 +585,6 @@ struct tcp_skb_cb { | |||
573 | 585 | ||
574 | #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) | 586 | #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) |
575 | 587 | ||
576 | #include <net/tcp_ecn.h> | ||
577 | |||
578 | /* Due to TSO, an SKB can be composed of multiple actual | 588 | /* Due to TSO, an SKB can be composed of multiple actual |
579 | * packets. To keep these tracked properly, we use this. | 589 | * packets. To keep these tracked properly, we use this. |
580 | */ | 590 | */ |
@@ -589,32 +599,19 @@ static inline int tcp_skb_mss(const struct sk_buff *skb) | |||
589 | return skb_shinfo(skb)->gso_size; | 599 | return skb_shinfo(skb)->gso_size; |
590 | } | 600 | } |
591 | 601 | ||
592 | static inline void tcp_dec_pcount_approx(__u32 *count, | 602 | static inline void tcp_dec_pcount_approx_int(__u32 *count, const int decr) |
593 | const struct sk_buff *skb) | ||
594 | { | 603 | { |
595 | if (*count) { | 604 | if (*count) { |
596 | *count -= tcp_skb_pcount(skb); | 605 | *count -= decr; |
597 | if ((int)*count < 0) | 606 | if ((int)*count < 0) |
598 | *count = 0; | 607 | *count = 0; |
599 | } | 608 | } |
600 | } | 609 | } |
601 | 610 | ||
602 | static inline void tcp_packets_out_inc(struct sock *sk, | 611 | static inline void tcp_dec_pcount_approx(__u32 *count, |
603 | const struct sk_buff *skb) | 612 | const struct sk_buff *skb) |
604 | { | ||
605 | struct tcp_sock *tp = tcp_sk(sk); | ||
606 | int orig = tp->packets_out; | ||
607 | |||
608 | tp->packets_out += tcp_skb_pcount(skb); | ||
609 | if (!orig) | ||
610 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, | ||
611 | inet_csk(sk)->icsk_rto, TCP_RTO_MAX); | ||
612 | } | ||
613 | |||
614 | static inline void tcp_packets_out_dec(struct tcp_sock *tp, | ||
615 | const struct sk_buff *skb) | ||
616 | { | 613 | { |
617 | tp->packets_out -= tcp_skb_pcount(skb); | 614 | tcp_dec_pcount_approx_int(count, tcp_skb_pcount(skb)); |
618 | } | 615 | } |
619 | 616 | ||
620 | /* Events passed to congestion control interface */ | 617 | /* Events passed to congestion control interface */ |
@@ -704,6 +701,39 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event) | |||
704 | icsk->icsk_ca_ops->cwnd_event(sk, event); | 701 | icsk->icsk_ca_ops->cwnd_event(sk, event); |
705 | } | 702 | } |
706 | 703 | ||
704 | /* These functions determine how the current flow behaves in respect of SACK | ||
705 | * handling. SACK is negotiated with the peer, and therefore it can vary | ||
706 | * between different flows. | ||
707 | * | ||
708 | * tcp_is_sack - SACK enabled | ||
709 | * tcp_is_reno - No SACK | ||
710 | * tcp_is_fack - FACK enabled, implies SACK enabled | ||
711 | */ | ||
712 | static inline int tcp_is_sack(const struct tcp_sock *tp) | ||
713 | { | ||
714 | return tp->rx_opt.sack_ok; | ||
715 | } | ||
716 | |||
717 | static inline int tcp_is_reno(const struct tcp_sock *tp) | ||
718 | { | ||
719 | return !tcp_is_sack(tp); | ||
720 | } | ||
721 | |||
722 | static inline int tcp_is_fack(const struct tcp_sock *tp) | ||
723 | { | ||
724 | return tp->rx_opt.sack_ok & 2; | ||
725 | } | ||
726 | |||
727 | static inline void tcp_enable_fack(struct tcp_sock *tp) | ||
728 | { | ||
729 | tp->rx_opt.sack_ok |= 2; | ||
730 | } | ||
731 | |||
732 | static inline unsigned int tcp_left_out(const struct tcp_sock *tp) | ||
733 | { | ||
734 | return tp->sacked_out + tp->lost_out; | ||
735 | } | ||
736 | |||
707 | /* This determines how many packets are "in the network" to the best | 737 | /* This determines how many packets are "in the network" to the best |
708 | * of our knowledge. In many cases it is conservative, but where | 738 | * of our knowledge. In many cases it is conservative, but where |
709 | * detailed information is available from the receiver (via SACK | 739 | * detailed information is available from the receiver (via SACK |
@@ -720,7 +750,7 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event) | |||
720 | */ | 750 | */ |
721 | static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp) | 751 | static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp) |
722 | { | 752 | { |
723 | return (tp->packets_out - tp->left_out + tp->retrans_out); | 753 | return tp->packets_out - tcp_left_out(tp) + tp->retrans_out; |
724 | } | 754 | } |
725 | 755 | ||
726 | /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. | 756 | /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. |
@@ -738,12 +768,8 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk) | |||
738 | (tp->snd_cwnd >> 2))); | 768 | (tp->snd_cwnd >> 2))); |
739 | } | 769 | } |
740 | 770 | ||
741 | static inline void tcp_sync_left_out(struct tcp_sock *tp) | 771 | /* Use define here intentionally to get WARN_ON location shown at the caller */ |
742 | { | 772 | #define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out) |
743 | BUG_ON(tp->rx_opt.sack_ok && | ||
744 | (tp->sacked_out + tp->lost_out > tp->packets_out)); | ||
745 | tp->left_out = tp->sacked_out + tp->lost_out; | ||
746 | } | ||
747 | 773 | ||
748 | extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); | 774 | extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); |
749 | extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); | 775 | extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); |
@@ -1040,12 +1066,18 @@ static inline void tcp_mib_init(void) | |||
1040 | TCP_ADD_STATS_USER(TCP_MIB_MAXCONN, -1); | 1066 | TCP_ADD_STATS_USER(TCP_MIB_MAXCONN, -1); |
1041 | } | 1067 | } |
1042 | 1068 | ||
1043 | /*from STCP */ | 1069 | /* from STCP */ |
1044 | static inline void clear_all_retrans_hints(struct tcp_sock *tp){ | 1070 | static inline void tcp_clear_retrans_hints_partial(struct tcp_sock *tp) |
1071 | { | ||
1045 | tp->lost_skb_hint = NULL; | 1072 | tp->lost_skb_hint = NULL; |
1046 | tp->scoreboard_skb_hint = NULL; | 1073 | tp->scoreboard_skb_hint = NULL; |
1047 | tp->retransmit_skb_hint = NULL; | 1074 | tp->retransmit_skb_hint = NULL; |
1048 | tp->forward_skb_hint = NULL; | 1075 | tp->forward_skb_hint = NULL; |
1076 | } | ||
1077 | |||
1078 | static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp) | ||
1079 | { | ||
1080 | tcp_clear_retrans_hints_partial(tp); | ||
1049 | tp->fastpath_skb_hint = NULL; | 1081 | tp->fastpath_skb_hint = NULL; |
1050 | } | 1082 | } |
1051 | 1083 | ||