Skip to content

Commit 78c784c

Browse files
Ingo Oeserdavem330
authored andcommitted
[IPV6]: Cleanup of net/ipv6/reassambly.c
Two minor cleanups: 1. Using kzalloc() in fraq_alloc_queue() saves the memset() in ipv6_frag_create(). 2. Invert sense of if-statements to streamline code. Inverts the comment, too. Signed-off-by: Ingo Oeser <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b3e83d6 commit 78c784c

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

net/ipv6/reassembly.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static inline void frag_free_queue(struct frag_queue *fq, int *work)
203203

204204
static inline struct frag_queue *frag_alloc_queue(void)
205205
{
206-
struct frag_queue *fq = kmalloc(sizeof(struct frag_queue), GFP_ATOMIC);
206+
struct frag_queue *fq = kzalloc(sizeof(struct frag_queue), GFP_ATOMIC);
207207

208208
if(!fq)
209209
return NULL;
@@ -288,6 +288,7 @@ static void ip6_evictor(void)
288288
static void ip6_frag_expire(unsigned long data)
289289
{
290290
struct frag_queue *fq = (struct frag_queue *) data;
291+
struct net_device *dev;
291292

292293
spin_lock(&fq->lock);
293294

@@ -299,22 +300,22 @@ static void ip6_frag_expire(unsigned long data)
299300
IP6_INC_STATS_BH(IPSTATS_MIB_REASMTIMEOUT);
300301
IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
301302

302-
/* Send error only if the first segment arrived. */
303-
if (fq->last_in&FIRST_IN && fq->fragments) {
304-
struct net_device *dev = dev_get_by_index(fq->iif);
303+
/* Don't send error if the first segment did not arrive. */
304+
if (!(fq->last_in&FIRST_IN) || !fq->fragments)
305+
goto out;
305306

306-
/*
307-
But use as source device on which LAST ARRIVED
308-
segment was received. And do not use fq->dev
309-
pointer directly, device might already disappeared.
310-
*/
311-
if (dev) {
312-
fq->fragments->dev = dev;
313-
icmpv6_send(fq->fragments, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0,
314-
dev);
315-
dev_put(dev);
316-
}
317-
}
307+
dev = dev_get_by_index(fq->iif);
308+
if (!dev)
309+
goto out;
310+
311+
/*
312+
But use as source device on which LAST ARRIVED
313+
segment was received. And do not use fq->dev
314+
pointer directly, device might already disappeared.
315+
*/
316+
fq->fragments->dev = dev;
317+
icmpv6_send(fq->fragments, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0, dev);
318+
dev_put(dev);
318319
out:
319320
spin_unlock(&fq->lock);
320321
fq_put(fq, NULL);
@@ -368,8 +369,6 @@ ip6_frag_create(unsigned int hash, u32 id, struct in6_addr *src, struct in6_addr
368369
if ((fq = frag_alloc_queue()) == NULL)
369370
goto oom;
370371

371-
memset(fq, 0, sizeof(struct frag_queue));
372-
373372
fq->id = id;
374373
ipv6_addr_copy(&fq->saddr, src);
375374
ipv6_addr_copy(&fq->daddr, dst);

0 commit comments

Comments
 (0)