netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] act_mirred: combine duplicate code
@ 2010-06-30  8:54 Changli Gao
  2010-06-30 10:24 ` jamal
  0 siblings, 1 reply; 4+ messages in thread
From: Changli Gao @ 2010-06-30  8:54 UTC (permalink / raw)
  To: Jamal Hadi Salim; +Cc: David S. Miller, netdev, linux-kernel, Changli Gao

act_mirred: combine duplicate code

tcf_bstats is updated in any way, so we can do it earlier to reduce the size of
the code.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
 net/sched/act_mirred.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 2e9a7b9..a16b017 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -160,6 +160,8 @@ static int tcf_mirred(struct sk_buff *skb, struct tc_action *a,
 
 	spin_lock(&m->tcf_lock);
 	m->tcf_tm.lastuse = jiffies;
+	m->tcf_bstats.bytes += qdisc_pkt_len(skb);
+	m->tcf_bstats.packets++;
 
 	dev = m->tcfm_dev;
 	if (!(dev->flags & IFF_UP)) {
@@ -174,8 +176,6 @@ static int tcf_mirred(struct sk_buff *skb, struct tc_action *a,
 	if (skb2 == NULL)
 		goto out;
 
-	m->tcf_bstats.bytes += qdisc_pkt_len(skb2);
-	m->tcf_bstats.packets++;
 	if (!(at & AT_EGRESS)) {
 		if (m->tcfm_ok_push)
 			skb_push(skb2, skb2->dev->hard_header_len);
@@ -193,8 +193,6 @@ static int tcf_mirred(struct sk_buff *skb, struct tc_action *a,
 out:
 	if (err) {
 		m->tcf_qstats.overlimits++;
-		m->tcf_bstats.bytes += qdisc_pkt_len(skb);
-		m->tcf_bstats.packets++;
 		/* should we be asking for packet to be dropped?
 		 * may make sense for redirect case only
 		 */

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] act_mirred: combine duplicate code
  2010-06-30  8:54 [PATCH] act_mirred: combine duplicate code Changli Gao
@ 2010-06-30 10:24 ` jamal
  2010-06-30 10:49   ` jamal
  0 siblings, 1 reply; 4+ messages in thread
From: jamal @ 2010-06-30 10:24 UTC (permalink / raw)
  To: Changli Gao; +Cc: David S. Miller, netdev


removed lkml

On Wed, 2010-06-30 at 16:54 +0800, Changli Gao wrote:
> act_mirred: combine duplicate code
> 
> tcf_bstats is updated in any way, so we can do it earlier to reduce the size of
> the code.

There is one condition when !(dev->flags & IFF_UP) where we dont update
the stats in current code. This changes with your patch. 
It would make sense to actually update at that point (as you do) and
additionally increment some other counter to track that like
m->tcf_qstats.drops. I suggest resubmit with that change and add my
signed-off.

cheers,
jamal


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] act_mirred: combine duplicate code
  2010-06-30 10:24 ` jamal
@ 2010-06-30 10:49   ` jamal
  2010-06-30 19:13     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: jamal @ 2010-06-30 10:49 UTC (permalink / raw)
  To: Changli Gao; +Cc: David S. Miller, netdev

On Wed, 2010-06-30 at 06:24 -0400, jamal wrote:

> m->tcf_qstats.drops.

Sorry - this nagged me - we are already incrementing overlimits - we
should increment drops. Scratch that too. I am going to say your patch
as is:
signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>

cheers,
jamal


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] act_mirred: combine duplicate code
  2010-06-30 10:49   ` jamal
@ 2010-06-30 19:13     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-06-30 19:13 UTC (permalink / raw)
  To: hadi; +Cc: xiaosuo, netdev

From: jamal <hadi@cyberus.ca>
Date: Wed, 30 Jun 2010 06:49:02 -0400

> On Wed, 2010-06-30 at 06:24 -0400, jamal wrote:
> 
>> m->tcf_qstats.drops.
> 
> Sorry - this nagged me - we are already incrementing overlimits - we
> should increment drops. Scratch that too. I am going to say your patch
> as is:
> signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>

Applied.

Jamal, please capitalize "Signed-off-by" in the future, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-06-30 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-30  8:54 [PATCH] act_mirred: combine duplicate code Changli Gao
2010-06-30 10:24 ` jamal
2010-06-30 10:49   ` jamal
2010-06-30 19:13     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).