OpenVZ Forum - RDF feed
type: channel
items: [PATCH 0/9] Consolidate IP fragment management
items: [PATCH 1/9] Move common fields from frag_queues in one place
items: [PATCH 2/9] Collect frag queues management objects together
items: [PATCH 3/9] Collect common sysctl variables together
items: [PATCH 4/9] Consolidate the xxx_frag_kill
items: [PATCH 5/9] Consolidate xxx_the secret_rebuild
items: [PATCH 6/9] Consolidate the xxx_frag_destroy
items: [PATCH 7/9] Consolidate the xxx_evictor
items: [PATCH 8/9] Small cleanup for xxx_put after evictor consolidation
items: [PATCH 9/9] Consolidate the xxx_put
items: Re: [PATCH 1/9] Move common fields from frag_queues in one place
items: Re: [PATCH 2/9] Collect frag queues management objects together
items: Re: [PATCH 3/9] Collect common sysctl variables together
items: Re: [PATCH 4/9] Consolidate the xxx_frag_kill
items: Re: [PATCH 5/9] Consolidate xxx_the secret_rebuild
items: Re: [PATCH 6/9] Consolidate the xxx_frag_destroy
items: Re: [PATCH 7/9] Consolidate the xxx_evictor
items: Re: [PATCH 8/9] Small cleanup for xxx_put after evictor consolidation
items: Re: [PATCH 9/9] Consolidate the xxx_put
items: Re: [PATCH 0/9] Consolidate IP fragment management

[PATCH 0/9] Consolidate IP fragment management
type: item
description: Patrick recently pointed out, that there are three places that perform IP fragments management. In ipv4, ipv6 and in ip6 conntracks. Looks like these places can be a bit consolidated. The proposal is to create a common structure inet_frag_queue to put common fields like list heads, refcounts etc in, and include it into the specific fragment queues. Then such objects like hash tables, lists, locks etc are moved to common place (struct inet_frags). At the end common code is moved to the net/ipv4/inet_fragment.c. The inet_ prefix in file names, data structures and functions, and the code place (net/ipv4) was proposed by Alexey, but the exact names were selectd by me, so maybe there can be a better ones. Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
creator: Pavel Emelianov
date: 2007-10-12T12:55:10-00:00

[PATCH 1/9] Move common fields from frag_queues in one place
type: item
description: Introduce the struct inet_frag_queue in include/net/inet_frag.h file and place there all the common fields from three structs: * struct ipq in ipv4/ip_fragment.c * struct nf_ct_frag6_queue in nf_conntrack_reasm.c * struct frag_queue in ipv6/reassembly.c After this, replace these fields on appropriate structures with this structure instance and fix the users to use correct names i.e. hunks like - atomic_dec(&fq->refcnt); + atomic_dec(&fq->q.refcnt); (these occupy most of the patch) Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h new file mode 100644 index 0000000..74e9cb9 --- /dev/null +++ b/include/net/inet_frag.h @@ -0,0 +1,21 @@ +#ifndef __NET_FRAG_H__ +#define __NET_FRAG_H__ + +struct inet_frag_queue { + struct hlist_node list; + struct list_head lru_list; /* lru list member */ + spinlock_t lock; + atomic_t refcnt; + struct timer_list timer; /* when will this queue expire? */ + struct sk_buff *fragments; /* list of received fragments */ + ktime_t stamp; + int len; /* total length of orig datagram */ + int meat; + __u8 last_in; /* first/last segment arrived? */ + +#define COMPLETE 4 +#define FIRST_IN 2 +#define LAST_IN 1 +}; + +#endif diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index fabb86d..3eb1b6d 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -39,6 +39,7 @@ #include <net/icmp.h> #include <net/checksum.h> #include <net/inetpeer.h> +#include <net/inet_frag.h> #include <linux/tcp.h> #include <linux/udp.h> #include <linux/inet.h> @@ -74,25 +75,13 @@ struct ipfrag_skb_cb /* Describe an entry in the "incomplete datagrams" queue. */ struct ipq { - struct hlist_node list; - struct list_head lru_list; /* lru list member */ + struct inet_frag_queue q; + u32 user; __be32 saddr; __be32 daddr; __be16 id; u8 protocol; - u8 last_in; -#define COMPLETE 4 -#define FIRST_IN 2 -#define LAST_IN 1 - - struct sk_buff *fragments; /* linked list of received fragments */ - int len…
creator: Pavel Emelianov
date: 2007-10-12T13:00:06-00:00

