Message ID | 1440172688-2163-3-git-send-email-phil@nwl.cc |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, 2015-08-21 at 17:58 +0200, Phil Sutter wrote: > Since tc_get_qdisc() does not allow to remove a qdisc with zero handle, > a handle needs to be allocated to default qdiscs (currently pfifo_fast > or mq) in order to allow removing them. > > Signed-off-by: Phil Sutter <phil@nwl.cc> > --- > include/net/sch_generic.h | 1 + > net/sched/sch_api.c | 3 ++- > net/sched/sch_generic.c | 5 +++++ > 3 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h > index 4495193..2bfc898 100644 > --- a/include/net/sch_generic.h > +++ b/include/net/sch_generic.h > @@ -391,6 +391,7 @@ void dev_deactivate(struct net_device *dev); > void dev_deactivate_many(struct list_head *head); > struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, > struct Qdisc *qdisc); > +u32 qdisc_alloc_handle(struct net_device *dev); > void qdisc_reset(struct Qdisc *qdisc); > void qdisc_destroy(struct Qdisc *qdisc); > void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n); > diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c > index f06aa01..224374c 100644 > --- a/net/sched/sch_api.c > +++ b/net/sched/sch_api.c > @@ -723,7 +723,7 @@ EXPORT_SYMBOL(qdisc_class_hash_remove); > /* Allocate an unique handle from space managed by kernel > * Possible range is [8000-FFFF]:0000 (0x8000 values) > */ > -static u32 qdisc_alloc_handle(struct net_device *dev) > +u32 qdisc_alloc_handle(struct net_device *dev) > { > int i = 0x8000; > static u32 autohandle = TC_H_MAKE(0x80000000U, 0); > @@ -739,6 +739,7 @@ static u32 qdisc_alloc_handle(struct net_device *dev) > > return 0; > } > +EXPORT_SYMBOL(qdisc_alloc_handle); > > void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n) > { > diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c > index 1fb65f9..ab614ee 100644 > --- a/net/sched/sch_generic.c > +++ b/net/sched/sch_generic.c > @@ -634,6 +634,11 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, > if (IS_ERR(sch)) > goto errout; > sch->parent = parentid; > +#ifdef CONFIG_NET_SCHED > + sch->handle = qdisc_alloc_handle(dev_queue->dev); > + if (!sch->handle) > + goto errout; > +#endif > > if (!ops->init || ops->init(sch, NULL) == 0) > return sch; This might break HTB setups with more than 32768 classes ? The pfifo qdisc that gets attached had no handle. qdisc_alloc_handle() has a limited range. -- 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
On Fri, Aug 21, 2015 at 09:14:58AM -0700, Eric Dumazet wrote: [...] > > diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c > > index 1fb65f9..ab614ee 100644 > > --- a/net/sched/sch_generic.c > > +++ b/net/sched/sch_generic.c > > @@ -634,6 +634,11 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, > > if (IS_ERR(sch)) > > goto errout; > > sch->parent = parentid; > > +#ifdef CONFIG_NET_SCHED > > + sch->handle = qdisc_alloc_handle(dev_queue->dev); > > + if (!sch->handle) > > + goto errout; > > +#endif > > > > if (!ops->init || ops->init(sch, NULL) == 0) > > return sch; > > This might break HTB setups with more than 32768 classes ? Urgh. Thanks for noticing this! > The pfifo qdisc that gets attached had no handle. Yes, looks like I need to leave qdisc_create_dflt() alone. It is possible, by doing the above twice in sch_generic.c (once in attach_one_default_qdisc(), and in attach_default_qdiscs() as well). > qdisc_alloc_handle() has a limited range. Yes, I noticed this. Handles aren't reused in a running system either, which might contribute to this problem in other situations. V2 will follow, thanks again. Cheers, Phil -- 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 --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 4495193..2bfc898 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -391,6 +391,7 @@ void dev_deactivate(struct net_device *dev); void dev_deactivate_many(struct list_head *head); struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, struct Qdisc *qdisc); +u32 qdisc_alloc_handle(struct net_device *dev); void qdisc_reset(struct Qdisc *qdisc); void qdisc_destroy(struct Qdisc *qdisc); void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n); diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index f06aa01..224374c 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -723,7 +723,7 @@ EXPORT_SYMBOL(qdisc_class_hash_remove); /* Allocate an unique handle from space managed by kernel * Possible range is [8000-FFFF]:0000 (0x8000 values) */ -static u32 qdisc_alloc_handle(struct net_device *dev) +u32 qdisc_alloc_handle(struct net_device *dev) { int i = 0x8000; static u32 autohandle = TC_H_MAKE(0x80000000U, 0); @@ -739,6 +739,7 @@ static u32 qdisc_alloc_handle(struct net_device *dev) return 0; } +EXPORT_SYMBOL(qdisc_alloc_handle); void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n) { diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 1fb65f9..ab614ee 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -634,6 +634,11 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, if (IS_ERR(sch)) goto errout; sch->parent = parentid; +#ifdef CONFIG_NET_SCHED + sch->handle = qdisc_alloc_handle(dev_queue->dev); + if (!sch->handle) + goto errout; +#endif if (!ops->init || ops->init(sch, NULL) == 0) return sch;
Since tc_get_qdisc() does not allow to remove a qdisc with zero handle, a handle needs to be allocated to default qdiscs (currently pfifo_fast or mq) in order to allow removing them. Signed-off-by: Phil Sutter <phil@nwl.cc> --- include/net/sch_generic.h | 1 + net/sched/sch_api.c | 3 ++- net/sched/sch_generic.c | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-)