aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_fragment.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2018-03-31 15:58:53 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-31 23:25:39 -0400
commit3e67f106f619dcfaf6f4e2039599bdb69848c714 (patch)
tree2c8c6574733f683d59de6fe388e308694b3c904d /net/ipv4/ip_fragment.c
parent2d44ed22e607f9a285b049de2263e3840673a260 (diff)
inet: frags: break the 2GB limit for frags storage
Some users are willing to provision huge amounts of memory to be able to perform reassembly reasonnably well under pressure. Current memory tracking is using one atomic_t and integers. Switch to atomic_long_t so that 64bit arches can use more than 2GB, without any cost for 32bit arches. Note that this patch avoids an overflow error, if high_thresh was set to ~2GB, since this test in inet_frag_alloc() was never true : if (... || frag_mem_limit(nf) > nf->high_thresh) Tested: $ echo 16000000000 >/proc/sys/net/ipv4/ipfrag_high_thresh <frag DDOS> $ grep FRAG /proc/net/sockstat FRAG: inuse 14705885 memory 16000002880 $ nstat -n ; sleep 1 ; nstat | grep Reas IpReasmReqds 3317150 0.0 IpReasmFails 3317112 0.0 Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_fragment.c')
-rw-r--r--net/ipv4/ip_fragment.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index b0366224f314..053869f2c49b 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -678,23 +678,23 @@ struct sk_buff *ip_check_defrag(struct net *net, struct sk_buff *skb, u32 user)
678EXPORT_SYMBOL(ip_check_defrag); 678EXPORT_SYMBOL(ip_check_defrag);
679 679
680#ifdef CONFIG_SYSCTL 680#ifdef CONFIG_SYSCTL
681static int zero; 681static long zero;
682 682
683static struct ctl_table ip4_frags_ns_ctl_table[] = { 683static struct ctl_table ip4_frags_ns_ctl_table[] = {
684 { 684 {
685 .procname = "ipfrag_high_thresh", 685 .procname = "ipfrag_high_thresh",
686 .data = &init_net.ipv4.frags.high_thresh, 686 .data = &init_net.ipv4.frags.high_thresh,
687 .maxlen = sizeof(int), 687 .maxlen = sizeof(unsigned long),
688 .mode = 0644, 688 .mode = 0644,
689 .proc_handler = proc_dointvec_minmax, 689 .proc_handler = proc_doulongvec_minmax,
690 .extra1 = &init_net.ipv4.frags.low_thresh 690 .extra1 = &init_net.ipv4.frags.low_thresh
691 }, 691 },
692 { 692 {
693 .procname = "ipfrag_low_thresh", 693 .procname = "ipfrag_low_thresh",
694 .data = &init_net.ipv4.frags.low_thresh, 694 .data = &init_net.ipv4.frags.low_thresh,
695 .maxlen = sizeof(int), 695 .maxlen = sizeof(unsigned long),
696 .mode = 0644, 696 .mode = 0644,
697 .proc_handler = proc_dointvec_minmax, 697 .proc_handler = proc_doulongvec_minmax,
698 .extra1 = &zero, 698 .extra1 = &zero,
699 .extra2 = &init_net.ipv4.frags.high_thresh 699 .extra2 = &init_net.ipv4.frags.high_thresh
700 }, 700 },