netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] act_mirred: optimization
@ 2009-11-16  8:56 Changli Gao
  2009-11-16  9:29 ` jamal
  0 siblings, 1 reply; 16+ messages in thread
From: Changli Gao @ 2009-11-16  8:56 UTC (permalink / raw)
  To: Jamal Hadi Salim; +Cc: David S. Miller, Stephen Hemminger, netdev, Changli Gao

act_mirred: optimization.

1. move checking if eaction is valid in tcf_mirred_init()
2. fixed a race condition between __dev_get_by_index() and dev_get()

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
 act_mirred.c |   67
 +++++++++++++++++++++++++++++------------------------------
  1 file changed, 34 insertions(+), 33 deletions(-)
--- a/net/sched/act_mirred.c	2009-11-16 16:21:21.000000000 +0800
+++ b/net/sched/act_mirred.c	2009-11-16 16:25:37.000000000 +0800
@@ -65,52 +65,61 @@
 	struct tc_mirred *parm;
 	struct tcf_mirred *m;
 	struct tcf_common *pc;
-	struct net_device *dev = NULL;
-	int ret = 0, err;
-	int ok_push = 0;
+	struct net_device *dev;
+	int ret, ok_push = 0;

 	if (nla == NULL)
 		return -EINVAL;
-
-	err = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, mirred_policy);
-	if (err < 0)
-		return err;
-
+	ret = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, mirred_policy);
+	if (ret < 0)
+		return ret;
 	if (tb[TCA_MIRRED_PARMS] == NULL)
 		return -EINVAL;
 	parm = nla_data(tb[TCA_MIRRED_PARMS]);
-
+	switch (parm->eaction) {
+	case TCA_EGRESS_MIRROR:
+	case TCA_EGRESS_REDIR:
+		break;
+	default:
+		return -EINVAL;
+	}
 	if (parm->ifindex) {
-		dev = __dev_get_by_index(&init_net, parm->ifindex);
+		dev = dev_get_by_index(&init_net, parm->ifindex);
 		if (dev == NULL)
 			return -ENODEV;
 		switch (dev->type) {
-			case ARPHRD_TUNNEL:
-			case ARPHRD_TUNNEL6:
-			case ARPHRD_SIT:
-			case ARPHRD_IPGRE:
-			case ARPHRD_VOID:
-			case ARPHRD_NONE:
-				ok_push = 0;
-				break;
-			default:
-				ok_push = 1;
-				break;
+		case ARPHRD_TUNNEL:
+		case ARPHRD_TUNNEL6:
+		case ARPHRD_SIT:
+		case ARPHRD_IPGRE:
+		case ARPHRD_VOID:
+		case ARPHRD_NONE:
+			ok_push = 0;
+			break;
+		default:
+			ok_push = 1;
+			break;
 		}
+	} else {
+		dev = NULL;
 	}

 	pc = tcf_hash_check(parm->index, a, bind, &mirred_hash_info);
 	if (!pc) {
-		if (!parm->ifindex)
+		if (dev == NULL)
 			return -EINVAL;
 		pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind,
 				     &mirred_idx_gen, &mirred_hash_info);
-		if (IS_ERR(pc))
-		    return PTR_ERR(pc);
+		if (IS_ERR(pc)) {
+			dev_put(dev);
+			return PTR_ERR(pc);
+		}
 		ret = ACT_P_CREATED;
 	} else {
 		if (!ovr) {
 			tcf_mirred_release(to_mirred(pc), bind);
+			if (dev != NULL)
+				dev_put(dev);
 			return -EEXIST;
 		}
 	}
@@ -119,12 +128,11 @@
 	spin_lock_bh(&m->tcf_lock);
 	m->tcf_action = parm->action;
 	m->tcfm_eaction = parm->eaction;
-	if (parm->ifindex) {
+	if (dev != NULL) {
 		m->tcfm_ifindex = parm->ifindex;
 		if (ret != ACT_P_CREATED)
 			dev_put(m->tcfm_dev);
 		m->tcfm_dev = dev;
-		dev_hold(dev);
 		m->tcfm_ok_push = ok_push;
 	}
 	spin_unlock_bh(&m->tcf_lock);
@@ -154,13 +162,6 @@

 	spin_lock(&m->tcf_lock);
 	m->tcf_tm.lastuse = jiffies;
-	if (m->tcfm_eaction != TCA_EGRESS_MIRROR &&
-	    m->tcfm_eaction != TCA_EGRESS_REDIR) {
-		if (net_ratelimit())
-			printk("tcf_mirred unknown action %d\n",
-			       m->tcfm_eaction);
-		goto out;
-	}

 	dev = m->tcfm_dev;
 	if (!(dev->flags & IFF_UP)) {

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16  8:56 Changli Gao
@ 2009-11-16  9:29 ` jamal
  2009-11-16  9:40   ` Changli Gao
  0 siblings, 1 reply; 16+ messages in thread
From: jamal @ 2009-11-16  9:29 UTC (permalink / raw)
  To: Changli Gao; +Cc: David S. Miller, Stephen Hemminger, netdev

On Mon, 2009-11-16 at 16:56 +0800, Changli Gao wrote:
> act_mirred: optimization.
> 
> 1. move checking if eaction is valid in tcf_mirred_init()

This one looks ok - and like i mentioned earlier it should be
a patch on its own. Can you please make it a separate patch,
test it and add my signed-off?

> 2. fixed a race condition between __dev_get_by_index() and dev_get()

This one i am not sure. What broke to motivate the patch?
Also note: if you moved things into _init() I am pretty sure
we have at least rtnl held.

cheers,
jamal




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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16  9:29 ` jamal
@ 2009-11-16  9:40   ` Changli Gao
  0 siblings, 0 replies; 16+ messages in thread
From: Changli Gao @ 2009-11-16  9:40 UTC (permalink / raw)
  To: hadi; +Cc: David S. Miller, Stephen Hemminger, netdev

On Mon, Nov 16, 2009 at 5:29 PM, jamal <hadi@cyberus.ca> wrote:
> On Mon, 2009-11-16 at 16:56 +0800, Changli Gao wrote:
>> act_mirred: optimization.
>>
>> 1. move checking if eaction is valid in tcf_mirred_init()
>
> This one looks ok - and like i mentioned earlier it should be
> a patch on its own. Can you please make it a separate patch,
> test it and add my signed-off?
>
>> 2. fixed a race condition between __dev_get_by_index() and dev_get()
>
> This one i am not sure. What broke to motivate the patch?
> Also note: if you moved things into _init() I am pretty sure
> we have at least rtnl held.
>

OK, I'll use the old __dev_get_by_index() and post the patch with your
signed-off again. Thanks.



-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

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

* [PATCH 2/2] act_mirred: optimization
@ 2009-11-16  9:53 Changli Gao
  2009-11-16 10:06 ` jamal
  2009-11-16 10:48 ` David Miller
  0 siblings, 2 replies; 16+ messages in thread
From: Changli Gao @ 2009-11-16  9:53 UTC (permalink / raw)
  To: Jamal Hadi Salim; +Cc: David S. Miller, Stephen Hemminger, netdev, Changli Gao

act_mirred: optimization.

move checking if eaction is valid in tcf_mirred_init()

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
----
 net/sched/act_mirred.c |   60
 +++++++++++++++++++++++--------------------------
  1 file changed, 29 insertions(+), 31 deletions(-)
--- a/net/sched/act_mirred.c	2009-11-16 16:21:21.000000000 +0800
+++ b/net/sched/act_mirred.c	2009-11-16 17:43:37.000000000 +0800
@@ -65,48 +65,53 @@
 	struct tc_mirred *parm;
 	struct tcf_mirred *m;
 	struct tcf_common *pc;
-	struct net_device *dev = NULL;
-	int ret = 0, err;
-	int ok_push = 0;
+	struct net_device *dev;
+	int ret, ok_push = 0;

 	if (nla == NULL)
 		return -EINVAL;
-
-	err = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, mirred_policy);
-	if (err < 0)
-		return err;
-
+	ret = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, mirred_policy);
+	if (ret < 0)
+		return ret;
 	if (tb[TCA_MIRRED_PARMS] == NULL)
 		return -EINVAL;
 	parm = nla_data(tb[TCA_MIRRED_PARMS]);
-
+	switch (parm->eaction) {
+	case TCA_EGRESS_MIRROR:
+	case TCA_EGRESS_REDIR:
+		break;
+	default:
+		return -EINVAL;
+	}
 	if (parm->ifindex) {
 		dev = __dev_get_by_index(&init_net, parm->ifindex);
 		if (dev == NULL)
 			return -ENODEV;
 		switch (dev->type) {
-			case ARPHRD_TUNNEL:
-			case ARPHRD_TUNNEL6:
-			case ARPHRD_SIT:
-			case ARPHRD_IPGRE:
-			case ARPHRD_VOID:
-			case ARPHRD_NONE:
-				ok_push = 0;
-				break;
-			default:
-				ok_push = 1;
-				break;
+		case ARPHRD_TUNNEL:
+		case ARPHRD_TUNNEL6:
+		case ARPHRD_SIT:
+		case ARPHRD_IPGRE:
+		case ARPHRD_VOID:
+		case ARPHRD_NONE:
+			ok_push = 0;
+			break;
+		default:
+			ok_push = 1;
+			break;
 		}
+	} else {
+		dev = NULL;
 	}

 	pc = tcf_hash_check(parm->index, a, bind, &mirred_hash_info);
 	if (!pc) {
-		if (!parm->ifindex)
+		if (dev == NULL)
 			return -EINVAL;
 		pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind,
 				     &mirred_idx_gen, &mirred_hash_info);
 		if (IS_ERR(pc))
-		    return PTR_ERR(pc);
+			return PTR_ERR(pc);
 		ret = ACT_P_CREATED;
 	} else {
 		if (!ovr) {
@@ -119,12 +124,12 @@
 	spin_lock_bh(&m->tcf_lock);
 	m->tcf_action = parm->action;
 	m->tcfm_eaction = parm->eaction;
-	if (parm->ifindex) {
+	if (dev != NULL) {
 		m->tcfm_ifindex = parm->ifindex;
 		if (ret != ACT_P_CREATED)
 			dev_put(m->tcfm_dev);
-		m->tcfm_dev = dev;
 		dev_hold(dev);
+		m->tcfm_dev = dev;
 		m->tcfm_ok_push = ok_push;
 	}
 	spin_unlock_bh(&m->tcf_lock);
@@ -154,13 +159,6 @@

 	spin_lock(&m->tcf_lock);
 	m->tcf_tm.lastuse = jiffies;
-	if (m->tcfm_eaction != TCA_EGRESS_MIRROR &&
-	    m->tcfm_eaction != TCA_EGRESS_REDIR) {
-		if (net_ratelimit())
-			printk("tcf_mirred unknown action %d\n",
-			       m->tcfm_eaction);
-		goto out;
-	}

 	dev = m->tcfm_dev;
 	if (!(dev->flags & IFF_UP)) {

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16  9:53 [PATCH 2/2] act_mirred: optimization Changli Gao
@ 2009-11-16 10:06 ` jamal
  2009-11-16 10:21   ` David Miller
  2009-11-16 10:48 ` David Miller
  1 sibling, 1 reply; 16+ messages in thread
