aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-01-22 09:11:48 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:10:39 -0500
commit3140c25c82106645a6b1fc469dab7006a1d09fd0 (patch)
treecbf97e7138610c1f1f0ad4528d59b4bbd14039c7 /net
parent3b4bc4a2bfe80d01ebd4f2b6dcc58986c970ed16 (diff)
[NETNS][FRAGS]: Make the LRU list per namespace.
The inet_frags.lru_list is used for evicting only, so we have to make it per-namespace, to evict only those fragments, who's namespace exceeded its high threshold, but not the whole hash. Besides, this helps to avoid long loops in evictor. The spinlock is not per-namespace because it protects the hash table as well, which is global. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/inet_fragment.c8
-rw-r--r--net/ipv4/ip_fragment.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c2
-rw-r--r--net/ipv6/reassembly.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index fcf5252166fa..f1b95e128772 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -57,7 +57,6 @@ void inet_frags_init(struct inet_frags *f)
57 for (i = 0; i < INETFRAGS_HASHSZ; i++) 57 for (i = 0; i < INETFRAGS_HASHSZ; i++)
58 INIT_HLIST_HEAD(&f->hash[i]); 58 INIT_HLIST_HEAD(&f->hash[i]);
59 59
60 INIT_LIST_HEAD(&f->lru_list);
61 rwlock_init(&f->lock); 60 rwlock_init(&f->lock);
62 61
63 f->rnd = (u32) ((num_physpages ^ (num_physpages>>7)) ^ 62 f->rnd = (u32) ((num_physpages ^ (num_physpages>>7)) ^
@@ -74,6 +73,7 @@ void inet_frags_init_net(struct netns_frags *nf)
74{ 73{
75 nf->nqueues = 0; 74 nf->nqueues = 0;
76 atomic_set(&nf->mem, 0); 75 atomic_set(&nf->mem, 0);
76 INIT_LIST_HEAD(&nf->lru_list);
77} 77}
78EXPORT_SYMBOL(inet_frags_init_net); 78EXPORT_SYMBOL(inet_frags_init_net);
79 79
@@ -156,12 +156,12 @@ int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f)
156 work = atomic_read(&nf->mem) - nf->low_thresh; 156 work = atomic_read(&nf->mem) - nf->low_thresh;
157 while (work > 0) { 157 while (work > 0) {
158 read_lock(&f->lock); 158 read_lock(&f->lock);
159 if (list_empty(&f->lru_list)) { 159 if (list_empty(&nf->lru_list)) {
160 read_unlock(&f->lock); 160 read_unlock(&f->lock);
161 break; 161 break;
162 } 162 }
163 163
164 q = list_first_entry(&f->lru_list, 164 q = list_first_entry(&nf->lru_list,
165 struct inet_frag_queue, lru_list); 165 struct inet_frag_queue, lru_list);
166 atomic_inc(&q->refcnt); 166 atomic_inc(&q->refcnt);
167 read_unlock(&f->lock); 167 read_unlock(&f->lock);
@@ -211,7 +211,7 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
211 211
212 atomic_inc(&qp->refcnt); 212 atomic_inc(&qp->refcnt);
213 hlist_add_head(&qp->list, &f->hash[hash]); 213 hlist_add_head(&qp->list, &f->hash[hash]);
214 list_add_tail(&qp->lru_list, &f->lru_list); 214 list_add_tail(&qp->lru_list, &nf->lru_list);
215 nf->nqueues++; 215 nf->nqueues++;
216 write_unlock(&f->lock); 216 write_unlock(&f->lock);
217 return qp; 217 return qp;
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 00646ed451f5..29b4b0972e44 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -441,7 +441,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
441 return ip_frag_reasm(qp, prev, dev); 441 return ip_frag_reasm(qp, prev, dev);
442 442
443 write_lock(&ip4_frags.lock); 443 write_lock(&ip4_frags.lock);
444 list_move_tail(&qp->q.lru_list, &ip4_frags.lru_list); 444 list_move_tail(&qp->q.lru_list, &qp->q.net->lru_list);
445 write_unlock(&ip4_frags.lock); 445 write_unlock(&ip4_frags.lock);
446 return -EINPROGRESS; 446 return -EINPROGRESS;
447 447
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 6eed991a4a3f..022da6ce4c0f 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -385,7 +385,7 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
385 fq->q.last_in |= FIRST_IN; 385 fq->q.last_in |= FIRST_IN;
386 } 386 }
387 write_lock(&nf_frags.lock); 387 write_lock(&nf_frags.lock);
388 list_move_tail(&fq->q.lru_list, &nf_frags.lru_list); 388 list_move_tail(&fq->q.lru_list, &nf_init_frags.lru_list);
389 write_unlock(&nf_frags.lock); 389 write_unlock(&nf_frags.lock);
390 return 0; 390 return 0;
391 391
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 852070087307..0c4bc46dee0c 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -424,7 +424,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
424 return ip6_frag_reasm(fq, prev, dev); 424 return ip6_frag_reasm(fq, prev, dev);
425 425
426 write_lock(&ip6_frags.lock); 426 write_lock(&ip6_frags.lock);
427 list_move_tail(&fq->q.lru_list, &ip6_frags.lru_list); 427 list_move_tail(&fq->q.lru_list, &fq->q.net->lru_list);
428 write_unlock(&ip6_frags.lock); 428 write_unlock(&ip6_frags.lock);
429 return -1; 429 return -1;
430 430