From: Alexander Aring <aring@mojatatu.com>
Date: Wed, 20 Dec 2017 12:35:20 -0500
Subject: net: sch: api: add extack support in qdisc_alloc
Patch-mainline: v4.16-rc1
Git-commit: d0bd684dddab51ed017ece0359f26b038ec31940
References: bsc#1109837
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 <dsahern@gmail.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
include/net/sch_generic.h | 3 ++-
net/sched/sch_api.c | 2 +-
net/sched/sch_generic.c | 6 ++++--
3 files changed, 7 insertions(+), 4 deletions(-)
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -468,7 +468,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);
void qdisc_free(struct Qdisc *qdisc);
struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
const struct Qdisc_ops *ops, u32 parentid);
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1052,7 +1052,7 @@ static struct Qdisc *qdisc_create(struct
goto err_out;
}
- sch = qdisc_alloc(dev_queue, ops);
+ sch = qdisc_alloc(dev_queue, ops, extack);
if (IS_ERR(sch)) {
err = PTR_ERR(sch);
goto err_out2;
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -752,7 +752,8 @@ static struct lock_class_key qdisc_tx_bu
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;
@@ -761,6 +762,7 @@ struct Qdisc *qdisc_alloc(struct netdev_
struct net_device *dev;
if (!dev_queue) {
+ NL_SET_ERR_MSG(extack, "No device queue given");
err = -EINVAL;
goto errout;
}
@@ -845,7 +847,7 @@ struct Qdisc *qdisc_create_dflt(struct n
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;