diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-01-22 09:07:25 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:10:36 -0500 |
commit | 6ddc082223ef0f73717b4133fa7e648842bbfd02 (patch) | |
tree | 62315ac04e396bc6e68543502fb6aeec50be6662 /net/ipv6/reassembly.c | |
parent | e5a2bb842cd9681d00d4ca963e63e4d3647e66f8 (diff) |
[NETNS][FRAGS]: Make the mem counter per-namespace.
This is also simple, but introduces more changes, since
then mem counter is altered in more places.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/reassembly.c')
-rw-r--r-- | net/ipv6/reassembly.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 77a874020f3a..241b2cc49bf5 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -89,9 +89,9 @@ int ip6_frag_nqueues(struct net *net) | |||
89 | return net->ipv6.frags.nqueues; | 89 | return net->ipv6.frags.nqueues; |
90 | } | 90 | } |
91 | 91 | ||
92 | int ip6_frag_mem(void) | 92 | int ip6_frag_mem(struct net *net) |
93 | { | 93 | { |
94 | return atomic_read(&ip6_frags.mem); | 94 | return atomic_read(&net->ipv6.frags.mem); |
95 | } | 95 | } |
96 | 96 | ||
97 | static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, | 97 | static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, |
@@ -149,11 +149,12 @@ int ip6_frag_match(struct inet_frag_queue *q, void *a) | |||
149 | EXPORT_SYMBOL(ip6_frag_match); | 149 | EXPORT_SYMBOL(ip6_frag_match); |
150 | 150 | ||
151 | /* Memory Tracking Functions. */ | 151 | /* Memory Tracking Functions. */ |
152 | static inline void frag_kfree_skb(struct sk_buff *skb, int *work) | 152 | static inline void frag_kfree_skb(struct netns_frags *nf, |
153 | struct sk_buff *skb, int *work) | ||
153 | { | 154 | { |
154 | if (work) | 155 | if (work) |
155 | *work -= skb->truesize; | 156 | *work -= skb->truesize; |
156 | atomic_sub(skb->truesize, &ip6_frags.mem); | 157 | atomic_sub(skb->truesize, &nf->mem); |
157 | kfree_skb(skb); | 158 | kfree_skb(skb); |
158 | } | 159 | } |
159 | 160 | ||
@@ -183,11 +184,11 @@ static __inline__ void fq_kill(struct frag_queue *fq) | |||
183 | inet_frag_kill(&fq->q, &ip6_frags); | 184 | inet_frag_kill(&fq->q, &ip6_frags); |
184 | } | 185 | } |
185 | 186 | ||
186 | static void ip6_evictor(struct inet6_dev *idev) | 187 | static void ip6_evictor(struct net *net, struct inet6_dev *idev) |
187 | { | 188 | { |
188 | int evicted; | 189 | int evicted; |
189 | 190 | ||
190 | evicted = inet_frag_evictor(&ip6_frags); | 191 | evicted = inet_frag_evictor(&net->ipv6.frags, &ip6_frags); |
191 | if (evicted) | 192 | if (evicted) |
192 | IP6_ADD_STATS_BH(idev, IPSTATS_MIB_REASMFAILS, evicted); | 193 | IP6_ADD_STATS_BH(idev, IPSTATS_MIB_REASMFAILS, evicted); |
193 | } | 194 | } |
@@ -389,7 +390,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, | |||
389 | fq->q.fragments = next; | 390 | fq->q.fragments = next; |
390 | 391 | ||
391 | fq->q.meat -= free_it->len; | 392 | fq->q.meat -= free_it->len; |
392 | frag_kfree_skb(free_it, NULL); | 393 | frag_kfree_skb(fq->q.net, free_it, NULL); |
393 | } | 394 | } |
394 | } | 395 | } |
395 | 396 | ||
@@ -409,7 +410,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, | |||
409 | } | 410 | } |
410 | fq->q.stamp = skb->tstamp; | 411 | fq->q.stamp = skb->tstamp; |
411 | fq->q.meat += skb->len; | 412 | fq->q.meat += skb->len; |
412 | atomic_add(skb->truesize, &ip6_frags.mem); | 413 | atomic_add(skb->truesize, &fq->q.net->mem); |
413 | 414 | ||
414 | /* The first fragment. | 415 | /* The first fragment. |
415 | * nhoffset is obtained from the first fragment, of course. | 416 | * nhoffset is obtained from the first fragment, of course. |
@@ -503,7 +504,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, | |||
503 | head->len -= clone->len; | 504 | head->len -= clone->len; |
504 | clone->csum = 0; | 505 | clone->csum = 0; |
505 | clone->ip_summed = head->ip_summed; | 506 | clone->ip_summed = head->ip_summed; |
506 | atomic_add(clone->truesize, &ip6_frags.mem); | 507 | atomic_add(clone->truesize, &fq->q.net->mem); |
507 | } | 508 | } |
508 | 509 | ||
509 | /* We have to remove fragment header from datagram and to relocate | 510 | /* We have to remove fragment header from datagram and to relocate |
@@ -518,7 +519,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, | |||
518 | skb_shinfo(head)->frag_list = head->next; | 519 | skb_shinfo(head)->frag_list = head->next; |
519 | skb_reset_transport_header(head); | 520 | skb_reset_transport_header(head); |
520 | skb_push(head, head->data - skb_network_header(head)); | 521 | skb_push(head, head->data - skb_network_header(head)); |
521 | atomic_sub(head->truesize, &ip6_frags.mem); | 522 | atomic_sub(head->truesize, &fq->q.net->mem); |
522 | 523 | ||
523 | for (fp=head->next; fp; fp = fp->next) { | 524 | for (fp=head->next; fp; fp = fp->next) { |
524 | head->data_len += fp->len; | 525 | head->data_len += fp->len; |
@@ -528,7 +529,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, | |||
528 | else if (head->ip_summed == CHECKSUM_COMPLETE) | 529 | else if (head->ip_summed == CHECKSUM_COMPLETE) |
529 | head->csum = csum_add(head->csum, fp->csum); | 530 | head->csum = csum_add(head->csum, fp->csum); |
530 | head->truesize += fp->truesize; | 531 | head->truesize += fp->truesize; |
531 | atomic_sub(fp->truesize, &ip6_frags.mem); | 532 | atomic_sub(fp->truesize, &fq->q.net->mem); |
532 | } | 533 | } |
533 | 534 | ||
534 | head->next = NULL; | 535 | head->next = NULL; |
@@ -600,8 +601,9 @@ static int ipv6_frag_rcv(struct sk_buff *skb) | |||
600 | } | 601 | } |
601 | 602 | ||
602 | net = skb->dev->nd_net; | 603 | net = skb->dev->nd_net; |
603 | if (atomic_read(&ip6_frags.mem) > init_net.ipv6.sysctl.frags.high_thresh) | 604 | if (atomic_read(&net->ipv6.frags.mem) > |
604 | ip6_evictor(ip6_dst_idev(skb->dst)); | 605 | init_net.ipv6.sysctl.frags.high_thresh) |
606 | ip6_evictor(net, ip6_dst_idev(skb->dst)); | ||
605 | 607 | ||
606 | if ((fq = fq_find(net, fhdr->identification, &hdr->saddr, &hdr->daddr, | 608 | if ((fq = fq_find(net, fhdr->identification, &hdr->saddr, &hdr->daddr, |
607 | ip6_dst_idev(skb->dst))) != NULL) { | 609 | ip6_dst_idev(skb->dst))) != NULL) { |