From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Aring Subject: [PATCHv2 net-next 11/15] net: sch: api: add extack support in qdisc_alloc Date: Thu, 14 Dec 2017 13:39:01 -0500 Message-ID: <20171214183905.23066-12-aring@mojatatu.com> References: <20171214183905.23066-1-aring@mojatatu.com> Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern To: jhs@mojatatu.com Return-path: Received: from mail-it0-f66.google.com ([209.85.214.66]:35703 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754115AbdLNSju (ORCPT ); Thu, 14 Dec 2017 13:39:50 -0500 Received: by mail-it0-f66.google.com with SMTP id f143so13359941itb.0 for ; Thu, 14 Dec 2017 10:39:50 -0800 (PST) In-Reply-To: <20171214183905.23066-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org List-ID: This patch adds extack support for the function qdisc_alloc which is a common used function in the tc subsystem. Callers which are interested in the receiving error can assign extack to get a more detailed information why qdisc_alloc failed. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/sch_api.c | 5 +++-- net/sched/sch_generic.c | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 2ea04863ea34..1dbfbec00050 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -470,7 +470,8 @@ void qdisc_destroy(struct Qdisc *qdisc); void qdisc_tree_reduce_backlog(struct Qdisc *qdisc, unsigned int n, unsigned int len); struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, - const struct Qdisc_ops *ops); + const struct Qdisc_ops *ops, + struct netlink_ext_ack *extack); struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, const struct Qdisc_ops *ops, u32 parentid); void __qdisc_calculate_pkt_len(struct sk_buff *skb, diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 24b286d763b7..4c896330e2f0 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1050,10 +1050,11 @@ static struct Qdisc *qdisc_create(struct net_device *dev, goto err_out; } - sch = qdisc_alloc(dev_queue, ops); - if (IS_ERR(sch)) + sch = qdisc_alloc(dev_queue, ops, extack); + if (IS_ERR(sch)) { err = PTR_ERR(sch); goto err_out2; + } sch->parent = parent; diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 5cdafe88b902..01457b27d36e 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -749,7 +749,8 @@ static struct lock_class_key qdisc_tx_busylock; static struct lock_class_key qdisc_running_key; struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, - const struct Qdisc_ops *ops) + const struct Qdisc_ops *ops, + struct netlink_ext_ack *extack) { void *p; struct Qdisc *sch; @@ -758,6 +759,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, struct net_device *dev; if (!dev_queue) { + NL_SET_ERR_MSG(extack, "No device queue given"); err = -EINVAL; goto errout; } @@ -829,7 +831,7 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, if (!try_module_get(ops->owner)) return NULL; - sch = qdisc_alloc(dev_queue, ops); + sch = qdisc_alloc(dev_queue, ops, NULL); if (IS_ERR(sch)) { module_put(ops->owner); return NULL; -- 2.11.0