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.h47
1 files changed, 39 insertions, 8 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index df6a2eb20193..4fee0424af7e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -268,11 +268,21 @@ static inline int between(__u32 seq1, __u32 seq2, __u32 seq3)
268 return seq3 - seq2 >= seq1 - seq2; 268 return seq3 - seq2 >= seq1 - seq2;
269} 269}
270 270
271static inline int tcp_too_many_orphans(struct sock *sk, int num) 271static inline bool tcp_too_many_orphans(struct sock *sk, int shift)
272{ 272{
273 return (num > sysctl_tcp_max_orphans) || 273 struct percpu_counter *ocp = sk->sk_prot->orphan_count;
274 (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && 274 int orphans = percpu_counter_read_positive(ocp);
275 atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]); 275
276 if (orphans << shift > sysctl_tcp_max_orphans) {
277 orphans = percpu_counter_sum_positive(ocp);
278 if (orphans << shift > sysctl_tcp_max_orphans)
279 return true;
280 }
281
282 if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF &&
283 atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2])
284 return true;
285 return false;
276} 286}
277 287
278/* syncookies: remember time of last synqueue overflow */ 288/* syncookies: remember time of last synqueue overflow */
@@ -336,8 +346,6 @@ static inline void tcp_dec_quickack_mode(struct sock *sk,
336 } 346 }
337} 347}
338 348
339extern void tcp_enter_quickack_mode(struct sock *sk);
340
341#define TCP_ECN_OK 1 349#define TCP_ECN_OK 1
342#define TCP_ECN_QUEUE_CWR 2 350#define TCP_ECN_QUEUE_CWR 2
343#define TCP_ECN_DEMAND_CWR 4 351#define TCP_ECN_DEMAND_CWR 4
@@ -465,8 +473,22 @@ extern unsigned int tcp_current_mss(struct sock *sk);
465/* Bound MSS / TSO packet size with the half of the window */ 473/* Bound MSS / TSO packet size with the half of the window */
466static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) 474static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
467{ 475{
468 if (tp->max_window && pktsize > (tp->max_window >> 1)) 476 int cutoff;
469 return max(tp->max_window >> 1, 68U - tp->tcp_header_len); 477
478 /* When peer uses tiny windows, there is no use in packetizing
479 * to sub-MSS pieces for the sake of SWS or making sure there
480 * are enough packets in the pipe for fast recovery.
481 *
482 * On the other hand, for extremely large MSS devices, handling
483 * smaller than MSS windows in this way does make sense.
484 */
485 if (tp->max_window >= 512)
486 cutoff = (tp->max_window >> 1);
487 else
488 cutoff = tp->max_window;
489
490 if (cutoff && pktsize > cutoff)
491 return max_t(int, cutoff, 68U - tp->tcp_header_len);
470 else 492 else
471 return pktsize; 493 return pktsize;
472} 494}
@@ -779,6 +801,15 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk)
779/* Use define here intentionally to get WARN_ON location shown at the caller */ 801/* Use define here intentionally to get WARN_ON location shown at the caller */
780#define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out) 802#define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out)
781 803
804/*
805 * Convert RFC 3390 larger initial window into an equivalent number of packets.
806 * This is based on the numbers specified in RFC 5681, 3.1.
807 */
808static inline u32 rfc3390_bytes_to_packets(const u32 smss)
809{
810 return smss <= 1095 ? 4 : (smss > 2190 ? 2 : 3);
811}
812
782extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); 813extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh);
783extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); 814extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst);
784 815