diff options
author | David S. Miller <davem@davemloft.net> | 2012-02-04 16:39:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-02-04 16:39:32 -0500 |
commit | dd48dc34fe7639a8b2e22d8b609672f5f81aa7cb (patch) | |
tree | f16ace0ae09edab16bf6d0be9e8280dfbb7100da /net/ipv4 | |
parent | 8d9eb069eafce49307f839783e4a4673414b1fd5 (diff) | |
parent | 5962b35c1de3254a2f03b95efd3b7854b874d7b7 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 7 | ||||
-rw-r--r-- | net/ipv4/ip_gre.c | 4 | ||||
-rw-r--r-- | net/ipv4/sysctl_net_ipv4.c | 7 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 33 | ||||
-rw-r--r-- | net/ipv4/tcp_output.c | 6 | ||||
-rw-r--r-- | net/ipv4/tcp_timer.c | 5 |
6 files changed, 40 insertions, 22 deletions
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 2e4e24476c4c..19d66cefd7d3 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -123,11 +123,14 @@ again: | |||
123 | smallest_size = tb->num_owners; | 123 | smallest_size = tb->num_owners; |
124 | smallest_rover = rover; | 124 | smallest_rover = rover; |
125 | if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) { | 125 | if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) { |
126 | spin_unlock(&head->lock); | ||
127 | snum = smallest_rover; | 126 | snum = smallest_rover; |
128 | goto have_snum; | 127 | goto tb_found; |
129 | } | 128 | } |
130 | } | 129 | } |
130 | if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) { | ||
131 | snum = rover; | ||
132 | goto tb_found; | ||
133 | } | ||
131 | goto next; | 134 | goto next; |
132 | } | 135 | } |
133 | break; | 136 | break; |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index bf9541648b96..0286d78c589c 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -422,6 +422,10 @@ static struct ip_tunnel *ipgre_tunnel_locate(struct net *net, | |||
422 | if (register_netdevice(dev) < 0) | 422 | if (register_netdevice(dev) < 0) |
423 | goto failed_free; | 423 | goto failed_free; |
424 | 424 | ||
425 | /* Can use a lockless transmit, unless we generate output sequences */ | ||
426 | if (!(nt->parms.o_flags & GRE_SEQ)) | ||
427 | dev->features |= NETIF_F_LLTX; | ||
428 | |||
425 | dev_hold(dev); | 429 | dev_hold(dev); |
426 | ipgre_tunnel_link(ign, nt); | 430 | ipgre_tunnel_link(ign, nt); |
427 | return nt; | 431 | return nt; |
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 4aa7e9dc0cbb..7a7724da9bff 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c | |||
@@ -778,7 +778,6 @@ EXPORT_SYMBOL_GPL(net_ipv4_ctl_path); | |||
778 | static __net_init int ipv4_sysctl_init_net(struct net *net) | 778 | static __net_init int ipv4_sysctl_init_net(struct net *net) |
779 | { | 779 | { |
780 | struct ctl_table *table; | 780 | struct ctl_table *table; |
781 | unsigned long limit; | ||
782 | 781 | ||
783 | table = ipv4_net_table; | 782 | table = ipv4_net_table; |
784 | if (!net_eq(net, &init_net)) { | 783 | if (!net_eq(net, &init_net)) { |
@@ -814,11 +813,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net) | |||
814 | 813 | ||
815 | net->ipv4.sysctl_rt_cache_rebuild_count = 4; | 814 | net->ipv4.sysctl_rt_cache_rebuild_count = 4; |
816 | 815 | ||
817 | limit = nr_free_buffer_pages() / 8; | 816 | tcp_init_mem(net); |
818 | limit = max(limit, 128UL); | ||
819 | net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3; | ||
820 | net->ipv4.sysctl_tcp_mem[1] = limit; | ||
821 | net->ipv4.sysctl_tcp_mem[2] = net->ipv4.sysctl_tcp_mem[0] * 2; | ||
822 | 817 | ||
823 | net->ipv4.ipv4_hdr = register_net_sysctl_table(net, | 818 | net->ipv4.ipv4_hdr = register_net_sysctl_table(net, |
824 | net_ipv4_ctl_path, table); | 819 | net_ipv4_ctl_path, table); |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 9bcdec3ad772..37755ccc0e96 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -1876,6 +1876,20 @@ void tcp_shutdown(struct sock *sk, int how) | |||
1876 | } | 1876 | } |
1877 | EXPORT_SYMBOL(tcp_shutdown); | 1877 | EXPORT_SYMBOL(tcp_shutdown); |
1878 | 1878 | ||
1879 | bool tcp_check_oom(struct sock *sk, int shift) | ||
1880 | { | ||
1881 | bool too_many_orphans, out_of_socket_memory; | ||
1882 | |||
1883 | too_many_orphans = tcp_too_many_orphans(sk, shift); | ||
1884 | out_of_socket_memory = tcp_out_of_memory(sk); | ||
1885 | |||
1886 | if (too_many_orphans && net_ratelimit()) | ||
1887 | pr_info("TCP: too many orphaned sockets\n"); | ||
1888 | if (out_of_socket_memory && net_ratelimit()) | ||
1889 | pr_info("TCP: out of memory -- consider tuning tcp_mem\n"); | ||
1890 | return too_many_orphans || out_of_socket_memory; | ||
1891 | } | ||
1892 | |||
1879 | void tcp_close(struct sock *sk, long timeout) | 1893 | void tcp_close(struct sock *sk, long timeout) |
1880 | { | 1894 | { |
1881 | struct sk_buff *skb; | 1895 | struct sk_buff *skb; |
@@ -2015,10 +2029,7 @@ adjudge_to_death: | |||
2015 | } | 2029 | } |
2016 | if (sk->sk_state != TCP_CLOSE) { | 2030 | if (sk->sk_state != TCP_CLOSE) { |
2017 | sk_mem_reclaim(sk); | 2031 | sk_mem_reclaim(sk); |
2018 | if (tcp_too_many_orphans(sk, 0)) { | 2032 | if (tcp_check_oom(sk, 0)) { |
2019 | if (net_ratelimit()) | ||
2020 | printk(KERN_INFO "TCP: too many of orphaned " | ||
2021 | "sockets\n"); | ||
2022 | tcp_set_state(sk, TCP_CLOSE); | 2033 | tcp_set_state(sk, TCP_CLOSE); |
2023 | tcp_send_active_reset(sk, GFP_ATOMIC); | 2034 | tcp_send_active_reset(sk, GFP_ATOMIC); |
2024 | NET_INC_STATS_BH(sock_net(sk), | 2035 | NET_INC_STATS_BH(sock_net(sk), |
@@ -3216,6 +3227,15 @@ static int __init set_thash_entries(char *str) | |||
3216 | } | 3227 | } |
3217 | __setup("thash_entries=", set_thash_entries); | 3228 | __setup("thash_entries=", set_thash_entries); |
3218 | 3229 | ||
3230 | void tcp_init_mem(struct net *net) | ||
3231 | { | ||
3232 | unsigned long limit = nr_free_buffer_pages() / 8; | ||
3233 | limit = max(limit, 128UL); | ||
3234 | net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3; | ||
3235 | net->ipv4.sysctl_tcp_mem[1] = limit; | ||
3236 | net->ipv4.sysctl_tcp_mem[2] = net->ipv4.sysctl_tcp_mem[0] * 2; | ||
3237 | } | ||
3238 | |||
3219 | void __init tcp_init(void) | 3239 | void __init tcp_init(void) |
3220 | { | 3240 | { |
3221 | struct sk_buff *skb = NULL; | 3241 | struct sk_buff *skb = NULL; |
@@ -3276,9 +3296,10 @@ void __init tcp_init(void) | |||
3276 | sysctl_tcp_max_orphans = cnt / 2; | 3296 | sysctl_tcp_max_orphans = cnt / 2; |
3277 | sysctl_max_syn_backlog = max(128, cnt / 256); | 3297 | sysctl_max_syn_backlog = max(128, cnt / 256); |
3278 | 3298 | ||
3299 | tcp_init_mem(&init_net); | ||
3279 | /* Set per-socket limits to no more than 1/128 the pressure threshold */ | 3300 | /* Set per-socket limits to no more than 1/128 the pressure threshold */ |
3280 | limit = ((unsigned long)init_net.ipv4.sysctl_tcp_mem[1]) | 3301 | limit = nr_free_buffer_pages() << (PAGE_SHIFT - 10); |
3281 | << (PAGE_SHIFT - 7); | 3302 | limit = max(limit, 128UL); |
3282 | max_share = min(4UL*1024*1024, limit); | 3303 | max_share = min(4UL*1024*1024, limit); |
3283 | 3304 | ||
3284 | sysctl_tcp_wmem[0] = SK_MEM_QUANTUM; | 3305 | sysctl_tcp_wmem[0] = SK_MEM_QUANTUM; |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 561550ab3c30..364784a91939 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -1141,11 +1141,9 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) | |||
1141 | sk_mem_uncharge(sk, len); | 1141 | sk_mem_uncharge(sk, len); |
1142 | sock_set_flag(sk, SOCK_QUEUE_SHRUNK); | 1142 | sock_set_flag(sk, SOCK_QUEUE_SHRUNK); |
1143 | 1143 | ||
1144 | /* Any change of skb->len requires recalculation of tso | 1144 | /* Any change of skb->len requires recalculation of tso factor. */ |
1145 | * factor and mss. | ||
1146 | */ | ||
1147 | if (tcp_skb_pcount(skb) > 1) | 1145 | if (tcp_skb_pcount(skb) > 1) |
1148 | tcp_set_skb_tso_segs(sk, skb, tcp_current_mss(sk)); | 1146 | tcp_set_skb_tso_segs(sk, skb, tcp_skb_mss(skb)); |
1149 | 1147 | ||
1150 | return 0; | 1148 | return 0; |
1151 | } | 1149 | } |
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index a516d1e399df..cd2e0723266d 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -77,10 +77,7 @@ static int tcp_out_of_resources(struct sock *sk, int do_reset) | |||
77 | if (sk->sk_err_soft) | 77 | if (sk->sk_err_soft) |
78 | shift++; | 78 | shift++; |
79 | 79 | ||
80 | if (tcp_too_many_orphans(sk, shift)) { | 80 | if (tcp_check_oom(sk, shift)) { |
81 | if (net_ratelimit()) | ||
82 | printk(KERN_INFO "Out of socket memory\n"); | ||
83 | |||
84 | /* Catch exceptional cases, when connection requires reset. | 81 | /* Catch exceptional cases, when connection requires reset. |
85 | * 1. Last segment was sent recently. */ | 82 | * 1. Last segment was sent recently. */ |
86 | if ((s32)(tcp_time_stamp - tp->lsndtime) <= TCP_TIMEWAIT_LEN || | 83 | if ((s32)(tcp_time_stamp - tp->lsndtime) <= TCP_TIMEWAIT_LEN || |