aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/inet_fragment.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-01-22 09:07:25 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:10:36 -0500
commit6ddc082223ef0f73717b4133fa7e648842bbfd02 (patch)
tree62315ac04e396bc6e68543502fb6aeec50be6662 /net/ipv4/inet_fragment.c
parente5a2bb842cd9681d00d4ca963e63e4d3647e66f8 (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/ipv4/inet_fragment.c')
-rw-r--r--net/ipv4/inet_fragment.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 4fec0b911f85..ad79ae0c0264 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -63,8 +63,6 @@ void inet_frags_init(struct inet_frags *f)
63 f->rnd = (u32) ((num_physpages ^ (num_physpages>>7)) ^ 63 f->rnd = (u32) ((num_physpages ^ (num_physpages>>7)) ^
64 (jiffies ^ (jiffies >> 6))); 64 (jiffies ^ (jiffies >> 6)));
65 65
66 atomic_set(&f->mem, 0);
67
68 setup_timer(&f->secret_timer, inet_frag_secret_rebuild, 66 setup_timer(&f->secret_timer, inet_frag_secret_rebuild,
69 (unsigned long)f); 67 (unsigned long)f);
70 f->secret_timer.expires = jiffies + f->ctl->secret_interval; 68 f->secret_timer.expires = jiffies + f->ctl->secret_interval;
@@ -75,6 +73,7 @@ EXPORT_SYMBOL(inet_frags_init);
75void inet_frags_init_net(struct netns_frags *nf) 73void inet_frags_init_net(struct netns_frags *nf)
76{ 74{
77 nf->nqueues = 0; 75 nf->nqueues = 0;
76 atomic_set(&nf->mem, 0);
78} 77}
79EXPORT_SYMBOL(inet_frags_init_net); 78EXPORT_SYMBOL(inet_frags_init_net);
80 79
@@ -107,13 +106,13 @@ void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f)
107 106
108EXPORT_SYMBOL(inet_frag_kill); 107EXPORT_SYMBOL(inet_frag_kill);
109 108
110static inline void frag_kfree_skb(struct inet_frags *f, struct sk_buff *skb, 109static inline void frag_kfree_skb(struct netns_frags *nf, struct inet_frags *f,
111 int *work) 110 struct sk_buff *skb, int *work)
112{ 111{
113 if (work) 112 if (work)
114 *work -= skb->truesize; 113 *work -= skb->truesize;
115 114
116 atomic_sub(skb->truesize, &f->mem); 115 atomic_sub(skb->truesize, &nf->mem);
117 if (f->skb_free) 116 if (f->skb_free)
118 f->skb_free(skb); 117 f->skb_free(skb);
119 kfree_skb(skb); 118 kfree_skb(skb);
@@ -123,22 +122,24 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f,
123 int *work) 122 int *work)
124{ 123{
125 struct sk_buff *fp; 124 struct sk_buff *fp;
125 struct netns_frags *nf;
126 126
127 BUG_TRAP(q->last_in & COMPLETE); 127 BUG_TRAP(q->last_in & COMPLETE);
128 BUG_TRAP(del_timer(&q->timer) == 0); 128 BUG_TRAP(del_timer(&q->timer) == 0);
129 129
130 /* Release all fragment data. */ 130 /* Release all fragment data. */
131 fp = q->fragments; 131 fp = q->fragments;
132 nf = q->net;
132 while (fp) { 133 while (fp) {
133 struct sk_buff *xp = fp->next; 134 struct sk_buff *xp = fp->next;
134 135
135 frag_kfree_skb(f, fp, work); 136 frag_kfree_skb(nf, f, fp, work);
136 fp = xp; 137 fp = xp;
137 } 138 }
138 139
139 if (work) 140 if (work)
140 *work -= f->qsize; 141 *work -= f->qsize;
141 atomic_sub(f->qsize, &f->mem); 142 atomic_sub(f->qsize, &nf->mem);
142 143
143 if (f->destructor) 144 if (f->destructor)
144 f->destructor(q); 145 f->destructor(q);
@@ -147,12 +148,12 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f,
147} 148}
148EXPORT_SYMBOL(inet_frag_destroy); 149EXPORT_SYMBOL(inet_frag_destroy);
149 150
150int inet_frag_evictor(struct inet_frags *f) 151int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f)
151{ 152{
152 struct inet_frag_queue *q; 153 struct inet_frag_queue *q;
153 int work, evicted = 0; 154 int work, evicted = 0;
154 155
155 work = atomic_read(&f->mem) - f->ctl->low_thresh; 156 work = atomic_read(&nf->mem) - f->ctl->low_thresh;
156 while (work > 0) { 157 while (work > 0) {
157 read_lock(&f->lock); 158 read_lock(&f->lock);
158 if (list_empty(&f->lru_list)) { 159 if (list_empty(&f->lru_list)) {
@@ -226,7 +227,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
226 return NULL; 227 return NULL;
227 228
228 f->constructor(q, arg); 229 f->constructor(q, arg);
229 atomic_add(f->qsize, &f->mem); 230 atomic_add(f->qsize, &nf->mem);
230 setup_timer(&q->timer, f->frag_expire, (unsigned long)q); 231 setup_timer(&q->timer, f->frag_expire, (unsigned long)q);
231 spin_lock_init(&q->lock); 232 spin_lock_init(&q->lock);
232 atomic_set(&q->refcnt, 1); 233 atomic_set(&q->refcnt, 1);