summaryrefslogtreecommitdiffstats
path: root/net/sched/sch_api.c
diff options
context:
space:
mode:
authorJarek Poplawski <jarkao2@gmail.com>2010-08-09 12:18:48 +0000
committerDavid S. Miller <davem@davemloft.net>2010-08-10 01:39:14 -0700
commit68fd26b59856b466edd14d8a90d01255983cd3ee (patch)
tree75dc4e5cb9c5af0b8281b278ae408efdf1569ad8 /net/sched/sch_api.c
parentda7115d94a15f53efa224e47f16c57fd1998355f (diff)
downloadlinux-68fd26b59856b466edd14d8a90d01255983cd3ee.tar.gz
linux-68fd26b59856b466edd14d8a90d01255983cd3ee.tar.bz2
linux-68fd26b59856b466edd14d8a90d01255983cd3ee.zip
pkt_sched: Add some basic qdisc class ops verification. Was: [PATCH] sfq: add dummy bind/unbind handles
Verify in register_qdisc() some basic qdisc class handlers are present. Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_api.c')
-rw-r--r--net/sched/sch_api.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index b9e8c3b7d406..8ed2f5649029 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -150,22 +150,34 @@ int register_qdisc(struct Qdisc_ops *qops)
if (qops->enqueue == NULL)
qops->enqueue = noop_qdisc_ops.enqueue;
if (qops->peek == NULL) {
- if (qops->dequeue == NULL) {
+ if (qops->dequeue == NULL)
qops->peek = noop_qdisc_ops.peek;
- } else {
- rc = -EINVAL;
- goto out;
- }
+ else
+ goto out_einval;
}
if (qops->dequeue == NULL)
qops->dequeue = noop_qdisc_ops.dequeue;
+ if (qops->cl_ops) {
+ const struct Qdisc_class_ops *cops = qops->cl_ops;
+
+ if (!(cops->get && cops->put))
+ goto out_einval;
+
+ if (cops->tcf_chain && !(cops->bind_tcf && cops->unbind_tcf))
+ goto out_einval;
+ }
+
qops->next = NULL;
*qp = qops;
rc = 0;
out:
write_unlock(&qdisc_mod_lock);
return rc;
+
+out_einval:
+ rc = -EINVAL;
+ goto out;
}
EXPORT_SYMBOL(register_qdisc);