diff options
author | Amerigo Wang <amwang@redhat.com> | 2012-09-18 12:50:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-09-19 17:23:28 -0400 |
commit | 6b102865e7ba9ff1e3c49c32c7187bb427d91798 (patch) | |
tree | 21a7f917457ab79f40d5bd579e547a030b2f0610 /net/ipv4 | |
parent | d4915c087f7c2457c580efc16fe0bfa1a576274d (diff) |
ipv6: unify fragment thresh handling code
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Michal Kubeček <mkubecek@suse.cz>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/inet_fragment.c | 9 | ||||
-rw-r--r-- | net/ipv4/ip_fragment.c | 5 |
2 files changed, 9 insertions, 5 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 85190e69297b..4750d2b74d79 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c | |||
@@ -89,7 +89,7 @@ void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f) | |||
89 | nf->low_thresh = 0; | 89 | nf->low_thresh = 0; |
90 | 90 | ||
91 | local_bh_disable(); | 91 | local_bh_disable(); |
92 | inet_frag_evictor(nf, f); | 92 | inet_frag_evictor(nf, f, true); |
93 | local_bh_enable(); | 93 | local_bh_enable(); |
94 | } | 94 | } |
95 | EXPORT_SYMBOL(inet_frags_exit_net); | 95 | EXPORT_SYMBOL(inet_frags_exit_net); |
@@ -158,11 +158,16 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f, | |||
158 | } | 158 | } |
159 | EXPORT_SYMBOL(inet_frag_destroy); | 159 | EXPORT_SYMBOL(inet_frag_destroy); |
160 | 160 | ||
161 | int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f) | 161 | int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force) |
162 | { | 162 | { |
163 | struct inet_frag_queue *q; | 163 | struct inet_frag_queue *q; |
164 | int work, evicted = 0; | 164 | int work, evicted = 0; |
165 | 165 | ||
166 | if (!force) { | ||
167 | if (atomic_read(&nf->mem) <= nf->high_thresh) | ||
168 | return 0; | ||
169 | } | ||
170 | |||
166 | work = atomic_read(&nf->mem) - nf->low_thresh; | 171 | work = atomic_read(&nf->mem) - nf->low_thresh; |
167 | while (work > 0) { | 172 | while (work > 0) { |
168 | read_lock(&f->lock); | 173 | read_lock(&f->lock); |
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index fa6a12c51066..448e68546827 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -219,7 +219,7 @@ static void ip_evictor(struct net *net) | |||
219 | { | 219 | { |
220 | int evicted; | 220 | int evicted; |
221 | 221 | ||
222 | evicted = inet_frag_evictor(&net->ipv4.frags, &ip4_frags); | 222 | evicted = inet_frag_evictor(&net->ipv4.frags, &ip4_frags, false); |
223 | if (evicted) | 223 | if (evicted) |
224 | IP_ADD_STATS_BH(net, IPSTATS_MIB_REASMFAILS, evicted); | 224 | IP_ADD_STATS_BH(net, IPSTATS_MIB_REASMFAILS, evicted); |
225 | } | 225 | } |
@@ -684,8 +684,7 @@ int ip_defrag(struct sk_buff *skb, u32 user) | |||
684 | IP_INC_STATS_BH(net, IPSTATS_MIB_REASMREQDS); | 684 | IP_INC_STATS_BH(net, IPSTATS_MIB_REASMREQDS); |
685 | 685 | ||
686 | /* Start by cleaning up the memory. */ | 686 | /* Start by cleaning up the memory. */ |
687 | if (atomic_read(&net->ipv4.frags.mem) > net->ipv4.frags.high_thresh) | 687 | ip_evictor(net); |
688 | ip_evictor(net); | ||
689 | 688 | ||
690 | /* Lookup (or create) queue header */ | 689 | /* Lookup (or create) queue header */ |
691 | if ((qp = ip_find(net, ip_hdr(skb), user)) != NULL) { | 690 | if ((qp = ip_find(net, ip_hdr(skb), user)) != NULL) { |