aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-28 18:42:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-28 18:42:44 -0400
commit29cfcddc0e745b515ec360ffe2ee4e7a4015efd8 (patch)
tree1682b6caaf84d4863e65b2e4e387afa6a972146f /net/ipv4/tcp.c
parent303fd2c2ce5addef1aacac962a5b099cc0af71ea (diff)
parentc34186ed008229e7f7e3f1de8e6acf6374995358 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: net/ipv4: Eliminate kstrdup memory leak net/caif/cfrfml.c: use asm/unaligned.h ax25: missplaced sock_put(sk) qlge: reset the chip before freeing the buffers l2tp: test for ethernet header in l2tp_eth_dev_recv() tcp: select(writefds) don't hang up when a peer close connection tcp: fix three tcp sysctls tuning tcp: Combat per-cpu skew in orphan tests. pxa168_eth: silence gcc warnings pxa168_eth: update call to phy_mii_ioctl() pxa168_eth: fix error handling in prope pxa168_eth: remove unneeded null check phylib: Fix race between returning phydev and calling adjust_link caif-driver: add HAS_DMA dependency 3c59x: Fix deadlock between boomerang_interrupt and boomerang_start_tx qlcnic: fix poll implementation netxen: fix poll implementation bridge: netfilter: fix a memory leak
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 176e11aaea77..3fb1428e526e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -451,7 +451,8 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
451 if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) 451 if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
452 mask |= POLLOUT | POLLWRNORM; 452 mask |= POLLOUT | POLLWRNORM;
453 } 453 }
454 } 454 } else
455 mask |= POLLOUT | POLLWRNORM;
455 456
456 if (tp->urg_data & TCP_URG_VALID) 457 if (tp->urg_data & TCP_URG_VALID)
457 mask |= POLLPRI; 458 mask |= POLLPRI;
@@ -2011,11 +2012,8 @@ adjudge_to_death:
2011 } 2012 }
2012 } 2013 }
2013 if (sk->sk_state != TCP_CLOSE) { 2014 if (sk->sk_state != TCP_CLOSE) {
2014 int orphan_count = percpu_counter_read_positive(
2015 sk->sk_prot->orphan_count);
2016
2017 sk_mem_reclaim(sk); 2015 sk_mem_reclaim(sk);
2018 if (tcp_too_many_orphans(sk, orphan_count)) { 2016 if (tcp_too_many_orphans(sk, 0)) {
2019 if (net_ratelimit()) 2017 if (net_ratelimit())
2020 printk(KERN_INFO "TCP: too many of orphaned " 2018 printk(KERN_INFO "TCP: too many of orphaned "
2021 "sockets\n"); 2019 "sockets\n");
@@ -3212,7 +3210,7 @@ void __init tcp_init(void)
3212{ 3210{
3213 struct sk_buff *skb = NULL; 3211 struct sk_buff *skb = NULL;
3214 unsigned long nr_pages, limit; 3212 unsigned long nr_pages, limit;
3215 int order, i, max_share; 3213 int i, max_share, cnt;
3216 unsigned long jiffy = jiffies; 3214 unsigned long jiffy = jiffies;
3217 3215
3218 BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb)); 3216 BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb));
@@ -3261,22 +3259,12 @@ void __init tcp_init(void)
3261 INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain); 3259 INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain);
3262 } 3260 }
3263 3261
3264 /* Try to be a bit smarter and adjust defaults depending 3262
3265 * on available memory. 3263 cnt = tcp_hashinfo.ehash_mask + 1;
3266 */ 3264
3267 for (order = 0; ((1 << order) << PAGE_SHIFT) < 3265 tcp_death_row.sysctl_max_tw_buckets = cnt / 2;
3268 (tcp_hashinfo.bhash_size * sizeof(struct inet_bind_hashbucket)); 3266 sysctl_tcp_max_orphans = cnt / 2;
3269 order++) 3267 sysctl_max_syn_backlog = max(128, cnt / 256);
3270 ;
3271 if (order >= 4) {
3272 tcp_death_row.sysctl_max_tw_buckets = 180000;
3273 sysctl_tcp_max_orphans = 4096 << (order - 4);
3274 sysctl_max_syn_backlog = 1024;
3275 } else if (order < 3) {
3276 tcp_death_row.sysctl_max_tw_buckets >>= (3 - order);
3277 sysctl_tcp_max_orphans >>= (3 - order);
3278 sysctl_max_syn_backlog = 128;
3279 }
3280 3268
3281 /* Set the pressure threshold to be a fraction of global memory that 3269 /* Set the pressure threshold to be a fraction of global memory that
3282 * is up to 1/2 at 256 MB, decreasing toward zero with the amount of 3270 * is up to 1/2 at 256 MB, decreasing toward zero with the amount of