netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: sched: add checks for tbf classid
@ 2018-12-19  7:08 xiangxia.m.yue
  2018-12-19 17:40 ` Cong Wang
  0 siblings, 1 reply; 3+ messages in thread
From: xiangxia.m.yue @ 2018-12-19  7:08 UTC (permalink / raw)
  To: netdev, xiyou.wangcong; +Cc: Tonghao Zhang

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

tbf has only one qdisc class. When adding qdisc for it,
we should check the classid, otherwise the parentid:1
classid is available, no matter what classid tc specified.

$ tc qdisc add dev eth1 handle 10: root tbf rate 0.5mbit burst 5kb latency 70ms
$ tc class show dev eth1
class tbf 10:1 parent 10:

$ tc qdisc add dev eth1 parent 10:2 handle 20: pfifo_fast
or
$ tc qdisc add dev eth1 parent 10:0 handle 20: pfifo_fast
$ tc class show dev eth1
class tbf 10:1 parent 10: leaf 20:

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 net/sched/sch_tbf.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 942dcca..df636b1 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -505,12 +505,18 @@ static int tbf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
 static struct Qdisc *tbf_leaf(struct Qdisc *sch, unsigned long arg)
 {
 	struct tbf_sched_data *q = qdisc_priv(sch);
-	return q->qdisc;
+	if (arg == 1)
+		return q->qdisc;
+
+	return NULL;
 }
 
 static unsigned long tbf_find(struct Qdisc *sch, u32 classid)
 {
-	return 1;
+	if (TC_H_MIN(classid) == 1)
+		return 1;
+
+	return 0;
 }
 
 static void tbf_walk(struct Qdisc *sch, struct qdisc_walker *walker)
-- 
1.8.3.1

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

* Re: [PATCH net-next] net: sched: add checks for tbf classid
  2018-12-19  7:08 [PATCH net-next] net: sched: add checks for tbf classid xiangxia.m.yue
@ 2018-12-19 17:40 ` Cong Wang
  2018-12-20  2:18   ` Tonghao Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2018-12-19 17:40 UTC (permalink / raw)
  To: Tonghao Zhang; +Cc: Linux Kernel Network Developers

On Tue, Dec 18, 2018 at 11:08 PM <xiangxia.m.yue@gmail.com> wrote:
>
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> tbf has only one qdisc class. When adding qdisc for it,
> we should check the classid, otherwise the parentid:1
> classid is available, no matter what classid tc specified.
>
> $ tc qdisc add dev eth1 handle 10: root tbf rate 0.5mbit burst 5kb latency 70ms
> $ tc class show dev eth1
> class tbf 10:1 parent 10:
>
> $ tc qdisc add dev eth1 parent 10:2 handle 20: pfifo_fast
> or
> $ tc qdisc add dev eth1 parent 10:0 handle 20: pfifo_fast
> $ tc class show dev eth1
> class tbf 10:1 parent 10: leaf 20:

I think it is the intended behavior of tbf class.

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

* Re: [PATCH net-next] net: sched: add checks for tbf classid
  2018-12-19 17:40 ` Cong Wang
@ 2018-12-20  2:18   ` Tonghao Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Tonghao Zhang @ 2018-12-20  2:18 UTC (permalink / raw)
  To: Cong Wang; +Cc: Linux Kernel Network Developers

On Thu, Dec 20, 2018 at 1:40 AM Cong Wang <xiyou.wangcong@gmail.com> wrote:
>
> On Tue, Dec 18, 2018 at 11:08 PM <xiangxia.m.yue@gmail.com> wrote:
> >
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > tbf has only one qdisc class. When adding qdisc for it,
> > we should check the classid, otherwise the parentid:1
> > classid is available, no matter what classid tc specified.
> >
> > $ tc qdisc add dev eth1 handle 10: root tbf rate 0.5mbit burst 5kb latency 70ms
> > $ tc class show dev eth1
> > class tbf 10:1 parent 10:
> >
> > $ tc qdisc add dev eth1 parent 10:2 handle 20: pfifo_fast
> > or
> > $ tc qdisc add dev eth1 parent 10:0 handle 20: pfifo_fast
> > $ tc class show dev eth1
> > class tbf 10:1 parent 10: leaf 20:
>
> I think it is the intended behavior of tbf class.
The parent id such as parent-id:0 is invalid for other qdisc, is
available for tbf. It is confused for administrator.
Should we add that check ?

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

end of thread, other threads:[~2018-12-20  2:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-19  7:08 [PATCH net-next] net: sched: add checks for tbf classid xiangxia.m.yue
2018-12-19 17:40 ` Cong Wang
2018-12-20  2:18   ` Tonghao Zhang

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