[PATCH 2/9] Collect frag queues management objects together
type: item
description: There are some objects that are common in all the places which are used to keep track of frag queues, they are: * hash table * LRU list * rw lock * rnd number for hash function * the number of queues * the amount of memory occupied by queues * secret timer Move all this stuff into one structure (struct inet_frags) to make it possible use them uniformly in the future. Like with the previous patch this mostly consists of hunks like - write_lock(&ipfrag_lock); + write_lock(&ip4_frags.lock); To address the issue with exporting the number of queues and the amount of memory occupied by queues outside the .c file they are declared in, I introduce a couple of helpers. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 74e9cb9..d51f238 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -18,4 +18,19 @@ struct inet_frag_queue { #define LAST_IN 1 }; +#define INETFRAGS_HASHSZ 64 + +struct inet_frags { + struct list_head lru_list; + struct hlist_head hash[INETFRAGS_HASHSZ]; + rwlock_t lock; + u32 rnd; + int nqueues; + atomic_t mem; + struct timer_list secret_timer; +}; + +void inet_frags_init(struct inet_frags *); +void inet_frags_fini(struct inet_frags *); + #endif diff --git a/include/net/ip.h b/include/net/ip.h index 3af3ed9..a18dcec 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -333,8 +333,8 @@ enum ip_defrag_users }; struct sk_buff *ip_defrag(struct sk_buff *skb, u32 user); -extern int ip_frag_nqueues; -extern atomic_t ip_frag_mem; +int ip_frag_mem(void); +int ip_frag_nqueues(void); /* * Functions provided by ip_forward.c diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 31b3f1b..77cdab3 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -252,8 +252,8 @@ struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb); -extern int ip6_frag_nqueues; -extern atomic_t ip6_frag_mem; +i…
creator: Pavel Emelianov
date: 2007-10-12T13:06:13-00:00

[PATCH 3/9] Collect common sysctl variables together
type: item
description: Some sysctl variables are used to tune the frag queues management and it will be useful to work with them in a common way in the future, so move them into one structure, moreover they are the same for all the frag management codes. I don't place them in the existing inet_frags object, introduced in the previous patch for two reasons: 1. to keep them in the __read_mostly section; 2. not to export the whole inet_frags objects outside. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index d51f238..ada03ba 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -20,6 +20,13 @@ struct inet_frag_queue { #define INETFRAGS_HASHSZ 64 +struct inet_frags_ctl { + int high_thresh; + int low_thresh; + int timeout; + int secret_interval; +}; + struct inet_frags { struct list_head lru_list; struct hlist_head hash[INETFRAGS_HASHSZ]; @@ -28,6 +35,7 @@ struct inet_frags { int nqueues; atomic_t mem; struct timer_list secret_timer; + struct inet_frags_ctl *ctl; }; void inet_frags_init(struct inet_frags *); diff --git a/include/net/ip.h b/include/net/ip.h index a18dcec..e7b0feb 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -177,10 +177,8 @@ extern int sysctl_ip_default_ttl; extern int sysctl_ip_nonlocal_bind; /* From ip_fragment.c */ -extern int sysctl_ipfrag_high_thresh; -extern int sysctl_ipfrag_low_thresh; -extern int sysctl_ipfrag_time; -extern int sysctl_ipfrag_secret_interval; +struct inet_frags_ctl; +extern struct inet_frags_ctl ip4_frags_ctl; extern int sysctl_ipfrag_max_dist; /* From inetpeer.c */ diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 77cdab3..b29d76c 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -565,10 +565,8 @@ extern int inet6_hash_connect(struct inet_timewait_death_row *death_row, /* * reassembly.c */ -extern int sysctl_ip6frag_high_thresh; -extern int sysctl_ip6frag_low_thresh; -extern int sysctl_ip6frag_time; -extern int sysctl_ip6frag_secret_int…
creator: Pavel Emelianov
date: 2007-10-12T13:10:05-00:00

[PATCH 4/9] Consolidate the xxx_frag_kill
type: item
description: Since now all the xxx_frag_kill functions now work with the generic inet_frag_queue data type, this can be moved into a common place. The xxx_unlink() code is moved as well. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index ada03ba..9902363 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -41,4 +41,6 @@ struct inet_frags { void inet_frags_init(struct inet_frags *); void inet_frags_fini(struct inet_frags *); +void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); + #endif diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 69623ff..534eaa8 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -42,3 +42,26 @@ void inet_frags_fini(struct inet_frags *f) { } EXPORT_SYMBOL(inet_frags_fini); + +static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f) +{ + write_lock(&f->lock); + hlist_del(&fq->list); + list_del(&fq->lru_list); + f->nqueues--; + write_unlock(&f->lock); +} + +void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f) +{ + if (del_timer(&fq->timer)) + atomic_dec(&fq->refcnt); + + if (!(fq->last_in & COMPLETE)) { + fq_unlink(fq, f); + atomic_dec(&fq->refcnt); + fq->last_in |= COMPLETE; + } +} + +EXPORT_SYMBOL(inet_frag_kill); diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 61035a8..5b376c4 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -105,20 +105,6 @@ int ip_frag_mem(void) return atomic_read(&ip4_frags.mem); } -static __inline__ void __ipq_unlink(struct ipq *qp) -{ - hlist_del(&qp->q.list); - list_del(&qp->q.lru_list); - ip4_frags.nqueues--; -} - -static __inline__ void ipq_unlink(struct ipq *ipq) -{ - write_lock(&ip4_frags.lock); - __ipq_unlink(ipq); - write_unlock(&ip4_frags.lock); -} - static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot) { return jhash_3words((__force u32)id << 16 | prot, @@ -219,14 +205,7 @@ static…
creator: Pavel Emelianov
date: 2007-10-12T13:12:43-00:00

[PATCH 5/9] Consolidate xxx_the secret_rebuild
type: item
description: This code works with the generic data types as well, so move this into inet_fragment.c This move makes it possible to hide the secret_timer management and the secret_rebuild routine completely in the inet_fragment.c Introduce the ->hashfn() callback in inet_frags() to get the hashfun for a given inet_frag_queue() object. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 9902363..e374412 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -36,6 +36,8 @@ struct inet_frags { atomic_t mem; struct timer_list secret_timer; struct inet_frags_ctl *ctl; + + unsigned int (*hashfn)(struct inet_frag_queue *); }; void inet_frags_init(struct inet_frags *); diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 534eaa8..ec10e05 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -16,9 +16,38 @@ #include <linux/module.h> #include <linux/timer.h> #include <linux/mm.h> +#include <linux/random.h> #include <net/inet_frag.h> +static void inet_frag_secret_rebuild(unsigned long dummy) +{ + struct inet_frags *f = (struct inet_frags *)dummy; + unsigned long now = jiffies; + int i; + + write_lock(&f->lock); + get_random_bytes(&f->rnd, sizeof(u32)); + for (i = 0; i < INETFRAGS_HASHSZ; i++) { + struct inet_frag_queue *q; + struct hlist_node *p, *n; + + hlist_for_each_entry_safe(q, p, n, &f->hash[i], list) { + unsigned int hval = f->hashfn(q); + + if (hval != i) { + hlist_del(&q->list); + + /* Relink to new hash chain. */ + hlist_add_head(&q->list, &f->hash[hval]); + } + } + } + write_unlock(&f->lock); + + mod_timer(&f->secret_timer, now + f->ctl->secret_interval); +} + void inet_frags_init(struct inet_frags *f) { int i; @@ -35,11 +64,17 @@ void inet_frags_init(struct inet_frags *f) f->nqueues = 0; atomic_set(&f->mem, 0); + init_timer(&f->secret_timer); + f->secret_timer.function = inet_frag_secret_rebuild; + f->secret_timer.data = (unsigned long)f; + f->secret_timer.ex…
creator: Pavel Emelianov
date: 2007-10-12T13:16:25-00:00

[PATCH 6/9] Consolidate the xxx_frag_destroy
type: item
description: To make in possible we need to know the exact frag queue size for inet_frags->mem management and two callbacks: * to destoy the skb (optional, used in conntracks only) * to free the queue itself (mandatory, but later I plan to move the allocation and the destruction of frag_queues into the common place, so this callback will most likely be optional too). Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index e374412..2dd1cd4 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -33,16 +33,21 @@ struct inet_frags { rwlock_t lock; u32 rnd; int nqueues; + int qsize; atomic_t mem; struct timer_list secret_timer; struct inet_frags_ctl *ctl; unsigned int (*hashfn)(struct inet_frag_queue *); + void (*destructor)(struct inet_frag_queue *); + void (*skb_free)(struct sk_buff *); }; void inet_frags_init(struct inet_frags *); void inet_frags_fini(struct inet_frags *); void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); +void inet_frag_destroy(struct inet_frag_queue *q, + struct inet_frags *f, int *work); #endif diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index ec10e05..15fb2c4 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -17,6 +17,8 @@ #include <linux/timer.h> #include <linux/mm.h> #include <linux/random.h> +#include <linux/skbuff.h> +#include <linux/rtnetlink.h> #include <net/inet_frag.h> @@ -100,3 +102,41 @@ void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f) } EXPORT_SYMBOL(inet_frag_kill); + +static inline void frag_kfree_skb(struct inet_frags *f, struct sk_buff *skb, + int *work) +{ + if (work) + *work -= skb->truesize; + + atomic_sub(skb->truesize, &f->mem); + if (f->skb_free) + f->skb_free(skb); + kfree_skb(skb); +} + +void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f, + int *work) +{ + struct sk_buff *fp; + + BUG_TRAP(q->last_in & COMPLETE); + BUG_TRAP(del_timer(&q->timer) == 0); + + …
creator: Pavel Emelianov
date: 2007-10-12T13:21:06-00:00

