net_sched: fix an extack message in tcf_block_find()
Subsystems (3)
PATCH 1/1 net_sched: fix an extack message in tcf_block_find()
It is clearly a copy-n-paste.
--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/cls_api.c +1 -1
@@ -655,7 +655,7 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, *q =qdisc_refcount_inc_nz (*q);if (!*q) { -NL_SET_ERR_MSG (extack,"Parent Qdisc doesn't exists" ); +NL_SET_ERR_MSG (extack,"Can't increase Qdisc refcount" ); err = -EINVAL ; goto errout_rcu; }
Signature · 1 line
2.14.4
PATCH 1/1 net_sched: fix a crash in tc_new_tfilter()
When tcf_block_find() fails, it already rollbacks the qdisc refcnt, so its caller doesn't need to clean up this again. Avoid calling qdisc_put() again by resetting qdisc to NULL for callers.
--- net/sched/cls_api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/sched/cls_api.c +3 -1
@@ -717,8 +717,10 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, errout_rcu:rcu_read_unlock (); errout_qdisc: -if (*q) +if (*q) {qdisc_put (*q); + *q =NULL ; + }return ERR_PTR (err); }
Signature · 1 line
2.14.4
Quoted 12 lines · Cong Wang
It is clearly a copy-n-paste.
Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sched/cls_api.c +0
-0
net/sched/cls_api.c static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, · line 658
Quoted 5 lines
net/sched/cls_api.c +1
-1@@ -655,7 +655,7 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, *q =qdisc_refcount_inc_nz (*q);if (!*q) { -NL_SET_ERR_MSG (extack,"Parent Qdisc doesn't exists" ); +NL_SET_ERR_MSG (extack,"Can't increase Qdisc refcount" );
I am not sure it was a copy-n-paste.
Qdisc refcount business is kernel internal.
If we can not increase the refcount, this is precisely because this qdisc is about to be destroyed. Nothing fundamentally different than having this thread delayed a bit and qdisc_lookup_rcu() returning NULL in the first place.
This also means that using RCU for control path is problematic, as surely the caller of this interface would prefer something that succeeds, even if this means waiting a bit in the kernel.
Or are we willing to change ip command and make it restart failed syscalls ?
Quoted 17 lines · Eric Dumazet
Quoted 13 lines · Cong Wang
It is clearly a copy-n-paste.
Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sched/cls_api.c +0
-0@@ -655,7 +655,7 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q,
Quoted 7 lines
net/sched/cls_api.c static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, · line 658
Quoted 4 lines
net/sched/cls_api.c +1
-1*q =qdisc_refcount_inc_nz (*q);if (!*q) { -NL_SET_ERR_MSG (extack,"Parent Qdisc doesn't exists" ); +NL_SET_ERR_MSG (extack,"Can't increase Qdisc refcount" );I am not sure it was a copy-n-paste.
Make sure you knew there is an exactly same extack message (with a same English grammar error).
Quoted 2 lines
Qdisc refcount business is kernel internal.
Yeah, but the extack message is already there, this patch doesn't add any new extack. Or you are suggesting we should remove it?
Quoted 3 lines
If we can not increase the refcount, this is precisely because this qdisc is about to be destroyed. Nothing fundamentally different than having this thread delayed a bit and
qdisc_lookup_rcu()returning NULL in the first place.
qdisc_lookup_rcu() is not always called, it could be dev->qdisc. I am pretty sure parent exists in dev->qdisc.
Quoted 4 lines
This also means that using RCU for control path is problematic, as surely the caller of this interface would prefer something that succeeds, even if this means waiting a bit in the kernel.
I fail to validate this statement, Why it prefers success when refcnt reaches 0?
Quoted 3 lines
Or are we willing to change ip command and make it restart failed syscalls ?
I don't understand what you mean by changing ip command, you must mean tc command, but still, I have no idea about how restarting failed syscall could be related to my patch and why we need to restart anything here. If the refcnt goes to 0, it will never come back, retrying won't help anything.
BTW:
If you have any other question beyond my patch's scope, isn't it better that we start a new thread for discussion?
In case you still misunderstand, my patch never intends to address any other problem rather than correcting an inaccurate extack message.
Quoted 6 lines · Cong Wang
I don't understand what you mean by changing ip command, you must mean tc command, but still, I have no idea about how restarting failed syscall could be related to my patch and why we need to restart anything here. If the refcnt goes to 0, it will never come back, retrying won't help anything.
Yep, tc command it is.
I was not especially commenting your patch (replacing an english message by another does not seem very big deal), but the fact that the code right there seems to be prepared for parallel changes.
But using RCU lookups in control path will lead to occasional failures that most user space tools would not expect.
Lets assume two tasks are launching "tc qdisc replace dev eth0 root XXX" in whatever order/parallelism.
Both should succeed, after/before major RTNL->other_locking_mechanism
Control paths are usually using a mutex or a spinlock so that they never hit a 0-refcount at all.
rcu_read_lock() in tcf_block_find()
(Changing $subject as the discussion is going to a completely different topic)
Quoted 12 lines · Eric Dumazet
Quoted 6 lines · Cong Wang
I don't understand what you mean by changing ip command, you must mean tc command, but still, I have no idea about how restarting failed syscall could be related to my patch and why we need to restart anything here. If the refcnt goes to 0, it will never come back, retrying won't help anything.
Quoted 9 lines
Yep, tc command it is.
I was not especially commenting your patch (replacing an english message by another does not seem very big deal), but the fact that the code right there seems to be prepared for parallel changes.
But using RCU lookups in control path will lead to occasional failures that most user space tools would not expect.
I already discussed this with Vlad in the beginning of his RTNL removal patches, we both agreed some lock is still needed, it is not completely lockless. Take a look at tc action code now, two spinlocks are still needed even after we will remove the RTNL there.
Quoted 3 lines
Lets assume two tasks are launching "tc qdisc replace dev eth0 root XXX" in whatever order/parallelism.
Both should succeed, after/before major
RTNL->other_locking_mechanism
Yes, it is never going to be completely lockless.
Quoted 2 lines
Control paths are usually using a mutex or a spinlock so that they never hit a 0-refcount at all.
For dev->qdisc, sure, we should already hold a refcnt, it can't be gone.
For qdisc_lookup_rcu(), it could be that refcnt goes to 0 before we remove it from hashtable, right? call_rcu() is only called after refcnt==0, so rcu read lock can't help here.
Thanks.
Quoted 32 lines · Cong Wang
Quoted 17 lines · Eric Dumazet
Quoted 13 lines · Cong Wang
It is clearly a copy-n-paste.
Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sched/cls_api.c +0
-0@@ -655,7 +655,7 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q,Quoted 7 lines
net/sched/cls_api.c static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, · line 658
Quoted 4 lines
net/sched/cls_api.c +1
-1*q =qdisc_refcount_inc_nz (*q);if (!*q) { -NL_SET_ERR_MSG (extack,"Parent Qdisc doesn't exists" ); +NL_SET_ERR_MSG (extack,"Can't increase Qdisc refcount" );I am not sure it was a copy-n-paste.
Make sure you knew there is an exactly same extack message (with a same English grammar error).
Quoted 1 line
Quoted 4 lines
Quoted 1 line
Qdisc refcount business is kernel internal.
Yeah, but the extack message is already there, this patch doesn't add any new extack. Or you are suggesting we should remove it?
IMO the message grammar should be fixed, but the content is correct -- ie, parent qdisc does not exist.
Quoted 12 lines · Cong Wang
It is clearly a copy-n-paste.
Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sched/cls_api.c +0
-0
net/sched/cls_api.c static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, · line 661
Quoted 8 lines
net/sched/cls_api.c +1
-1@@ -655,7 +655,7 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, *q =qdisc_refcount_inc_nz (*q);if (!*q) { -NL_SET_ERR_MSG (extack,"Parent Qdisc doesn't exists" ); +NL_SET_ERR_MSG (extack,"Can't increase Qdisc refcount" ); err = -EINVAL ; goto errout_rcu; }
Is there a benefit in exposing this info to user? For all intents and purposes Qdisc is gone at that point.
Quoted 15 lines · Vlad Buslov
Quoted 13 lines · Cong Wang
It is clearly a copy-n-paste.
Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sched/cls_api.c +0
-0@@ -655,7 +655,7 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q,
Quoted 9 lines
net/sched/cls_api.c static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, · line 661
Quoted 7 lines
net/sched/cls_api.c +1
-1*q =qdisc_refcount_inc_nz (*q);if (!*q) { -NL_SET_ERR_MSG (extack,"Parent Qdisc doesn't exists" ); +NL_SET_ERR_MSG (extack,"Can't increase Qdisc refcount" ); err = -EINVAL ; goto errout_rcu; }Is there a benefit in exposing this info to user?
Depends on what user you mean here. For kernel developers, yes, this is useful. For others, no.
Quoted 1 line
For all intents and purposes Qdisc is gone at that point.
I don't want to be a language lawyer, but there is a difference between "it doesn't exist" and "it exists but being removed". The errno EINVAL betrays what you said too, it must be ENOENT to mach "Qdisc is gone".
I don't want to waste my time on this any more. Let's just drop it.
I really don't care, do you?
Quoted 32 lines · Cong Wang
Quoted 15 lines · Vlad Buslov
Quoted 13 lines · Cong Wang
It is clearly a copy-n-paste.
Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sched/cls_api.c +0
-0@@ -655,7 +655,7 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q,Quoted 9 lines
net/sched/cls_api.c static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q, · line 661
Quoted 7 lines
net/sched/cls_api.c +1
-1*q =qdisc_refcount_inc_nz (*q);if (!*q) { -NL_SET_ERR_MSG (extack,"Parent Qdisc doesn't exists" ); +NL_SET_ERR_MSG (extack,"Can't increase Qdisc refcount" ); err = -EINVAL ; goto errout_rcu; }Is there a benefit in exposing this info to user?
Depends on what user you mean here. For kernel developers, yes, this is useful. For others, no.
Quoted 1 line
For all intents and purposes Qdisc is gone at that point.
Quoted 7 lines
I don't want to be a language lawyer, but there is a difference between "it doesn't exist" and "it exists but being removed". The errno EINVAL betrays what you said too, it must be ENOENT to mach "Qdisc is gone".
I don't want to waste my time on this any more. Let's just drop it.
I really don't care, do you?
I'm asked the question in order to improve error messages in my future patches, not because I care about this particular string.
Quoted 4 lines · Cong Wang
It is clearly a copy-n-paste.
Signed-off-by Cong Wang <[email protected]>
I regret again for wasting my time, so:
I really don't care, do you?