aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_fragment.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/ip_fragment.c')
-rw-r--r--net/ipv4/ip_fragment.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 187c6fcc3027..efbd47d1a531 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -54,8 +54,6 @@
54 * code now. If you change something here, _PLEASE_ update ipv6/reassembly.c 54 * code now. If you change something here, _PLEASE_ update ipv6/reassembly.c
55 * as well. Or notify me, at least. --ANK 55 * as well. Or notify me, at least. --ANK
56 */ 56 */
57
58static int sysctl_ipfrag_max_dist __read_mostly = 64;
59static const char ip_frag_cache_name[] = "ip4-frags"; 57static const char ip_frag_cache_name[] = "ip4-frags";
60 58
61struct ipfrag_skb_cb 59struct ipfrag_skb_cb
@@ -150,7 +148,7 @@ static void ip4_frag_init(struct inet_frag_queue *q, const void *a)
150 qp->daddr = arg->iph->daddr; 148 qp->daddr = arg->iph->daddr;
151 qp->vif = arg->vif; 149 qp->vif = arg->vif;
152 qp->user = arg->user; 150 qp->user = arg->user;
153 qp->peer = sysctl_ipfrag_max_dist ? 151 qp->peer = q->net->max_dist ?
154 inet_getpeer_v4(net->ipv4.peers, arg->iph->saddr, arg->vif, 1) : 152 inet_getpeer_v4(net->ipv4.peers, arg->iph->saddr, arg->vif, 1) :
155 NULL; 153 NULL;
156} 154}
@@ -275,7 +273,7 @@ static struct ipq *ip_find(struct net *net, struct iphdr *iph,
275static int ip_frag_too_far(struct ipq *qp) 273static int ip_frag_too_far(struct ipq *qp)
276{ 274{
277 struct inet_peer *peer = qp->peer; 275 struct inet_peer *peer = qp->peer;
278 unsigned int max = sysctl_ipfrag_max_dist; 276 unsigned int max = qp->q.net->max_dist;
279 unsigned int start, end; 277 unsigned int start, end;
280 278
281 int rc; 279 int rc;
@@ -749,6 +747,14 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = {
749 .mode = 0644, 747 .mode = 0644,
750 .proc_handler = proc_dointvec_jiffies, 748 .proc_handler = proc_dointvec_jiffies,
751 }, 749 },
750 {
751 .procname = "ipfrag_max_dist",
752 .data = &init_net.ipv4.frags.max_dist,
753 .maxlen = sizeof(int),
754 .mode = 0644,
755 .proc_handler = proc_dointvec_minmax,
756 .extra1 = &zero
757 },
752 { } 758 { }
753}; 759};
754 760
@@ -762,14 +768,6 @@ static struct ctl_table ip4_frags_ctl_table[] = {
762 .mode = 0644, 768 .mode = 0644,
763 .proc_handler = proc_dointvec_jiffies, 769 .proc_handler = proc_dointvec_jiffies,
764 }, 770 },
765 {
766 .procname = "ipfrag_max_dist",
767 .data = &sysctl_ipfrag_max_dist,
768 .maxlen = sizeof(int),
769 .mode = 0644,
770 .proc_handler = proc_dointvec_minmax,
771 .extra1 = &zero
772 },
773 { } 771 { }
774}; 772};
775 773
@@ -790,10 +788,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
790 table[1].data = &net->ipv4.frags.low_thresh; 788 table[1].data = &net->ipv4.frags.low_thresh;
791 table[1].extra2 = &net->ipv4.frags.high_thresh; 789 table[1].extra2 = &net->ipv4.frags.high_thresh;
792 table[2].data = &net->ipv4.frags.timeout; 790 table[2].data = &net->ipv4.frags.timeout;
793 791 table[3].data = &net->ipv4.frags.max_dist;
794 /* Don't export sysctls to unprivileged users */
795 if (net->user_ns != &init_user_ns)
796 table[0].procname = NULL;
797 } 792 }
798 793
799 hdr = register_net_sysctl(net, "net/ipv4", table); 794 hdr = register_net_sysctl(net, "net/ipv4", table);
@@ -865,6 +860,8 @@ static int __net_init ipv4_frags_init_net(struct net *net)
865 */ 860 */
866 net->ipv4.frags.timeout = IP_FRAG_TIME; 861 net->ipv4.frags.timeout = IP_FRAG_TIME;
867 862
863 net->ipv4.frags.max_dist = 64;
864
868 res = inet_frags_init_net(&net->ipv4.frags); 865 res = inet_frags_init_net(&net->ipv4.frags);
869 if (res) 866 if (res)
870 return res; 867 return res;