aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-07-24 10:50:37 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-28 01:34:36 -0400
commit1bab4c75075b84675b96992ac47580a57c26958d (patch)
treed015ddcf9d9d16e423efb63e9ddbd46fb02d95c3 /net
parentab1c724f633080ed2e8a0cfe61654599b55cf8f9 (diff)
inet: frag: set limits and make init_net's high_thresh limit global
This patch makes init_net's high_thresh limit to be the maximum for all namespaces, thus introducing a global memory limit threshold equal to the sum of the individual high_thresh limits which are capped. It also introduces some sane minimums for low_thresh as it shouldn't be able to drop below 0 (or > high_thresh in the unsigned case), and overall low_thresh should not ever be above high_thresh, so we make the following relations for a namespace: init_net: high_thresh - max(not capped), min(init_net low_thresh) low_thresh - max(init_net high_thresh), min (0) all other namespaces: high_thresh = max(init_net high_thresh), min(namespace's low_thresh) low_thresh = max(namespace's high_thresh), min(0) The major issue with having low_thresh > high_thresh is that we'll schedule eviction but never evict anything and thus rely only on the timers. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ieee802154/reassembly.c12
-rw-r--r--net/ipv4/ip_fragment.c10
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c12
-rw-r--r--net/ipv6/reassembly.c12
4 files changed, 38 insertions, 8 deletions
diff --git a/net/ieee802154/reassembly.c b/net/ieee802154/reassembly.c
index 8da635d92a58..f13d4f32e207 100644
--- a/net/ieee802154/reassembly.c
+++ b/net/ieee802154/reassembly.c
@@ -386,20 +386,25 @@ err:
386EXPORT_SYMBOL(lowpan_frag_rcv); 386EXPORT_SYMBOL(lowpan_frag_rcv);
387 387
388#ifdef CONFIG_SYSCTL 388#ifdef CONFIG_SYSCTL
389static int zero;
390
389static struct ctl_table lowpan_frags_ns_ctl_table[] = { 391static struct ctl_table lowpan_frags_ns_ctl_table[] = {
390 { 392 {
391 .procname = "6lowpanfrag_high_thresh", 393 .procname = "6lowpanfrag_high_thresh",
392 .data = &init_net.ieee802154_lowpan.frags.high_thresh, 394 .data = &init_net.ieee802154_lowpan.frags.high_thresh,
393 .maxlen = sizeof(int), 395 .maxlen = sizeof(int),
394 .mode = 0644, 396 .mode = 0644,
395 .proc_handler = proc_dointvec 397 .proc_handler = proc_dointvec_minmax,
398 .extra1 = &init_net.ieee802154_lowpan.frags.low_thresh
396 }, 399 },
397 { 400 {
398 .procname = "6lowpanfrag_low_thresh", 401 .procname = "6lowpanfrag_low_thresh",
399 .data = &init_net.ieee802154_lowpan.frags.low_thresh, 402 .data = &init_net.ieee802154_lowpan.frags.low_thresh,
400 .maxlen = sizeof(int), 403 .maxlen = sizeof(int),
401 .mode = 0644, 404 .mode = 0644,
402 .proc_handler = proc_dointvec 405 .proc_handler = proc_dointvec_minmax,
406 .extra1 = &zero,
407 .extra2 = &init_net.ieee802154_lowpan.frags.high_thresh
403 }, 408 },
404 { 409 {
405 .procname = "6lowpanfrag_time", 410 .procname = "6lowpanfrag_time",
@@ -446,7 +451,10 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
446 goto err_alloc; 451 goto err_alloc;
447 452
448 table[0].data = &ieee802154_lowpan->frags.high_thresh; 453 table[0].data = &ieee802154_lowpan->frags.high_thresh;
454 table[0].extra1 = &ieee802154_lowpan->frags.low_thresh;
455 table[0].extra2 = &init_net.ieee802154_lowpan.frags.high_thresh;
449 table[1].data = &ieee802154_lowpan->frags.low_thresh; 456 table[1].data = &ieee802154_lowpan->frags.low_thresh;
457 table[1].extra2 = &ieee802154_lowpan->frags.high_thresh;
450 table[2].data = &ieee802154_lowpan->frags.timeout; 458 table[2].data = &ieee802154_lowpan->frags.timeout;
451 table[3].data = &ieee802154_lowpan->max_dsize; 459 table[3].data = &ieee802154_lowpan->max_dsize;
452 460
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index ccee68dffd6e..634fc31aa243 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -700,14 +700,17 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = {
700 .data = &init_net.ipv4.frags.high_thresh, 700 .data = &init_net.ipv4.frags.high_thresh,
701 .maxlen = sizeof(int), 701 .maxlen = sizeof(int),
702 .mode = 0644, 702 .mode = 0644,
703 .proc_handler = proc_dointvec 703 .proc_handler = proc_dointvec_minmax,
704 .extra1 = &init_net.ipv4.frags.low_thresh
704 }, 705 },
705 { 706 {
706 .procname = "ipfrag_low_thresh", 707 .procname = "ipfrag_low_thresh",
707 .data = &init_net.ipv4.frags.low_thresh, 708 .data = &init_net.ipv4.frags.low_thresh,
708 .maxlen = sizeof(int), 709 .maxlen = sizeof(int),
709 .mode = 0644, 710 .mode = 0644,
710 .proc_handler = proc_dointvec 711 .proc_handler = proc_dointvec_minmax,
712 .extra1 = &zero,
713 .extra2 = &init_net.ipv4.frags.high_thresh
711 }, 714 },
712 { 715 {
713 .procname = "ipfrag_time", 716 .procname = "ipfrag_time",
@@ -752,7 +755,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
752 goto err_alloc; 755 goto err_alloc;
753 756
754 table[0].data = &net->ipv4.frags.high_thresh; 757 table[0].data = &net->ipv4.frags.high_thresh;
758 table[0].extra1 = &net->ipv4.frags.low_thresh;
759 table[0].extra2 = &init_net.ipv4.frags.high_thresh;
755 table[1].data = &net->ipv4.frags.low_thresh; 760 table[1].data = &net->ipv4.frags.low_thresh;
761 table[1].extra2 = &net->ipv4.frags.high_thresh;
756 table[2].data = &net->ipv4.frags.timeout; 762 table[2].data = &net->ipv4.frags.timeout;
757 763
758 /* Don't export sysctls to unprivileged users */ 764 /* Don't export sysctls to unprivileged users */
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 4d9da1e35f8c..3d4bccf6d67d 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -63,6 +63,8 @@ struct nf_ct_frag6_skb_cb
63static struct inet_frags nf_frags; 63static struct inet_frags nf_frags;
64 64
65#ifdef CONFIG_SYSCTL 65#ifdef CONFIG_SYSCTL
66static int zero;
67
66static struct ctl_table nf_ct_frag6_sysctl_table[] = { 68static struct ctl_table nf_ct_frag6_sysctl_table[] = {
67 { 69 {
68 .procname = "nf_conntrack_frag6_timeout", 70 .procname = "nf_conntrack_frag6_timeout",
@@ -76,14 +78,17 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
76 .data = &init_net.nf_frag.frags.low_thresh, 78 .data = &init_net.nf_frag.frags.low_thresh,
77 .maxlen = sizeof(unsigned int), 79 .maxlen = sizeof(unsigned int),
78 .mode = 0644, 80 .mode = 0644,
79 .proc_handler = proc_dointvec, 81 .proc_handler = proc_dointvec_minmax,
82 .extra1 = &zero,
83 .extra2 = &init_net.nf_frag.frags.high_thresh
80 }, 84 },
81 { 85 {
82 .procname = "nf_conntrack_frag6_high_thresh", 86 .procname = "nf_conntrack_frag6_high_thresh",
83 .data = &init_net.nf_frag.frags.high_thresh, 87 .data = &init_net.nf_frag.frags.high_thresh,
84 .maxlen = sizeof(unsigned int), 88 .maxlen = sizeof(unsigned int),
85 .mode = 0644, 89 .mode = 0644,
86 .proc_handler = proc_dointvec, 90 .proc_handler = proc_dointvec_minmax,
91 .extra1 = &init_net.nf_frag.frags.low_thresh
87 }, 92 },
88 { } 93 { }
89}; 94};
@@ -102,7 +107,10 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
102 107
103 table[0].data = &net->nf_frag.frags.timeout; 108 table[0].data = &net->nf_frag.frags.timeout;
104 table[1].data = &net->nf_frag.frags.low_thresh; 109 table[1].data = &net->nf_frag.frags.low_thresh;
110 table[1].extra2 = &net->nf_frag.frags.high_thresh;
105 table[2].data = &net->nf_frag.frags.high_thresh; 111 table[2].data = &net->nf_frag.frags.high_thresh;
112 table[2].extra1 = &net->nf_frag.frags.low_thresh;
113 table[2].extra2 = &init_net.nf_frag.frags.high_thresh;
106 } 114 }
107 115
108 hdr = register_net_sysctl(net, "net/netfilter", table); 116 hdr = register_net_sysctl(net, "net/netfilter", table);
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 57a9707b2032..f1709c4a289a 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -578,20 +578,25 @@ static const struct inet6_protocol frag_protocol =
578}; 578};
579 579
580#ifdef CONFIG_SYSCTL 580#ifdef CONFIG_SYSCTL
581static int zero;
582
581static struct ctl_table ip6_frags_ns_ctl_table[] = { 583static struct ctl_table ip6_frags_ns_ctl_table[] = {
582 { 584 {
583 .procname = "ip6frag_high_thresh", 585 .procname = "ip6frag_high_thresh",
584 .data = &init_net.ipv6.frags.high_thresh, 586 .data = &init_net.ipv6.frags.high_thresh,
585 .maxlen = sizeof(int), 587 .maxlen = sizeof(int),
586 .mode = 0644, 588 .mode = 0644,
587 .proc_handler = proc_dointvec 589 .proc_handler = proc_dointvec_minmax,
590 .extra1 = &init_net.ipv6.frags.low_thresh
588 }, 591 },
589 { 592 {
590 .procname = "ip6frag_low_thresh", 593 .procname = "ip6frag_low_thresh",
591 .data = &init_net.ipv6.frags.low_thresh, 594 .data = &init_net.ipv6.frags.low_thresh,
592 .maxlen = sizeof(int), 595 .maxlen = sizeof(int),
593 .mode = 0644, 596 .mode = 0644,
594 .proc_handler = proc_dointvec 597 .proc_handler = proc_dointvec_minmax,
598 .extra1 = &zero,
599 .extra2 = &init_net.ipv6.frags.high_thresh
595 }, 600 },
596 { 601 {
597 .procname = "ip6frag_time", 602 .procname = "ip6frag_time",
@@ -628,7 +633,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
628 goto err_alloc; 633 goto err_alloc;
629 634
630 table[0].data = &net->ipv6.frags.high_thresh; 635 table[0].data = &net->ipv6.frags.high_thresh;
636 table[0].extra1 = &net->ipv6.frags.low_thresh;
637 table[0].extra2 = &init_net.ipv6.frags.high_thresh;
631 table[1].data = &net->ipv6.frags.low_thresh; 638 table[1].data = &net->ipv6.frags.low_thresh;
639 table[1].extra2 = &net->ipv6.frags.high_thresh;
632 table[2].data = &net->ipv6.frags.timeout; 640 table[2].data = &net->ipv6.frags.timeout;
633 641
634 /* Don't export sysctls to unprivileged users */ 642 /* Don't export sysctls to unprivileged users */