Skip to contentSkip to conversation

nfnetlink_log: Kill duplicate code

PATCH In review Michał Mirosław 2 participants 3 messages Sep 21, 2007 – Sep 24, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 nfnetlink_log: Kill duplicate code

Kill some cut'n'paste effect.
Just after __nfulnl_send() returning, inst->skb is always NULL.

net/netfilter/nfnetlink_log.c +14 -16
diff -urN linux-2.6.22.3-routes-ck1-r4/net/netfilter/nfnetlink_log.c lq1/net/netfilter/nfnetlink_log.c
@@ -189,7 +189,7 @@
 	return NULL;
 }
 
-static int __nfulnl_send(struct nfulnl_instance *inst);
+static int __nfulnl_flush(struct nfulnl_instance *inst);
 
 static void
 __instance_destroy(struct nfulnl_instance *inst)
@@ -203,17 +203,8 @@
 	/* 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 */
@@ -363,6 +354,16 @@
 	return status;
 }
 
+static int
+__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;
@@ -649,10 +650,7 @@
 		 * 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) {

-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw
Quoted 2 lines · Micha³ Miros³aw

Kill some cut'n'paste effect.
Just after __nfulnl_send() returning, inst->skb is always NULL.

This patch introduces a warning:

net/netfilter/nfnetlink_log.c: In function '__nfulnl_flush':
net/netfilter/nfnetlink_log.c:365: warning: control reaches end of non-void function

I fixed it by changing __nfulnl_flush to void, but please make sure this doesn't happen again.

-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 10 lines · Patrick McHardy
Quoted 2 lines · Micha³ Miros³aw

Kill some cut'n'paste effect.
Just after __nfulnl_send() returning, inst->skb is always NULL.

This patch introduces a warning:
net/netfilter/nfnetlink_log.c: In function '__nfulnl_flush':
net/netfilter/nfnetlink_log.c:365: warning: control reaches end of non-void function

I fixed it by changing __nfulnl_flush to void, but please make sure this doesn't happen again.

Ah... Looks like no one is interested a value returned by __nfulnl_send() but nevertheless it's there... I'll keep my eyes open wider next time.

Thanks,
Michal Miroslaw
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html