From patchwork Mon Dec 18 22:45:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850466 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="Une1TNgd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x2R66nfz9t2M for ; Tue, 19 Dec 2017 09:45:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936284AbdLRWpd (ORCPT ); Mon, 18 Dec 2017 17:45:33 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:36532 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936043AbdLRWpa (ORCPT ); Mon, 18 Dec 2017 17:45:30 -0500 Received: by mail-io0-f194.google.com with SMTP id l10so11532857ioc.3 for ; Mon, 18 Dec 2017 14:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n+miYz7C7D0G2mEDWWtL41YYpkfTcS91aqzRzFoaWlM=; b=Une1TNgdJ9tk2yNprznRgzXIEXEZgtOfUko9nmeYvNJ8pFwRS7roxALK+J/6E3K+87 4bGF1cnO5N/EBPQNClEnoWQT2W1jHXTbdy8ZOpTNCId2akxBb+XVvU9IGSyroz82C+dE hy9OyyhnAjbVUdAoVdS1KMJwl4c9H9mx8e7g+Yjsaksiw4qYf9EWkBE8HhqAJmzVlgz2 GyPFlb62bHrd2cu1MiOymMDNvdOjUfJ67R9P3TT7Eb0ryhCFHadrq4MhJSqNWRnuI30j 19a9V1sRmohd15mClAYeteFaOwrLEhprQ0UBxh/jypJRF1IM10A/sVxzvumyLBCM6BPz dwlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n+miYz7C7D0G2mEDWWtL41YYpkfTcS91aqzRzFoaWlM=; b=lASMcE6UeR4yikx163hL7QERJFQYtQYwZX+ib35giGUZl9uFPVr0UkeJLbQLXw27k+ 6wymPBhgLCL+pnP2unafFVDBIW1qRYCz8A9zA0j5y9Wa8JavPKfnyaed/7VErj+BHTyI c5ntLC0Q7tQ2rW9FGB60D9LAAtFxPbpql/7YckcV6lWuZqJsZAlKF5D6VWm8mTKB4MPR hzk6ETVc5uf7kjZvdv/PnUQVQq7gdLmXGrk0BT7Ml0ZS9iyQtx1gprCH3urrMkUBP6tH ZYjUL4/EHb+bN+5ykcClMqhbcezMlFvoAc/yNZBmSn1F3XCEkRSOlw/FY5wEZ7u0moS6 YRjw== X-Gm-Message-State: AKGB3mIk7Cp6OlurmTW/34h2FAvU5NdilfRKzDblqSoxMryHpn56yfun EXIJRJjgLTQ3DCuu0z0jdfQS3w== X-Google-Smtp-Source: ACJfBouHGJ6GGIQ/5bZi5Pw2KMWY3pDgWIxH3WaqO5z0xIebg4dDa1gS+BZW1lM5HedOQ0da+yByiQ== X-Received: by 10.107.174.106 with SMTP id x103mr1521389ioe.141.1513637129440; Mon, 18 Dec 2017 14:45:29 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:29 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring Subject: [PATCHv3 net-next 01/14] net: sched: fix coding style issues Date: Mon, 18 Dec 2017 17:45:00 -0500 Message-Id: <20171218224513.29836-2-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch fix checkpatch issues for upcomming patches according to the sched api file. It changes mostly how to check on null pointer. Signed-off-by: Alexander Aring --- net/sched/sch_api.c | 2 +- net/sched/sch_cbq.c | 12 ++++++------ net/sched/sch_gred.c | 7 ++++--- net/sched/sch_hfsc.c | 2 +- net/sched/sch_multiq.c | 2 +- net/sched/sch_tbf.c | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index a904276b657d..b54917f4ad87 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -669,7 +669,7 @@ int qdisc_class_hash_init(struct Qdisc_class_hash *clhash) unsigned int size = 4; clhash->hash = qdisc_class_hash_alloc(size); - if (clhash->hash == NULL) + if (!clhash->hash) return -ENOMEM; clhash->hashsize = size; clhash->hashmask = size - 1; diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 525eb3a6d625..0692fe35f4ec 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1150,12 +1150,13 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt) if (err < 0) return err; - if (tb[TCA_CBQ_RTAB] == NULL || tb[TCA_CBQ_RATE] == NULL) + if (!tb[TCA_CBQ_RTAB] || !tb[TCA_CBQ_RATE]) return -EINVAL; r = nla_data(tb[TCA_CBQ_RATE]); - if ((q->link.R_tab = qdisc_get_rtab(r, tb[TCA_CBQ_RTAB])) == NULL) + q->link.R_tab = qdisc_get_rtab(r, tb[TCA_CBQ_RTAB]); + if (!q->link.R_tab) return -EINVAL; err = tcf_block_get(&q->link.block, &q->link.filter_list, sch); @@ -1460,7 +1461,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t struct cbq_class *parent; struct qdisc_rate_table *rtab = NULL; - if (opt == NULL) + if (!opt) return -EINVAL; err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy, NULL); @@ -1532,8 +1533,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t if (parentid == TC_H_ROOT) return -EINVAL; - if (tb[TCA_CBQ_WRROPT] == NULL || tb[TCA_CBQ_RATE] == NULL || - tb[TCA_CBQ_LSSOPT] == NULL) + if (!tb[TCA_CBQ_WRROPT] || !tb[TCA_CBQ_RATE] || !tb[TCA_CBQ_LSSOPT]) return -EINVAL; rtab = qdisc_get_rtab(nla_data(tb[TCA_CBQ_RATE]), tb[TCA_CBQ_RTAB]); @@ -1565,7 +1565,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t if (parentid) { parent = cbq_class_lookup(q, parentid); err = -EINVAL; - if (parent == NULL) + if (!parent) goto failure; } diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c index bc30f9186ac6..ccd1a00e2a9a 100644 --- a/net/sched/sch_gred.c +++ b/net/sched/sch_gred.c @@ -306,12 +306,13 @@ static inline int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps) struct tc_gred_sopt *sopt; int i; - if (dps == NULL) + if (!dps) return -EINVAL; sopt = nla_data(dps); - if (sopt->DPs > MAX_DPs || sopt->DPs == 0 || sopt->def_DP >= sopt->DPs) + if (sopt->DPs > MAX_DPs || sopt->DPs == 0 || + sopt->def_DP >= sopt->DPs) return -EINVAL; sch_tree_lock(sch); @@ -470,7 +471,7 @@ static int gred_init(struct Qdisc *sch, struct nlattr *opt) struct nlattr *tb[TCA_GRED_MAX + 1]; int err; - if (opt == NULL) + if (!opt) return -EINVAL; err = nla_parse_nested(tb, TCA_GRED_MAX, opt, gred_policy, NULL); diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index d04068a97d81..94db20352f37 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1396,7 +1396,7 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt) qdisc_watchdog_init(&q->watchdog, sch); - if (opt == NULL || nla_len(opt) < sizeof(*qopt)) + if (!opt || nla_len(opt) < sizeof(*qopt)) return -EINVAL; qopt = nla_data(opt); diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c index 012216386c0b..37195e0c64ba 100644 --- a/net/sched/sch_multiq.c +++ b/net/sched/sch_multiq.c @@ -243,7 +243,7 @@ static int multiq_init(struct Qdisc *sch, struct nlattr *opt) q->queues = NULL; - if (opt == NULL) + if (!opt) return -EINVAL; err = tcf_block_get(&q->block, &q->filter_list, sch); diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 120f4f365967..e8f3345674c5 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -428,7 +428,7 @@ static int tbf_init(struct Qdisc *sch, struct nlattr *opt) qdisc_watchdog_init(&q->watchdog, sch); q->qdisc = &noop_qdisc; - if (opt == NULL) + if (!opt) return -EINVAL; q->t_c = ktime_get_ns(); From patchwork Mon Dec 18 22:45:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850479 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="n+KpwHCP"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x3p429Zz9t2M for ; Tue, 19 Dec 2017 09:46:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935129AbdLRWqo (ORCPT ); Mon, 18 Dec 2017 17:46:44 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:35748 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934968AbdLRWpb (ORCPT ); Mon, 18 Dec 2017 17:45:31 -0500 Received: by mail-io0-f194.google.com with SMTP id 14so5069852iou.2 for ; Mon, 18 Dec 2017 14:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZM5RlZn0XrLmgEZDjlcBy942mPc8vRN4xjyYsvCKKPA=; b=n+KpwHCPN/pR5SbC+ZXLSVmIJHSM0Jgt8se2OPPPv+issbrn/SDgJ140Zvfv09otqS Q95Tqi1NFhzSMTmdjSUbuHYbiRaXutJkBbv/UGPXZ8eplXtHrvkNDoQK2RQCCU3aIcKF J3KzCunb2VHzQA5Re0MxXKdzwNnj+TiTCzbzDPwTrmYRjgLhUd+/NjAyDWN7YmKcrbyU 051clasBFEovNKTpFS+Q/NZu22QchbOePGhM14+KaUMNZ0XLvkBnh8dNRmuAdISlKkL0 josr7xXMdtmLCGFdkdXX0sWisl9BRcELnEcSWt6w4hxwQ+PVwtxU+jLMPYOciG0MFdDH FDRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZM5RlZn0XrLmgEZDjlcBy942mPc8vRN4xjyYsvCKKPA=; b=LBFTDGo+ftrT9FK1e98T5WEmSVZybK+jZN+pnKK95JaguW1LaPrfaNSBblEWbQiOtR v+KbAXC0SlfTi+4rP36IaX1RMTKG27y9+RJqXPKtNQDkdwE4Jwbz9xHEb+GN4L2F+7PD OA0QSLOafJQBB/lvqHhybpXtc//03xvfSzPXyCGzG7DbIZqhzZaYxO7TBebLyaY+ojsQ 62rXZAdEI2zakjR5DCdMAEBqITp/nmdwfl93nrctcfWO9Pbq9BqI1PE2+t5YGOCwwLpc sdOtiZttDsqXZOaF4flst/wz2dv8ewBfOB8Ri0O+o56efy10k++CThvZJEbikTtDyq4T pSUw== X-Gm-Message-State: AKGB3mKYW4s5w0IlKWsGUseR+HaAk7VODTIUxraVk/KxVNBDVMGFh+RD d7bYqL0C52u/HoQLNwwZOT2BdQ== X-Google-Smtp-Source: ACJfBovDhampeoqv20mPvs8nL02b3pxI1ApkR+dqKgp+vgwUvGAmaKnsiTBmvVSiccREXoGo7HLvsw== X-Received: by 10.107.31.21 with SMTP id f21mr1541285iof.135.1513637130610; Mon, 18 Dec 2017 14:45:30 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:30 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 02/14] net: sched: sch_api: handle generic qdisc errors Date: Mon, 18 Dec 2017 17:45:01 -0500 Message-Id: <20171218224513.29836-3-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for generic qdisc handling. The extack will be set deeper to each called function which is not part of netdev core api. Cc: David Ahern Signed-off-by: Alexander Aring --- net/sched/sch_api.c | 148 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 105 insertions(+), 43 deletions(-) diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index b54917f4ad87..81c6716281f4 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -449,7 +449,8 @@ static const struct nla_policy stab_policy[TCA_STAB_MAX + 1] = { [TCA_STAB_DATA] = { .type = NLA_BINARY }, }; -static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt) +static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt, + struct netlink_ext_ack *extack) { struct nlattr *tb[TCA_STAB_MAX + 1]; struct qdisc_size_table *stab; @@ -458,23 +459,29 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt) u16 *tab = NULL; int err; - err = nla_parse_nested(tb, TCA_STAB_MAX, opt, stab_policy, NULL); + err = nla_parse_nested(tb, TCA_STAB_MAX, opt, stab_policy, extack); if (err < 0) return ERR_PTR(err); - if (!tb[TCA_STAB_BASE]) + if (!tb[TCA_STAB_BASE]) { + NL_SET_ERR_MSG(extack, "Size table base attribute is missing"); return ERR_PTR(-EINVAL); + } s = nla_data(tb[TCA_STAB_BASE]); if (s->tsize > 0) { - if (!tb[TCA_STAB_DATA]) + if (!tb[TCA_STAB_DATA]) { + NL_SET_ERR_MSG(extack, "Size table data attribute is missing"); return ERR_PTR(-EINVAL); + } tab = nla_data(tb[TCA_STAB_DATA]); tsize = nla_len(tb[TCA_STAB_DATA]) / sizeof(u16); } - if (tsize != s->tsize || (!tab && tsize > 0)) + if (tsize != s->tsize || (!tab && tsize > 0)) { + NL_SET_ERR_MSG(extack, "Invalid size of size table"); return ERR_PTR(-EINVAL); + } list_for_each_entry(stab, &qdisc_stab_list, list) { if (memcmp(&stab->szopts, s, sizeof(*s))) @@ -897,7 +904,8 @@ static void notify_and_destroy(struct net *net, struct sk_buff *skb, static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, struct sk_buff *skb, struct nlmsghdr *n, u32 classid, - struct Qdisc *new, struct Qdisc *old) + struct Qdisc *new, struct Qdisc *old, + struct netlink_ext_ack *extack) { struct Qdisc *q = old; struct net *net = dev_net(dev); @@ -912,8 +920,10 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, (new && new->flags & TCQ_F_INGRESS)) { num_q = 1; ingress = 1; - if (!dev_ingress_queue(dev)) + if (!dev_ingress_queue(dev)) { + NL_SET_ERR_MSG(extack, "Device does not have an ingress queue"); return -ENOENT; + } } if (dev->flags & IFF_UP) @@ -964,10 +974,12 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, if (cops && cops->graft) { unsigned long cl = cops->find(parent, classid); - if (cl) + if (cl) { err = cops->graft(parent, cl, new, &old); - else + } else { + NL_SET_ERR_MSG(extack, "Specified class not found"); err = -ENOENT; + } } if (!err) notify_and_destroy(net, skb, n, classid, old, new); @@ -988,7 +1000,8 @@ static struct lock_class_key qdisc_rx_lock; static struct Qdisc *qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, struct Qdisc *p, u32 parent, u32 handle, - struct nlattr **tca, int *errp) + struct nlattr **tca, int *errp, + struct netlink_ext_ack *extack) { int err; struct nlattr *kind = tca[TCA_KIND]; @@ -1026,8 +1039,10 @@ static struct Qdisc *qdisc_create(struct net_device *dev, #endif err = -ENOENT; - if (!ops) + if (!ops) { + NL_SET_ERR_MSG(extack, "Specified qdisc not found"); goto err_out; + } sch = qdisc_alloc(dev_queue, ops); if (IS_ERR(sch)) { @@ -1084,7 +1099,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev, } if (tca[TCA_STAB]) { - stab = qdisc_get_stab(tca[TCA_STAB]); + stab = qdisc_get_stab(tca[TCA_STAB], extack); if (IS_ERR(stab)) { err = PTR_ERR(stab); goto err_out4; @@ -1095,8 +1110,10 @@ static struct Qdisc *qdisc_create(struct net_device *dev, seqcount_t *running; err = -EOPNOTSUPP; - if (sch->flags & TCQ_F_MQROOT) + if (sch->flags & TCQ_F_MQROOT) { + NL_SET_ERR_MSG(extack, "Cannot attach rate estimator to a multi-queue root qdisc"); goto err_out4; + } if (sch->parent != TC_H_ROOT && !(sch->flags & TCQ_F_INGRESS) && @@ -1111,8 +1128,10 @@ static struct Qdisc *qdisc_create(struct net_device *dev, NULL, running, tca[TCA_RATE]); - if (err) + if (err) { + NL_SET_ERR_MSG(extack, "Failed to generate new estimator"); goto err_out4; + } } qdisc_hash_add(sch, false); @@ -1145,21 +1164,24 @@ static struct Qdisc *qdisc_create(struct net_device *dev, goto err_out3; } -static int qdisc_change(struct Qdisc *sch, struct nlattr **tca) +static int qdisc_change(struct Qdisc *sch, struct nlattr **tca, + struct netlink_ext_ack *extack) { struct qdisc_size_table *ostab, *stab = NULL; int err = 0; if (tca[TCA_OPTIONS]) { - if (!sch->ops->change) + if (!sch->ops->change) { + NL_SET_ERR_MSG(extack, "Change operation not supported by specified qdisc"); return -EINVAL; + } err = sch->ops->change(sch, tca[TCA_OPTIONS]); if (err) return err; } if (tca[TCA_STAB]) { - stab = qdisc_get_stab(tca[TCA_STAB]); + stab = qdisc_get_stab(tca[TCA_STAB], extack); if (IS_ERR(stab)) return PTR_ERR(stab); } @@ -1257,8 +1279,10 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, if (clid != TC_H_ROOT) { if (TC_H_MAJ(clid) != TC_H_MAJ(TC_H_INGRESS)) { p = qdisc_lookup(dev, TC_H_MAJ(clid)); - if (!p) + if (!p) { + NL_SET_ERR_MSG(extack, "Failed to find qdisc with specified classid"); return -ENOENT; + } q = qdisc_leaf(p, clid); } else if (dev_ingress_queue(dev)) { q = dev_ingress_queue(dev)->qdisc_sleeping; @@ -1266,26 +1290,38 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, } else { q = dev->qdisc; } - if (!q) + if (!q) { + NL_SET_ERR_MSG(extack, "Cannot find specified qdisc on specified device"); return -ENOENT; + } - if (tcm->tcm_handle && q->handle != tcm->tcm_handle) + if (tcm->tcm_handle && q->handle != tcm->tcm_handle) { + NL_SET_ERR_MSG(extack, "Invalid handle"); return -EINVAL; + } } else { q = qdisc_lookup(dev, tcm->tcm_handle); - if (!q) + if (!q) { + NL_SET_ERR_MSG(extack, "Failed to find qdisc with specified handle"); return -ENOENT; + } } - if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id)) + if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id)) { + NL_SET_ERR_MSG(extack, "Invalid qdisc name"); return -EINVAL; + } if (n->nlmsg_type == RTM_DELQDISC) { - if (!clid) + if (!clid) { + NL_SET_ERR_MSG(extack, "Classid cannot be zero"); return -EINVAL; - if (q->handle == 0) + } + if (q->handle == 0) { + NL_SET_ERR_MSG(extack, "Cannot delete qdisc with handle of zero"); return -ENOENT; - err = qdisc_graft(dev, p, skb, n, clid, NULL, q); + } + err = qdisc_graft(dev, p, skb, n, clid, NULL, q, extack); if (err != 0) return err; } else { @@ -1331,8 +1367,10 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, if (clid != TC_H_ROOT) { if (clid != TC_H_INGRESS) { p = qdisc_lookup(dev, TC_H_MAJ(clid)); - if (!p) + if (!p) { + NL_SET_ERR_MSG(extack, "Failed to find specified qdisc"); return -ENOENT; + } q = qdisc_leaf(p, clid); } else if (dev_ingress_queue_create(dev)) { q = dev_ingress_queue(dev)->qdisc_sleeping; @@ -1347,21 +1385,33 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, if (!q || !tcm->tcm_handle || q->handle != tcm->tcm_handle) { if (tcm->tcm_handle) { - if (q && !(n->nlmsg_flags & NLM_F_REPLACE)) + if (q && !(n->nlmsg_flags & NLM_F_REPLACE)) { + NL_SET_ERR_MSG(extack, "NLM_F_REPLACE needed to override"); return -EEXIST; - if (TC_H_MIN(tcm->tcm_handle)) + } + if (TC_H_MIN(tcm->tcm_handle)) { + NL_SET_ERR_MSG(extack, "Invalid minor handle"); return -EINVAL; + } q = qdisc_lookup(dev, tcm->tcm_handle); - if (!q) + if (!q) { + NL_SET_ERR_MSG(extack, "No qdisc found for specified handle"); goto create_n_graft; - if (n->nlmsg_flags & NLM_F_EXCL) + } + if (n->nlmsg_flags & NLM_F_EXCL) { + NL_SET_ERR_MSG(extack, "Exclusivity flag on, cannot override"); return -EEXIST; + } if (tca[TCA_KIND] && - nla_strcmp(tca[TCA_KIND], q->ops->id)) + nla_strcmp(tca[TCA_KIND], q->ops->id)) { + NL_SET_ERR_MSG(extack, "Invalid qdisc name"); return -EINVAL; + } if (q == p || - (p && check_loop(q, p, 0))) + (p && check_loop(q, p, 0))) { + NL_SET_ERR_MSG(extack, "Qdisc parent/child loop detected"); return -ELOOP; + } qdisc_refcount_inc(q); goto graft; } else { @@ -1396,33 +1446,45 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, } } } else { - if (!tcm->tcm_handle) + if (!tcm->tcm_handle) { + NL_SET_ERR_MSG(extack, "Handle cannot be zero"); return -EINVAL; + } q = qdisc_lookup(dev, tcm->tcm_handle); } /* Change qdisc parameters */ - if (!q) + if (!q) { + NL_SET_ERR_MSG(extack, "Specified qdisc not found"); return -ENOENT; - if (n->nlmsg_flags & NLM_F_EXCL) + } + if (n->nlmsg_flags & NLM_F_EXCL) { + NL_SET_ERR_MSG(extack, "Exclusivity flag on, cannot modify"); return -EEXIST; - if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id)) + } + if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id)) { + NL_SET_ERR_MSG(extack, "Invalid qdisc name"); return -EINVAL; - err = qdisc_change(q, tca); + } + err = qdisc_change(q, tca, extack); if (err == 0) qdisc_notify(net, skb, n, clid, NULL, q); return err; create_n_graft: - if (!(n->nlmsg_flags & NLM_F_CREATE)) + if (!(n->nlmsg_flags & NLM_F_CREATE)) { + NL_SET_ERR_MSG(extack, "Qdisc not found. To create specify NLM_F_CREATE flag"); return -ENOENT; + } if (clid == TC_H_INGRESS) { - if (dev_ingress_queue(dev)) + if (dev_ingress_queue(dev)) { q = qdisc_create(dev, dev_ingress_queue(dev), p, tcm->tcm_parent, tcm->tcm_parent, - tca, &err); - else + tca, &err, extack); + } else { + NL_SET_ERR_MSG(extack, "Cannot find ingress queue for specified device"); err = -ENOENT; + } } else { struct netdev_queue *dev_queue; @@ -1435,7 +1497,7 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, q = qdisc_create(dev, dev_queue, p, tcm->tcm_parent, tcm->tcm_handle, - tca, &err); + tca, &err, extack); } if (q == NULL) { if (err == -EAGAIN) @@ -1444,7 +1506,7 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, } graft: - err = qdisc_graft(dev, p, skb, n, clid, q, NULL); + err = qdisc_graft(dev, p, skb, n, clid, q, NULL, extack); if (err) { if (q) qdisc_destroy(q); From patchwork Mon Dec 18 22:45:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850468 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="UwZMxN2S"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x2h6ThDz9s4s for ; Tue, 19 Dec 2017 09:45:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936434AbdLRWpr (ORCPT ); Mon, 18 Dec 2017 17:45:47 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:45434 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936267AbdLRWpc (ORCPT ); Mon, 18 Dec 2017 17:45:32 -0500 Received: by mail-io0-f195.google.com with SMTP id e204so11542603iof.12 for ; Mon, 18 Dec 2017 14:45:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gAp0xT1NVGRlPmLHNVyFh4vo7ahzGyfJfPr+eujsQ2Q=; b=UwZMxN2SmOfCFBvJS0cZkb8gBwWv5eDbEdw6YKu0mBIv4acQE5LCiVNTZzC/CmYCU1 9Qe9s49DxzpwJJ+ab5qmI+YZbEIGdv+4aFLPBGl5w+6P2UXN0ZkiwfsUSLof+hpfX3bj QkE3ZgziVVZ88b5t+ipfSagrTDDSO4oZ4dsYTCipE0LYMOfaIW4rZiVtbziNijHBsQQ/ opr65jsArruSiqOXazXR6GGSax0lEPL3TFvgYcor6oAZhKhRs+lbWAExu5yfRVedF5z8 mH6cqnJ3Eojars2rg/yBYEZioNc4K/k9e78vgM5woPbGwFRRwPvLnAaY8cGFOIApLAks +Elg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gAp0xT1NVGRlPmLHNVyFh4vo7ahzGyfJfPr+eujsQ2Q=; b=EFmEQPNzXNOdlzBC2M+ov4w5xdKU53WPPAoQqpbzQBgFUAqXQuifCng3GxJDqCxgUz fVbNXQTUyBynYo3K3Gcg7fw18Qlwbu3jpzqbHEPRtbDmpX/zq0eYcvG8Mte9g6QKij9G Qaai5wlQ1ByxteELw57RsN1oE49KbI9y5M3gUD9B9mBUs6B9XqO1Xn2/5QEFCAUVncvq zzyIvfqEE278+x+2wOo/9479XQZaKf8EX22gHop/b6UnbnDhk/NJ8SVoSzHMVcAArC8C wQnNnwa8STACnIot5Sp66R3O/xXjGDS8WJZKu11MzpmndXbs1/ReHHaNk6aEf/PAW0io xzsg== X-Gm-Message-State: AKGB3mKSDIy5r/51jDnePYhfy7+yecmLfsys5qdyGKV4ByfrylSRYZ8L dmvDPGgwYTUO1cSmDyGvdkrllA== X-Google-Smtp-Source: ACJfBoux6iIVqemUbr5qNEIsoKdHWecnbDr9pni/BCvi2Jft5o/uexwLAViFsrYtic5MQjDvKkD6Lg== X-Received: by 10.107.199.131 with SMTP id x125mr1637999iof.70.1513637131735; Mon, 18 Dec 2017 14:45:31 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:31 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 03/14] net: sched: sch: add extack for init callback Date: Mon, 18 Dec 2017 17:45:02 -0500 Message-Id: <20171218224513.29836-4-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for init callback to prepare per-qdisc specific changes for extack. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/sch_api.c | 2 +- net/sched/sch_atm.c | 3 ++- net/sched/sch_cbq.c | 3 ++- net/sched/sch_cbs.c | 3 ++- net/sched/sch_choke.c | 3 ++- net/sched/sch_codel.c | 3 ++- net/sched/sch_drr.c | 3 ++- net/sched/sch_dsmark.c | 3 ++- net/sched/sch_fifo.c | 14 ++++++++++---- net/sched/sch_fq.c | 3 ++- net/sched/sch_fq_codel.c | 3 ++- net/sched/sch_generic.c | 8 +++++--- net/sched/sch_gred.c | 3 ++- net/sched/sch_hfsc.c | 3 ++- net/sched/sch_hhf.c | 3 ++- net/sched/sch_htb.c | 3 ++- net/sched/sch_ingress.c | 6 ++++-- net/sched/sch_mq.c | 3 ++- net/sched/sch_mqprio.c | 3 ++- net/sched/sch_multiq.c | 3 ++- net/sched/sch_netem.c | 3 ++- net/sched/sch_pie.c | 3 ++- net/sched/sch_plug.c | 3 ++- net/sched/sch_prio.c | 3 ++- net/sched/sch_qfq.c | 3 ++- net/sched/sch_red.c | 3 ++- net/sched/sch_sfb.c | 3 ++- net/sched/sch_sfq.c | 3 ++- net/sched/sch_tbf.c | 3 ++- net/sched/sch_teql.c | 3 ++- 31 files changed, 74 insertions(+), 37 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 8f8c0afe529b..0f1c4b3a6cb7 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -188,7 +188,8 @@ struct Qdisc_ops { struct sk_buff * (*dequeue)(struct Qdisc *); struct sk_buff * (*peek)(struct Qdisc *); - int (*init)(struct Qdisc *sch, struct nlattr *arg); + int (*init)(struct Qdisc *sch, struct nlattr *arg, + struct netlink_ext_ack *extack); void (*reset)(struct Qdisc *); void (*destroy)(struct Qdisc *); int (*change)(struct Qdisc *sch, diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 81c6716281f4..bd8adb0c431d 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1082,7 +1082,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev, } if (ops->init) { - err = ops->init(sch, tca[TCA_OPTIONS]); + err = ops->init(sch, tca[TCA_OPTIONS], extack); if (err != 0) goto err_out5; } diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 2dbd249c0b2f..53a07687c0fb 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c @@ -531,7 +531,8 @@ static struct sk_buff *atm_tc_peek(struct Qdisc *sch) return p->link.q->ops->peek(p->link.q); } -static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt) +static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct atm_qdisc_data *p = qdisc_priv(sch); int err; diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 0692fe35f4ec..86eba01457f3 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1132,7 +1132,8 @@ static const struct nla_policy cbq_policy[TCA_CBQ_MAX + 1] = { [TCA_CBQ_POLICE] = { .len = sizeof(struct tc_cbq_police) }, }; -static int cbq_init(struct Qdisc *sch, struct nlattr *opt) +static int cbq_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct cbq_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_CBQ_MAX + 1]; diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c index 7a72980c1509..d77c632a276c 100644 --- a/net/sched/sch_cbs.c +++ b/net/sched/sch_cbs.c @@ -291,7 +291,8 @@ static int cbs_change(struct Qdisc *sch, struct nlattr *opt) return 0; } -static int cbs_init(struct Qdisc *sch, struct nlattr *opt) +static int cbs_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct cbs_sched_data *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c index 531250fceb9e..49dda301e3bb 100644 --- a/net/sched/sch_choke.c +++ b/net/sched/sch_choke.c @@ -431,7 +431,8 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt) return 0; } -static int choke_init(struct Qdisc *sch, struct nlattr *opt) +static int choke_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { return choke_change(sch, opt); } diff --git a/net/sched/sch_codel.c b/net/sched/sch_codel.c index c518a1efcb9d..7221244e7f3b 100644 --- a/net/sched/sch_codel.c +++ b/net/sched/sch_codel.c @@ -184,7 +184,8 @@ static int codel_change(struct Qdisc *sch, struct nlattr *opt) return 0; } -static int codel_init(struct Qdisc *sch, struct nlattr *opt) +static int codel_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct codel_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index 5bbcef3dcd8c..1a88473cd768 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -408,7 +408,8 @@ static struct sk_buff *drr_dequeue(struct Qdisc *sch) return NULL; } -static int drr_init_qdisc(struct Qdisc *sch, struct nlattr *opt) +static int drr_init_qdisc(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct drr_sched *q = qdisc_priv(sch); int err; diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index fb4fb71c68cf..16dd480b5583 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -330,7 +330,8 @@ static struct sk_buff *dsmark_peek(struct Qdisc *sch) return p->q->ops->peek(p->q); } -static int dsmark_init(struct Qdisc *sch, struct nlattr *opt) +static int dsmark_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct dsmark_qdisc_data *p = qdisc_priv(sch); struct nlattr *tb[TCA_DSMARK_MAX + 1]; diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c index 1e37247656f8..a2d1c9f9b798 100644 --- a/net/sched/sch_fifo.c +++ b/net/sched/sch_fifo.c @@ -55,7 +55,8 @@ static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc *sch, return NET_XMIT_CN; } -static int fifo_init(struct Qdisc *sch, struct nlattr *opt) +static int fifo_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { bool bypass; bool is_bfifo = sch->ops == &bfifo_qdisc_ops; @@ -88,6 +89,11 @@ static int fifo_init(struct Qdisc *sch, struct nlattr *opt) return 0; } +static int fifo_change(struct Qdisc *sch, struct nlattr *opt) +{ + return fifo_init(sch, opt, NULL); +} + static int fifo_dump(struct Qdisc *sch, struct sk_buff *skb) { struct tc_fifo_qopt opt = { .limit = sch->limit }; @@ -108,7 +114,7 @@ struct Qdisc_ops pfifo_qdisc_ops __read_mostly = { .peek = qdisc_peek_head, .init = fifo_init, .reset = qdisc_reset_queue, - .change = fifo_init, + .change = fifo_change, .dump = fifo_dump, .owner = THIS_MODULE, }; @@ -122,7 +128,7 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = { .peek = qdisc_peek_head, .init = fifo_init, .reset = qdisc_reset_queue, - .change = fifo_init, + .change = fifo_change, .dump = fifo_dump, .owner = THIS_MODULE, }; @@ -136,7 +142,7 @@ struct Qdisc_ops pfifo_head_drop_qdisc_ops __read_mostly = { .peek = qdisc_peek_head, .init = fifo_init, .reset = qdisc_reset_queue, - .change = fifo_init, + .change = fifo_change, .dump = fifo_dump, .owner = THIS_MODULE, }; diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c index 263d16e3219e..c9f61ffe220e 100644 --- a/net/sched/sch_fq.c +++ b/net/sched/sch_fq.c @@ -788,7 +788,8 @@ static void fq_destroy(struct Qdisc *sch) qdisc_watchdog_cancel(&q->watchdog); } -static int fq_init(struct Qdisc *sch, struct nlattr *opt) +static int fq_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct fq_sched_data *q = qdisc_priv(sch); int err; diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index 0305d791ea94..5d0b20898ffa 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c @@ -458,7 +458,8 @@ static void fq_codel_destroy(struct Qdisc *sch) kvfree(q->flows); } -static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) +static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct fq_codel_sched_data *q = qdisc_priv(sch); int i; diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 981c08fe810b..5cdafe88b902 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -551,7 +551,8 @@ struct Qdisc noop_qdisc = { }; EXPORT_SYMBOL(noop_qdisc); -static int noqueue_init(struct Qdisc *qdisc, struct nlattr *opt) +static int noqueue_init(struct Qdisc *qdisc, struct nlattr *opt, + struct netlink_ext_ack *extack) { /* register_qdisc() assigns a default of noop_enqueue if unset, * but __dev_queue_xmit() treats noqueue only as such @@ -684,7 +685,8 @@ static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb) return -1; } -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt) +static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt, + struct netlink_ext_ack *extack) { unsigned int qlen = qdisc_dev(qdisc)->tx_queue_len; struct pfifo_fast_priv *priv = qdisc_priv(qdisc); @@ -834,7 +836,7 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, } sch->parent = parentid; - if (!ops->init || ops->init(sch, NULL) == 0) + if (!ops->init || ops->init(sch, NULL, NULL) == 0) return sch; qdisc_destroy(sch); diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c index ccd1a00e2a9a..4cab6ccad643 100644 --- a/net/sched/sch_gred.c +++ b/net/sched/sch_gred.c @@ -466,7 +466,8 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt) return err; } -static int gred_init(struct Qdisc *sch, struct nlattr *opt) +static int gred_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct nlattr *tb[TCA_GRED_MAX + 1]; int err; diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 94db20352f37..1102943c46c9 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1388,7 +1388,8 @@ hfsc_schedule_watchdog(struct Qdisc *sch) } static int -hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt) +hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct hfsc_sched *q = qdisc_priv(sch); struct tc_hfsc_qopt *qopt; diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c index 73a53c08091b..b3a80f0ed4b0 100644 --- a/net/sched/sch_hhf.c +++ b/net/sched/sch_hhf.c @@ -571,7 +571,8 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt) return 0; } -static int hhf_init(struct Qdisc *sch, struct nlattr *opt) +static int hhf_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct hhf_sched_data *q = qdisc_priv(sch); int i; diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index fa0380730ff0..41d9b7da9273 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1017,7 +1017,8 @@ static void htb_work_func(struct work_struct *work) rcu_read_unlock(); } -static int htb_init(struct Qdisc *sch, struct nlattr *opt) +static int htb_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct htb_sched *q = qdisc_priv(sch); struct nlattr *tb[TCA_HTB_MAX + 1]; diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index 5ecc38f35d47..c703cf3a0bed 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -62,7 +62,8 @@ static void clsact_chain_head_change(struct tcf_proto *tp_head, void *priv) mini_qdisc_pair_swap(miniqp, tp_head); } -static int ingress_init(struct Qdisc *sch, struct nlattr *opt) +static int ingress_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct ingress_sched_data *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); @@ -166,7 +167,8 @@ static struct tcf_block *clsact_tcf_block(struct Qdisc *sch, unsigned long cl) } } -static int clsact_init(struct Qdisc *sch, struct nlattr *opt) +static int clsact_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct clsact_sched_data *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c index 8cbb5c829d59..b91f7d8cb184 100644 --- a/net/sched/sch_mq.c +++ b/net/sched/sch_mq.c @@ -36,7 +36,8 @@ static void mq_destroy(struct Qdisc *sch) kfree(priv->qdiscs); } -static int mq_init(struct Qdisc *sch, struct nlattr *opt) +static int mq_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct net_device *dev = qdisc_dev(sch); struct mq_sched *priv = qdisc_priv(sch); diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 8622745f3cd9..0379fc4ee7bb 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -132,7 +132,8 @@ static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla, return 0; } -static int mqprio_init(struct Qdisc *sch, struct nlattr *opt) +static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct net_device *dev = qdisc_dev(sch); struct mqprio_sched *priv = qdisc_priv(sch); diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c index 37195e0c64ba..54132dde6d42 100644 --- a/net/sched/sch_multiq.c +++ b/net/sched/sch_multiq.c @@ -236,7 +236,8 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt) return 0; } -static int multiq_init(struct Qdisc *sch, struct nlattr *opt) +static int multiq_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct multiq_sched_data *q = qdisc_priv(sch); int i, err; diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index dd70924cbcdf..6490ce08d29e 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -984,7 +984,8 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt) return ret; } -static int netem_init(struct Qdisc *sch, struct nlattr *opt) +static int netem_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct netem_sched_data *q = qdisc_priv(sch); int ret; diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c index 776c694c77c7..c4c87ed3971f 100644 --- a/net/sched/sch_pie.c +++ b/net/sched/sch_pie.c @@ -439,7 +439,8 @@ static void pie_timer(struct timer_list *t) } -static int pie_init(struct Qdisc *sch, struct nlattr *opt) +static int pie_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct pie_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_plug.c b/net/sched/sch_plug.c index 1c6cbab3e7b9..d9c6fbe55ae5 100644 --- a/net/sched/sch_plug.c +++ b/net/sched/sch_plug.c @@ -123,7 +123,8 @@ static struct sk_buff *plug_dequeue(struct Qdisc *sch) return qdisc_dequeue_head(sch); } -static int plug_init(struct Qdisc *sch, struct nlattr *opt) +static int plug_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct plug_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index 2c79559a0d31..8632d795e6ee 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c @@ -205,7 +205,8 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt) return 0; } -static int prio_init(struct Qdisc *sch, struct nlattr *opt) +static int prio_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct prio_sched_data *q = qdisc_priv(sch); int err; diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 6962b37a3ad3..7c1b976314bd 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -1413,7 +1413,8 @@ static void qfq_qlen_notify(struct Qdisc *sch, unsigned long arg) qfq_deactivate_class(q, cl); } -static int qfq_init_qdisc(struct Qdisc *sch, struct nlattr *opt) +static int qfq_init_qdisc(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct qfq_sched *q = qdisc_priv(sch); struct qfq_group *grp; diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index 9d874e60e032..e7fb68613f4d 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c @@ -264,7 +264,8 @@ static inline void red_adaptative_timer(struct timer_list *t) spin_unlock(root_lock); } -static int red_init(struct Qdisc *sch, struct nlattr *opt) +static int red_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct red_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index 0678debdd856..b2205eaa0f51 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c @@ -549,7 +549,8 @@ static int sfb_change(struct Qdisc *sch, struct nlattr *opt) return 0; } -static int sfb_init(struct Qdisc *sch, struct nlattr *opt) +static int sfb_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct sfb_sched_data *q = qdisc_priv(sch); int err; diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 930e5bd26d3d..3b5869c7b3f3 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -721,7 +721,8 @@ static void sfq_destroy(struct Qdisc *sch) kfree(q->red_parms); } -static int sfq_init(struct Qdisc *sch, struct nlattr *opt) +static int sfq_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct sfq_sched_data *q = qdisc_priv(sch); int i; diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index e8f3345674c5..9abff1271ec0 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -421,7 +421,8 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt) return err; } -static int tbf_init(struct Qdisc *sch, struct nlattr *opt) +static int tbf_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct tbf_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c index 9fe6b427afed..93f04cf5cac1 100644 --- a/net/sched/sch_teql.c +++ b/net/sched/sch_teql.c @@ -167,7 +167,8 @@ teql_destroy(struct Qdisc *sch) } } -static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt) +static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct net_device *dev = qdisc_dev(sch); struct teql_master *m = (struct teql_master *)sch->ops; From patchwork Mon Dec 18 22:45:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850470 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="whm1kdVz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x341S5gz9s4s for ; Tue, 19 Dec 2017 09:46:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964905AbdLRWpo (ORCPT ); Mon, 18 Dec 2017 17:45:44 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:44835 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936306AbdLRWpd (ORCPT ); Mon, 18 Dec 2017 17:45:33 -0500 Received: by mail-io0-f196.google.com with SMTP id w127so11538345iow.11 for ; Mon, 18 Dec 2017 14:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kEKtU6f0fpO4mZcGxuRWBIFcLjhgIJ4hsE82vJzF6ag=; b=whm1kdVze4+XitJGcg6mM0DQUp2kj48cxsuxOygb5UFOqOLsmNMZ4ap/Bm+kW36fT0 wMlT6y/r/2R+dSBUQLzL9XQlQfkUrMLpzZ0v+VtAkQNRMQ5k2FXikQS0gm5CTAW678Z2 OlG0oXYv22eXiWh4MJqmJ/30/jowvbsK0O75d8Y6fIn6kYpnOeh3GCEZm+gXZBiQtk75 1w0k4QISw2LsSyXwS+1drJ8XRY8FMT7XzdZe3VNkqyNWUJaIlsm/GfkK0rdQ8uxYT0/j MWnd7Bd6+KOkbrYS7OIi6+D1ORyUO4S8Rj8Gb3L8hfASP1BdcG417DleRSHl7pmRehXY BDBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kEKtU6f0fpO4mZcGxuRWBIFcLjhgIJ4hsE82vJzF6ag=; b=dWlonikbKCP3Ml2BDeC2FlPAYrvVmZc7Gwf92HbA0Pu/9kD93hBXLuiZZ2f5G16ok/ e/eCcj1cc76IPkHfIaFLNlQrPju6vExEz0UzookZgsMkpi5L2Dis8cgNyOXfdPWBVzHc YDFoEivlfNBDUm1JJL047ybwT2pqufxztZoYXEAgBsHQhUZD1ENb04PGpwmgTzUdf8p6 MNl57EJYB2ZJjCpH2FizzeSYHcinZ6AByD1zeZMl1EdDY5bIeiLltMug8byvVUH9788g vJIys8v0EWR4BLb7IRyKZKm3f/6hhBIALXOzpOyJPgLUQFTGlQ+B9A8CAK2lZ5SkSbr8 ndyg== X-Gm-Message-State: AKGB3mJy5VPxAB0fF5huQxmKnSklbTXb39gvzm6F7GQtBWqdgBab3esj tv717oBHm7rvRPG9Ur5nitz3lkU4 X-Google-Smtp-Source: ACJfBos3dV8LuQ0HMrlOG2zxZFh4QG3v2fYzRAfJTqPm/NGYEvXPD7zwGKVlzDkIbp33SVBHh+ldPA== X-Received: by 10.107.107.23 with SMTP id g23mr1627738ioc.283.1513637132882; Mon, 18 Dec 2017 14:45:32 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:32 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 04/14] net: sched: sch: add extack for change qdisc ops Date: Mon, 18 Dec 2017 17:45:03 -0500 Message-Id: <20171218224513.29836-5-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for change callback for qdisc ops structtur to prepare per-qdisc specific changes for extack. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/sch_api.c | 2 +- net/sched/sch_cbs.c | 5 +++-- net/sched/sch_choke.c | 5 +++-- net/sched/sch_codel.c | 5 +++-- net/sched/sch_fifo.c | 13 ++++--------- net/sched/sch_fq.c | 5 +++-- net/sched/sch_fq_codel.c | 5 +++-- net/sched/sch_gred.c | 3 ++- net/sched/sch_hfsc.c | 3 ++- net/sched/sch_hhf.c | 5 +++-- net/sched/sch_multiq.c | 5 +++-- net/sched/sch_netem.c | 5 +++-- net/sched/sch_pie.c | 5 +++-- net/sched/sch_plug.c | 3 ++- net/sched/sch_prio.c | 5 +++-- net/sched/sch_red.c | 5 +++-- net/sched/sch_sfb.c | 5 +++-- net/sched/sch_tbf.c | 5 +++-- 19 files changed, 52 insertions(+), 40 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 0f1c4b3a6cb7..7f35e71a478b 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -193,7 +193,8 @@ struct Qdisc_ops { void (*reset)(struct Qdisc *); void (*destroy)(struct Qdisc *); int (*change)(struct Qdisc *sch, - struct nlattr *arg); + struct nlattr *arg, + struct netlink_ext_ack *extack); void (*attach)(struct Qdisc *sch); int (*dump)(struct Qdisc *, struct sk_buff *); diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index bd8adb0c431d..d57dc5cd4ecf 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1175,7 +1175,7 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca, NL_SET_ERR_MSG(extack, "Change operation not supported by specified qdisc"); return -EINVAL; } - err = sch->ops->change(sch, tca[TCA_OPTIONS]); + err = sch->ops->change(sch, tca[TCA_OPTIONS], extack); if (err) return err; } diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c index d77c632a276c..8bf6e163d29c 100644 --- a/net/sched/sch_cbs.c +++ b/net/sched/sch_cbs.c @@ -246,7 +246,8 @@ static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q, return 0; } -static int cbs_change(struct Qdisc *sch, struct nlattr *opt) +static int cbs_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct cbs_sched_data *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); @@ -307,7 +308,7 @@ static int cbs_init(struct Qdisc *sch, struct nlattr *opt, qdisc_watchdog_init(&q->watchdog, sch); - return cbs_change(sch, opt); + return cbs_change(sch, opt, extack); } static void cbs_destroy(struct Qdisc *sch) diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c index 49dda301e3bb..eafc0d17d174 100644 --- a/net/sched/sch_choke.c +++ b/net/sched/sch_choke.c @@ -344,7 +344,8 @@ static void choke_free(void *addr) kvfree(addr); } -static int choke_change(struct Qdisc *sch, struct nlattr *opt) +static int choke_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct choke_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_CHOKE_MAX + 1]; @@ -434,7 +435,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt) static int choke_init(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) { - return choke_change(sch, opt); + return choke_change(sch, opt, extack); } static int choke_dump(struct Qdisc *sch, struct sk_buff *skb) diff --git a/net/sched/sch_codel.c b/net/sched/sch_codel.c index 7221244e7f3b..17cd81f84b5d 100644 --- a/net/sched/sch_codel.c +++ b/net/sched/sch_codel.c @@ -130,7 +130,8 @@ static const struct nla_policy codel_policy[TCA_CODEL_MAX + 1] = { [TCA_CODEL_CE_THRESHOLD]= { .type = NLA_U32 }, }; -static int codel_change(struct Qdisc *sch, struct nlattr *opt) +static int codel_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct codel_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_CODEL_MAX + 1]; @@ -197,7 +198,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt, q->params.mtu = psched_mtu(qdisc_dev(sch)); if (opt) { - int err = codel_change(sch, opt); + int err = codel_change(sch, opt, extack); if (err) return err; diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c index a2d1c9f9b798..c65f23c70f40 100644 --- a/net/sched/sch_fifo.c +++ b/net/sched/sch_fifo.c @@ -89,11 +89,6 @@ static int fifo_init(struct Qdisc *sch, struct nlattr *opt, return 0; } -static int fifo_change(struct Qdisc *sch, struct nlattr *opt) -{ - return fifo_init(sch, opt, NULL); -} - static int fifo_dump(struct Qdisc *sch, struct sk_buff *skb) { struct tc_fifo_qopt opt = { .limit = sch->limit }; @@ -114,7 +109,7 @@ struct Qdisc_ops pfifo_qdisc_ops __read_mostly = { .peek = qdisc_peek_head, .init = fifo_init, .reset = qdisc_reset_queue, - .change = fifo_change, + .change = fifo_init, .dump = fifo_dump, .owner = THIS_MODULE, }; @@ -128,7 +123,7 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = { .peek = qdisc_peek_head, .init = fifo_init, .reset = qdisc_reset_queue, - .change = fifo_change, + .change = fifo_init, .dump = fifo_dump, .owner = THIS_MODULE, }; @@ -142,7 +137,7 @@ struct Qdisc_ops pfifo_head_drop_qdisc_ops __read_mostly = { .peek = qdisc_peek_head, .init = fifo_init, .reset = qdisc_reset_queue, - .change = fifo_change, + .change = fifo_init, .dump = fifo_dump, .owner = THIS_MODULE, }; @@ -163,7 +158,7 @@ int fifo_set_limit(struct Qdisc *q, unsigned int limit) nla->nla_len = nla_attr_size(sizeof(struct tc_fifo_qopt)); ((struct tc_fifo_qopt *)nla_data(nla))->limit = limit; - ret = q->ops->change(q, nla); + ret = q->ops->change(q, nla, NULL); kfree(nla); } return ret; diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c index c9f61ffe220e..a366e4c9413a 100644 --- a/net/sched/sch_fq.c +++ b/net/sched/sch_fq.c @@ -685,7 +685,8 @@ static const struct nla_policy fq_policy[TCA_FQ_MAX + 1] = { [TCA_FQ_LOW_RATE_THRESHOLD] = { .type = NLA_U32 }, }; -static int fq_change(struct Qdisc *sch, struct nlattr *opt) +static int fq_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct fq_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_FQ_MAX + 1]; @@ -812,7 +813,7 @@ static int fq_init(struct Qdisc *sch, struct nlattr *opt, qdisc_watchdog_init(&q->watchdog, sch); if (opt) - err = fq_change(sch, opt); + err = fq_change(sch, opt, extack); else err = fq_resize(sch, q->fq_trees_log); diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index 5d0b20898ffa..d798c93f7c96 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c @@ -377,7 +377,8 @@ static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { [TCA_FQ_CODEL_MEMORY_LIMIT] = { .type = NLA_U32 }, }; -static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) +static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct fq_codel_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; @@ -478,7 +479,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, q->cparams.mtu = psched_mtu(qdisc_dev(sch)); if (opt) { - int err = fq_codel_change(sch, opt); + int err = fq_codel_change(sch, opt, NULL); if (err) return err; } diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c index 4cab6ccad643..cbe4831f46f4 100644 --- a/net/sched/sch_gred.c +++ b/net/sched/sch_gred.c @@ -392,7 +392,8 @@ static const struct nla_policy gred_policy[TCA_GRED_MAX + 1] = { [TCA_GRED_LIMIT] = { .type = NLA_U32 }, }; -static int gred_change(struct Qdisc *sch, struct nlattr *opt) +static int gred_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct gred_sched *table = qdisc_priv(sch); struct tc_gred_qopt *ctl; diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 1102943c46c9..f49a4a4fe095 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1430,7 +1430,8 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt, } static int -hfsc_change_qdisc(struct Qdisc *sch, struct nlattr *opt) +hfsc_change_qdisc(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct hfsc_sched *q = qdisc_priv(sch); struct tc_hfsc_qopt *qopt; diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c index b3a80f0ed4b0..bce2632212d3 100644 --- a/net/sched/sch_hhf.c +++ b/net/sched/sch_hhf.c @@ -504,7 +504,8 @@ static const struct nla_policy hhf_policy[TCA_HHF_MAX + 1] = { [TCA_HHF_NON_HH_WEIGHT] = { .type = NLA_U32 }, }; -static int hhf_change(struct Qdisc *sch, struct nlattr *opt) +static int hhf_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct hhf_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_HHF_MAX + 1]; @@ -590,7 +591,7 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt, q->hhf_non_hh_weight = 2; if (opt) { - int err = hhf_change(sch, opt); + int err = hhf_change(sch, opt, extack); if (err) return err; diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c index 54132dde6d42..a8db1dbeb04f 100644 --- a/net/sched/sch_multiq.c +++ b/net/sched/sch_multiq.c @@ -180,7 +180,8 @@ multiq_destroy(struct Qdisc *sch) kfree(q->queues); } -static int multiq_tune(struct Qdisc *sch, struct nlattr *opt) +static int multiq_tune(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct multiq_sched_data *q = qdisc_priv(sch); struct tc_multiq_qopt *qopt; @@ -259,7 +260,7 @@ static int multiq_init(struct Qdisc *sch, struct nlattr *opt, for (i = 0; i < q->max_bands; i++) q->queues[i] = &noop_qdisc; - return multiq_tune(sch, opt); + return multiq_tune(sch, opt, extack); } static int multiq_dump(struct Qdisc *sch, struct sk_buff *skb) diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 6490ce08d29e..f45040b55531 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -893,7 +893,8 @@ static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla, } /* Parse netlink message to set options */ -static int netem_change(struct Qdisc *sch, struct nlattr *opt) +static int netem_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct netem_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_NETEM_MAX + 1]; @@ -996,7 +997,7 @@ static int netem_init(struct Qdisc *sch, struct nlattr *opt, return -EINVAL; q->loss_model = CLG_RANDOM; - ret = netem_change(sch, opt); + ret = netem_change(sch, opt, extack); if (ret) pr_info("netem: change failed\n"); return ret; diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c index c4c87ed3971f..18d30bb86881 100644 --- a/net/sched/sch_pie.c +++ b/net/sched/sch_pie.c @@ -181,7 +181,8 @@ static const struct nla_policy pie_policy[TCA_PIE_MAX + 1] = { [TCA_PIE_BYTEMODE] = {.type = NLA_U32}, }; -static int pie_change(struct Qdisc *sch, struct nlattr *opt) +static int pie_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct pie_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_PIE_MAX + 1]; @@ -452,7 +453,7 @@ static int pie_init(struct Qdisc *sch, struct nlattr *opt, timer_setup(&q->adapt_timer, pie_timer, 0); if (opt) { - int err = pie_change(sch, opt); + int err = pie_change(sch, opt, extack); if (err) return err; diff --git a/net/sched/sch_plug.c b/net/sched/sch_plug.c index d9c6fbe55ae5..5619d2eb17b6 100644 --- a/net/sched/sch_plug.c +++ b/net/sched/sch_plug.c @@ -159,7 +159,8 @@ static int plug_init(struct Qdisc *sch, struct nlattr *opt, * command is received (just act as a pass-thru queue). * TCQ_PLUG_LIMIT: Increase/decrease queue size */ -static int plug_change(struct Qdisc *sch, struct nlattr *opt) +static int plug_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct plug_sched_data *q = qdisc_priv(sch); struct tc_plug_qopt *msg; diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index 8632d795e6ee..5f8ecbaa2610 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c @@ -153,7 +153,8 @@ prio_destroy(struct Qdisc *sch) qdisc_destroy(q->queues[prio]); } -static int prio_tune(struct Qdisc *sch, struct nlattr *opt) +static int prio_tune(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct prio_sched_data *q = qdisc_priv(sch); struct Qdisc *queues[TCQ_PRIO_BANDS]; @@ -218,7 +219,7 @@ static int prio_init(struct Qdisc *sch, struct nlattr *opt, if (err) return err; - return prio_tune(sch, opt); + return prio_tune(sch, opt, extack); } static int prio_dump(struct Qdisc *sch, struct sk_buff *skb) diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index e7fb68613f4d..66b33b829b54 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c @@ -189,7 +189,8 @@ static const struct nla_policy red_policy[TCA_RED_MAX + 1] = { [TCA_RED_MAX_P] = { .type = NLA_U32 }, }; -static int red_change(struct Qdisc *sch, struct nlattr *opt) +static int red_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct red_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_RED_MAX + 1]; @@ -272,7 +273,7 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt, q->qdisc = &noop_qdisc; q->sch = sch; timer_setup(&q->adapt_timer, red_adaptative_timer, 0); - return red_change(sch, opt); + return red_change(sch, opt, extack); } static int red_dump_offload(struct Qdisc *sch, struct tc_red_qopt *opt) diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index b2205eaa0f51..1b9d69bd6ed6 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c @@ -488,7 +488,8 @@ static const struct tc_sfb_qopt sfb_default_ops = { .penalty_burst = 20, }; -static int sfb_change(struct Qdisc *sch, struct nlattr *opt) +static int sfb_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { struct sfb_sched_data *q = qdisc_priv(sch); struct Qdisc *child; @@ -560,7 +561,7 @@ static int sfb_init(struct Qdisc *sch, struct nlattr *opt, return err; q->qdisc = &noop_qdisc; - return sfb_change(sch, opt); + return sfb_change(sch, opt, extack); } static int sfb_dump(struct Qdisc *sch, struct sk_buff *skb) diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 9abff1271ec0..273228eb5ce0 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -302,7 +302,8 @@ static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = { [TCA_TBF_PBURST] = { .type = NLA_U32 }, }; -static int tbf_change(struct Qdisc *sch, struct nlattr *opt) +static int tbf_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) { int err; struct tbf_sched_data *q = qdisc_priv(sch); @@ -434,7 +435,7 @@ static int tbf_init(struct Qdisc *sch, struct nlattr *opt, q->t_c = ktime_get_ns(); - return tbf_change(sch, opt); + return tbf_change(sch, opt, extack); } static void tbf_destroy(struct Qdisc *sch) From patchwork Mon Dec 18 22:45:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850473 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="UAGfuw8Q"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x3D2VLKz9t2M for ; Tue, 19 Dec 2017 09:46:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938303AbdLRWpm (ORCPT ); Mon, 18 Dec 2017 17:45:42 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:45436 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936346AbdLRWpe (ORCPT ); Mon, 18 Dec 2017 17:45:34 -0500 Received: by mail-io0-f196.google.com with SMTP id e204so11542678iof.12 for ; Mon, 18 Dec 2017 14:45:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=plIPkI+dtPml7mdGRR5eFHJ5BB7ZCzHDgF42cup1hIA=; b=UAGfuw8QYmuXBgSpTBmcil9GkTbu2XzLvGwOCXOQzUqwgLLQsmru84/3s3hJyFyHWu 2qSNnkeLVbwr+PQypDW3YuZpXulHor3yR71IVyszYVyS4EoUb2czC0R/h9UJpT4hDnVE LmGxcmoY5lR3vSJ7kJ/yNACmFEKPr2IzVPdzTypQRtNYPo67LIIA0A5vfcyJdD9Sp60a ivayiNEY9hG713hE39tELHFOD4NtdMzEfBwzf6U5HOq8P9GeCHvhkNYLlfEk5Qfw3nBL GDj08zc4yfOoif3FyIdtHhXzyWF5QJqZsEqFgVgrYsqasjJ9/fmUiK/X48Ey5RweghH4 POHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=plIPkI+dtPml7mdGRR5eFHJ5BB7ZCzHDgF42cup1hIA=; b=f+vl13jKSRam02RdQQmMhcytypNwp+/ra0zA9neBSEHszaKU4mSpmhczRK53OzKWSV UPmUTp6B9ujPInAgwcvNIFoAL99ln7iU58oQ8DrX8e40getDcDXoMIa77NSf1vTWvwJs V0iNeDYDV8utSBTlIrPWQrlvMmIId5OY2FFN9XIaP//FiwYYuEOY2TZxEfPSirtas0al hh0ByCAA82ZKG+gW5dSgoLls5+uRBk7sw5sQVF6g5kZjppama+VFl6QcCQQrynwY9Mq6 FdYbOhD1w5HYo4nDcMy0OBTtCtqZ63BptWLkF/loXTcRLXTPiSXeIqBkIlEHTN6peb/f EwXg== X-Gm-Message-State: AKGB3mK28uwimRJwSDnKvM753uRitrPRSPlBv79hsFRLxc8A1Dr/tlFe 3PW90n3QX9xihT/q39kkSOPX6Q== X-Google-Smtp-Source: ACJfBosc6mESKWTq3st3o2nhQV9QWDo+eVfkQZ0g7EEgs0W9Nu5g/ib2JptkBywY0F7ScQqTkcU/yA== X-Received: by 10.107.47.93 with SMTP id j90mr1571361ioo.262.1513637134000; Mon, 18 Dec 2017 14:45:34 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:33 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 05/14] net: sched: sch: add extack to change class Date: Mon, 18 Dec 2017 17:45:04 -0500 Message-Id: <20171218224513.29836-6-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for class change callback api. This prepares to handle extack support inside each specific class implementation. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/sch_api.c | 2 +- net/sched/sch_atm.c | 3 ++- net/sched/sch_cbq.c | 2 +- net/sched/sch_drr.c | 3 ++- net/sched/sch_dsmark.c | 3 ++- net/sched/sch_fq_codel.c | 2 +- net/sched/sch_hfsc.c | 3 ++- net/sched/sch_htb.c | 2 +- net/sched/sch_qfq.c | 3 ++- net/sched/sch_sfb.c | 3 ++- 11 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 7f35e71a478b..219ad45cc4cd 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -157,7 +157,8 @@ struct Qdisc_class_ops { /* Class manipulation routines */ unsigned long (*find)(struct Qdisc *, u32 classid); int (*change)(struct Qdisc *, u32, u32, - struct nlattr **, unsigned long *); + struct nlattr **, unsigned long *, + struct netlink_ext_ack *); int (*delete)(struct Qdisc *, unsigned long); void (*walk)(struct Qdisc *, struct qdisc_walker * arg); diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index d57dc5cd4ecf..4a77b3d06f9b 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1905,7 +1905,7 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, new_cl = cl; err = -EOPNOTSUPP; if (cops->change) - err = cops->change(q, clid, portid, tca, &new_cl); + err = cops->change(q, clid, portid, tca, &new_cl, extack); if (err == 0) { tclass_notify(net, skb, n, q, new_cl, RTM_NEWTCLASS); /* We just create a new class, need to do reverse binding. */ diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 53a07687c0fb..80ada9affe81 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c @@ -191,7 +191,8 @@ static const struct nla_policy atm_policy[TCA_ATM_MAX + 1] = { }; static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, - struct nlattr **tca, unsigned long *arg) + struct nlattr **tca, unsigned long *arg, + struct netlink_ext_ack *extack) { struct atm_qdisc_data *p = qdisc_priv(sch); struct atm_flow_data *flow = (struct atm_flow_data *)*arg; diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 86eba01457f3..8f1832df8b4f 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1452,7 +1452,7 @@ static void cbq_destroy(struct Qdisc *sch) static int cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **tca, - unsigned long *arg) + unsigned long *arg, struct netlink_ext_ack *extack) { int err; struct cbq_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index 1a88473cd768..73b914bc47a4 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -64,7 +64,8 @@ static const struct nla_policy drr_policy[TCA_DRR_MAX + 1] = { }; static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, - struct nlattr **tca, unsigned long *arg) + struct nlattr **tca, unsigned long *arg, + struct netlink_ext_ack *extack) { struct drr_sched *q = qdisc_priv(sch); struct drr_class *cl = (struct drr_class *)*arg; diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index 16dd480b5583..89e433bbd590 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -112,7 +112,8 @@ static const struct nla_policy dsmark_policy[TCA_DSMARK_MAX + 1] = { }; static int dsmark_change(struct Qdisc *sch, u32 classid, u32 parent, - struct nlattr **tca, unsigned long *arg) + struct nlattr **tca, unsigned long *arg, + struct netlink_ext_ack *extack) { struct dsmark_qdisc_data *p = qdisc_priv(sch); struct nlattr *opt = tca[TCA_OPTIONS]; diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index d798c93f7c96..b4ca46aafb5a 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c @@ -479,7 +479,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, q->cparams.mtu = psched_mtu(qdisc_dev(sch)); if (opt) { - int err = fq_codel_change(sch, opt, NULL); + int err = fq_codel_change(sch, opt, extack); if (err) return err; } diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index f49a4a4fe095..11410b0e4068 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -921,7 +921,8 @@ static const struct nla_policy hfsc_policy[TCA_HFSC_MAX + 1] = { static int hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, - struct nlattr **tca, unsigned long *arg) + struct nlattr **tca, unsigned long *arg, + struct netlink_ext_ack *extack) { struct hfsc_sched *q = qdisc_priv(sch); struct hfsc_class *cl = (struct hfsc_class *)*arg; diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 41d9b7da9273..eb535a23a69b 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1327,7 +1327,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg) static int htb_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **tca, - unsigned long *arg) + unsigned long *arg, struct netlink_ext_ack *extack) { int err = -EINVAL; struct htb_sched *q = qdisc_priv(sch); diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 7c1b976314bd..1f4a84b687d2 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -402,7 +402,8 @@ static int qfq_change_agg(struct Qdisc *sch, struct qfq_class *cl, u32 weight, } static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, - struct nlattr **tca, unsigned long *arg) + struct nlattr **tca, unsigned long *arg, + struct netlink_ext_ack *extack) { struct qfq_sched *q = qdisc_priv(sch); struct qfq_class *cl = (struct qfq_class *)*arg; diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index 1b9d69bd6ed6..d70d470361be 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c @@ -645,7 +645,8 @@ static void sfb_unbind(struct Qdisc *sch, unsigned long arg) } static int sfb_change_class(struct Qdisc *sch, u32 classid, u32 parentid, - struct nlattr **tca, unsigned long *arg) + struct nlattr **tca, unsigned long *arg, + struct netlink_ext_ack *extack) { return -ENOSYS; } From patchwork Mon Dec 18 22:45:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850467 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="vCZ4QWFa"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x2Z1GFvz9s4s for ; Tue, 19 Dec 2017 09:45:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936418AbdLRWpk (ORCPT ); Mon, 18 Dec 2017 17:45:40 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:41565 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936043AbdLRWpf (ORCPT ); Mon, 18 Dec 2017 17:45:35 -0500 Received: by mail-io0-f193.google.com with SMTP id o2so11535518ioe.8 for ; Mon, 18 Dec 2017 14:45:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v0q66t5dlE9vFyivYP0dtgXQB6PM+n/4nsb1YpoE8qA=; b=vCZ4QWFaycW9daReTTwwKQRce+ta4zJ1ro3KjmrtTobMhdN48s5cpwH4XgPAu8PGeI jQzgdvKikPo+7VVDq4Mr+vFx2SjDVMmjbre6M+xg/wzGSrivRUVVoOpnkPMJEnUKbrzF GU6twTbD+peSKEyewx6GHT8xG4XVLnAehiBQAW7uAsUZuevCVTZCj4DIat5ww4s3ZfBc qxTILhNq5IB3fBQQUtkYdoO1w7vnY9/zMI5wFoy9aBDtQ4153Jg1bRLodfNPRSbSmGWI JH9wwSUJWPwJ/lF7LgPh6l+WApF1svSOTOi3GtaK0z7Z70CZBhhHCzF+58XzHFNqSQqR 1iiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v0q66t5dlE9vFyivYP0dtgXQB6PM+n/4nsb1YpoE8qA=; b=R5JE/5sCPbNmIyALD3eSLUhc88073mivl11/b28jjWZVVnJZK/VN6GkHoHAqyHKZf4 i+qI6DB0Ru7r17d68xmEK/tT9dj//aPuXm1vTh2MIisIa0h40/PEETKvsE7ZRLYtF3iC FVhFIBcnE+C7ZiYtJDsLYsCONub3YbWjNtU4q7p8fYfZMB6QYuxxIrVe5kBMqv3ruawA HNf46eogluUZClGsHwdyAVQFOc9br7Nt7fxgt/kzFQ/Tx3w7kCgFCeip/HDQhjZRSHLU 271/SijwAB8hsH/eOAfqJJK5I6pnAQJJa77o/AAXH8mALwo5D11LfF+htXbX3uVcypNS WzDA== X-Gm-Message-State: AKGB3mJAKPKVOGbyxlBUqzlkIkycAos9zmNu5ixvYNSWiWeUS5icF3cz VgIUsA+ex3CwYKNApMgQf3vbCy2E X-Google-Smtp-Source: ACJfBou3wqxR/GteXEnjsb5RpLdieIAbUBzOmWVBki2Iks2bEvgoF7cbUI2HHwko/pMdKKnA/7KpNg== X-Received: by 10.107.161.5 with SMTP id k5mr1668191ioe.290.1513637135078; Mon, 18 Dec 2017 14:45:35 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:34 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 06/14] net: sched: sch: add extack for block callback Date: Mon, 18 Dec 2017 17:45:05 -0500 Message-Id: <20171218224513.29836-7-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for block callback to prepare per-qdisc specific changes for extack. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/cls_api.c | 4 ++-- net/sched/sch_api.c | 2 +- net/sched/sch_atm.c | 3 ++- net/sched/sch_cbq.c | 3 ++- net/sched/sch_drr.c | 3 ++- net/sched/sch_dsmark.c | 3 ++- net/sched/sch_fq_codel.c | 3 ++- net/sched/sch_hfsc.c | 3 ++- net/sched/sch_htb.c | 3 ++- net/sched/sch_ingress.c | 6 ++++-- net/sched/sch_multiq.c | 3 ++- net/sched/sch_prio.c | 3 ++- net/sched/sch_qfq.c | 3 ++- net/sched/sch_sfb.c | 3 ++- net/sched/sch_sfq.c | 3 ++- 16 files changed, 33 insertions(+), 18 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 219ad45cc4cd..280106691c58 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -164,7 +164,8 @@ struct Qdisc_class_ops { /* Filter manipulation */ struct tcf_block * (*tcf_block)(struct Qdisc *sch, - unsigned long arg); + unsigned long arg, + struct netlink_ext_ack *extack); unsigned long (*bind_tcf)(struct Qdisc *, unsigned long, u32 classid); void (*unbind_tcf)(struct Qdisc *, unsigned long); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 5b9b8a61e8c4..446ef956a79c 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -794,7 +794,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } /* And the last stroke */ - block = cops->tcf_block(q, cl); + block = cops->tcf_block(q, cl, extack); if (!block) { err = -EINVAL; goto errout; @@ -1041,7 +1041,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb) if (cl == 0) goto out; } - block = cops->tcf_block(q, cl); + block = cops->tcf_block(q, cl, NULL); if (!block) goto out; diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 4a77b3d06f9b..273f2c1e910f 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1758,7 +1758,7 @@ static void tc_bind_tclass(struct Qdisc *q, u32 portid, u32 clid, cl = cops->find(q, portid); if (!cl) return; - block = cops->tcf_block(q, cl); + block = cops->tcf_block(q, cl, NULL); if (!block) return; list_for_each_entry(chain, &block->chain_list, list) { diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 80ada9affe81..b606a75af333 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c @@ -357,7 +357,8 @@ static void atm_tc_walk(struct Qdisc *sch, struct qdisc_walker *walker) } } -static struct tcf_block *atm_tc_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *atm_tc_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct atm_qdisc_data *p = qdisc_priv(sch); struct atm_flow_data *flow = (struct atm_flow_data *)cl; diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 8f1832df8b4f..d46048a439a6 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1679,7 +1679,8 @@ static int cbq_delete(struct Qdisc *sch, unsigned long arg) return 0; } -static struct tcf_block *cbq_tcf_block(struct Qdisc *sch, unsigned long arg) +static struct tcf_block *cbq_tcf_block(struct Qdisc *sch, unsigned long arg, + struct netlink_ext_ack *extack) { struct cbq_sched_data *q = qdisc_priv(sch); struct cbq_class *cl = (struct cbq_class *)arg; diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index 73b914bc47a4..44a2870f6f10 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -173,7 +173,8 @@ static unsigned long drr_search_class(struct Qdisc *sch, u32 classid) return (unsigned long)drr_find_class(sch, classid); } -static struct tcf_block *drr_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *drr_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct drr_sched *q = qdisc_priv(sch); diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index 89e433bbd590..5dc5d5216fbb 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -185,7 +185,8 @@ static void dsmark_walk(struct Qdisc *sch, struct qdisc_walker *walker) } } -static struct tcf_block *dsmark_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *dsmark_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct dsmark_qdisc_data *p = qdisc_priv(sch); diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index b4ca46aafb5a..06e5360c54d8 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c @@ -597,7 +597,8 @@ static void fq_codel_unbind(struct Qdisc *q, unsigned long cl) { } -static struct tcf_block *fq_codel_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *fq_codel_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct fq_codel_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 11410b0e4068..961668d657a0 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1247,7 +1247,8 @@ hfsc_unbind_tcf(struct Qdisc *sch, unsigned long arg) cl->filter_cnt--; } -static struct tcf_block *hfsc_tcf_block(struct Qdisc *sch, unsigned long arg) +static struct tcf_block *hfsc_tcf_block(struct Qdisc *sch, unsigned long arg, + struct netlink_ext_ack *extack) { struct hfsc_sched *q = qdisc_priv(sch); struct hfsc_class *cl = (struct hfsc_class *)arg; diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index eb535a23a69b..79cf24468a38 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1525,7 +1525,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, return err; } -static struct tcf_block *htb_tcf_block(struct Qdisc *sch, unsigned long arg) +static struct tcf_block *htb_tcf_block(struct Qdisc *sch, unsigned long arg, + struct netlink_ext_ack *extack) { struct htb_sched *q = qdisc_priv(sch); struct htb_class *cl = (struct htb_class *)arg; diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index c703cf3a0bed..17fa8969f7e7 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -48,7 +48,8 @@ static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker) { } -static struct tcf_block *ingress_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *ingress_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct ingress_sched_data *q = qdisc_priv(sch); @@ -153,7 +154,8 @@ static unsigned long clsact_bind_filter(struct Qdisc *sch, return clsact_find(sch, classid); } -static struct tcf_block *clsact_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *clsact_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct clsact_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c index a8db1dbeb04f..4bcbd3636606 100644 --- a/net/sched/sch_multiq.c +++ b/net/sched/sch_multiq.c @@ -371,7 +371,8 @@ static void multiq_walk(struct Qdisc *sch, struct qdisc_walker *arg) } } -static struct tcf_block *multiq_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *multiq_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct multiq_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index 5f8ecbaa2610..077af4730749 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c @@ -329,7 +329,8 @@ static void prio_walk(struct Qdisc *sch, struct qdisc_walker *arg) } } -static struct tcf_block *prio_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *prio_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct prio_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 1f4a84b687d2..e77e7131e620 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -565,7 +565,8 @@ static unsigned long qfq_search_class(struct Qdisc *sch, u32 classid) return (unsigned long)qfq_find_class(sch, classid); } -static struct tcf_block *qfq_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *qfq_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct qfq_sched *q = qdisc_priv(sch); diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index d70d470361be..9e01b80edfe7 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c @@ -668,7 +668,8 @@ static void sfb_walk(struct Qdisc *sch, struct qdisc_walker *walker) } } -static struct tcf_block *sfb_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *sfb_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct sfb_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 3b5869c7b3f3..7a217be39f2a 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -837,7 +837,8 @@ static void sfq_unbind(struct Qdisc *q, unsigned long cl) { } -static struct tcf_block *sfq_tcf_block(struct Qdisc *sch, unsigned long cl) +static struct tcf_block *sfq_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) { struct sfq_sched_data *q = qdisc_priv(sch); From patchwork Mon Dec 18 22:45:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850478 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="uS6SwEal"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x3n1Pkzz9s4s for ; Tue, 19 Dec 2017 09:46:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936368AbdLRWqn (ORCPT ); Mon, 18 Dec 2017 17:46:43 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:36540 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936350AbdLRWph (ORCPT ); Mon, 18 Dec 2017 17:45:37 -0500 Received: by mail-io0-f196.google.com with SMTP id l10so11533075ioc.3 for ; Mon, 18 Dec 2017 14:45:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+8csk6qZ/sS/c/dWN6l11DgRH4Z/o+YZbINg2yNQPS8=; b=uS6SwEalj/BbbuhntBiyl4VGRtcjr8Sf43x1fFA1u1AY1Q5FAeMb7vRBBZGiAzta9i GUlwicKhJsBDhhvwAUWpqRxmdDhJz9I0mttMWQUWQNpPni6mB+tshBHjqKRns//ks3YY jeE+xx7IAV+IJ6WlFToCYXIMFC4FisG+1zJKvgGrATCHh16kzBTTz/hemh8wxftZzgPo JiHM83S7HUWecQrEn1/FfZ6mwxcBgb70rvA5MiDYV4rKCDN+sUXnma0oRt7tX3ue/Q76 qcXbtJMu8h050733XbLMIRn7UkRwioMlb0gKsH2OQBhoWljAtDVTBDDdEoNOlipxXEhN YFtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+8csk6qZ/sS/c/dWN6l11DgRH4Z/o+YZbINg2yNQPS8=; b=ShMlXYcJoEMNYH/OSCdTvBkv2wTiTbe2FsHFKi14M+OOSG93fEdyu7T2PxxV5zVdoN K4LgweiDUw5k17Pcsto9GOIMRUfwQFUd/XObwRLM4m3tbdMBAKMq3t1PsYp3XMa7C6LS 7XY5BqMT/w5pK8YtiSQIeY4CJrbCpYaxLiaNkAfnpmh07R+AJZFUhWS6160WKPPJ2r1L Jizf0aTGvL+gFkaY6wqjoEwGZwRCftIn7pP/9p+0eU7Cq1qeQQwDFWJyuu1agwdC2UwU B8bcd5WaK/97KsNRE6Q5IzaIcTrojmq7eYVfnMNpIoOw5eFofyaTo57PCEz7O8xNXoM8 tQaA== X-Gm-Message-State: AKGB3mK7MbIhcjMAgmVWSaAGwNF9y+u60g1RdvdV25Ucy9Xd1Fuvh8Kh B+0r9USOChoDOJCYqk7vzfIO3w== X-Google-Smtp-Source: ACJfBovUhECvSVbZwTxe0Jt3EHznVWQNIVYP82M06VLJpGq0mO3XEWcUTJGrv6Ab6CWwzv7r5d+glw== X-Received: by 10.107.9.66 with SMTP id j63mr1717633ioi.111.1513637136311; Mon, 18 Dec 2017 14:45:36 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:35 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 07/14] net: sched: sch: add extack for graft callback Date: Mon, 18 Dec 2017 17:45:06 -0500 Message-Id: <20171218224513.29836-8-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for graft callback to prepare per-qdisc specific changes for extack. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/sch_api.c | 3 ++- net/sched/sch_atm.c | 3 ++- net/sched/sch_cbq.c | 2 +- net/sched/sch_drr.c | 3 ++- net/sched/sch_dsmark.c | 3 ++- net/sched/sch_hfsc.c | 2 +- net/sched/sch_htb.c | 2 +- net/sched/sch_mq.c | 2 +- net/sched/sch_mqprio.c | 2 +- net/sched/sch_multiq.c | 2 +- net/sched/sch_netem.c | 2 +- net/sched/sch_prio.c | 2 +- net/sched/sch_qfq.c | 3 ++- net/sched/sch_red.c | 2 +- net/sched/sch_sfb.c | 2 +- net/sched/sch_tbf.c | 2 +- 17 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 280106691c58..2ea04863ea34 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -150,7 +150,8 @@ struct Qdisc_class_ops { /* Child qdisc manipulation */ struct netdev_queue * (*select_queue)(struct Qdisc *, struct tcmsg *); int (*graft)(struct Qdisc *, unsigned long cl, - struct Qdisc *, struct Qdisc **); + struct Qdisc *, struct Qdisc **, + struct netlink_ext_ack *extack); struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl); void (*qlen_notify)(struct Qdisc *, unsigned long); diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 273f2c1e910f..1bf6da80c6e7 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -975,7 +975,8 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, unsigned long cl = cops->find(parent, classid); if (cl) { - err = cops->graft(parent, cl, new, &old); + err = cops->graft(parent, cl, new, &old, + extack); } else { NL_SET_ERR_MSG(extack, "Specified class not found"); err = -ENOENT; diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index b606a75af333..8972ab72cda5 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c @@ -82,7 +82,8 @@ static inline struct atm_flow_data *lookup_flow(struct Qdisc *sch, u32 classid) } static int atm_tc_graft(struct Qdisc *sch, unsigned long arg, - struct Qdisc *new, struct Qdisc **old) + struct Qdisc *new, struct Qdisc **old, + struct netlink_ext_ack *extack) { struct atm_qdisc_data *p = qdisc_priv(sch); struct atm_flow_data *flow = (struct atm_flow_data *)arg; diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index d46048a439a6..bb7e4ccd7caf 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1371,7 +1371,7 @@ cbq_dump_class_stats(struct Qdisc *sch, unsigned long arg, } static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct cbq_class *cl = (struct cbq_class *)arg; diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index 44a2870f6f10..30e9cba54ddb 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -203,7 +203,8 @@ static void drr_unbind_tcf(struct Qdisc *sch, unsigned long arg) } static int drr_graft_class(struct Qdisc *sch, unsigned long arg, - struct Qdisc *new, struct Qdisc **old) + struct Qdisc *new, struct Qdisc **old, + struct netlink_ext_ack *extack) { struct drr_class *cl = (struct drr_class *)arg; diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index 5dc5d5216fbb..92a36aa4c713 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -61,7 +61,8 @@ static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index) /* ------------------------- Class/flow operations ------------------------- */ static int dsmark_graft(struct Qdisc *sch, unsigned long arg, - struct Qdisc *new, struct Qdisc **old) + struct Qdisc *new, struct Qdisc **old, + struct netlink_ext_ack *extack) { struct dsmark_qdisc_data *p = qdisc_priv(sch); diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 961668d657a0..7f6a06ac4b9f 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1177,7 +1177,7 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) static int hfsc_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct hfsc_class *cl = (struct hfsc_class *)arg; diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 79cf24468a38..65762d57a70d 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1172,7 +1172,7 @@ htb_dump_class_stats(struct Qdisc *sch, unsigned long arg, struct gnet_dump *d) } static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct htb_class *cl = (struct htb_class *)arg; diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c index b91f7d8cb184..50292e470432 100644 --- a/net/sched/sch_mq.c +++ b/net/sched/sch_mq.c @@ -155,7 +155,7 @@ static struct netdev_queue *mq_select_queue(struct Qdisc *sch, } static int mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct netdev_queue *dev_queue = mq_queue_get(sch, cl); struct net_device *dev = qdisc_dev(sch); diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 0379fc4ee7bb..29071cf329f3 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -320,7 +320,7 @@ static struct netdev_queue *mqprio_queue_get(struct Qdisc *sch, } static int mqprio_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct net_device *dev = qdisc_dev(sch); struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl); diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c index 4bcbd3636606..177d86de4b32 100644 --- a/net/sched/sch_multiq.c +++ b/net/sched/sch_multiq.c @@ -283,7 +283,7 @@ static int multiq_dump(struct Qdisc *sch, struct sk_buff *skb) } static int multiq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct multiq_sched_data *q = qdisc_priv(sch); unsigned long band = arg - 1; diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index f45040b55531..7bbc13b8ca47 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -1159,7 +1159,7 @@ static int netem_dump_class(struct Qdisc *sch, unsigned long cl, } static int netem_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct netem_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index 077af4730749..8fbd65661d77 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c @@ -242,7 +242,7 @@ static int prio_dump(struct Qdisc *sch, struct sk_buff *skb) } static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct prio_sched_data *q = qdisc_priv(sch); unsigned long band = arg - 1; diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index e77e7131e620..7ec893f770d2 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -595,7 +595,8 @@ static void qfq_unbind_tcf(struct Qdisc *sch, unsigned long arg) } static int qfq_graft_class(struct Qdisc *sch, unsigned long arg, - struct Qdisc *new, struct Qdisc **old) + struct Qdisc *new, struct Qdisc **old, + struct netlink_ext_ack *extack) { struct qfq_class *cl = (struct qfq_class *)arg; diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index 66b33b829b54..19616fa0a1a8 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c @@ -383,7 +383,7 @@ static int red_dump_class(struct Qdisc *sch, unsigned long cl, } static int red_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct red_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index 9e01b80edfe7..1a33d6c3ac42 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c @@ -617,7 +617,7 @@ static int sfb_dump_class(struct Qdisc *sch, unsigned long cl, } static int sfb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct sfb_sched_data *q = qdisc_priv(sch); diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 273228eb5ce0..db6bd23530d4 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -496,7 +496,7 @@ static int tbf_dump_class(struct Qdisc *sch, unsigned long cl, } static int tbf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, - struct Qdisc **old) + struct Qdisc **old, struct netlink_ext_ack *extack) { struct tbf_sched_data *q = qdisc_priv(sch); From patchwork Mon Dec 18 22:45:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850480 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="aW562yPX"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x3w6f5Rz9s4s for ; Tue, 19 Dec 2017 09:46:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965850AbdLRWql (ORCPT ); Mon, 18 Dec 2017 17:46:41 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:40662 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936367AbdLRWpi (ORCPT ); Mon, 18 Dec 2017 17:45:38 -0500 Received: by mail-io0-f196.google.com with SMTP id v186so11546309iod.7 for ; Mon, 18 Dec 2017 14:45:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mlbbS/HKThbT0vC4TgXXATzqbQiY/USpyUqWGBlizkg=; b=aW562yPX3zomPD4QBB++TMw5G2r+jbcqajtoWtJSVkKo4xTX6W1MKOx8vhGx4iD1cE +LGT/nZaiQUTnDCGBS2htGd1F/SqRxSCYgdlBHDqvZYTmuCfr6XM4mmDEtB6FwtAFwbB SsLZu513NCggpEU4Zkm7XZAtULnVTfNkShG4JMUtcezUR1lbd9rPRTDl5+rmCyWvI8xK HGc1pjV2XsBsTiiL7C9QL+mXOXUNVTcoASYpcp1zeroipjTChDynCAZWtrSAFnwAImmw U1MxY2iOkFozyJCkVw5WDmPYrkbtbgjVeWfRQVS7Zmlf17UcGQcdq2L19ST+pPapRyGQ KWhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mlbbS/HKThbT0vC4TgXXATzqbQiY/USpyUqWGBlizkg=; b=lseZgxJc23QpA17D72EkcM6c5ED7a0tbXVnoQfwkZC/j/es17yLH0vhWTBNl7Gp8uQ qFNAHxYQPGtMD2LZGe5UWLm0F/fn4qhCp7yPOFTCs+BKRTWZoRMbgqMa3cpCCX9YHWCV jl1sUXkeTHoWCDTzpPUa4DkLXD5H3k28eV2uEeehnE6GlPRRXv86EmH/yqFq6+AAvPRF 3B518HaxjPd5O5RHzjZNfp7yZ7OAi0cOHR7S0K2FuDvhOh8O7COE3ngazBcyiWTgPeRk ez2hlxugSXP81VgsIQ59O+YVTGmjl5fc2D8Ofpyx3vKlfOnVmeSpck8z04mK0FEoG2p0 oa6Q== X-Gm-Message-State: AKGB3mLPXbrR2l4EHuK4mbSbKKpMgaIXlDpkrY8yMFrCBbp38HHG5rST D67hdCdO39lrF3GWL6dWFfpCjA== X-Google-Smtp-Source: ACJfBovSiMgVu7reZLyMwdatMS7PgILaBY5b728yTvGmEOm4uOuggPWNg+a99OG321N5H2jPmUM+Yw== X-Received: by 10.107.30.81 with SMTP id e78mr1564664ioe.130.1513637137317; Mon, 18 Dec 2017 14:45:37 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:36 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 08/14] net: sch: api: add extack support in qdisc_get_rtab Date: Mon, 18 Dec 2017 17:45:07 -0500 Message-Id: <20171218224513.29836-9-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for the function qdisc_get_rtab 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_get_rtab failed. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/pkt_sched.h | 3 ++- net/sched/act_police.c | 4 ++-- net/sched/sch_api.c | 9 +++++++-- net/sched/sch_cbq.c | 7 ++++--- net/sched/sch_htb.c | 6 ++++-- net/sched/sch_tbf.c | 6 ++++-- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 240469228851..a4f21c0b4a43 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -101,7 +101,8 @@ void qdisc_hash_del(struct Qdisc *q); struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle); struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle); struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, - struct nlattr *tab); + struct nlattr *tab, + struct netlink_ext_ack *extack); void qdisc_put_rtab(struct qdisc_rate_table *tab); void qdisc_put_stab(struct qdisc_size_table *tab); void qdisc_warn_nonwc(const char *txt, struct Qdisc *qdisc); diff --git a/net/sched/act_police.c b/net/sched/act_police.c index bf483db993a1..95d3c9097b25 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -118,13 +118,13 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla, police = to_police(*a); if (parm->rate.rate) { err = -ENOMEM; - R_tab = qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE]); + R_tab = qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE], NULL); if (R_tab == NULL) goto failure; if (parm->peakrate.rate) { P_tab = qdisc_get_rtab(&parm->peakrate, - tb[TCA_POLICE_PEAKRATE]); + tb[TCA_POLICE_PEAKRATE], NULL); if (P_tab == NULL) goto failure; } diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 1bf6da80c6e7..a58459569f35 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -393,13 +393,16 @@ static __u8 __detect_linklayer(struct tc_ratespec *r, __u32 *rtab) static struct qdisc_rate_table *qdisc_rtab_list; struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, - struct nlattr *tab) + struct nlattr *tab, + struct netlink_ext_ack *extack) { struct qdisc_rate_table *rtab; if (tab == NULL || r->rate == 0 || r->cell_log == 0 || - nla_len(tab) != TC_RTAB_SIZE) + nla_len(tab) != TC_RTAB_SIZE) { + NL_SET_ERR_MSG(extack, "Invalid rate table parameters for searching"); return NULL; + } for (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) { if (!memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) && @@ -418,6 +421,8 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, r->linklayer = __detect_linklayer(r, rtab->data); rtab->next = qdisc_rtab_list; qdisc_rtab_list = rtab; + } else { + NL_SET_ERR_MSG(extack, "Failed to allocate new qdisc rate table"); } return rtab; } diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index bb7e4ccd7caf..79f081eb6bb0 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1156,7 +1156,7 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt, r = nla_data(tb[TCA_CBQ_RATE]); - q->link.R_tab = qdisc_get_rtab(r, tb[TCA_CBQ_RTAB]); + q->link.R_tab = qdisc_get_rtab(r, tb[TCA_CBQ_RTAB], extack); if (!q->link.R_tab) return -EINVAL; @@ -1484,7 +1484,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t if (tb[TCA_CBQ_RATE]) { rtab = qdisc_get_rtab(nla_data(tb[TCA_CBQ_RATE]), - tb[TCA_CBQ_RTAB]); + tb[TCA_CBQ_RTAB], extack); if (rtab == NULL) return -EINVAL; } @@ -1537,7 +1537,8 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t if (!tb[TCA_CBQ_WRROPT] || !tb[TCA_CBQ_RATE] || !tb[TCA_CBQ_LSSOPT]) return -EINVAL; - rtab = qdisc_get_rtab(nla_data(tb[TCA_CBQ_RATE]), tb[TCA_CBQ_RTAB]); + rtab = qdisc_get_rtab(nla_data(tb[TCA_CBQ_RATE]), tb[TCA_CBQ_RTAB], + extack); if (rtab == NULL) return -EINVAL; diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 65762d57a70d..51be1b756e4e 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1357,10 +1357,12 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, /* Keeping backward compatible with rate_table based iproute2 tc */ if (hopt->rate.linklayer == TC_LINKLAYER_UNAWARE) - qdisc_put_rtab(qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB])); + qdisc_put_rtab(qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB], + NULL)); if (hopt->ceil.linklayer == TC_LINKLAYER_UNAWARE) - qdisc_put_rtab(qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB])); + qdisc_put_rtab(qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB], + NULL)); if (!cl) { /* new class */ struct Qdisc *new_q; diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index db6bd23530d4..1ab53ff80f46 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -327,11 +327,13 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt, qopt = nla_data(tb[TCA_TBF_PARMS]); if (qopt->rate.linklayer == TC_LINKLAYER_UNAWARE) qdisc_put_rtab(qdisc_get_rtab(&qopt->rate, - tb[TCA_TBF_RTAB])); + tb[TCA_TBF_RTAB], + NULL)); if (qopt->peakrate.linklayer == TC_LINKLAYER_UNAWARE) qdisc_put_rtab(qdisc_get_rtab(&qopt->peakrate, - tb[TCA_TBF_PTAB])); + tb[TCA_TBF_PTAB], + NULL)); buffer = min_t(u64, PSCHED_TICKS2NS(qopt->buffer), ~0U); mtu = min_t(u64, PSCHED_TICKS2NS(qopt->mtu), ~0U); From patchwork Mon Dec 18 22:45:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850477 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="FbFTJCOE"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x3Z59Bjz9s4s for ; Tue, 19 Dec 2017 09:46:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965847AbdLRWqc (ORCPT ); Mon, 18 Dec 2017 17:46:32 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:37977 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936368AbdLRWpj (ORCPT ); Mon, 18 Dec 2017 17:45:39 -0500 Received: by mail-io0-f194.google.com with SMTP id 87so7374426ior.5 for ; Mon, 18 Dec 2017 14:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/uunvjgYb8dG2pK0AWM0xzh5b9q7v//arZ7ga9jWHpM=; b=FbFTJCOEiSYsckTEqXYoBQP6ZsQtjjWZxzIxxgAwWNA5zV8f0AR38+tgIBeB3axavn XqHw5wF/C/exnze5iRc+hUsxab32YwAbaO2rwaWsm8672FzNSdQwWmw7ED4ucflfB2wW 6pgk8yA85Go11jbMQV9UoEPpi6wL13oxbM9TMRZZEIrUNnsM3c85ZIR/VBkCXgSKPWUN QQOBJdJUm2t+pq+RTeUenzNidohwcLnPiJLOijY/yZAhbjKZ8SPAMs2uUUPsnuUq8lp3 vmIh75I/DxuftblJ+blBcA7EvGpsSK1LOGmIi8xobvfNVfjwN0K478rgG8jhcNVD53N9 15Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/uunvjgYb8dG2pK0AWM0xzh5b9q7v//arZ7ga9jWHpM=; b=E0IT6J9lCk9sigRJhq6bmJbgG1gF8o3lbePUUmbu+RQhBYGNFl1Klg0KvF6rvBpbdz OtOXR3D3h1eeOK6VxOWARP8buxQaXOSPE/kRFbG7/1KOzqjd67CXlgtYKWPsB2vo9fiV K//0XWj2Sn82K2pD5U1dWPHQRLd0cjTmKAEhoLFbDubnFlTKHY4M0HbiJpmRknxA81sh o25gRvPBdJiAQSVfctVCAyrp8gwUq3m6Uz2fEUWw6XiXg0LO1d1EMs1MHhEZgC5CyyeS ALZb73v7d0hkiQVS9iyAwnfdKxM+84nQvtlPLSvYP7U1ZExnV0WI2/CTlMpLuQb9ZO+C 25Fw== X-Gm-Message-State: AKGB3mLosZu62Hy30KLzP3otdXO8mTHzXw8czAolLi0iow+2WTey8k0x q4pEQMT8A3c8+7kmerNWfb5I9vlV X-Google-Smtp-Source: ACJfBougvYNWLhj4wS65XC0k+Bxkk5cefu+vKZMhcZN0G4s1BKTRI2VtBtuMvPjMoV9S0ENmEkssaQ== X-Received: by 10.107.48.197 with SMTP id w188mr1601836iow.301.1513637138401; Mon, 18 Dec 2017 14:45:38 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:38 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 09/14] net: sch: api: add extack support in tcf_block_get Date: Mon, 18 Dec 2017 17:45:08 -0500 Message-Id: <20171218224513.29836-10-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for the function tcf_block_get 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 tcf_block_get failed. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/pkt_cls.h | 6 ++++-- net/sched/cls_api.c | 13 +++++++++---- net/sched/sch_atm.c | 6 ++++-- net/sched/sch_cbq.c | 4 ++-- net/sched/sch_drr.c | 2 +- net/sched/sch_dsmark.c | 2 +- net/sched/sch_fq_codel.c | 2 +- net/sched/sch_hfsc.c | 4 ++-- net/sched/sch_htb.c | 4 ++-- net/sched/sch_ingress.c | 8 +++++--- net/sched/sch_multiq.c | 2 +- net/sched/sch_prio.c | 2 +- net/sched/sch_qfq.c | 2 +- net/sched/sch_sfb.c | 2 +- net/sched/sch_sfq.c | 2 +- 15 files changed, 36 insertions(+), 25 deletions(-) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 0105445cab83..58bba9c769ea 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -39,9 +39,11 @@ struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index, bool create); void tcf_chain_put(struct tcf_chain *chain); int tcf_block_get(struct tcf_block **p_block, - struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q); + struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q, + struct netlink_ext_ack *extack); int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q, - struct tcf_block_ext_info *ei); + struct tcf_block_ext_info *ei, + struct netlink_ext_ack *extack); void tcf_block_put(struct tcf_block *block); void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, struct tcf_block_ext_info *ei); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 446ef956a79c..11bcf95ac467 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -282,20 +282,24 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q, } int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q, - struct tcf_block_ext_info *ei) + struct tcf_block_ext_info *ei, + struct netlink_ext_ack *extack) { struct tcf_block *block = kzalloc(sizeof(*block), GFP_KERNEL); struct tcf_chain *chain; int err; - if (!block) + if (!block) { + NL_SET_ERR_MSG(extack, "Memory allocation for block failed"); return -ENOMEM; + } INIT_LIST_HEAD(&block->chain_list); INIT_LIST_HEAD(&block->cb_list); /* Create chain 0 by default, it has to be always present. */ chain = tcf_chain_create(block, 0); if (!chain) { + NL_SET_ERR_MSG(extack, "Failed to create new tcf chain"); err = -ENOMEM; goto err_chain_create; } @@ -322,7 +326,8 @@ static void tcf_chain_head_change_dflt(struct tcf_proto *tp_head, void *priv) } int tcf_block_get(struct tcf_block **p_block, - struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q) + struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q, + struct netlink_ext_ack *extack) { struct tcf_block_ext_info ei = { .chain_head_change = tcf_chain_head_change_dflt, @@ -330,7 +335,7 @@ int tcf_block_get(struct tcf_block **p_block, }; WARN_ON(!p_filter_chain); - return tcf_block_get_ext(p_block, q, &ei); + return tcf_block_get_ext(p_block, q, &ei, extack); } EXPORT_SYMBOL(tcf_block_get); diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 8972ab72cda5..493d5c25d83a 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c @@ -283,7 +283,8 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, goto err_out; } - error = tcf_block_get(&flow->block, &flow->filter_list, sch); + error = tcf_block_get(&flow->block, &flow->filter_list, sch, + extack); if (error) { kfree(flow); goto err_out; @@ -550,7 +551,8 @@ static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt, p->link.q = &noop_qdisc; pr_debug("atm_tc_init: link (%p) qdisc %p\n", &p->link, p->link.q); - err = tcf_block_get(&p->link.block, &p->link.filter_list, sch); + err = tcf_block_get(&p->link.block, &p->link.filter_list, sch, + extack); if (err) return err; diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 79f081eb6bb0..248ea26997b9 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1160,7 +1160,7 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt, if (!q->link.R_tab) return -EINVAL; - err = tcf_block_get(&q->link.block, &q->link.filter_list, sch); + err = tcf_block_get(&q->link.block, &q->link.filter_list, sch, extack); if (err) goto put_rtab; @@ -1576,7 +1576,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t if (cl == NULL) goto failure; - err = tcf_block_get(&cl->block, &cl->filter_list, sch); + err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack); if (err) { kfree(cl); return err; diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index 30e9cba54ddb..9dfff065e27d 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -417,7 +417,7 @@ static int drr_init_qdisc(struct Qdisc *sch, struct nlattr *opt, struct drr_sched *q = qdisc_priv(sch); int err; - err = tcf_block_get(&q->block, &q->filter_list, sch); + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) return err; err = qdisc_class_hash_init(&q->clhash); diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index 92a36aa4c713..63f523b5e282 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -348,7 +348,7 @@ static int dsmark_init(struct Qdisc *sch, struct nlattr *opt, if (!opt) goto errout; - err = tcf_block_get(&p->block, &p->filter_list, sch); + err = tcf_block_get(&p->block, &p->filter_list, sch, extack); if (err) return err; diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index 06e5360c54d8..22fa13cf5d8b 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c @@ -484,7 +484,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, return err; } - err = tcf_block_get(&q->block, &q->filter_list, sch); + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) return err; diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 7f6a06ac4b9f..9ae288fcbed8 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1034,7 +1034,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, if (cl == NULL) return -ENOBUFS; - err = tcf_block_get(&cl->block, &cl->filter_list, sch); + err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack); if (err) { kfree(cl); return err; @@ -1409,7 +1409,7 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt, return err; q->eligible = RB_ROOT; - err = tcf_block_get(&q->root.block, &q->root.filter_list, sch); + err = tcf_block_get(&q->root.block, &q->root.filter_list, sch, extack); if (err) return err; diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 51be1b756e4e..54e1f860f1e5 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1032,7 +1032,7 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt, if (!opt) return -EINVAL; - err = tcf_block_get(&q->block, &q->filter_list, sch); + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) return err; @@ -1397,7 +1397,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, if (!cl) goto failure; - err = tcf_block_get(&cl->block, &cl->filter_list, sch); + err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack); if (err) { kfree(cl); goto failure; diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index 17fa8969f7e7..0712fb3bcd5a 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -76,7 +76,7 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt, q->block_info.chain_head_change = clsact_chain_head_change; q->block_info.chain_head_change_priv = &q->miniqp; - err = tcf_block_get_ext(&q->block, sch, &q->block_info); + err = tcf_block_get_ext(&q->block, sch, &q->block_info, extack); if (err) return err; @@ -182,7 +182,8 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt, q->ingress_block_info.chain_head_change = clsact_chain_head_change; q->ingress_block_info.chain_head_change_priv = &q->miniqp_ingress; - err = tcf_block_get_ext(&q->ingress_block, sch, &q->ingress_block_info); + err = tcf_block_get_ext(&q->ingress_block, sch, &q->ingress_block_info, + extack); if (err) return err; @@ -192,7 +193,8 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt, q->egress_block_info.chain_head_change = clsact_chain_head_change; q->egress_block_info.chain_head_change_priv = &q->miniqp_egress; - err = tcf_block_get_ext(&q->egress_block, sch, &q->egress_block_info); + err = tcf_block_get_ext(&q->egress_block, sch, &q->egress_block_info, + extack); if (err) goto err_egress_block_get; diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c index 177d86de4b32..35cbaf8bd96a 100644 --- a/net/sched/sch_multiq.c +++ b/net/sched/sch_multiq.c @@ -248,7 +248,7 @@ static int multiq_init(struct Qdisc *sch, struct nlattr *opt, if (!opt) return -EINVAL; - err = tcf_block_get(&q->block, &q->filter_list, sch); + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) return err; diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index 8fbd65661d77..502352762f03 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c @@ -215,7 +215,7 @@ static int prio_init(struct Qdisc *sch, struct nlattr *opt, if (!opt) return -EINVAL; - err = tcf_block_get(&q->block, &q->filter_list, sch); + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) return err; diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 7ec893f770d2..6ab58509cf49 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -1424,7 +1424,7 @@ static int qfq_init_qdisc(struct Qdisc *sch, struct nlattr *opt, int i, j, err; u32 max_cl_shift, maxbudg_shift, max_classes; - err = tcf_block_get(&q->block, &q->filter_list, sch); + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) return err; diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index 1a33d6c3ac42..a1a11ded8e4f 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c @@ -556,7 +556,7 @@ static int sfb_init(struct Qdisc *sch, struct nlattr *opt, struct sfb_sched_data *q = qdisc_priv(sch); int err; - err = tcf_block_get(&q->block, &q->filter_list, sch); + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) return err; diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 7a217be39f2a..2f2678197760 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -731,7 +731,7 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt, q->sch = sch; timer_setup(&q->perturb_timer, sfq_perturbation, TIMER_DEFERRABLE); - err = tcf_block_get(&q->block, &q->filter_list, sch); + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); if (err) return err; From patchwork Mon Dec 18 22:45:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850469 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="1MSUKauI"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x2k5jcgz9s4s for ; Tue, 19 Dec 2017 09:45:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938350AbdLRWps (ORCPT ); Mon, 18 Dec 2017 17:45:48 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:34671 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936416AbdLRWpk (ORCPT ); Mon, 18 Dec 2017 17:45:40 -0500 Received: by mail-io0-f194.google.com with SMTP id f18so6484767ioh.1 for ; Mon, 18 Dec 2017 14:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x88Sv7+bTqW+X1L2h4kF1pwier5xJpbhmlgtoMcahPE=; b=1MSUKauISFUvyB/rimi5mDHO+DfH1OdF2dUl41YV+qqvx7mIRqnBEJy29gcwFcUpYj wgdnSi7/mpVtYOgzna83uk0xX32P2pyPY8mxV6GYMFUC4j4r4SIxpmT9w1h29R4t+XJZ oWZA11QDFTT6yaXrKRiKdzjiTMOUNSDNEKrxPG381J1EIRlLCORkkGlmHdf45mVVI2mO iZaoxJC5nj7HDAjUx7sahN9+ExQFAT/fXOnUkD6pC3027oIbGcDTY6pR8hyVgT6VXGY8 HcXI2FwBaj+MCiLJ9U41JT8xYX3I/x8FCco5b4RtvKEs8W0bwLUosHJdALsRfIEjYMmd EVwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x88Sv7+bTqW+X1L2h4kF1pwier5xJpbhmlgtoMcahPE=; b=MzRc5mxQd0dg82gU2WlmTdT6wVSRQMGtS0as08V/0ks7CE8fbDk9vvaEqe/+REogdy Kt+cPTXdOTZonphm5e0eEPctPChPsHyfpUd8oVmUl+VXoHPtJzxguJqNeY/iG1DEqIVn a6KEI9YeOyBmeHAskaLEIsDLr+F0po+RcMqi0duFPigiJRPfYuu6LrCnujKPCV4ooSu4 AAV97TlLiMQpWUBLUfhfBoOyBaJVgDvF1iJeDF5jVrh9PJrk3Xt2mR27k1ewxxk9i79q Q4boPrNOp0cWIPCsjF/shu+NqTo1wwZdse4rPZxt7xzdq5R24QlZrzd9XUUnkW6fWD+x nL7g== X-Gm-Message-State: AKGB3mLEUlYYeF47gRD7W/FiNNQpWQraKvamoBs2XKEKTgEeu7uI9uh7 Jkt0tLBSyH40PXv7y+gysDiVjg== X-Google-Smtp-Source: ACJfBoudcAb+uzZoblj8/Q96rcsMFjD0xlzEgoL+SFdlmgeruNvCLzEaNcRhkWLPNBZ+iYi/g1eK6g== X-Received: by 10.107.175.208 with SMTP id p77mr1722748ioo.30.1513637139435; Mon, 18 Dec 2017 14:45:39 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:39 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 10/14] net: sch: api: add extack support in qdisc_alloc Date: Mon, 18 Dec 2017 17:45:09 -0500 Message-Id: <20171218224513.29836-11-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 | 2 +- net/sched/sch_generic.c | 6 ++++-- 3 files changed, 7 insertions(+), 4 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 a58459569f35..fd3960ff0fe4 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1050,7 +1050,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev, 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; 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; From patchwork Mon Dec 18 22:45:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850476 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="cKBtZjQW"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x3W1Z4cz9s4s for ; Tue, 19 Dec 2017 09:46:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965841AbdLRWq2 (ORCPT ); Mon, 18 Dec 2017 17:46:28 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:36547 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936043AbdLRWpl (ORCPT ); Mon, 18 Dec 2017 17:45:41 -0500 Received: by mail-io0-f194.google.com with SMTP id l10so11533260ioc.3 for ; Mon, 18 Dec 2017 14:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vrqj3SrVFZpeNkU6MgLm3h8W2CGTrcz6ivvxng0L/0E=; b=cKBtZjQW2BSyEhJL7w9Mxgu4gb4IepSPLx0aLgEShEPTYiDKnsEGtRWtdicYEcSp6L zsTE5KuNGKzMieJ/iK4joDwrYk1Ef36gO0whfbZZ4P+1pkrRhOu4JKKzno8CoOynlSJn t8K504+SC/K1nPvq4vPlizbsU2VrasCyxFR6XKMsTK64pR/iwf4RTEwxvfgqMTCAke4D mcYFGyucs0LE7XGFzAFqMBLDkwyuFD/w28L/87U68pcmF8K7clcTPTWTHa5QhfMMtyl7 fuW6KlCbHwBShHombOLYu6iM6oIBhyyZR+NGhsji4QzqXfj8Gtl1JKqxum/dxhfVvT1b M1eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vrqj3SrVFZpeNkU6MgLm3h8W2CGTrcz6ivvxng0L/0E=; b=JHADCosZNrP8dR2/n35F6bJV+PkX8sbqUvoIh6VXBa1RuOvnLWOUVyZMFRydbyZ69l PonuuwZDIRE4i6lBtG16ijo+gjdRu0WRSA7rAExBTemGJE3emP+e7haurj++pXfSSCAG JY6a6VUvu+kkccbUPYjp9NSD7mqxZcQBiuJlT3xG4s4KOw5mwuXyxpguH8PGHbj2rwxu nBXcfTYvhrn+9Bbvu7wbUEwmp4a3okuaPGFIgJ+iC3oAECotu3jhDzTcnBXqkUdeez/f 3T06haDh5zJ44t1VKDfaTsctp+MShHuN24kg/OEQfoanaVr16sq2pyUR+/IRXfuLROki 75TA== X-Gm-Message-State: AKGB3mKpNcvX3j1LwCPov/qCkCuhQCqYnA3fjxHuDDpLvxxwKQZANCPK E1XcHOkLF3O38ZOCvm3X+3z3Bg== X-Google-Smtp-Source: ACJfBovEbhXjYEridXmtc49ZFElJh5OzQwmjdf92jJSFJ5aFYAsTPgg3N3JKxVvAojCOuazOiK06qw== X-Received: by 10.107.183.195 with SMTP id h186mr1677061iof.159.1513637140555; Mon, 18 Dec 2017 14:45:40 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:40 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 11/14] net: sch: api: add extack support in qdisc_create_dflt Date: Mon, 18 Dec 2017 17:45:10 -0500 Message-Id: <20171218224513.29836-12-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for the function qdisc_create_dflt 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_create_dflt failed. The function qdisc_create_dflt will also call an init callback which can fail by any per-qdisc specfic handling. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/pkt_sched.h | 3 ++- include/net/sch_generic.h | 3 ++- net/sched/sch_atm.c | 5 +++-- net/sched/sch_cbq.c | 9 +++++---- net/sched/sch_drr.c | 7 ++++--- net/sched/sch_dsmark.c | 5 +++-- net/sched/sch_fifo.c | 6 ++++-- net/sched/sch_generic.c | 15 +++++++++------ net/sched/sch_hfsc.c | 8 ++++---- net/sched/sch_htb.c | 9 +++++---- net/sched/sch_mq.c | 3 ++- net/sched/sch_mqprio.c | 2 +- net/sched/sch_multiq.c | 2 +- net/sched/sch_prio.c | 3 ++- net/sched/sch_qfq.c | 8 ++++---- net/sched/sch_red.c | 3 ++- net/sched/sch_sfb.c | 2 +- net/sched/sch_tbf.c | 3 ++- 18 files changed, 56 insertions(+), 40 deletions(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index a4f21c0b4a43..e2c75f52557b 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -89,7 +89,8 @@ extern struct Qdisc_ops pfifo_head_drop_qdisc_ops; int fifo_set_limit(struct Qdisc *q, unsigned int limit); struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops, - unsigned int limit); + unsigned int limit, + struct netlink_ext_ack *extack); int register_qdisc(struct Qdisc_ops *qops); int unregister_qdisc(struct Qdisc_ops *qops); diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 1dbfbec00050..e4ef4f6e7baf 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -473,7 +473,8 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, 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); + const struct Qdisc_ops *ops, u32 parentid, + struct netlink_ext_ack *extack); void __qdisc_calculate_pkt_len(struct sk_buff *skb, const struct qdisc_size_table *stab); int skb_do_redirect(struct sk_buff *); diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 493d5c25d83a..cd49afca9617 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c @@ -290,7 +290,8 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, goto err_out; } - flow->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, classid); + flow->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, classid, + extack); if (!flow->q) flow->q = &noop_qdisc; pr_debug("atm_tc_change: qdisc %p\n", flow->q); @@ -546,7 +547,7 @@ static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt, INIT_LIST_HEAD(&p->link.list); list_add(&p->link.list, &p->flows); p->link.q = qdisc_create_dflt(sch->dev_queue, - &pfifo_qdisc_ops, sch->handle); + &pfifo_qdisc_ops, sch->handle, extack); if (!p->link.q) p->link.q = &noop_qdisc; pr_debug("atm_tc_init: link (%p) qdisc %p\n", &p->link, p->link.q); diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 248ea26997b9..efe5bf15b031 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1172,7 +1172,7 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt, q->link.common.classid = sch->handle; q->link.qdisc = sch; q->link.q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, - sch->handle); + sch->handle, NULL); if (!q->link.q) q->link.q = &noop_qdisc; else @@ -1376,8 +1376,8 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, struct cbq_class *cl = (struct cbq_class *)arg; if (new == NULL) { - new = qdisc_create_dflt(sch->dev_queue, - &pfifo_qdisc_ops, cl->common.classid); + new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + cl->common.classid, extack); if (new == NULL) return -ENOBUFS; } @@ -1596,7 +1596,8 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t cl->R_tab = rtab; rtab = NULL; - cl->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, classid); + cl->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, classid, + NULL); if (!cl->q) cl->q = &noop_qdisc; else diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index 9dfff065e27d..bf638ce57c50 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -114,7 +114,8 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, cl->common.classid = classid; cl->quantum = quantum; cl->qdisc = qdisc_create_dflt(sch->dev_queue, - &pfifo_qdisc_ops, classid); + &pfifo_qdisc_ops, classid, + NULL); if (cl->qdisc == NULL) cl->qdisc = &noop_qdisc; else @@ -209,8 +210,8 @@ static int drr_graft_class(struct Qdisc *sch, unsigned long arg, struct drr_class *cl = (struct drr_class *)arg; if (new == NULL) { - new = qdisc_create_dflt(sch->dev_queue, - &pfifo_qdisc_ops, cl->common.classid); + new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + cl->common.classid, NULL); if (new == NULL) new = &noop_qdisc; } diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index 63f523b5e282..049714c57075 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -71,7 +71,7 @@ static int dsmark_graft(struct Qdisc *sch, unsigned long arg, if (new == NULL) { new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, - sch->handle); + sch->handle, NULL); if (new == NULL) new = &noop_qdisc; } @@ -381,7 +381,8 @@ static int dsmark_init(struct Qdisc *sch, struct nlattr *opt, p->default_index = default_index; p->set_tc_index = nla_get_flag(tb[TCA_DSMARK_SET_TC_INDEX]); - p->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, sch->handle); + p->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, sch->handle, + NULL); if (p->q == NULL) p->q = &noop_qdisc; else diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c index c65f23c70f40..24893d3b5d22 100644 --- a/net/sched/sch_fifo.c +++ b/net/sched/sch_fifo.c @@ -166,12 +166,14 @@ int fifo_set_limit(struct Qdisc *q, unsigned int limit) EXPORT_SYMBOL(fifo_set_limit); struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops, - unsigned int limit) + unsigned int limit, + struct netlink_ext_ack *extack) { struct Qdisc *q; int err = -ENOMEM; - q = qdisc_create_dflt(sch->dev_queue, ops, TC_H_MAKE(sch->handle, 1)); + q = qdisc_create_dflt(sch->dev_queue, ops, TC_H_MAKE(sch->handle, 1), + extack); if (q) { err = fifo_set_limit(q, limit); if (err < 0) { diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 01457b27d36e..020db5e57290 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -824,21 +824,24 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, const struct Qdisc_ops *ops, - unsigned int parentid) + unsigned int parentid, + struct netlink_ext_ack *extack) { struct Qdisc *sch; - if (!try_module_get(ops->owner)) + if (!try_module_get(ops->owner)) { + NL_SET_ERR_MSG(extack, "Failed to increase module reference counter"); return NULL; + } - sch = qdisc_alloc(dev_queue, ops, NULL); + sch = qdisc_alloc(dev_queue, ops, extack); if (IS_ERR(sch)) { module_put(ops->owner); return NULL; } sch->parent = parentid; - if (!ops->init || ops->init(sch, NULL, NULL) == 0) + if (!ops->init || ops->init(sch, NULL, extack) == 0) return sch; qdisc_destroy(sch); @@ -950,7 +953,7 @@ static void attach_one_default_qdisc(struct net_device *dev, if (dev->priv_flags & IFF_NO_QUEUE) ops = &noqueue_qdisc_ops; - qdisc = qdisc_create_dflt(dev_queue, ops, TC_H_ROOT); + qdisc = qdisc_create_dflt(dev_queue, ops, TC_H_ROOT, NULL); if (!qdisc) { netdev_info(dev, "activation failed\n"); return; @@ -973,7 +976,7 @@ static void attach_default_qdiscs(struct net_device *dev) dev->qdisc = txq->qdisc_sleeping; qdisc_refcount_inc(dev->qdisc); } else { - qdisc = qdisc_create_dflt(txq, &mq_qdisc_ops, TC_H_ROOT); + qdisc = qdisc_create_dflt(txq, &mq_qdisc_ops, TC_H_ROOT, NULL); if (qdisc) { dev->qdisc = qdisc; qdisc->ops->attach(qdisc); diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 9ae288fcbed8..3ae9877ea205 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1062,8 +1062,8 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, cl->cl_common.classid = classid; cl->sched = q; cl->cl_parent = parent; - cl->qdisc = qdisc_create_dflt(sch->dev_queue, - &pfifo_qdisc_ops, classid); + cl->qdisc = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + classid, NULL); if (cl->qdisc == NULL) cl->qdisc = &noop_qdisc; else @@ -1185,7 +1185,7 @@ hfsc_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, return -EINVAL; if (new == NULL) { new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, - cl->cl_common.classid); + cl->cl_common.classid, NULL); if (new == NULL) new = &noop_qdisc; } @@ -1416,7 +1416,7 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt, q->root.cl_common.classid = sch->handle; q->root.sched = q; q->root.qdisc = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, - sch->handle); + sch->handle, NULL); if (q->root.qdisc == NULL) q->root.qdisc = &noop_qdisc; else diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 54e1f860f1e5..1ea9846cc6ce 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -1180,7 +1180,7 @@ static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, return -EINVAL; if (new == NULL && (new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, - cl->common.classid)) == NULL) + cl->common.classid, extack)) == NULL) return -ENOBUFS; *old = qdisc_replace(sch, new, &cl->un.leaf.q); @@ -1290,7 +1290,8 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg) if (!cl->level && htb_parent_last_child(cl)) { new_q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, - cl->parent->common.classid); + cl->parent->common.classid, + NULL); last_child = 1; } @@ -1426,8 +1427,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, * so that can't be used inside of sch_tree_lock * -- thanks to Karlis Peisenieks */ - new_q = qdisc_create_dflt(sch->dev_queue, - &pfifo_qdisc_ops, classid); + new_q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + classid, NULL); sch_tree_lock(sch); if (parent && !parent->level) { unsigned int qlen = parent->un.leaf.q->q.qlen; diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c index 50292e470432..f062a18e9162 100644 --- a/net/sched/sch_mq.c +++ b/net/sched/sch_mq.c @@ -61,7 +61,8 @@ static int mq_init(struct Qdisc *sch, struct nlattr *opt, dev_queue = netdev_get_tx_queue(dev, ntx); qdisc = qdisc_create_dflt(dev_queue, get_default_qdisc_ops(dev, ntx), TC_H_MAKE(TC_H_MAJ(sch->handle), - TC_H_MIN(ntx + 1))); + TC_H_MIN(ntx + 1)), + extack); if (!qdisc) return -ENOMEM; priv->qdiscs[ntx] = qdisc; diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 29071cf329f3..0e9d761cdd80 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -230,7 +230,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, qdisc = qdisc_create_dflt(dev_queue, get_default_qdisc_ops(dev, i), TC_H_MAKE(TC_H_MAJ(sch->handle), - TC_H_MIN(i + 1))); + TC_H_MIN(i + 1)), extack); if (!qdisc) return -ENOMEM; diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c index 35cbaf8bd96a..1da7ea8de0ad 100644 --- a/net/sched/sch_multiq.c +++ b/net/sched/sch_multiq.c @@ -216,7 +216,7 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt, child = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, TC_H_MAKE(sch->handle, - i + 1)); + i + 1), extack); if (child) { sch_tree_lock(sch); old = q->queues[i]; diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index 502352762f03..fe1510eb111f 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c @@ -176,7 +176,8 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt, /* Before commit, make sure we can allocate all new qdiscs */ for (i = oldbands; i < qopt->bands; i++) { queues[i] = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, - TC_H_MAKE(sch->handle, i + 1)); + TC_H_MAKE(sch->handle, i + 1), + extack); if (!queues[i]) { while (i > oldbands) qdisc_destroy(queues[--i]); diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 6ab58509cf49..bb1a9c11fc54 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -480,8 +480,8 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, cl->common.classid = classid; cl->deficit = lmax; - cl->qdisc = qdisc_create_dflt(sch->dev_queue, - &pfifo_qdisc_ops, classid); + cl->qdisc = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + classid, NULL); if (cl->qdisc == NULL) cl->qdisc = &noop_qdisc; @@ -601,8 +601,8 @@ static int qfq_graft_class(struct Qdisc *sch, unsigned long arg, struct qfq_class *cl = (struct qfq_class *)arg; if (new == NULL) { - new = qdisc_create_dflt(sch->dev_queue, - &pfifo_qdisc_ops, cl->common.classid); + new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + cl->common.classid, NULL); if (new == NULL) new = &noop_qdisc; } diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index 19616fa0a1a8..094fcf072e78 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c @@ -217,7 +217,8 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt, return -EINVAL; if (ctl->limit > 0) { - child = fifo_create_dflt(sch, &bfifo_qdisc_ops, ctl->limit); + child = fifo_create_dflt(sch, &bfifo_qdisc_ops, ctl->limit, + extack); if (IS_ERR(child)) return PTR_ERR(child); } diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index a1a11ded8e4f..7cbdad8419b7 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c @@ -513,7 +513,7 @@ static int sfb_change(struct Qdisc *sch, struct nlattr *opt, if (limit == 0) limit = qdisc_dev(sch)->tx_queue_len; - child = fifo_create_dflt(sch, &pfifo_qdisc_ops, limit); + child = fifo_create_dflt(sch, &pfifo_qdisc_ops, limit, extack); if (IS_ERR(child)) return PTR_ERR(child); diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 1ab53ff80f46..83e76d046993 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -386,7 +386,8 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt, if (err) goto done; } else if (qopt->limit > 0) { - child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit); + child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit, + extack); if (IS_ERR(child)) { err = PTR_ERR(child); goto done; From patchwork Mon Dec 18 22:45:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850475 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="uagppYB2"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x3L4tHNz9s4s for ; Tue, 19 Dec 2017 09:46:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965834AbdLRWqV (ORCPT ); Mon, 18 Dec 2017 17:46:21 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:43532 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936477AbdLRWpm (ORCPT ); Mon, 18 Dec 2017 17:45:42 -0500 Received: by mail-it0-f65.google.com with SMTP id u62so581595ita.2 for ; Mon, 18 Dec 2017 14:45:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HXyu5TZb8bA8TfPFKJ08xUA7owXv8Gy4eFLCbX83r3I=; b=uagppYB29sAL8bIRZUfxXqIPRxk4+i4bXQkitAxDAuAlST3ooSjSsnwsJNfQ5AuiRj OTMT/EBJqbz8PJ2WpjhuOl+g2+oT1aa5BacLsho58R+3M1eMHB9lPMyo/E4Wta4c0Xs4 5qf5dPDf9npSDZQ0sGET9gI137mG0xhOUool9PIb+ZL39PVbAKLYcWevVgTSXcILnHfo kRPevUguqouW8glJ7x/yMGaQLEFzmwULZKn2OoB5MYIMCRk0un84LD8jdXUvib4yQczP AdxY0mZXAhdmmVvN6puV5ccQYUlEek/Ty3S1nk9QAE3uXqnBdTxFQWet60REGEOMbA/v 42og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HXyu5TZb8bA8TfPFKJ08xUA7owXv8Gy4eFLCbX83r3I=; b=K/e59XN5OELJWXZC+O08kRyYGH542X9HpJ1xypVF+ar5JYypqpN5JJkzV2THnyWDv2 cgUUDFa4PfphZcR/tF1IUkfgZyrR5zzj5EZ84G+7s9wkIJFRUalS2CmBPHLGeXYBkdG0 kxFfickXnJvwqdAeJeqtMzlJ4DZVlt6tbJ45/AdQF2sdUvBMTzy0HDWzcOkw+RI52Yy3 ZzNr4KVZVXsTuIOWpdCT8rMZVApvf1188aVC//z3z9WGLVtoWXIDWQ+YCZh7NnztkoAg PWBTJidRxZDMctIWilnlZ9uULYMkWFmutWJUttp74q4Qnjp+ClEARsSU6jIRONWg2Frk 6sDg== X-Gm-Message-State: AKGB3mLkbIcfedAM7v4IBdT7q49X1VSA/LVK4PGGE7bahAm6YRQvwVy2 pYIYw5FXq9gV49NkZMXiYRDNrg== X-Google-Smtp-Source: ACJfBos8pdb7ppgrXgxOdRAJeyYhxUVhbkIv/NULiyuhK5oNxH++s7YVBqDmlSkxT5tDaEB3M77k+A== X-Received: by 10.36.170.9 with SMTP id b9mr838046itf.111.1513637141654; Mon, 18 Dec 2017 14:45:41 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:41 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 12/14] net: sch: sch_cbq: add extack support Date: Mon, 18 Dec 2017 17:45:11 -0500 Message-Id: <20171218224513.29836-13-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for the cbq qdisc implementation by adding NL_SET_ERR_MSG in validation of user input. Also it serves to illustrate a use case of how the infrastructure ops api changes are to be used by individual qdiscs. Cc: David Ahern Signed-off-by: Alexander Aring --- net/sched/sch_cbq.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index efe5bf15b031..f42025d53cfe 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1144,15 +1144,19 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt, hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED); q->delay_timer.function = cbq_undelay; - if (!opt) + if (!opt) { + NL_SET_ERR_MSG(extack, "CBQ options are required for this operation"); return -EINVAL; + } - err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy, NULL); + err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy, extack); if (err < 0) return err; - if (!tb[TCA_CBQ_RTAB] || !tb[TCA_CBQ_RATE]) + if (!tb[TCA_CBQ_RTAB] || !tb[TCA_CBQ_RATE]) { + NL_SET_ERR_MSG(extack, "Rate specification missing or incomplete"); return -EINVAL; + } r = nla_data(tb[TCA_CBQ_RATE]); @@ -1462,24 +1466,32 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t struct cbq_class *parent; struct qdisc_rate_table *rtab = NULL; - if (!opt) + if (!opt) { + NL_SET_ERR_MSG(extack, "Mandatory qdisc options missing"); return -EINVAL; + } - err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy, NULL); + err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy, extack); if (err < 0) return err; - if (tb[TCA_CBQ_OVL_STRATEGY] || tb[TCA_CBQ_POLICE]) + if (tb[TCA_CBQ_OVL_STRATEGY] || tb[TCA_CBQ_POLICE]) { + NL_SET_ERR_MSG(extack, "Neither overlimit strategy nor policing attributes can be used for changing class params"); return -EOPNOTSUPP; + } if (cl) { /* Check parent */ if (parentid) { if (cl->tparent && - cl->tparent->common.classid != parentid) + cl->tparent->common.classid != parentid) { + NL_SET_ERR_MSG(extack, "Invalid parent id"); return -EINVAL; - if (!cl->tparent && parentid != TC_H_ROOT) + } + if (!cl->tparent && parentid != TC_H_ROOT) { + NL_SET_ERR_MSG(extack, "Parent must be root"); return -EINVAL; + } } if (tb[TCA_CBQ_RATE]) { @@ -1496,6 +1508,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t qdisc_root_sleeping_running(sch), tca[TCA_RATE]); if (err) { + NL_SET_ERR_MSG(extack, "Failed to replace specified rate estimator"); qdisc_put_rtab(rtab); return err; } @@ -1534,8 +1547,10 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t if (parentid == TC_H_ROOT) return -EINVAL; - if (!tb[TCA_CBQ_WRROPT] || !tb[TCA_CBQ_RATE] || !tb[TCA_CBQ_LSSOPT]) + if (!tb[TCA_CBQ_WRROPT] || !tb[TCA_CBQ_RATE] || !tb[TCA_CBQ_LSSOPT]) { + NL_SET_ERR_MSG(extack, "One of the following attributes MUST be specified: WRR, rate or link sharing"); return -EINVAL; + } rtab = qdisc_get_rtab(nla_data(tb[TCA_CBQ_RATE]), tb[TCA_CBQ_RTAB], extack); @@ -1545,8 +1560,10 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t if (classid) { err = -EINVAL; if (TC_H_MAJ(classid ^ sch->handle) || - cbq_class_lookup(q, classid)) + cbq_class_lookup(q, classid)) { + NL_SET_ERR_MSG(extack, "Specified class not found"); goto failure; + } } else { int i; classid = TC_H_MAKE(sch->handle, 0x8000); @@ -1558,8 +1575,10 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t break; } err = -ENOSR; - if (i >= 0x8000) + if (i >= 0x8000) { + NL_SET_ERR_MSG(extack, "Unable to generate classid"); goto failure; + } classid = classid|q->hgenerator; } @@ -1567,8 +1586,10 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t if (parentid) { parent = cbq_class_lookup(q, parentid); err = -EINVAL; - if (!parent) + if (!parent) { + NL_SET_ERR_MSG(extack, "Failed to find parentid"); goto failure; + } } err = -ENOBUFS; @@ -1588,6 +1609,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t qdisc_root_sleeping_running(sch), tca[TCA_RATE]); if (err) { + NL_SET_ERR_MSG(extack, "Couldn't create new estimator"); tcf_block_put(cl->block); kfree(cl); goto failure; From patchwork Mon Dec 18 22:45:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850474 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="tl8XtlXx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x3J5L6Kz9t2M for ; Tue, 19 Dec 2017 09:46:20 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965728AbdLRWqS (ORCPT ); Mon, 18 Dec 2017 17:46:18 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:36186 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936346AbdLRWpn (ORCPT ); Mon, 18 Dec 2017 17:45:43 -0500 Received: by mail-it0-f66.google.com with SMTP id d16so595222itj.1 for ; Mon, 18 Dec 2017 14:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NwJMDwD0b5VKHXPtXsFEyHCC+h0z0sxcurxM+Hek9fE=; b=tl8XtlXxZyLc7PfrzJpKujy69GyDtUzgKGA9lhWDFWkDGb+m6la2oqA4cDVtyXuYbY 1aYF83v/btMqoP0XDXTaa5vOeaKejL02BNPLV2c4mhwGFOtV3nV7obJxn88FCK8eT88Z fbHh29h2Etbs3Zkt6pczfrzFa2Ho9kBLjXSQG/qzq3kayjAwen+VfzuKTk7cernmzpGB RwP8wBi4LocnAMV0fNzFYHklymnuSD1T1wV1us/K3HUDrArjUL7A06cTN+tDVdHrG/PP n+rU322RaDcHRYuMFrj98eihqqe6/Ty6ZqMsMj4xspOqEVB+Q0pnWkkBw18lmZXxhPp2 LnNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NwJMDwD0b5VKHXPtXsFEyHCC+h0z0sxcurxM+Hek9fE=; b=Ex4gzGYYwWgMLwnyMMdQlTslHukHfM47KlSirTgRFAK+EI9rl7SU7oSvLeeTG2ZWP9 A+ad0pU/6N/ubt6D02/HqHtd68SAxfylroZXx7OOPaulcyQ8gH/gkMn1nj8sJ7QkTXTR m5MydwPq/0hLwUEuRKj4oRo/Fo68lGFeNFw1aND/8r6i/BCBku/w+Xci3PW9uqimnWLk UTlxQnC/1hidtzp/BxJKZyZJFkhOeb3s89iHXRaI96HD60G5zxx9k6vSm/fF6Hr9Kn9Q IbII8lc4geZ6d1UdplyIgRb2Ghro2xxc7+ueL/qNA/HKW3o/gjcqwYlz52NJoMpCcMl+ CA1A== X-Gm-Message-State: AKGB3mIVxcPlkPplfvF/5ELrVFN0aS80GO0nDgESqXfrq3y3kOe46Dhq qDPZijAXletTgbVtaHuCbfNdPw== X-Google-Smtp-Source: ACJfBosJvvzKLv9cD5RfIP5n95Z9sRKOHieBU6D88eU4Zw9p0y7Z+ocEbwXFR5rcsw8Da9ie8DTapg== X-Received: by 10.36.44.19 with SMTP id i19mr813518iti.143.1513637142757; Mon, 18 Dec 2017 14:45:42 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:42 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 13/14] net: sch: sch_cbs: add extack support Date: Mon, 18 Dec 2017 17:45:12 -0500 Message-Id: <20171218224513.29836-14-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for the cbs qdisc implementation by adding NL_SET_ERR_MSG in validation of user input. Also it serves to illustrate a use case of how the infrastructure ops api changes are to be used by individual qdiscs. Cc: David Ahern Signed-off-by: Alexander Aring --- net/sched/sch_cbs.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c index 8bf6e163d29c..cdd96b9a27bc 100644 --- a/net/sched/sch_cbs.c +++ b/net/sched/sch_cbs.c @@ -219,14 +219,17 @@ static void cbs_disable_offload(struct net_device *dev, } static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q, - const struct tc_cbs_qopt *opt) + const struct tc_cbs_qopt *opt, + struct netlink_ext_ack *extack) { const struct net_device_ops *ops = dev->netdev_ops; struct tc_cbs_qopt_offload cbs = { }; int err; - if (!ops->ndo_setup_tc) + if (!ops->ndo_setup_tc) { + NL_SET_ERR_MSG(extack, "Specified device does not support cbs offload"); return -EOPNOTSUPP; + } cbs.queue = q->queue; @@ -237,8 +240,10 @@ static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q, cbs.sendslope = opt->sendslope; err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_CBS, &cbs); - if (err < 0) + if (err < 0) { + NL_SET_ERR_MSG(extack, "Specified device failed to setup cbs hardware offload"); return err; + } q->enqueue = cbs_enqueue_offload; q->dequeue = cbs_dequeue_offload; @@ -255,12 +260,14 @@ static int cbs_change(struct Qdisc *sch, struct nlattr *opt, struct tc_cbs_qopt *qopt; int err; - err = nla_parse_nested(tb, TCA_CBS_MAX, opt, cbs_policy, NULL); + err = nla_parse_nested(tb, TCA_CBS_MAX, opt, cbs_policy, extack); if (err < 0) return err; - if (!tb[TCA_CBS_PARMS]) + if (!tb[TCA_CBS_PARMS]) { + NL_SET_ERR_MSG(extack, "Missing CBS parameter which are mandatory"); return -EINVAL; + } qopt = nla_data(tb[TCA_CBS_PARMS]); @@ -277,7 +284,7 @@ static int cbs_change(struct Qdisc *sch, struct nlattr *opt, cbs_disable_offload(dev, q); } else { - err = cbs_enable_offload(dev, q, qopt); + err = cbs_enable_offload(dev, q, qopt, extack); if (err < 0) return err; } @@ -298,8 +305,10 @@ static int cbs_init(struct Qdisc *sch, struct nlattr *opt, struct cbs_sched_data *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); - if (!opt) + if (!opt) { + NL_SET_ERR_MSG(extack, "Missing CBS qdisc options which are mandatory"); return -EINVAL; + } q->queue = sch->dev_queue - netdev_get_tx_queue(dev, 0); From patchwork Mon Dec 18 22:45:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 850471 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="V/ach8EN"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0x364tXJz9t2W for ; Tue, 19 Dec 2017 09:46:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965142AbdLRWqI (ORCPT ); Mon, 18 Dec 2017 17:46:08 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:41308 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964845AbdLRWpo (ORCPT ); Mon, 18 Dec 2017 17:45:44 -0500 Received: by mail-it0-f65.google.com with SMTP id x28so593742ita.0 for ; Mon, 18 Dec 2017 14:45:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bqafZxAQxVvbWdGLfRkPXFkmHQo5qcwC+s+S2MTwVLg=; b=V/ach8ENVZqMuuh4oP3lgOUDQm0jYGdArxnTlwoOnZQp5r6V9KuEikGl3O8a1AiilN bSdY4n2nD2hkMaIXOCsgV9OMk2mYpHXW2y6eKjEOpKiXtjRXtfxOjnA66AF4kRuUFxkq ieHWgE6qZYzT05RGKU6mj88U2FwHXqFJieVFqB4vZYNEhcEKTqo9J/oS8tY4OxBywHZx g9AuyEQSBkbVLiligePpo03VMKWMEnCAdbRdowqz+O9iaIsAyGgTli4s4qey/77gKUMH LUvJGqZahZQoKWe+qO3A8ZIfet8cgjYt3UUtNKEPXzl3USClP7jdN3TtzJlP1B6uXLzm ZzTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bqafZxAQxVvbWdGLfRkPXFkmHQo5qcwC+s+S2MTwVLg=; b=RZOsJKPbFB8LyVes2RRcc2566ZjldtFn+Jwy70a3cYdorvENKjFv8+Xdot138YD1JM PFfVI6iS3x2toGWwi3UDNoXByA9iHSGhTnCbvBVgpPX3BaUu5UeZtqy9Y4fZ2rfoqXuM JSkf6GOiv8BTSyz9K6F9gaJ7jaW4ATgLzQpN337HQGOcSAad11dQxzqiZ9MKDgpYDIhD Qa57VVPVMaJfjwCLOacxFxUJpz6VZ4kfsshcmMU6QuGn1al5lKzYVVeWC7hPgTL+8BH2 jx+jEZggqM/JPsUCGo0DsGfbyzgwwy12mQRUmoGLiGAUArMssl672kCpIKBq5ZC/T7Z1 cQiQ== X-Gm-Message-State: AKGB3mLV/QfJPirMfhRE72+/RBzSwcxZbyjtSCXZbYpzR3k4IFyZh7Si lWBxEsASDBdM/GhuMQRQHgEEjeir X-Google-Smtp-Source: ACJfBot3u2t0Eml5P9GTEuU7SF0P963RhAO77g5J3Jqy+cCkREbbiIeaPxVb+ratMKaZZBmruOjcCQ== X-Received: by 10.36.214.20 with SMTP id o20mr834880itg.112.1513637143809; Mon, 18 Dec 2017 14:45:43 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id o71sm210867itb.28.2017.12.18.14.45.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:45:43 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCHv3 net-next 14/14] net: sch: sch_drr: add extack support Date: Mon, 18 Dec 2017 17:45:13 -0500 Message-Id: <20171218224513.29836-15-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171218224513.29836-1-aring@mojatatu.com> References: <20171218224513.29836-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for the drr qdisc implementation by adding NL_SET_ERR_MSG in validation of user input. Also it serves to illustrate a use case of how the infrastructure ops api changes are to be used by individual qdiscs. Cc: David Ahern Signed-off-by: Alexander Aring --- net/sched/sch_drr.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index bf638ce57c50..e0b0cf8a9939 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c @@ -74,17 +74,21 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, u32 quantum; int err; - if (!opt) + if (!opt) { + NL_SET_ERR_MSG(extack, "DRR options are required for this operation"); return -EINVAL; + } - err = nla_parse_nested(tb, TCA_DRR_MAX, opt, drr_policy, NULL); + err = nla_parse_nested(tb, TCA_DRR_MAX, opt, drr_policy, extack); if (err < 0) return err; if (tb[TCA_DRR_QUANTUM]) { quantum = nla_get_u32(tb[TCA_DRR_QUANTUM]); - if (quantum == 0) + if (quantum == 0) { + NL_SET_ERR_MSG(extack, "Specified DRR quantum cannot be zero"); return -EINVAL; + } } else quantum = psched_mtu(qdisc_dev(sch)); @@ -95,8 +99,10 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, NULL, qdisc_root_sleeping_running(sch), tca[TCA_RATE]); - if (err) + if (err) { + NL_SET_ERR_MSG(extack, "Failed to replace estimator"); return err; + } } sch_tree_lock(sch); @@ -127,6 +133,7 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, qdisc_root_sleeping_running(sch), tca[TCA_RATE]); if (err) { + NL_SET_ERR_MSG(extack, "Failed to replace estimator"); qdisc_destroy(cl->qdisc); kfree(cl); return err; @@ -179,8 +186,10 @@ static struct tcf_block *drr_tcf_block(struct Qdisc *sch, unsigned long cl, { struct drr_sched *q = qdisc_priv(sch); - if (cl) + if (cl) { + NL_SET_ERR_MSG(extack, "DRR classid must be zero"); return NULL; + } return q->block; }