public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net/sched: cls_api: Fix nooffloaddevcnt counter in indr block call success
@ 2019-09-16 10:15 wenxu
  2019-09-16 10:28 ` Jiri Pirko
  0 siblings, 1 reply; 3+ messages in thread
From: wenxu @ 2019-09-16 10:15 UTC (permalink / raw)
  To: davem; +Cc: netdev

From: wenxu <wenxu@ucloud.cn>

When a block bind with a dev which support indr block call(vxlan/gretap
device). It can bind success but with nooffloaddevcnt++. It will fail
when replace the hw filter in tc_setup_cb_call with skip_sw mode for
checkout the nooffloaddevcnt and skip_sw.

if (block->nooffloaddevcnt && err_stop)
	return -EOPNOTSUPP;

So with this patch, if the indr block call success, it will not modify
the nooffloaddevcnt counter.

Fixes: 7f76fa36754b ("net: sched: register callbacks for indirect tc block binds")
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
 net/sched/cls_api.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index efd3cfb..8a1e3a5 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -766,10 +766,10 @@ void tc_indr_block_cb_unregister(struct net_device *dev,
 }
 EXPORT_SYMBOL_GPL(tc_indr_block_cb_unregister);
 
-static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
-			       struct tcf_block_ext_info *ei,
-			       enum flow_block_command command,
-			       struct netlink_ext_ack *extack)
+static int tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
+			      struct tcf_block_ext_info *ei,
+			      enum flow_block_command command,
+			      struct netlink_ext_ack *extack)
 {
 	struct tc_indr_block_cb *indr_block_cb;
 	struct tc_indr_block_dev *indr_dev;
@@ -785,7 +785,7 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
 
 	indr_dev = tc_indr_block_dev_lookup(dev);
 	if (!indr_dev)
-		return;
+		return -ENOENT;
 
 	indr_dev->block = command == FLOW_BLOCK_BIND ? block : NULL;
 
@@ -793,7 +793,10 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
 		indr_block_cb->cb(dev, indr_block_cb->cb_priv, TC_SETUP_BLOCK,
 				  &bo);
 
-	tcf_block_setup(block, &bo);
+	if (list_empty(&bo.cb_list))
+		return -EOPNOTSUPP;
+
+	return tcf_block_setup(block, &bo);
 }
 
 static bool tcf_block_offload_in_use(struct tcf_block *block)
@@ -849,14 +852,14 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,
 	if (err)
 		return err;
 
-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
 	return 0;
 
 no_offload_dev_inc:
 	if (tcf_block_offload_in_use(block))
 		return -EOPNOTSUPP;
-	block->nooffloaddevcnt++;
-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
+	err = tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
+	if (err)
+		block->nooffloaddevcnt++;
 	return 0;
 }
 
@@ -866,8 +869,6 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
 	struct net_device *dev = q->dev_queue->dev;
 	int err;
 
-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
-
 	if (!dev->netdev_ops->ndo_setup_tc)
 		goto no_offload_dev_dec;
 	err = tcf_block_offload_cmd(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
@@ -876,7 +877,9 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
 	return;
 
 no_offload_dev_dec:
-	WARN_ON(block->nooffloaddevcnt-- == 0);
+	err = tc_indr_block_call(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
+	if (err)
+		WARN_ON(block->nooffloaddevcnt-- == 0);
 }
 
 static int
-- 
1.8.3.1


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

* Re: [PATCH net] net/sched: cls_api: Fix nooffloaddevcnt counter in indr block call success
  2019-09-16 10:15 [PATCH net] net/sched: cls_api: Fix nooffloaddevcnt counter in indr block call success wenxu
@ 2019-09-16 10:28 ` Jiri Pirko
  2019-09-16 13:28   ` wenxu
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Pirko @ 2019-09-16 10:28 UTC (permalink / raw)
  To: wenxu; +Cc: davem, netdev

Please use get_maintainers script to get list of ccs.

Mon, Sep 16, 2019 at 12:15:34PM CEST, wenxu@ucloud.cn wrote:
>From: wenxu <wenxu@ucloud.cn>
>
>When a block bind with a dev which support indr block call(vxlan/gretap
>device). It can bind success but with nooffloaddevcnt++. It will fail
>when replace the hw filter in tc_setup_cb_call with skip_sw mode for
>checkout the nooffloaddevcnt and skip_sw.

I read this paragraph 5 times, I still don't understand :( Could you
please re-phrase?


>
>if (block->nooffloaddevcnt && err_stop)
>	return -EOPNOTSUPP;
>
>So with this patch, if the indr block call success, it will not modify
>the nooffloaddevcnt counter.
>
>Fixes: 7f76fa36754b ("net: sched: register callbacks for indirect tc block binds")
>Signed-off-by: wenxu <wenxu@ucloud.cn>
>---
> net/sched/cls_api.c | 27 +++++++++++++++------------
> 1 file changed, 15 insertions(+), 12 deletions(-)
>
>diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>index efd3cfb..8a1e3a5 100644
>--- a/net/sched/cls_api.c
>+++ b/net/sched/cls_api.c
>@@ -766,10 +766,10 @@ void tc_indr_block_cb_unregister(struct net_device *dev,
> }
> EXPORT_SYMBOL_GPL(tc_indr_block_cb_unregister);
> 
>-static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
>-			       struct tcf_block_ext_info *ei,
>-			       enum flow_block_command command,
>-			       struct netlink_ext_ack *extack)
>+static int tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
>+			      struct tcf_block_ext_info *ei,
>+			      enum flow_block_command command,
>+			      struct netlink_ext_ack *extack)
> {
> 	struct tc_indr_block_cb *indr_block_cb;
> 	struct tc_indr_block_dev *indr_dev;
>@@ -785,7 +785,7 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
> 
> 	indr_dev = tc_indr_block_dev_lookup(dev);
> 	if (!indr_dev)
>-		return;
>+		return -ENOENT;
> 
> 	indr_dev->block = command == FLOW_BLOCK_BIND ? block : NULL;
> 
>@@ -793,7 +793,10 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
> 		indr_block_cb->cb(dev, indr_block_cb->cb_priv, TC_SETUP_BLOCK,
> 				  &bo);
> 
>-	tcf_block_setup(block, &bo);
>+	if (list_empty(&bo.cb_list))
>+		return -EOPNOTSUPP;

How is this part related to the rest of the patch?

>+
>+	return tcf_block_setup(block, &bo);
> }
> 
> static bool tcf_block_offload_in_use(struct tcf_block *block)
>@@ -849,14 +852,14 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,
> 	if (err)
> 		return err;
> 
>-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
> 	return 0;
> 
> no_offload_dev_inc:
> 	if (tcf_block_offload_in_use(block))
> 		return -EOPNOTSUPP;
>-	block->nooffloaddevcnt++;
>-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
>+	err = tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
>+	if (err)
>+		block->nooffloaddevcnt++;
> 	return 0;
> }
> 
>@@ -866,8 +869,6 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
> 	struct net_device *dev = q->dev_queue->dev;
> 	int err;
> 
>-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
>-
> 	if (!dev->netdev_ops->ndo_setup_tc)
> 		goto no_offload_dev_dec;
> 	err = tcf_block_offload_cmd(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
>@@ -876,7 +877,9 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
> 	return;
> 
> no_offload_dev_dec:
>-	WARN_ON(block->nooffloaddevcnt-- == 0);
>+	err = tc_indr_block_call(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
>+	if (err)
>+		WARN_ON(block->nooffloaddevcnt-- == 0);
> }
> 
> static int
>-- 
>1.8.3.1
>

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

* Re: [PATCH net] net/sched: cls_api: Fix nooffloaddevcnt counter in indr block call success
  2019-09-16 10:28 ` Jiri Pirko