[PATCH 7/9] Consolidate the xxx_evictor
type: item
description: The evictors collect some statistics for ipv4 and ipv6, so make it return the number of evicted queues and account them all at once in the caller. The XXX_ADD_STATS_BH() macros are just for this case, but maybe there are places in code, that can make use of them as well. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 2dd1cd4..cf583cf 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -49,5 +49,6 @@ void inet_frags_fini(struct inet_frags *); void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f, int *work); +int inet_frag_evictor(struct inet_frags *f); #endif diff --git a/include/net/ip.h b/include/net/ip.h index e7b0feb..00ed4f3 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -160,6 +160,7 @@ DECLARE_SNMP_STAT(struct ipstats_mib, ip_statistics); #define IP_INC_STATS(field) SNMP_INC_STATS(ip_statistics, field) #define IP_INC_STATS_BH(field) SNMP_INC_STATS_BH(ip_statistics, field) #define IP_INC_STATS_USER(field) SNMP_INC_STATS_USER(ip_statistics, field) +#define IP_ADD_STATS_BH(field, val) SNMP_ADD_STATS_BH(ip_statistics, field, val) DECLARE_SNMP_STAT(struct linux_mib, net_statistics); #define NET_INC_STATS(field) SNMP_INC_STATS(net_statistics, field) #define NET_INC_STATS_BH(field) SNMP_INC_STATS_BH(net_statistics, field) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index b29d76c..a0f1042 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -120,12 +120,21 @@ extern int sysctl_mld_max_msf; SNMP_INC_STATS##modifier(statname##_statistics, (field)); \ }) +#define _DEVADD(statname, modifier, idev, field, val) \ +({ \ + struct inet6_dev *_idev = (idev); \ + if (likely(_idev != NULL)) \ + SNMP_ADD_STATS##modifier((_idev)->stats.statname, (field), (val)); \ + SNMP_ADD_STATS##modifier(statname##_statistics, (field), (val));\ +}) + /* MIBs */ DECLARE_SNMP_STAT(struct ipstat…
creator: Pavel Emelianov
date: 2007-10-12T13:24:27-00:00

