提交 0e60d245 编写于 作者: F Florian Westphal 提交者: David S. Miller

inet: frag: change *_frag_mem_limit functions to take netns_frags as argument

Followup patch will call it after inet_frag_queue was freed, so q->net
doesn't work anymore (but netf = q->net; free(q); mem_limit(netf) would).
Tested-by: NFrank Schreuder <fschreuder@transip.nl>
Signed-off-by: NFlorian Westphal <fw@strlen.de>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 d1fe1944
...@@ -141,14 +141,14 @@ static inline int frag_mem_limit(struct netns_frags *nf) ...@@ -141,14 +141,14 @@ static inline int frag_mem_limit(struct netns_frags *nf)
return percpu_counter_read(&nf->mem); return percpu_counter_read(&nf->mem);
} }
static inline void sub_frag_mem_limit(struct inet_frag_queue *q, int i) static inline void sub_frag_mem_limit(struct netns_frags *nf, int i)
{ {
__percpu_counter_add(&q->net->mem, -i, frag_percpu_counter_batch); __percpu_counter_add(&nf->mem, -i, frag_percpu_counter_batch);
} }
static inline void add_frag_mem_limit(struct inet_frag_queue *q, int i) static inline void add_frag_mem_limit(struct netns_frags *nf, int i)
{ {
__percpu_counter_add(&q->net->mem, i, frag_percpu_counter_batch); __percpu_counter_add(&nf->mem, i, frag_percpu_counter_batch);
} }
static inline void init_frag_mem_limit(struct netns_frags *nf) static inline void init_frag_mem_limit(struct netns_frags *nf)
......
...@@ -207,7 +207,7 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq, ...@@ -207,7 +207,7 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq,
} else { } else {
fq->q.meat += skb->len; fq->q.meat += skb->len;
} }
add_frag_mem_limit(&fq->q, skb->truesize); add_frag_mem_limit(fq->q.net, skb->truesize);
if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) && if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
fq->q.meat == fq->q.len) { fq->q.meat == fq->q.len) {
...@@ -287,7 +287,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev, ...@@ -287,7 +287,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
clone->data_len = clone->len; clone->data_len = clone->len;
head->data_len -= clone->len; head->data_len -= clone->len;
head->len -= clone->len; head->len -= clone->len;
add_frag_mem_limit(&fq->q, clone->truesize); add_frag_mem_limit(fq->q.net, clone->truesize);
} }
WARN_ON(head == NULL); WARN_ON(head == NULL);
...@@ -310,7 +310,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev, ...@@ -310,7 +310,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
} }
fp = next; fp = next;
} }
sub_frag_mem_limit(&fq->q, sum_truesize); sub_frag_mem_limit(fq->q.net, sum_truesize);
head->next = NULL; head->next = NULL;
head->dev = dev; head->dev = dev;
......
...@@ -328,7 +328,7 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f) ...@@ -328,7 +328,7 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f)
fp = xp; fp = xp;
} }
sum = sum_truesize + f->qsize; sum = sum_truesize + f->qsize;
sub_frag_mem_limit(q, sum); sub_frag_mem_limit(q->net, sum);
if (f->destructor) if (f->destructor)
f->destructor(q); f->destructor(q);
...@@ -388,7 +388,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf, ...@@ -388,7 +388,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
q->net = nf; q->net = nf;
f->constructor(q, arg); f->constructor(q, arg);
add_frag_mem_limit(q, f->qsize); add_frag_mem_limit(nf, f->qsize);
setup_timer(&q->timer, f->frag_expire, (unsigned long)q); setup_timer(&q->timer, f->frag_expire, (unsigned long)q);
spin_lock_init(&q->lock); spin_lock_init(&q->lock);
......
...@@ -309,7 +309,7 @@ static int ip_frag_reinit(struct ipq *qp) ...@@ -309,7 +309,7 @@ static int ip_frag_reinit(struct ipq *qp)
kfree_skb(fp); kfree_skb(fp);
fp = xp; fp = xp;
} while (fp); } while (fp);
sub_frag_mem_limit(&qp->q, sum_truesize); sub_frag_mem_limit(qp->q.net, sum_truesize);
qp->q.flags = 0; qp->q.flags = 0;
qp->q.len = 0; qp->q.len = 0;
...@@ -455,7 +455,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -455,7 +455,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
qp->q.fragments = next; qp->q.fragments = next;
qp->q.meat -= free_it->len; qp->q.meat -= free_it->len;
sub_frag_mem_limit(&qp->q, free_it->truesize); sub_frag_mem_limit(qp->q.net, free_it->truesize);
kfree_skb(free_it); kfree_skb(free_it);
} }
} }
...@@ -479,7 +479,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -479,7 +479,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
qp->q.stamp = skb->tstamp; qp->q.stamp = skb->tstamp;
qp->q.meat += skb->len; qp->q.meat += skb->len;
qp->ecn |= ecn; qp->ecn |= ecn;
add_frag_mem_limit(&qp->q, skb->truesize); add_frag_mem_limit(qp->q.net, skb->truesize);
if (offset == 0) if (offset == 0)
qp->q.flags |= INET_FRAG_FIRST_IN; qp->q.flags |= INET_FRAG_FIRST_IN;
...@@ -587,7 +587,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev, ...@@ -587,7 +587,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
head->len -= clone->len; head->len -= clone->len;
clone->csum = 0; clone->csum = 0;
clone->ip_summed = head->ip_summed; clone->ip_summed = head->ip_summed;
add_frag_mem_limit(&qp->q, clone->truesize); add_frag_mem_limit(qp->q.net, clone->truesize);
} }
skb_push(head, head->data - skb_network_header(head)); skb_push(head, head->data - skb_network_header(head));
...@@ -615,7 +615,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev, ...@@ -615,7 +615,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
} }
fp = next; fp = next;
} }
sub_frag_mem_limit(&qp->q, sum_truesize); sub_frag_mem_limit(qp->q.net, sum_truesize);
head->next = NULL; head->next = NULL;
head->dev = dev; head->dev = dev;
......
...@@ -348,7 +348,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -348,7 +348,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
fq->ecn |= ecn; fq->ecn |= ecn;
if (payload_len > fq->q.max_size) if (payload_len > fq->q.max_size)
fq->q.max_size = payload_len; fq->q.max_size = payload_len;
add_frag_mem_limit(&fq->q, skb->truesize); add_frag_mem_limit(fq->q.net, skb->truesize);
/* The first fragment. /* The first fragment.
* nhoffset is obtained from the first fragment, of course. * nhoffset is obtained from the first fragment, of course.
...@@ -430,7 +430,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev) ...@@ -430,7 +430,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
clone->ip_summed = head->ip_summed; clone->ip_summed = head->ip_summed;
NFCT_FRAG6_CB(clone)->orig = NULL; NFCT_FRAG6_CB(clone)->orig = NULL;
add_frag_mem_limit(&fq->q, clone->truesize); add_frag_mem_limit(fq->q.net, clone->truesize);
} }
/* We have to remove fragment header from datagram and to relocate /* We have to remove fragment header from datagram and to relocate
...@@ -454,7 +454,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev) ...@@ -454,7 +454,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
head->csum = csum_add(head->csum, fp->csum); head->csum = csum_add(head->csum, fp->csum);
head->truesize += fp->truesize; head->truesize += fp->truesize;
} }
sub_frag_mem_limit(&fq->q, head->truesize); sub_frag_mem_limit(fq->q.net, head->truesize);
head->ignore_df = 1; head->ignore_df = 1;
head->next = NULL; head->next = NULL;
......
...@@ -330,7 +330,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -330,7 +330,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
fq->q.stamp = skb->tstamp; fq->q.stamp = skb->tstamp;
fq->q.meat += skb->len; fq->q.meat += skb->len;
fq->ecn |= ecn; fq->ecn |= ecn;
add_frag_mem_limit(&fq->q, skb->truesize); add_frag_mem_limit(fq->q.net, skb->truesize);
/* The first fragment. /* The first fragment.
* nhoffset is obtained from the first fragment, of course. * nhoffset is obtained from the first fragment, of course.
...@@ -443,7 +443,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, ...@@ -443,7 +443,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
head->len -= clone->len; head->len -= clone->len;
clone->csum = 0; clone->csum = 0;
clone->ip_summed = head->ip_summed; clone->ip_summed = head->ip_summed;
add_frag_mem_limit(&fq->q, clone->truesize); add_frag_mem_limit(fq->q.net, clone->truesize);
} }
/* We have to remove fragment header from datagram and to relocate /* We have to remove fragment header from datagram and to relocate
...@@ -481,7 +481,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, ...@@ -481,7 +481,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
} }
fp = next; fp = next;
} }
sub_frag_mem_limit(&fq->q, sum_truesize); sub_frag_mem_limit(fq->q.net, sum_truesize);
head->next = NULL; head->next = NULL;
head->dev = dev; head->dev = dev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册