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 | |
| 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')
| -rw-r--r-- | net/ipv6/netfilter/nf_conntrack_reasm.c | 14 | ||||
| -rw-r--r-- | net/ipv6/proc.c | 2 | ||||
| -rw-r--r-- | net/ipv6/reassembly.c | 28 |
3 files changed, 23 insertions, 21 deletions
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 0b9d0097b68d..cb826bea4b1b 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
| @@ -155,7 +155,7 @@ static inline void frag_kfree_skb(struct sk_buff *skb, unsigned int *work) | |||
| 155 | { | 155 | { |
| 156 | if (work) | 156 | if (work) |
| 157 | *work -= skb->truesize; | 157 | *work -= skb->truesize; |
| 158 | atomic_sub(skb->truesize, &nf_frags.mem); | 158 | atomic_sub(skb->truesize, &nf_init_frags.mem); |
| 159 | nf_skb_free(skb); | 159 | nf_skb_free(skb); |
| 160 | kfree_skb(skb); | 160 | kfree_skb(skb); |
| 161 | } | 161 | } |
| @@ -177,7 +177,7 @@ static __inline__ void fq_kill(struct nf_ct_frag6_queue *fq) | |||
| 177 | 177 | ||
| 178 | static void nf_ct_frag6_evictor(void) | 178 | static void nf_ct_frag6_evictor(void) |
| 179 | { | 179 | { |
| 180 | inet_frag_evictor(&nf_frags); | 180 | inet_frag_evictor(&nf_init_frags, &nf_frags); |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | static void nf_ct_frag6_expire(unsigned long data) | 183 | static void nf_ct_frag6_expire(unsigned long data) |
| @@ -382,7 +382,7 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, | |||
| 382 | skb->dev = NULL; | 382 | skb->dev = NULL; |
| 383 | fq->q.stamp = skb->tstamp; | 383 | fq->q.stamp = skb->tstamp; |
| 384 | fq->q.meat += skb->len; | 384 | fq->q.meat += skb->len; |
| 385 | atomic_add(skb->truesize, &nf_frags.mem); | 385 | atomic_add(skb->truesize, &nf_init_frags.mem); |
| 386 | 386 | ||
| 387 | /* The first fragment. | 387 | /* The first fragment. |
| 388 | * nhoffset is obtained from the first fragment, of course. | 388 | * nhoffset is obtained from the first fragment, of course. |
| @@ -459,7 +459,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) | |||
| 459 | clone->ip_summed = head->ip_summed; | 459 | clone->ip_summed = head->ip_summed; |
| 460 | 460 | ||
| 461 | NFCT_FRAG6_CB(clone)->orig = NULL; | 461 | NFCT_FRAG6_CB(clone)->orig = NULL; |
| 462 | atomic_add(clone->truesize, &nf_frags.mem); | 462 | atomic_add(clone->truesize, &nf_init_frags.mem); |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | /* We have to remove fragment header from datagram and to relocate | 465 | /* We have to remove fragment header from datagram and to relocate |
| @@ -473,7 +473,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) | |||
| 473 | skb_shinfo(head)->frag_list = head->next; | 473 | skb_shinfo(head)->frag_list = head->next; |
| 474 | skb_reset_transport_header(head); | 474 | skb_reset_transport_header(head); |
| 475 | skb_push(head, head->data - skb_network_header(head)); | 475 | skb_push(head, head->data - skb_network_header(head)); |
| 476 | atomic_sub(head->truesize, &nf_frags.mem); | 476 | atomic_sub(head->truesize, &nf_init_frags.mem); |
| 477 | 477 | ||
| 478 | for (fp=head->next; fp; fp = fp->next) { | 478 | for (fp=head->next; fp; fp = fp->next) { |
| 479 | head->data_len += fp->len; | 479 | head->data_len += fp->len; |
| @@ -483,7 +483,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) | |||
| 483 | else if (head->ip_summed == CHECKSUM_COMPLETE) | 483 | else if (head->ip_summed == CHECKSUM_COMPLETE) |
| 484 | head->csum = csum_add(head->csum, fp->csum); | 484 | head->csum = csum_add(head->csum, fp->csum); |
| 485 | head->truesize += fp->truesize; | 485 | head->truesize += fp->truesize; |
| 486 | atomic_sub(fp->truesize, &nf_frags.mem); | 486 | atomic_sub(fp->truesize, &nf_init_frags.mem); |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | head->next = NULL; | 489 | head->next = NULL; |
| @@ -633,7 +633,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb) | |||
| 633 | goto ret_orig; | 633 | goto ret_orig; |
| 634 | } | 634 | } |
| 635 | 635 | ||
| 636 | if (atomic_read(&nf_frags.mem) > nf_frags_ctl.high_thresh) | 636 | if (atomic_read(&nf_init_frags.mem) > nf_frags_ctl.high_thresh) |
| 637 | nf_ct_frag6_evictor(); | 637 | nf_ct_frag6_evictor(); |
| 638 | 638 | ||
| 639 | fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr); | 639 | fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr); |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index dec34c87cb4a..35e502a72495 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
| @@ -44,7 +44,7 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v) | |||
| 44 | seq_printf(seq, "RAW6: inuse %d\n", | 44 | seq_printf(seq, "RAW6: inuse %d\n", |
| 45 | sock_prot_inuse_get(&rawv6_prot)); | 45 | sock_prot_inuse_get(&rawv6_prot)); |
| 46 | seq_printf(seq, "FRAG6: inuse %d memory %d\n", | 46 | seq_printf(seq, "FRAG6: inuse %d memory %d\n", |
| 47 | ip6_frag_nqueues(&init_net), ip6_frag_mem()); | 47 | ip6_frag_nqueues(&init_net), ip6_frag_mem(&init_net)); |
| 48 | return 0; | 48 | return 0; |
| 49 | } | 49 | } |
| 50 | 50 | ||
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) { |
