aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h49
1 files changed, 48 insertions, 1 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 88af84306471..56b76027b85e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -469,6 +469,7 @@ extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
469 int nonagle); 469 int nonagle);
470extern int tcp_may_send_now(struct sock *sk); 470extern int tcp_may_send_now(struct sock *sk);
471extern int tcp_retransmit_skb(struct sock *, struct sk_buff *); 471extern int tcp_retransmit_skb(struct sock *, struct sk_buff *);
472extern void tcp_retransmit_timer(struct sock *sk);
472extern void tcp_xmit_retransmit_queue(struct sock *); 473extern void tcp_xmit_retransmit_queue(struct sock *);
473extern void tcp_simple_retransmit(struct sock *); 474extern void tcp_simple_retransmit(struct sock *);
474extern int tcp_trim_head(struct sock *, struct sk_buff *, u32); 475extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
@@ -521,6 +522,17 @@ extern int tcp_mtu_to_mss(struct sock *sk, int pmtu);
521extern int tcp_mss_to_mtu(struct sock *sk, int mss); 522extern int tcp_mss_to_mtu(struct sock *sk, int mss);
522extern void tcp_mtup_init(struct sock *sk); 523extern void tcp_mtup_init(struct sock *sk);
523 524
525static inline void tcp_bound_rto(const struct sock *sk)
526{
527 if (inet_csk(sk)->icsk_rto > TCP_RTO_MAX)
528 inet_csk(sk)->icsk_rto = TCP_RTO_MAX;
529}
530
531static inline u32 __tcp_set_rto(const struct tcp_sock *tp)
532{
533 return (tp->srtt >> 3) + tp->rttvar;
534}
535
524static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd) 536static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd)
525{ 537{
526 tp->pred_flags = htonl((tp->tcp_header_len << 26) | 538 tp->pred_flags = htonl((tp->tcp_header_len << 26) |
@@ -781,6 +793,13 @@ static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp)
781 return tp->packets_out - tcp_left_out(tp) + tp->retrans_out; 793 return tp->packets_out - tcp_left_out(tp) + tp->retrans_out;
782} 794}
783 795
796#define TCP_INFINITE_SSTHRESH 0x7fffffff
797
798static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp)
799{
800 return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH;
801}
802
784/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. 803/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd.
785 * The exception is rate halving phase, when cwnd is decreasing towards 804 * The exception is rate halving phase, when cwnd is decreasing towards
786 * ssthresh. 805 * ssthresh.
@@ -1007,6 +1026,11 @@ static inline int keepalive_time_when(const struct tcp_sock *tp)
1007 return tp->keepalive_time ? : sysctl_tcp_keepalive_time; 1026 return tp->keepalive_time ? : sysctl_tcp_keepalive_time;
1008} 1027}
1009 1028
1029static inline int keepalive_probes(const struct tcp_sock *tp)
1030{
1031 return tp->keepalive_probes ? : sysctl_tcp_keepalive_probes;
1032}
1033
1010static inline int tcp_fin_time(const struct sock *sk) 1034static inline int tcp_fin_time(const struct sock *sk)
1011{ 1035{
1012 int fin_timeout = tcp_sk(sk)->linger2 ? : sysctl_tcp_fin_timeout; 1036 int fin_timeout = tcp_sk(sk)->linger2 ? : sysctl_tcp_fin_timeout;
@@ -1169,7 +1193,7 @@ extern int tcp_v4_md5_do_del(struct sock *sk,
1169#define tcp_twsk_md5_key(twsk) NULL 1193#define tcp_twsk_md5_key(twsk) NULL
1170#endif 1194#endif
1171 1195
1172extern struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(void); 1196extern struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(struct sock *);
1173extern void tcp_free_md5sig_pool(void); 1197extern void tcp_free_md5sig_pool(void);
1174 1198
1175extern struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu); 1199extern struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu);
@@ -1235,6 +1259,29 @@ static inline struct sk_buff *tcp_write_queue_prev(struct sock *sk, struct sk_bu
1235#define tcp_for_write_queue_from_safe(skb, tmp, sk) \ 1259#define tcp_for_write_queue_from_safe(skb, tmp, sk) \
1236 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) 1260 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp)
1237 1261
1262/* This function calculates a "timeout" which is equivalent to the timeout of a
1263 * TCP connection after "boundary" unsucessful, exponentially backed-off
1264 * retransmissions with an initial RTO of TCP_RTO_MIN.
1265 */
1266static inline bool retransmits_timed_out(const struct sock *sk,
1267 unsigned int boundary)
1268{
1269 unsigned int timeout, linear_backoff_thresh;
1270
1271 if (!inet_csk(sk)->icsk_retransmits)
1272 return false;
1273
1274 linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN);
1275
1276 if (boundary <= linear_backoff_thresh)
1277 timeout = ((2 << boundary) - 1) * TCP_RTO_MIN;
1278 else
1279 timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN +
1280 (boundary - linear_backoff_thresh) * TCP_RTO_MAX;
1281
1282 return (tcp_time_stamp - tcp_sk(sk)->retrans_stamp) >= timeout;
1283}
1284
1238static inline struct sk_buff *tcp_send_head(struct sock *sk) 1285static inline struct sk_buff *tcp_send_head(struct sock *sk)
1239{ 1286{
1240 return sk->sk_send_head; 1287 return sk->sk_send_head;