Skip to content

Commit

Permalink
[NETFILTER]: nfnetlink_log: kill duplicate code
Browse files Browse the repository at this point in the history
Kill some cut'n'paste effect.
Just after __nfulnl_send() returning, inst->skb is always NULL.

Signed-off-by: Michal Miroslaw <[email protected]>
Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
osctobe authored and David S. Miller committed Oct 10, 2007
1 parent 5faa1f4 commit e356706
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions net/netfilter/nfnetlink_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ instance_create(u_int16_t group_num, int pid)
return NULL;
}

static int __nfulnl_send(struct nfulnl_instance *inst);
static void __nfulnl_flush(struct nfulnl_instance *inst);

static void
__instance_destroy(struct nfulnl_instance *inst)
Expand All @@ -202,17 +202,8 @@ __instance_destroy(struct nfulnl_instance *inst)
/* then flush all pending packets from skb */

spin_lock_bh(&inst->lock);
if (inst->skb) {
/* timer "holds" one reference (we have one more) */
if (del_timer(&inst->timer))
instance_put(inst);
if (inst->qlen)
__nfulnl_send(inst);
if (inst->skb) {
kfree_skb(inst->skb);
inst->skb = NULL;
}
}
if (inst->skb)
__nfulnl_flush(inst);
spin_unlock_bh(&inst->lock);

/* and finally put the refcount */
Expand Down Expand Up @@ -364,6 +355,16 @@ __nfulnl_send(struct nfulnl_instance *inst)
return status;
}

static void
__nfulnl_flush(struct nfulnl_instance *inst)
{
/* timer holds a reference */
if (del_timer(&inst->timer))
instance_put(inst);
if (inst->skb)
__nfulnl_send(inst);
}

static void nfulnl_timer(unsigned long data)
{
struct nfulnl_instance *inst = (struct nfulnl_instance *)data;
Expand Down Expand Up @@ -650,10 +651,7 @@ nfulnl_log_packet(unsigned int pf,
* enough room in the skb left. flush to userspace. */
UDEBUG("flushing old skb\n");

/* timer "holds" one reference (we have another one) */
if (del_timer(&inst->timer))
instance_put(inst);
__nfulnl_send(inst);
__nfulnl_flush(inst);
}

if (!inst->skb) {
Expand Down

0 comments on commit e356706

Please sign in to comment.