mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-18 10:17:39 +07:00
[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 <ioe-lkml@rameria.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b3e83d6d18
commit
78c784c47a
@ -203,7 +203,7 @@ static inline void frag_free_queue(struct frag_queue *fq, int *work)
|
|||||||
|
|
||||||
static inline struct frag_queue *frag_alloc_queue(void)
|
static inline struct frag_queue *frag_alloc_queue(void)
|
||||||
{
|
{
|
||||||
struct frag_queue *fq = kmalloc(sizeof(struct frag_queue), GFP_ATOMIC);
|
struct frag_queue *fq = kzalloc(sizeof(struct frag_queue), GFP_ATOMIC);
|
||||||
|
|
||||||
if(!fq)
|
if(!fq)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -288,6 +288,7 @@ static void ip6_evictor(void)
|
|||||||
static void ip6_frag_expire(unsigned long data)
|
static void ip6_frag_expire(unsigned long data)
|
||||||
{
|
{
|
||||||
struct frag_queue *fq = (struct frag_queue *) data;
|
struct frag_queue *fq = (struct frag_queue *) data;
|
||||||
|
struct net_device *dev;
|
||||||
|
|
||||||
spin_lock(&fq->lock);
|
spin_lock(&fq->lock);
|
||||||
|
|
||||||
@ -299,22 +300,22 @@ static void ip6_frag_expire(unsigned long data)
|
|||||||
IP6_INC_STATS_BH(IPSTATS_MIB_REASMTIMEOUT);
|
IP6_INC_STATS_BH(IPSTATS_MIB_REASMTIMEOUT);
|
||||||
IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
|
IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
|
||||||
|
|
||||||
/* Send error only if the first segment arrived. */
|
/* Don't send error if the first segment did not arrive. */
|
||||||
if (fq->last_in&FIRST_IN && fq->fragments) {
|
if (!(fq->last_in&FIRST_IN) || !fq->fragments)
|
||||||
struct net_device *dev = dev_get_by_index(fq->iif);
|
goto out;
|
||||||
|
|
||||||
|
dev = dev_get_by_index(fq->iif);
|
||||||
|
if (!dev)
|
||||||
|
goto out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
But use as source device on which LAST ARRIVED
|
But use as source device on which LAST ARRIVED
|
||||||
segment was received. And do not use fq->dev
|
segment was received. And do not use fq->dev
|
||||||
pointer directly, device might already disappeared.
|
pointer directly, device might already disappeared.
|
||||||
*/
|
*/
|
||||||
if (dev) {
|
|
||||||
fq->fragments->dev = dev;
|
fq->fragments->dev = dev;
|
||||||
icmpv6_send(fq->fragments, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0,
|
icmpv6_send(fq->fragments, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0, dev);
|
||||||
dev);
|
|
||||||
dev_put(dev);
|
dev_put(dev);
|
||||||
}
|
|
||||||
}
|
|
||||||
out:
|
out:
|
||||||
spin_unlock(&fq->lock);
|
spin_unlock(&fq->lock);
|
||||||
fq_put(fq, NULL);
|
fq_put(fq, NULL);
|
||||||
@ -368,8 +369,6 @@ ip6_frag_create(unsigned int hash, u32 id, struct in6_addr *src, struct in6_addr
|
|||||||
if ((fq = frag_alloc_queue()) == NULL)
|
if ((fq = frag_alloc_queue()) == NULL)
|
||||||
goto oom;
|
goto oom;
|
||||||
|
|
||||||
memset(fq, 0, sizeof(struct frag_queue));
|
|
||||||
|
|
||||||
fq->id = id;
|
fq->id = id;
|
||||||
ipv6_addr_copy(&fq->saddr, src);
|
ipv6_addr_copy(&fq->saddr, src);
|
||||||
ipv6_addr_copy(&fq->daddr, dst);
|
ipv6_addr_copy(&fq->daddr, dst);
|
||||||
|
Loading…
Reference in New Issue
Block a user