[PATCH 8/9] Small cleanup for xxx_put after evictor consolidation
type: item
description: After the evictor code is consolidated there is no need in passing the extra pointer to the xxx_put() functions. The only place when it made sense was the evictor code itself. Maybe this change must got with the previous (or with the next) patch, but I try to make them shorter as much as possible to simplify the review (but they are still large anyway), so this change goes in a separate patch. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index a59ac39..4ea7948 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -152,10 +152,10 @@ static __inline__ struct ipq *frag_alloc_queue(void) /* Destruction primitives. */ -static __inline__ void ipq_put(struct ipq *ipq, int *work) +static __inline__ void ipq_put(struct ipq *ipq) { if (atomic_dec_and_test(&ipq->q.refcnt)) - inet_frag_destroy(&ipq->q, &ip4_frags, work); + inet_frag_destroy(&ipq->q, &ip4_frags, NULL); } /* Kill ipq entry. It is not destroyed immediately, @@ -227,7 +205,7 @@ static void ip_expire(unsigned long arg) } out: spin_unlock(&qp->q.lock); - ipq_put(qp, NULL); + ipq_put(qp); } /* Creation primitives. */ @@ -257,7 +235,7 @@ static struct ipq *ip_frag_intern(struct ipq *qp_in) atomic_inc(&qp->q.refcnt); write_unlock(&ip4_frags.lock); qp_in->q.last_in |= COMPLETE; - ipq_put(qp_in, NULL); + ipq_put(qp_in); return qp; } } @@ -652,7 +630,7 @@ struct sk_buff *ip_defrag(struct sk_buff *skb, u32 user) ret = ip_frag_reasm(qp, dev); spin_unlock(&qp->q.lock); - ipq_put(qp, NULL); + ipq_put(qp); return ret; } diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 785f5cd..862d089 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -147,10 +147,10 @@ static inline struct nf_ct_frag6_queue *frag_alloc_queue(void) /* Destruction primitives. */ -static __inline__ void fq_put(struct nf_ct_frag6_queue *fq, unsigned int *work) +static __inline__ v…
creator: Pavel Emelianov
date: 2007-10-12T13:27:40-00:00

