tcp_cong.c (8d58b66ed2b000f27658c88a4ed70e8042e86a58) | tcp_cong.c (c3a8d9474684d391b0afc3970d9b249add15ec07) |
---|---|
1/* 2 * Pluggable TCP congestion control support and newReno 3 * congestion control. 4 * Based on ideas from I/O scheduler support and Web100. 5 * 6 * Copyright (C) 2005 Stephen Hemminger <shemminger@osdl.org> 7 */ 8 --- 100 unchanged lines hidden (view full) --- 109 * A try_module_get() should fail by now as our module is 110 * in "going" state since no refs are held anymore and 111 * module_exit() handler being called. 112 */ 113 synchronize_rcu(); 114} 115EXPORT_SYMBOL_GPL(tcp_unregister_congestion_control); 116 | 1/* 2 * Pluggable TCP congestion control support and newReno 3 * congestion control. 4 * Based on ideas from I/O scheduler support and Web100. 5 * 6 * Copyright (C) 2005 Stephen Hemminger <shemminger@osdl.org> 7 */ 8 --- 100 unchanged lines hidden (view full) --- 109 * A try_module_get() should fail by now as our module is 110 * in "going" state since no refs are held anymore and 111 * module_exit() handler being called. 112 */ 113 synchronize_rcu(); 114} 115EXPORT_SYMBOL_GPL(tcp_unregister_congestion_control); 116 |
117u32 tcp_ca_get_key_by_name(const char *name) | 117u32 tcp_ca_get_key_by_name(const char *name, bool *ecn_ca) |
118{ 119 const struct tcp_congestion_ops *ca; | 118{ 119 const struct tcp_congestion_ops *ca; |
120 u32 key; | 120 u32 key = TCP_CA_UNSPEC; |
121 122 might_sleep(); 123 124 rcu_read_lock(); 125 ca = __tcp_ca_find_autoload(name); | 121 122 might_sleep(); 123 124 rcu_read_lock(); 125 ca = __tcp_ca_find_autoload(name); |
126 key = ca ? ca->key : TCP_CA_UNSPEC; | 126 if (ca) { 127 key = ca->key; 128 *ecn_ca = ca->flags & TCP_CONG_NEEDS_ECN; 129 } |
127 rcu_read_unlock(); 128 129 return key; 130} 131EXPORT_SYMBOL_GPL(tcp_ca_get_key_by_name); 132 133char *tcp_ca_get_name_by_key(u32 key, char *buffer) 134{ --- 225 unchanged lines hidden (view full) --- 360 * something better;) a packet is only considered (s)acked in its entirety to 361 * defend the ACK attacks described in the RFC. Slow start processes a stretch 362 * ACK of degree N as if N acks of degree 1 are received back to back except 363 * ABC caps N to 2. Slow start exits when cwnd grows over ssthresh and 364 * returns the leftover acks to adjust cwnd in congestion avoidance mode. 365 */ 366u32 tcp_slow_start(struct tcp_sock *tp, u32 acked) 367{ | 130 rcu_read_unlock(); 131 132 return key; 133} 134EXPORT_SYMBOL_GPL(tcp_ca_get_key_by_name); 135 136char *tcp_ca_get_name_by_key(u32 key, char *buffer) 137{ --- 225 unchanged lines hidden (view full) --- 363 * something better;) a packet is only considered (s)acked in its entirety to 364 * defend the ACK attacks described in the RFC. Slow start processes a stretch 365 * ACK of degree N as if N acks of degree 1 are received back to back except 366 * ABC caps N to 2. Slow start exits when cwnd grows over ssthresh and 367 * returns the leftover acks to adjust cwnd in congestion avoidance mode. 368 */ 369u32 tcp_slow_start(struct tcp_sock *tp, u32 acked) 370{ |
368 u32 cwnd = tp->snd_cwnd + acked; | 371 u32 cwnd = min(tp->snd_cwnd + acked, tp->snd_ssthresh); |
369 | 372 |
370 if (cwnd > tp->snd_ssthresh) 371 cwnd = tp->snd_ssthresh + 1; | |
372 acked -= cwnd - tp->snd_cwnd; 373 tp->snd_cwnd = min(cwnd, tp->snd_cwnd_clamp); 374 375 return acked; 376} 377EXPORT_SYMBOL_GPL(tcp_slow_start); 378 379/* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w), --- 28 unchanged lines hidden (view full) --- 408void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked) 409{ 410 struct tcp_sock *tp = tcp_sk(sk); 411 412 if (!tcp_is_cwnd_limited(sk)) 413 return; 414 415 /* In "safe" area, increase. */ | 373 acked -= cwnd - tp->snd_cwnd; 374 tp->snd_cwnd = min(cwnd, tp->snd_cwnd_clamp); 375 376 return acked; 377} 378EXPORT_SYMBOL_GPL(tcp_slow_start); 379 380/* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w), --- 28 unchanged lines hidden (view full) --- 409void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked) 410{ 411 struct tcp_sock *tp = tcp_sk(sk); 412 413 if (!tcp_is_cwnd_limited(sk)) 414 return; 415 416 /* In "safe" area, increase. */ |
416 if (tp->snd_cwnd <= tp->snd_ssthresh) { | 417 if (tcp_in_slow_start(tp)) { |
417 acked = tcp_slow_start(tp, acked); 418 if (!acked) 419 return; 420 } 421 /* In dangerous area, increase slowly. */ 422 tcp_cong_avoid_ai(tp, tp->snd_cwnd, acked); 423} 424EXPORT_SYMBOL_GPL(tcp_reno_cong_avoid); --- 17 unchanged lines hidden --- | 418 acked = tcp_slow_start(tp, acked); 419 if (!acked) 420 return; 421 } 422 /* In dangerous area, increase slowly. */ 423 tcp_cong_avoid_ai(tp, tp->snd_cwnd, acked); 424} 425EXPORT_SYMBOL_GPL(tcp_reno_cong_avoid); --- 17 unchanged lines hidden --- |