From: jamal @ 2009-11-16 10:06 UTC (permalink / raw)
  To: Changli Gao; +Cc: David S. Miller, Stephen Hemminger, netdev

On Mon, 2009-11-16 at 17:53 +0800, Changli Gao wrote:

Just one small comment; sorry, i missed this the first time:

> +		if (dev == NULL)
>  			return -EINVAL;
>  		pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind,
>  				     &mirred_idx_gen, &mirred_hash_info);
>  		if (IS_ERR(pc))
> -		    return PTR_ERR(pc);
> +			return PTR_ERR(pc);

One indent too many? 

cheers,
jamal


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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 10:06 ` jamal
@ 2009-11-16 10:21   ` David Miller
  2009-11-16 10:24     ` jamal
  0 siblings, 1 reply; 16+ messages in thread
From: David Miller @ 2009-11-16 10:21 UTC (permalink / raw)
  To: hadi; +Cc: xiaosuo, shemminger, netdev

From: jamal <hadi@cyberus.ca>
Date: Mon, 16 Nov 2009 05:06:30 -0500

> On Mon, 2009-11-16 at 17:53 +0800, Changli Gao wrote:
> 
> Just one small comment; sorry, i missed this the first time:
> 
>> +		if (dev == NULL)
>>  			return -EINVAL;
>>  		pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind,
>>  				     &mirred_idx_gen, &mirred_hash_info);
>>  		if (IS_ERR(pc))
>> -		    return PTR_ERR(pc);
>> +			return PTR_ERR(pc);
> 
> One indent too many? 

It's actually fixing some stray space characters into a real proper
tab character.

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 10:21   ` David Miller
@ 2009-11-16 10:24     ` jamal
  0 siblings, 0 replies; 16+ messages in thread
From: jamal @ 2009-11-16 10:24 UTC (permalink / raw)
  To: David Miller; +Cc: xiaosuo, shemminger, netdev

On Mon, 2009-11-16 at 02:21 -0800, David Miller wrote:
> From: jamal <hadi@cyberus.ca>
> Date: Mon, 16 Nov 2009 05:06:30 -0500
 
> > One indent too many? 
> 
> It's actually fixing some stray space characters into a real proper
> tab character.

good enough for me then.

cheers,
jamal


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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16  9:53 [PATCH 2/2] act_mirred: optimization Changli Gao
  2009-11-16 10:06 ` jamal
