netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Subject: [PATCH net-next] net_sched: add messages to distinguish errors when modify qdisc
Date: Tue, 10 Dec 2013 16:49:00 +0800	[thread overview]
Message-ID: <1386665340-16820-1-git-send-email-yangyingliang@huawei.com> (raw)

When tc_modify_qdisc return EINVAL, user cannot distinguish
errors easliy. Add some messages to make it easier.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 net/sched/sch_api.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index cd81505..6b0e53c 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -995,8 +995,11 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca)
 	int err = 0;
 
 	if (tca[TCA_OPTIONS]) {
-		if (sch->ops->change == NULL)
+		if (sch->ops->change == NULL) {
+			pr_err_ratelimited("Can't change %s qdisc parameters.\n",
+					   sch->ops->id);
 			return -EINVAL;
+		}
 		err = sch->ops->change(sch, tca[TCA_OPTIONS]);
 		if (err)
 			return err;
@@ -1186,15 +1189,20 @@ replay:
 			if (tcm->tcm_handle) {
 				if (q && !(n->nlmsg_flags & NLM_F_REPLACE))
 					return -EEXIST;
-				if (TC_H_MIN(tcm->tcm_handle))
+				if (TC_H_MIN(tcm->tcm_handle)) {
+					pr_err_ratelimited("Wrong minor handle, it must be 0.\n");
 					return -EINVAL;
+				}
 				q = qdisc_lookup(dev, tcm->tcm_handle);
 				if (!q)
 					goto create_n_graft;
 				if (n->nlmsg_flags & NLM_F_EXCL)
 					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)) {
+					pr_err_ratelimited("A different qdisc(%s) with handle %d: already exists.\n",
+							   q->ops->id, TC_H_MAJ(tcm->tcm_handle) >> 16);
 					return -EINVAL;
+				}
 				if (q == p ||
 				    (p && check_loop(q, p, 0)))
 					return -ELOOP;
@@ -1232,8 +1240,10 @@ replay:
 			}
 		}
 	} else {
-		if (!tcm->tcm_handle)
+		if (!tcm->tcm_handle) {
+			pr_err_ratelimited("Wrong handle, it can't be 0.\n");
 			return -EINVAL;
+		}
 		q = qdisc_lookup(dev, tcm->tcm_handle);
 	}
 
@@ -1242,8 +1252,13 @@ replay:
 		return -ENOENT;
 	if (n->nlmsg_flags & NLM_F_EXCL)
 		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)) {
+		char name[IFNAMSIZ];
+		nla_strlcpy(name, tca[TCA_KIND], IFNAMSIZ);
+		pr_err_ratelimited("A %s qdisc already exists, can't change its parameters to %s's.\n",
+				   q->ops->id, name);
 		return -EINVAL;
+	}
 	err = qdisc_change(q, tca);
 	if (err == 0)
 		qdisc_notify(net, skb, n, clid, NULL, q);
-- 
1.8.0

             reply	other threads:[~2013-12-10  8:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10  8:49 Yang Yingliang [this message]
2013-12-10 18:47 ` [PATCH net-next] net_sched: add messages to distinguish errors when modify qdisc David Miller
2013-12-11  2:37   ` Yang Yingliang
2013-12-11  2:39     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386665340-16820-1-git-send-email-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).