diff options
-rw-r--r-- | include/net/inet_frag.h | 1 | ||||
-rw-r--r-- | net/ieee802154/reassembly.c | 2 | ||||
-rw-r--r-- | net/ipv4/inet_fragment.c | 16 | ||||
-rw-r--r-- | net/ipv4/ip_fragment.c | 15 | ||||
-rw-r--r-- | net/ipv6/netfilter/nf_conntrack_reasm.c | 4 | ||||
-rw-r--r-- | net/ipv6/reassembly.c | 6 |
6 files changed, 9 insertions, 35 deletions
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 15033057d44e..9fe644d1a26e 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h | |||
@@ -90,7 +90,6 @@ void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f); | |||
90 | void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); | 90 | void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); |
91 | void inet_frag_destroy(struct inet_frag_queue *q, | 91 | void inet_frag_destroy(struct inet_frag_queue *q, |
92 | struct inet_frags *f, int *work); | 92 | struct inet_frags *f, int *work); |
93 | int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force); | ||
94 | struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, | 93 | struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, |
95 | struct inet_frags *f, void *key, unsigned int hash) | 94 | struct inet_frags *f, void *key, unsigned int hash) |
96 | __releases(&f->lock); | 95 | __releases(&f->lock); |
diff --git a/net/ieee802154/reassembly.c b/net/ieee802154/reassembly.c index a707995fd4d7..9503a48556f7 100644 --- a/net/ieee802154/reassembly.c +++ b/net/ieee802154/reassembly.c | |||
@@ -369,8 +369,6 @@ int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type) | |||
369 | if (frag_info->d_size > ieee802154_lowpan->max_dsize) | 369 | if (frag_info->d_size > ieee802154_lowpan->max_dsize) |
370 | goto err; | 370 | goto err; |
371 | 371 | ||
372 | inet_frag_evictor(&ieee802154_lowpan->frags, &lowpan_frags, false); | ||
373 | |||
374 | fq = fq_find(net, frag_info, &source, &dest); | 372 | fq = fq_find(net, frag_info, &source, &dest); |
375 | if (fq != NULL) { | 373 | if (fq != NULL) { |
376 | int ret; | 374 | int ret; |
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 930d23870811..535636017534 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c | |||
@@ -46,6 +46,8 @@ const u8 ip_frag_ecn_table[16] = { | |||
46 | }; | 46 | }; |
47 | EXPORT_SYMBOL(ip_frag_ecn_table); | 47 | EXPORT_SYMBOL(ip_frag_ecn_table); |
48 | 48 | ||
49 | static int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force); | ||
50 | |||
49 | static unsigned int | 51 | static unsigned int |
50 | inet_frag_hashfn(const struct inet_frags *f, const struct inet_frag_queue *q) | 52 | inet_frag_hashfn(const struct inet_frags *f, const struct inet_frag_queue *q) |
51 | { | 53 | { |
@@ -203,16 +205,11 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f, | |||
203 | } | 205 | } |
204 | EXPORT_SYMBOL(inet_frag_destroy); | 206 | EXPORT_SYMBOL(inet_frag_destroy); |
205 | 207 | ||
206 | int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force) | 208 | static int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force) |
207 | { | 209 | { |
208 | struct inet_frag_queue *q; | 210 | struct inet_frag_queue *q; |
209 | int work, evicted = 0; | 211 | int work, evicted = 0; |
210 | 212 | ||
211 | if (!force) { | ||
212 | if (frag_mem_limit(nf) <= nf->high_thresh) | ||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | work = frag_mem_limit(nf) - nf->low_thresh; | 213 | work = frag_mem_limit(nf) - nf->low_thresh; |
217 | while (work > 0 || force) { | 214 | while (work > 0 || force) { |
218 | spin_lock(&nf->lru_lock); | 215 | spin_lock(&nf->lru_lock); |
@@ -242,7 +239,6 @@ int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force) | |||
242 | 239 | ||
243 | return evicted; | 240 | return evicted; |
244 | } | 241 | } |
245 | EXPORT_SYMBOL(inet_frag_evictor); | ||
246 | 242 | ||
247 | static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf, | 243 | static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf, |
248 | struct inet_frag_queue *qp_in, struct inet_frags *f, | 244 | struct inet_frag_queue *qp_in, struct inet_frags *f, |
@@ -296,6 +292,9 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf, | |||
296 | { | 292 | { |
297 | struct inet_frag_queue *q; | 293 | struct inet_frag_queue *q; |
298 | 294 | ||
295 | if (frag_mem_limit(nf) > nf->high_thresh) | ||
296 | return NULL; | ||
297 | |||
299 | q = kzalloc(f->qsize, GFP_ATOMIC); | 298 | q = kzalloc(f->qsize, GFP_ATOMIC); |
300 | if (q == NULL) | 299 | if (q == NULL) |
301 | return NULL; | 300 | return NULL; |
@@ -332,6 +331,9 @@ struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, | |||
332 | struct inet_frag_queue *q; | 331 | struct inet_frag_queue *q; |
333 | int depth = 0; | 332 | int depth = 0; |
334 | 333 | ||
334 | if (frag_mem_limit(nf) > nf->high_thresh) | ||
335 | inet_frag_evictor(nf, f, false); | ||
336 | |||
335 | hash &= (INETFRAGS_HASHSZ - 1); | 337 | hash &= (INETFRAGS_HASHSZ - 1); |
336 | hb = &f->hash[hash]; | 338 | hb = &f->hash[hash]; |
337 | 339 | ||
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index b769eb6c83c0..54988672d00d 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -177,18 +177,6 @@ static void ipq_kill(struct ipq *ipq) | |||
177 | inet_frag_kill(&ipq->q, &ip4_frags); | 177 | inet_frag_kill(&ipq->q, &ip4_frags); |
178 | } | 178 | } |
179 | 179 | ||
180 | /* Memory limiting on fragments. Evictor trashes the oldest | ||
181 | * fragment queue until we are back under the threshold. | ||
182 | */ | ||
183 | static void ip_evictor(struct net *net) | ||
184 | { | ||
185 | int evicted; | ||
186 | |||
187 | evicted = inet_frag_evictor(&net->ipv4.frags, &ip4_frags, false); | ||
188 | if (evicted) | ||
189 | IP_ADD_STATS_BH(net, IPSTATS_MIB_REASMFAILS, evicted); | ||
190 | } | ||
191 | |||
192 | /* | 180 | /* |
193 | * Oops, a fragment queue timed out. Kill it and send an ICMP reply. | 181 | * Oops, a fragment queue timed out. Kill it and send an ICMP reply. |
194 | */ | 182 | */ |
@@ -655,9 +643,6 @@ int ip_defrag(struct sk_buff *skb, u32 user) | |||
655 | net = skb->dev ? dev_net(skb->dev) : dev_net(skb_dst(skb)->dev); | 643 | net = skb->dev ? dev_net(skb->dev) : dev_net(skb_dst(skb)->dev); |
656 | IP_INC_STATS_BH(net, IPSTATS_MIB_REASMREQDS); | 644 | IP_INC_STATS_BH(net, IPSTATS_MIB_REASMREQDS); |
657 | 645 | ||
658 | /* Start by cleaning up the memory. */ | ||
659 | ip_evictor(net); | ||
660 | |||
661 | /* Lookup (or create) queue header */ | 646 | /* Lookup (or create) queue header */ |
662 | if ((qp = ip_find(net, ip_hdr(skb), user)) != NULL) { | 647 | if ((qp = ip_find(net, ip_hdr(skb), user)) != NULL) { |
663 | int ret; | 648 | int ret; |
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 607e4a94ef41..58e32cf91c95 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
@@ -594,10 +594,6 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user) | |||
594 | hdr = ipv6_hdr(clone); | 594 | hdr = ipv6_hdr(clone); |
595 | fhdr = (struct frag_hdr *)skb_transport_header(clone); | 595 | fhdr = (struct frag_hdr *)skb_transport_header(clone); |
596 | 596 | ||
597 | local_bh_disable(); | ||
598 | inet_frag_evictor(&net->nf_frag.frags, &nf_frags, false); | ||
599 | local_bh_enable(); | ||
600 | |||
601 | fq = fq_find(net, fhdr->identification, user, &hdr->saddr, &hdr->daddr, | 597 | fq = fq_find(net, fhdr->identification, user, &hdr->saddr, &hdr->daddr, |
602 | ip6_frag_ecn(hdr)); | 598 | ip6_frag_ecn(hdr)); |
603 | if (fq == NULL) { | 599 | if (fq == NULL) { |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 2b76549a1016..97acbc490d9e 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -519,7 +519,6 @@ static int ipv6_frag_rcv(struct sk_buff *skb) | |||
519 | struct frag_queue *fq; | 519 | struct frag_queue *fq; |
520 | const struct ipv6hdr *hdr = ipv6_hdr(skb); | 520 | const struct ipv6hdr *hdr = ipv6_hdr(skb); |
521 | struct net *net = dev_net(skb_dst(skb)->dev); | 521 | struct net *net = dev_net(skb_dst(skb)->dev); |
522 | int evicted; | ||
523 | 522 | ||
524 | if (IP6CB(skb)->flags & IP6SKB_FRAGMENTED) | 523 | if (IP6CB(skb)->flags & IP6SKB_FRAGMENTED) |
525 | goto fail_hdr; | 524 | goto fail_hdr; |
@@ -548,11 +547,6 @@ static int ipv6_frag_rcv(struct sk_buff *skb) | |||
548 | return 1; | 547 | return 1; |
549 | } | 548 | } |
550 | 549 | ||
551 | evicted = inet_frag_evictor(&net->ipv6.frags, &ip6_frags, false); | ||
552 | if (evicted) | ||
553 | IP6_ADD_STATS_BH(net, ip6_dst_idev(skb_dst(skb)), | ||
554 | IPSTATS_MIB_REASMFAILS, evicted); | ||
555 | |||
556 | fq = fq_find(net, fhdr->identification, &hdr->saddr, &hdr->daddr, | 550 | fq = fq_find(net, fhdr->identification, &hdr->saddr, &hdr->daddr, |
557 | ip6_frag_ecn(hdr)); | 551 | ip6_frag_ecn(hdr)); |
558 | if (fq != NULL) { | 552 | if (fq != NULL) { |