@ 2009-11-16 10:48 ` David Miller
  2009-11-16 10:58   ` David Miller
  1 sibling, 1 reply; 16+ messages in thread
From: David Miller @ 2009-11-16 10:48 UTC (permalink / raw)
  To: xiaosuo; +Cc: hadi, shemminger, netdev

From: Changli Gao <xiaosuo@gmail.com>
Date: Mon, 16 Nov 2009 17:53:29 +0800

> act_mirred: optimization.
> 
> move checking if eaction is valid in tcf_mirred_init()
> 
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>

Also applied, thank you.

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 10:48 ` David Miller
@ 2009-11-16 10:58   ` David Miller
  2009-11-16 13:05     ` Changli Gao
  0 siblings, 1 reply; 16+ messages in thread
From: David Miller @ 2009-11-16 10:58 UTC (permalink / raw)
  To: xiaosuo; +Cc: hadi, shemminger, netdev

From: David Miller <davem@davemloft.net>
Date: Mon, 16 Nov 2009 02:48:39 -0800 (PST)

> From: Changli Gao <xiaosuo@gmail.com>
> Date: Mon, 16 Nov 2009 17:53:29 +0800
> 
>> act_mirred: optimization.
>> 
>> move checking if eaction is valid in tcf_mirred_init()
>> 
>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>> Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
> 
> Also applied, thank you.

Nevermind, you're NOT TESTING the patches you are posting:

net/sched/act_mirred.c: In function ‘tcf_mirred’:
net/sched/act_mirred.c:168: error: label ‘out’ used but not defined
net/sched/act_mirred.c:158: warning: unused variable ‘err’
net/sched/act_mirred.c:158: warning: unused variable ‘retval’
make[2]: *** [net/sched/act_mirred.o] Error 1
make[1]: *** [net/sched] Error 2
make[1]: *** Waiting for unfinished jobs....

I'm thus reverting both changes.

Don't submit changes which are untested, it wastes my time.

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 10:58   ` David Miller
@ 2009-11-16 13:05     ` Changli Gao
  2009-11-16 13:17       ` David Miller
  2009-11-16 13:27       ` Jarek Poplawski
  0 siblings, 2 replies; 16+ messages in thread
From: Changli Gao @ 2009-11-16 13:05 UTC (permalink / raw)
  To: David Miller; +Cc: hadi, shemminger, netdev

On Mon, Nov 16, 2009 at 6:58 PM, David Miller <davem@davemloft.net> wrote:
> From: David Miller <davem@davemloft.net>
> Date: Mon, 16 Nov 2009 02:48:39 -0800 (PST)
>
>> From: Changli Gao <xiaosuo@gmail.com>
>> Date: Mon, 16 Nov 2009 17:53:29 +0800
>>
>>> act_mirred: optimization.
>>>
>>> move checking if eaction is valid in tcf_mirred_init()
>>>
>>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>>> Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
>>
>> Also applied, thank you.
>
> Nevermind, you're NOT TESTING the patches you are posting:
>
> net/sched/act_mirred.c: In function ‘tcf_mirred’:
> net/sched/act_mirred.c:168: error: label ‘out’ used but not defined
> net/sched/act_mirred.c:158: warning: unused variable ‘err’
> net/sched/act_mirred.c:158: warning: unused variable ‘retval’
> make[2]: *** [net/sched/act_mirred.o] Error 1
> make[1]: *** [net/sched] Error 2
> make[1]: *** Waiting for unfinished jobs....
>
> I'm thus reverting both changes.
>
> Don't submit changes which are untested, it wastes my time.
>

I am sorry about that. But I did test it before submitting these two,
and I am just wondering if they are applied without any error. Would
you post the file after being patched? I think it will be helpful to
finger out the real problem.

BTW: since my email client thunderbird was broken, I used google
webmail(with ViewSourceWith addon) to submit these two patches.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 13:05     ` Changli Gao
@ 2009-11-16 13:17       ` David Miller
  2009-11-16 13:22         ` Changli Gao
  2009-11-16 13:27       ` Jarek Poplawski
  1 sibling, 1 reply; 16+ messages in thread
From: David Miller @ 2009-11-16 13:17 UTC (permalink / raw)
  To: xiaosuo; +Cc: hadi, shemminger, netdev

From: Changli Gao <xiaosuo@gmail.com>
Date: Mon, 16 Nov 2009 21:05:28 +0800

> I am sorry about that. But I did test it before submitting these two,
> and I am just wondering if they are applied without any error. Would
> you post the file after being patched? I think it will be helpful to
> finger out the real problem.

I don't have time for that sorry.

I think the problem might be that you are developing against
either net-2.6 or Linus's tree, whereas you should be working
against net-next-2.6

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 13:17       ` David Miller
@ 2009-11-16 13:22         ` Changli Gao
  2009-11-16 13:33           ` David Miller
  0 siblings, 1 reply; 16+ messages in thread