@ 2019-09-16 13:28   ` wenxu
  0 siblings, 0 replies; 3+ messages in thread
From: wenxu @ 2019-09-16 13:28 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: davem, netdev


在 2019/9/16 18:28, Jiri Pirko 写道:
> Please use get_maintainers script to get list of ccs.
>
> Mon, Sep 16, 2019 at 12:15:34PM CEST, wenxu@ucloud.cn wrote:
>> From: wenxu <wenxu@ucloud.cn>
>>
>> When a block bind with a dev which support indr block call(vxlan/gretap
>> device). It can bind success but with nooffloaddevcnt++. It will fail
>> when replace the hw filter in tc_setup_cb_call with skip_sw mode for
>> checkout the nooffloaddevcnt and skip_sw.
> I read this paragraph 5 times, I still don't understand :( Could you
> please re-phrase?
will do.
>> if (block->nooffloaddevcnt && err_stop)
>> 	return -EOPNOTSUPP;
>>
>> So with this patch, if the indr block call success, it will not modify
>> the nooffloaddevcnt counter.
>>
>> Fixes: 7f76fa36754b ("net: sched: register callbacks for indirect tc block binds")
>> Signed-off-by: wenxu <wenxu@ucloud.cn>
>> ---
>> net/sched/cls_api.c | 27 +++++++++++++++------------
>> 1 file changed, 15 insertions(+), 12 deletions(-)
>>
>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>> index efd3cfb..8a1e3a5 100644
>> --- a/net/sched/cls_api.c
>> +++ b/net/sched/cls_api.c
>> @@ -766,10 +766,10 @@ void tc_indr_block_cb_unregister(struct net_device *dev,
>> }
>> EXPORT_SYMBOL_GPL(tc_indr_block_cb_unregister);
>>
>> -static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
>> -			       struct tcf_block_ext_info *ei,
>> -			       enum flow_block_command command,
>> -			       struct netlink_ext_ack *extack)
>> +static int tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
>> +			      struct tcf_block_ext_info *ei,
>> +			      enum flow_block_command command,
>> +			      struct netlink_ext_ack *extack)
>> {
>> 	struct tc_indr_block_cb *indr_block_cb;
>> 	struct tc_indr_block_dev *indr_dev;
>> @@ -785,7 +785,7 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
>>
>> 	indr_dev = tc_indr_block_dev_lookup(dev);
>> 	if (!indr_dev)
>> -		return;
>> +		return -ENOENT;
>>
>> 	indr_dev->block = command == FLOW_BLOCK_BIND ? block : NULL;
>>
>> @@ -793,7 +793,10 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
>> 		indr_block_cb->cb(dev, indr_block_cb->cb_priv, TC_SETUP_BLOCK,
>> 				  &bo);
>>
>> -	tcf_block_setup(block, &bo);
>> +	if (list_empty(&bo.cb_list))
>> +		return -EOPNOTSUPP;
> How is this part related to the rest of the patch?

This check the list is to make sure there is real hw-offload for the indr device( There maybe

get some wrong with indr_block_cb->cb in the driver).  It should a return err to indicate the

caller add the nooffloaddevcnt counter.

.


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

end of thread, other threads:[~2019-09-16 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-16 10:15 [PATCH net] net/sched: cls_api: Fix nooffloaddevcnt counter in indr block call success wenxu
2019-09-16 10:28 ` Jiri Pirko
2019-09-16 13:28   ` wenxu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox