net_sched: fix class grafting errno codes
authorPatrick McHardy <kaber@trash.net>
Fri, 4 Sep 2009 06:41:13 +0000 (06:41 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 5 Sep 2009 06:10:15 +0000 (23:10 -0700)
If the parent qdisc doesn't support classes, use EOPNOTSUPP.
If the parent class doesn't exist, use ENOENT. Currently EINVAL
is returned in both cases.

Additionally check whether grafting is supported and remove a now
unnecessary graft function from sch_ingress.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_api.c
net/sched/sch_ingress.c

index 24d17ce9c294f384f1a638b7888540455479f3aa..bef2d645a3662201d39e618c7478a2df0384a84a 100644 (file)
@@ -728,14 +728,14 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
        } else {
                const struct Qdisc_class_ops *cops = parent->ops->cl_ops;
 
-               err = -EINVAL;
-
-               if (cops) {
+               err = -EOPNOTSUPP;
+               if (cops && cops->graft) {
                        unsigned long cl = cops->get(parent, classid);
                        if (cl) {
                                err = cops->graft(parent, cl, new, &old);
                                cops->put(parent, cl);
-                       }
+                       } else
+                               err = -ENOENT;
                }
                if (!err)
                        notify_and_destroy(skb, n, classid, old, new);
index 4a2b773743589733533d7ca48ca902f44b5980fa..ace7902b5097fed3908e2081246f970ef4f973fd 100644 (file)
@@ -22,12 +22,6 @@ struct ingress_qdisc_data {
 
 /* ------------------------- Class/flow operations ------------------------- */
 
-static int ingress_graft(struct Qdisc *sch, unsigned long arg,
-                        struct Qdisc *new, struct Qdisc **old)
-{
-       return -EOPNOTSUPP;
-}
-
 static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
 {
        return NULL;
@@ -123,7 +117,6 @@ nla_put_failure:
 }
 
 static const struct Qdisc_class_ops ingress_class_ops = {
-       .graft          =       ingress_graft,
        .leaf           =       ingress_leaf,
        .get            =       ingress_get,
        .put            =       ingress_put,