From: Changli Gao @ 2009-11-16 13:22 UTC (permalink / raw)
  To: David Miller; +Cc: hadi, shemminger, netdev

On Mon, Nov 16, 2009 at 9:17 PM, David Miller <davem@davemloft.net> wrote:
> From: Changli Gao <xiaosuo@gmail.com>
> Date: Mon, 16 Nov 2009 21:05:28 +0800
>
>> I am sorry about that. But I did test it before submitting these two,
>> and I am just wondering if they are applied without any error. Would
>> you post the file after being patched? I think it will be helpful to
>> finger out the real problem.
>
> I don't have time for that sorry.

Thanks all the same!

>
> I think the problem might be that you are developing against
> either net-2.6 or Linus's tree, whereas you should be working
> against net-next-2.6
>

I am working against linux-next. I'll check if there is any
difference. BTW: were these patches applied in order, 1 - 2?

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 13:05     ` Changli Gao
  2009-11-16 13:17       ` David Miller
@ 2009-11-16 13:27       ` Jarek Poplawski
  1 sibling, 0 replies; 16+ messages in thread
From: Jarek Poplawski @ 2009-11-16 13:27 UTC (permalink / raw)
  To: Changli Gao; +Cc: David Miller, hadi, shemminger, netdev

On 16-11-2009 14:05, Changli Gao wrote:
> On Mon, Nov 16, 2009 at 6:58 PM, David Miller <davem@davemloft.net> wrote:
>> From: David Miller <davem@davemloft.net>
>> Date: Mon, 16 Nov 2009 02:48:39 -0800 (PST)
>>
>>> From: Changli Gao <xiaosuo@gmail.com>
>>> Date: Mon, 16 Nov 2009 17:53:29 +0800
>>>
>>>> act_mirred: optimization.
>>>>
>>>> move checking if eaction is valid in tcf_mirred_init()
>>>>
>>>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>>>> Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
>>> Also applied, thank you.
>> Nevermind, you're NOT TESTING the patches you are posting:
>>
>> net/sched/act_mirred.c: In function â??tcf_mirredâ??:
>> net/sched/act_mirred.c:168: error: label â??outâ?? used but not defined
>> net/sched/act_mirred.c:158: warning: unused variable â??errâ??
>> net/sched/act_mirred.c:158: warning: unused variable â??retvalâ??
>> make[2]: *** [net/sched/act_mirred.o] Error 1
>> make[1]: *** [net/sched] Error 2
>> make[1]: *** Waiting for unfinished jobs....
>>
>> I'm thus reverting both changes.
>>
>> Don't submit changes which are untested, it wastes my time.
>>
> 
> I am sorry about that. But I did test it before submitting these two,
> and I am just wondering if they are applied without any error. Would
> you post the file after being patched? I think it will be helpful to
> finger out the real problem.
> 
> BTW: since my email client thunderbird was broken, I used google
> webmail(with ViewSourceWith addon) to submit these two patches.
> 

It seems PATCH 1/2 might be broken by email (but I got it second hand
from gmail). checkpatch output:

ERROR: patch seems to be corrupt (line wrapped?)
#17: FILE: net/sched/act_mirred.c:147:
struct tc_action *a,

WARNING: printk() should include KERN_ facility level
#34: FILE: net/sched/act_mirred.c:160:
+                       printk("tcf_mirred unknown action %d\n",

total: 1 errors, 1 warnings, 89 lines checked

mirred1.diff has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Jarek P.

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 13:22         ` Changli Gao
@ 2009-11-16 13:33           ` David Miller
  2009-11-17  5:49             ` Changli Gao
  0 siblings, 1 reply; 16+ messages in thread