[PATCH 9/9] Consolidate the xxx_put
type: item
description: These ones use the generic data types too, so move them in one place. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> --- diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index cf583cf..911c2cd 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -51,4 +51,10 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f, int *work); int inet_frag_evictor(struct inet_frags *f); +static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f) +{ + if (atomic_dec_and_test(&q->refcnt)) + inet_frag_destroy(q, f, NULL); +} + #endif diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 4ea7948..4470a50 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -154,8 +154,7 @@ static __inline__ struct ipq *frag_alloc_queue(void) static __inline__ void ipq_put(struct ipq *ipq) { - if (atomic_dec_and_test(&ipq->q.refcnt)) - inet_frag_destroy(&ipq->q, &ip4_frags, NULL); + inet_frag_put(&ipq->q, &ip4_frags); } /* Kill ipq entry. It is not destroyed immediately, diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 862d089..bf6f2f0 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -149,8 +149,7 @@ static inline struct nf_ct_frag6_queue *frag_alloc_queue(void) static __inline__ void fq_put(struct nf_ct_frag6_queue *fq) { - if (atomic_dec_and_test(&fq->q.refcnt)) - inet_frag_destroy(&fq->q, &nf_frags, NULL); + inet_frag_put(&fq->q, &nf_frags); } /* Kill fq entry. It is not destroyed immediately, diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 454db16..a50fbea 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -167,8 +167,7 @@ static inline struct frag_queue *frag_alloc_queue(void) static __inline__ void fq_put(struct frag_queue *fq) { - if (atomic_dec_and_test(&fq->q.refcnt)) - inet_frag_destroy(&fq->q, &ip6_frags, NULL); + inet_frag_put(&fq->q, &ip6_frags); } /* Kill…
creator: Pavel Emelianov
date: 2007-10-12T13:29:01-00:00

Re: [PATCH 1/9] Move common fields from frag_queues in one place
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:00:06 +0400 > Introduce the struct inet_frag_queue in include/net/inet_frag.h > file and place there all the common fields from three structs: > > * struct ipq in ipv4/ip_fragment.c > * struct nf_ct_frag6_queue in nf_conntrack_reasm.c > * struct frag_queue in ipv6/reassembly.c > > After this, replace these fields on appropriate structures with > this structure instance and fix the users to use correct names > i.e. hunks like > > - atomic_dec(&fq->refcnt); > + atomic_dec(&fq->q.refcnt); > > (these occupy most of the patch) > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Applied.
creator: davem
date: 2007-10-15T09:24:43-00:00

Re: [PATCH 2/9] Collect frag queues management objects together
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:06:13 +0400 > There are some objects that are common in all the places > which are used to keep track of frag queues, they are: > > * hash table > * LRU list > * rw lock > * rnd number for hash function > * the number of queues > * the amount of memory occupied by queues > * secret timer > > Move all this stuff into one structure (struct inet_frags) > to make it possible use them uniformly in the future. Like > with the previous patch this mostly consists of hunks like > > - write_lock(&ipfrag_lock); > + write_lock(&ip4_frags.lock); > > To address the issue with exporting the number of queues and > the amount of memory occupied by queues outside the .c file > they are declared in, I introduce a couple of helpers. > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Applied. 'ipfrag_secret_timer' became unused, so I deleted it in this patch too.
creator: davem
date: 2007-10-15T09:32:28-00:00

Re: [PATCH 3/9] Collect common sysctl variables together
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:10:05 +0400 > Some sysctl variables are used to tune the frag queues > management and it will be useful to work with them in > a common way in the future, so move them into one > structure, moreover they are the same for all the frag > management codes. > > I don't place them in the existing inet_frags object, > introduced in the previous patch for two reasons: > > 1. to keep them in the __read_mostly section; > 2. not to export the whole inet_frags objects outside. > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Applied.
creator: davem
date: 2007-10-15T09:33:57-00:00

Re: [PATCH 4/9] Consolidate the xxx_frag_kill
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:12:43 +0400 > Since now all the xxx_frag_kill functions now work > with the generic inet_frag_queue data type, this can > be moved into a common place. > > The xxx_unlink() code is moved as well. > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Applied.
creator: davem
date: 2007-10-15T09:37:31-00:00

Re: [PATCH 5/9] Consolidate xxx_the secret_rebuild
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:16:25 +0400 > This code works with the generic data types as well, so > move this into inet_fragment.c > > This move makes it possible to hide the secret_timer > management and the secret_rebuild routine completely in > the inet_fragment.c > > Introduce the ->hashfn() callback in inet_frags() to get > the hashfun for a given inet_frag_queue() object. > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Applied.
creator: davem
date: 2007-10-15T09:38:40-00:00

Re: [PATCH 6/9] Consolidate the xxx_frag_destroy
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:21:06 +0400 > To make in possible we need to know the exact frag queue > size for inet_frags->mem management and two callbacks: > > * to destoy the skb (optional, used in conntracks only) > * to free the queue itself (mandatory, but later I plan to > move the allocation and the destruction of frag_queues > into the common place, so this callback will most likely > be optional too). > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Applied.
creator: davem
date: 2007-10-15T09:39:34-00:00

Re: [PATCH 7/9] Consolidate the xxx_evictor
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:24:27 +0400 > The evictors collect some statistics for ipv4 and ipv6, > so make it return the number of evicted queues and account > them all at once in the caller. > > The XXX_ADD_STATS_BH() macros are just for this case, > but maybe there are places in code, that can make use of > them as well. > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Applied, thanks!
creator: davem
date: 2007-10-15T09:40:14-00:00

Re: [PATCH 8/9] Small cleanup for xxx_put after evictor consolidation
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:27:40 +0400 > After the evictor code is consolidated there is no need in > passing the extra pointer to the xxx_put() functions. > > The only place when it made sense was the evictor code itself. > > Maybe this change must got with the previous (or with the > next) patch, but I try to make them shorter as much as > possible to simplify the review (but they are still large > anyway), so this change goes in a separate patch. > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Applied.
creator: davem
date: 2007-10-15T09:41:33-00:00

Re: [PATCH 9/9] Consolidate the xxx_put
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 17:29:01 +0400 > These ones use the generic data types too, so move > them in one place. > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Also applied, thanks!
creator: davem
date: 2007-10-15T09:42:05-00:00

Re: [PATCH 0/9] Consolidate IP fragment management
type: item
description: From: Pavel Emelyanov <xemul@openvz.org> Date: Fri, 12 Oct 2007 16:55:10 +0400 > Patrick recently pointed out, that there are three places that > perform IP fragments management. In ipv4, ipv6 and in ip6 > conntracks. Looks like these places can be a bit consolidated. > > The proposal is to create a common structure inet_frag_queue to > put common fields like list heads, refcounts etc in, and include > it into the specific fragment queues. Then such objects like > hash tables, lists, locks etc are moved to common place (struct > inet_frags). At the end common code is moved to the > net/ipv4/inet_fragment.c. > > The inet_ prefix in file names, data structures and functions, and > the code place (net/ipv4) was proposed by Alexey, but the exact > names were selectd by me, so maybe there can be a better ones. > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Thank you for doing this work, I applied it all. I had to decide whether to apply Herbert's recent patches first or your's, because either way there would be some conflicts to resolve. I handled it the best I could, but it seems OK from here.
creator: davem
date: 2007-10-15T09:42:48-00:00