diff mbox

[net-next,2/5] net_sched: add replace func in struct Qdisc_ops

Message ID 1394111321-11192-3-git-send-email-yangyingliang@huawei.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Yang Yingliang March 6, 2014, 1:08 p.m. UTC
Add replace func, if NLM_F_REPLACE is set, use replace func.
Otherwise, use change func.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 include/net/sch_generic.h |  1 +
 net/sched/sch_api.c       | 12 +++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

Comments

Eric Dumazet March 6, 2014, 2:55 p.m. UTC | #1
On Thu, 2014-03-06 at 21:08 +0800, Yang Yingliang wrote:
> Add replace func, if NLM_F_REPLACE is set, use replace func.
> Otherwise, use change func.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  include/net/sch_generic.h |  1 +
>  net/sched/sch_api.c       | 12 +++++++++---
>  2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
> index d062f81c692f..ef8a41bcb9a7 100644
> --- a/include/net/sch_generic.h
> +++ b/include/net/sch_generic.h
> @@ -170,6 +170,7 @@ struct Qdisc_ops {
>  	void			(*reset)(struct Qdisc *);
>  	void			(*destroy)(struct Qdisc *);
>  	int			(*change)(struct Qdisc *, struct nlattr *arg);
> +	int			(*replace)(struct Qdisc *, struct nlattr *arg);
>  	void			(*attach)(struct Qdisc *);
>  
>  	int			(*dump)(struct Qdisc *, struct sk_buff *);
> diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> index 961cb0f1bd0c..8f0f8e9d5475 100644
> --- a/net/sched/sch_api.c
> +++ b/net/sched/sch_api.c
> @@ -999,9 +999,15 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca, u16 flags)
>  	int err = 0;
>  
>  	if (tca[TCA_OPTIONS]) {
> -		if (sch->ops->change == NULL)
> -			return -EINVAL;
> -		err = sch->ops->change(sch, tca[TCA_OPTIONS]);
> +		if (flags & NLM_F_REPLACE) {
> +			if (sch->ops->replace == NULL)
> +				return -EINVAL;
> +			err = sch->ops->replace(sch, tca[TCA_OPTIONS]);
> +		} else {
> +			if (sch->ops->change == NULL)
> +				return -EINVAL;
> +			err = sch->ops->change(sch, tca[TCA_OPTIONS]);
> +		}
>  		if (err)
>  			return err;
>  	}

NACK

This breaks existing userland scripts.

Have you tried :

tc qdisc replace dev eth0 root fq



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yang Yingliang March 7, 2014, 2:13 a.m. UTC | #2
On 2014/3/6 22:55, Eric Dumazet wrote:
> On Thu, 2014-03-06 at 21:08 +0800, Yang Yingliang wrote:
>> Add replace func, if NLM_F_REPLACE is set, use replace func.
>> Otherwise, use change func.
>>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>>  include/net/sch_generic.h |  1 +
>>  net/sched/sch_api.c       | 12 +++++++++---
>>  2 files changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
>> index d062f81c692f..ef8a41bcb9a7 100644
>> --- a/include/net/sch_generic.h
>> +++ b/include/net/sch_generic.h
>> @@ -170,6 +170,7 @@ struct Qdisc_ops {
>>  	void			(*reset)(struct Qdisc *);
>>  	void			(*destroy)(struct Qdisc *);
>>  	int			(*change)(struct Qdisc *, struct nlattr *arg);
>> +	int			(*replace)(struct Qdisc *, struct nlattr *arg);
>>  	void			(*attach)(struct Qdisc *);
>>  
>>  	int			(*dump)(struct Qdisc *, struct sk_buff *);
>> diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
>> index 961cb0f1bd0c..8f0f8e9d5475 100644
>> --- a/net/sched/sch_api.c
>> +++ b/net/sched/sch_api.c
>> @@ -999,9 +999,15 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca, u16 flags)
>>  	int err = 0;
>>  
>>  	if (tca[TCA_OPTIONS]) {
>> -		if (sch->ops->change == NULL)
>> -			return -EINVAL;
>> -		err = sch->ops->change(sch, tca[TCA_OPTIONS]);
>> +		if (flags & NLM_F_REPLACE) {
>> +			if (sch->ops->replace == NULL)
>> +				return -EINVAL;
>> +			err = sch->ops->replace(sch, tca[TCA_OPTIONS]);
>> +		} else {
>> +			if (sch->ops->change == NULL)
>> +				return -EINVAL;
>> +			err = sch->ops->change(sch, tca[TCA_OPTIONS]);
>> +		}
>>  		if (err)
>>  			return err;
>>  	}
> 
> NACK
> 
> This breaks existing userland scripts.

Yes, it is.

Maybe I need do some change for this code.

Thanks!

> 
> Have you tried :
> 
> tc qdisc replace dev eth0 root fq
> 



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index d062f81c692f..ef8a41bcb9a7 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -170,6 +170,7 @@  struct Qdisc_ops {
 	void			(*reset)(struct Qdisc *);
 	void			(*destroy)(struct Qdisc *);
 	int			(*change)(struct Qdisc *, struct nlattr *arg);
+	int			(*replace)(struct Qdisc *, struct nlattr *arg);
 	void			(*attach)(struct Qdisc *);
 
 	int			(*dump)(struct Qdisc *, struct sk_buff *);
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 961cb0f1bd0c..8f0f8e9d5475 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -999,9 +999,15 @@  static int qdisc_change(struct Qdisc *sch, struct nlattr **tca, u16 flags)
 	int err = 0;
 
 	if (tca[TCA_OPTIONS]) {
-		if (sch->ops->change == NULL)
-			return -EINVAL;
-		err = sch->ops->change(sch, tca[TCA_OPTIONS]);
+		if (flags & NLM_F_REPLACE) {
+			if (sch->ops->replace == NULL)
+				return -EINVAL;
+			err = sch->ops->replace(sch, tca[TCA_OPTIONS]);
+		} else {
+			if (sch->ops->change == NULL)
+				return -EINVAL;
+			err = sch->ops->change(sch, tca[TCA_OPTIONS]);
+		}
 		if (err)
 			return err;
 	}