From: David Miller @ 2009-11-16 13:33 UTC (permalink / raw)
  To: xiaosuo; +Cc: hadi, shemminger, netdev

From: Changli Gao <xiaosuo@gmail.com>
Date: Mon, 16 Nov 2009 21:22:46 +0800

> I am working against linux-next. I'll check if there is any
> difference. BTW: were these patches applied in order, 1 - 2?

Yes, they were.

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-16 13:33           ` David Miller
@ 2009-11-17  5:49             ` Changli Gao
  2009-11-17 12:16               ` David Miller
  0 siblings, 1 reply; 16+ messages in thread
From: Changli Gao @ 2009-11-17  5:49 UTC (permalink / raw)
  To: David Miller; +Cc: hadi, shemminger, netdev

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

On Mon, Nov 16, 2009 at 9:33 PM, David Miller <davem@davemloft.net> wrote:
> From: Changli Gao <xiaosuo@gmail.com>
> Date: Mon, 16 Nov 2009 21:22:46 +0800
>
>> I am working against linux-next. I'll check if there is any
>> difference. BTW: were these patches applied in order, 1 - 2?
>
> Yes, they were.
>

Patch is resubmitted as attachment.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

[-- Attachment #2: act_mirred_opt.diff --]
[-- Type: application/octet-stream, Size: 2485 bytes --]

--- a/net/sched/act_mirred.c	2009-11-16 16:21:21.000000000 +0800
+++ b/net/sched/act_mirred.c	2009-11-16 17:43:37.000000000 +0800
@@ -65,48 +65,53 @@
 	struct tc_mirred *parm;
 	struct tcf_mirred *m;
 	struct tcf_common *pc;
-	struct net_device *dev = NULL;
-	int ret = 0, err;
-	int ok_push = 0;
+	struct net_device *dev;
+	int ret, ok_push = 0;
 
 	if (nla == NULL)
 		return -EINVAL;
-
-	err = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, mirred_policy);
-	if (err < 0)
-		return err;
-
+	ret = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, mirred_policy);
+	if (ret < 0)
+		return ret;
 	if (tb[TCA_MIRRED_PARMS] == NULL)
 		return -EINVAL;
 	parm = nla_data(tb[TCA_MIRRED_PARMS]);
-
+	switch (parm->eaction) {
+	case TCA_EGRESS_MIRROR:
+	case TCA_EGRESS_REDIR:
+		break;
+	default:
+		return -EINVAL;
+	}
 	if (parm->ifindex) {
 		dev = __dev_get_by_index(&init_net, parm->ifindex);
 		if (dev == NULL)
 			return -ENODEV;
 		switch (dev->type) {
-			case ARPHRD_TUNNEL:
-			case ARPHRD_TUNNEL6:
-			case ARPHRD_SIT:
-			case ARPHRD_IPGRE:
-			case ARPHRD_VOID:
-			case ARPHRD_NONE:
-				ok_push = 0;
-				break;
-			default:
-				ok_push = 1;
-				break;
+		case ARPHRD_TUNNEL:
+		case ARPHRD_TUNNEL6:
+		case ARPHRD_SIT:
+		case ARPHRD_IPGRE:
+		case ARPHRD_VOID:
+		case ARPHRD_NONE:
+			ok_push = 0;
+			break;
+		default:
+			ok_push = 1;
+			break;
 		}
+	} else {
+		dev = NULL;
 	}
 
 	pc = tcf_hash_check(parm->index, a, bind, &mirred_hash_info);
 	if (!pc) {
-		if (!parm->ifindex)
+		if (dev == NULL)
 			return -EINVAL;
 		pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind,
 				     &mirred_idx_gen, &mirred_hash_info);
 		if (IS_ERR(pc))
-		    return PTR_ERR(pc);
+			return PTR_ERR(pc);
 		ret = ACT_P_CREATED;
 	} else {
 		if (!ovr) {
@@ -119,12 +124,12 @@
 	spin_lock_bh(&m->tcf_lock);
 	m->tcf_action = parm->action;
 	m->tcfm_eaction = parm->eaction;
-	if (parm->ifindex) {
+	if (dev != NULL) {
 		m->tcfm_ifindex = parm->ifindex;
 		if (ret != ACT_P_CREATED)
 			dev_put(m->tcfm_dev);
-		m->tcfm_dev = dev;
 		dev_hold(dev);
+		m->tcfm_dev = dev;
 		m->tcfm_ok_push = ok_push;
 	}
 	spin_unlock_bh(&m->tcf_lock);
@@ -154,13 +159,6 @@
 
 	spin_lock(&m->tcf_lock);
 	m->tcf_tm.lastuse = jiffies;
-	if (m->tcfm_eaction != TCA_EGRESS_MIRROR &&
-	    m->tcfm_eaction != TCA_EGRESS_REDIR) {
-		if (net_ratelimit())
-			printk("tcf_mirred unknown action %d\n",
-			       m->tcfm_eaction);
-		goto out;
-	}
 
 	dev = m->tcfm_dev;
 	if (!(dev->flags & IFF_UP)) {

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

* Re: [PATCH 2/2] act_mirred: optimization
  2009-11-17  5:49             ` Changli Gao
