diff options
| author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-15 05:24:19 -0400 |
|---|---|---|
| committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-15 15:26:38 -0400 |
| commit | 5ab11c98d3a950faf6922b6166e5f8fc874590e7 (patch) | |
| tree | ef9ab897361f106309df37b6d4f2e95fdecdb240 | |
| parent | 114342f2d38439cb1a54f1f724fa38729b093c48 (diff) | |
[INET]: Move common fields from frag_queues in one place.
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/net/inet_frag.h | 21 | ||||
| -rw-r--r-- | net/ipv4/ip_fragment.c | 177 | ||||
| -rw-r--r-- | net/ipv6/netfilter/nf_conntrack_reasm.c | 137 | ||||
| -rw-r--r-- | net/ipv6/reassembly.c | 153 |
4 files changed, 238 insertions, 250 deletions
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h new file mode 100644 index 000000000000..74e9cb9b6943 --- /dev/null +++ b/include/net/inet_frag.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #ifndef __NET_FRAG_H__ | ||
| 2 | #define __NET_FRAG_H__ | ||
| 3 | |||
| 4 | struct inet_frag_queue { | ||
| 5 | struct hlist_node list; | ||
| 6 | struct list_head lru_list; /* lru list member */ | ||
| 7 | spinlock_t lock; | ||
| 8 | atomic_t refcnt; | ||
| 9 | struct timer_list timer; /* when will this queue expire? */ | ||
| 10 | struct sk_buff *fragments; /* list of received fragments */ | ||
| 11 | ktime_t stamp; | ||
| 12 | int len; /* total length of orig datagram */ | ||
| 13 | int meat; | ||
| 14 | __u8 last_in; /* first/last segment arrived? */ | ||
| 15 | |||
| 16 | #define COMPLETE 4 | ||
| 17 | #define FIRST_IN 2 | ||
| 18 | #define LAST_IN 1 | ||
| 19 | }; | ||
| 20 | |||
| 21 | #endif | ||
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 32108cf2a784..428eaa502ec2 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include <net/icmp.h> | 39 | #include <net/icmp.h> |
| 40 | #include <net/checksum.h> | 40 | #include <net/checksum.h> |
| 41 | #include <net/inetpeer.h> | 41 | #include <net/inetpeer.h> |
| 42 | #include <net/inet_frag.h> | ||
| 42 | #include <linux/tcp.h> | 43 | #include <linux/tcp.h> |
| 43 | #include <linux/udp.h> | 44 | #include <linux/udp.h> |
| 44 | #include <linux/inet.h> | 45 | #include <linux/inet.h> |
| @@ -74,25 +75,13 @@ struct ipfrag_skb_cb | |||
| 74 | 75 | ||
| 75 | /* Describe an entry in the "incomplete datagrams" queue. */ | 76 | /* Describe an entry in the "incomplete datagrams" queue. */ |
| 76 | struct ipq { | 77 | struct ipq { |
| 77 | struct hlist_node list; | 78 | struct inet_frag_queue q; |
| 78 | struct list_head lru_list; /* lru list member */ | 79 | |
| 79 | u32 user; | 80 | u32 user; |
| 80 | __be32 saddr; | 81 | __be32 saddr; |
| 81 | __be32 daddr; | 82 | __be32 daddr; |
| 82 | __be16 id; | 83 | __be16 id; |
| 83 | u8 protocol; | 84 | u8 protocol; |
| 84 | u8 last_in; | ||
| 85 | #define COMPLETE 4 | ||
| 86 | #define FIRST_IN 2 | ||
| 87 | #define LAST_IN 1 | ||
| 88 | |||
| 89 | struct sk_buff *fragments; /* linked list of received fragments */ | ||
| 90 | int len; /* total length of original datagram */ | ||
| 91 | int meat; | ||
| 92 | spinlock_t lock; | ||
| 93 | atomic_t refcnt; | ||
| 94 | struct timer_list timer; /* when will this queue expire? */ | ||
| 95 | ktime_t stamp; | ||
| 96 | int iif; | 85 | int iif; |
| 97 | unsigned int rid; | 86 | unsigned int rid; |
| 98 | struct inet_peer *peer; | 87 | struct inet_peer *peer; |
| @@ -114,8 +103,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev, | |||
| 114 | 103 | ||
| 115 | static __inline__ void __ipq_unlink(struct ipq *qp) | 104 | static __inline__ void __ipq_unlink(struct ipq *qp) |
| 116 | { | 105 | { |
| 117 | hlist_del(&qp->list); | 106 | hlist_del(&qp->q.list); |
| 118 | list_del(&qp->lru_list); | 107 | list_del(&qp->q.lru_list); |
| 119 | ip_frag_nqueues--; | 108 | ip_frag_nqueues--; |
| 120 | } | 109 | } |
| 121 | 110 | ||
| @@ -147,15 +136,15 @@ static void ipfrag_secret_rebuild(unsigned long dummy) | |||
| 147 | struct ipq *q; | 136 | struct ipq *q; |
| 148 | struct hlist_node *p, *n; | 137 | struct hlist_node *p, *n; |
| 149 | 138 | ||
| 150 | hlist_for_each_entry_safe(q, p, n, &ipq_hash[i], list) { | 139 | hlist_for_each_entry_safe(q, p, n, &ipq_hash[i], q.list) { |
| 151 | unsigned int hval = ipqhashfn(q->id, q->saddr, | 140 | unsigned int hval = ipqhashfn(q->id, q->saddr, |
| 152 | q->daddr, q->protocol); | 141 | q->daddr, q->protocol); |
| 153 | 142 | ||
| 154 | if (hval != i) { | 143 | if (hval != i) { |
| 155 | hlist_del(&q->list); | 144 | hlist_del(&q->q.list); |
| 156 | 145 | ||
| 157 | /* Relink to new hash chain. */ | 146 | /* Relink to new hash chain. */ |
| 158 | hlist_add_head(&q->list, &ipq_hash[hval]); | 147 | hlist_add_head(&q->q.list, &ipq_hash[hval]); |
| 159 | } | 148 | } |
| 160 | } | 149 | } |
| 161 | } | 150 | } |
| @@ -201,14 +190,14 @@ static void ip_frag_destroy(struct ipq *qp, int *work) | |||
| 201 | { | 190 | { |
| 202 | struct sk_buff *fp; | 191 | struct sk_buff *fp; |
| 203 | 192 | ||
| 204 | BUG_TRAP(qp->last_in&COMPLETE); | 193 | BUG_TRAP(qp->q.last_in&COMPLETE); |
| 205 | BUG_TRAP(del_timer(&qp->timer) == 0); | 194 | BUG_TRAP(del_timer(&qp->q.timer) == 0); |
| 206 | 195 | ||
| 207 | if (qp->peer) | 196 | if (qp->peer) |
| 208 | inet_putpeer(qp->peer); | 197 | inet_putpeer(qp->peer); |
| 209 | 198 | ||
| 210 | /* Release all fragment data. */ | 199 | /* Release all fragment data. */ |
| 211 | fp = qp->fragments; | 200 | fp = qp->q.fragments; |
| 212 | while (fp) { | 201 | while (fp) { |
| 213 | struct sk_buff *xp = fp->next; | 202 | struct sk_buff *xp = fp->next; |
| 214 | 203 | ||
| @@ -222,7 +211,7 @@ static void ip_frag_destroy(struct ipq *qp, int *work) | |||
| 222 | 211 | ||
| 223 | static __inline__ void ipq_put(struct ipq *ipq, int *work) | 212 | static __inline__ void ipq_put(struct ipq *ipq, int *work) |
| 224 | { | 213 | { |
| 225 | if (atomic_dec_and_test(&ipq->refcnt)) | 214 | if (atomic_dec_and_test(&ipq->q.refcnt)) |
| 226 | ip_frag_destroy(ipq, work); | 215 | ip_frag_destroy(ipq, work); |
| 227 | } | 216 | } |
| 228 | 217 | ||
| @@ -231,13 +220,13 @@ static __inline__ void ipq_put(struct ipq *ipq, int *work) | |||
| 231 | */ | 220 | */ |
| 232 | static void ipq_kill(struct ipq *ipq) | 221 | static void ipq_kill(struct ipq *ipq) |
| 233 | { | 222 | { |
| 234 | if (del_timer(&ipq->timer)) | 223 | if (del_timer(&ipq->q.timer)) |
| 235 | atomic_dec(&ipq->refcnt); | 224 | atomic_dec(&ipq->q.refcnt); |
| 236 | 225 | ||
| 237 | if (!(ipq->last_in & COMPLETE)) { | 226 | if (!(ipq->q.last_in & COMPLETE)) { |
| 238 | ipq_unlink(ipq); | 227 | ipq_unlink(ipq); |
| 239 | atomic_dec(&ipq->refcnt); | 228 | atomic_dec(&ipq->q.refcnt); |
| 240 | ipq->last_in |= COMPLETE; | 229 | ipq->q.last_in |= COMPLETE; |
| 241 | } | 230 | } |
| 242 | } | 231 | } |
| 243 | 232 | ||
| @@ -261,14 +250,14 @@ static void ip_evictor(void) | |||
| 261 | return; | 250 | return; |
| 262 | } | 251 | } |
| 263 | tmp = ipq_lru_list.next; | 252 | tmp = ipq_lru_list.next; |
| 264 | qp = list_entry(tmp, struct ipq, lru_list); | 253 | qp = list_entry(tmp, struct ipq, q.lru_list); |
| 265 | atomic_inc(&qp->refcnt); | 254 | atomic_inc(&qp->q.refcnt); |
| 266 | read_unlock(&ipfrag_lock); | 255 | read_unlock(&ipfrag_lock); |
| 267 | 256 | ||
| 268 | spin_lock(&qp->lock); | 257 | spin_lock(&qp->q.lock); |
| 269 | if (!(qp->last_in&COMPLETE)) | 258 | if (!(qp->q.last_in&COMPLETE)) |
| 270 | ipq_kill(qp); | 259 | ipq_kill(qp); |
| 271 | spin_unlock(&qp->lock); | 260 | spin_unlock(&qp->q.lock); |
| 272 | 261 | ||
| 273 | ipq_put(qp, &work); | 262 | ipq_put(qp, &work); |
| 274 | IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); | 263 | IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); |
| @@ -282,9 +271,9 @@ static void ip_expire(unsigned long arg) | |||
| 282 | { | 271 | { |
| 283 | struct ipq *qp = (struct ipq *) arg; | 272 | struct ipq *qp = (struct ipq *) arg; |
| 284 | 273 | ||
| 285 | spin_lock(&qp->lock); | 274 | spin_lock(&qp->q.lock); |
| 286 | 275 | ||
| 287 | if (qp->last_in & COMPLETE) | 276 | if (qp->q.last_in & COMPLETE) |
| 288 | goto out; | 277 | goto out; |
| 289 | 278 | ||