@ 2009-11-17 12:16               ` David Miller
  0 siblings, 0 replies; 16+ messages in thread
From: David Miller @ 2009-11-17 12:16 UTC (permalink / raw)
  To: xiaosuo; +Cc: hadi, shemminger, netdev

From: Changli Gao <xiaosuo@gmail.com>
Date: Tue, 17 Nov 2009 13:49:00 +0800

> On Mon, Nov 16, 2009 at 9:33 PM, David Miller <davem@davemloft.net> wrote:
>> From: Changli Gao <xiaosuo@gmail.com>
>> Date: Mon, 16 Nov 2009 21:22:46 +0800
>>
>>> I am working against linux-next. I'll check if there is any
>>> difference. BTW: were these patches applied in order, 1 - 2?
>>
>> Yes, they were.
>>
> 
> Patch is resubmitted as attachment.

Also applied, thanks.

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

end of thread, other threads:[~2009-11-17 12:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-16  9:53 [PATCH 2/2] act_mirred: optimization Changli Gao
2009-11-16 10:06 ` jamal
2009-11-16 10:21   ` David Miller
2009-11-16 10:24     ` jamal
2009-11-16 10:48 ` David Miller
2009-11-16 10:58   ` David Miller
2009-11-16 13:05     ` Changli Gao
2009-11-16 13:17       ` David Miller
2009-11-16 13:22         ` Changli Gao
2009-11-16 13:33           ` David Miller
2009-11-17  5:49             ` Changli Gao
2009-11-17 12:16               ` David Miller
2009-11-16 13:27       ` Jarek Poplawski
  -- strict thread matches above, loose matches on Subject: below --
2009-11-16  8:56 Changli Gao
2009-11-16  9:29 ` jamal
2009-11-16  9:40   ` Changli Gao

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).