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>
This commit is contained in:
committed by
David S. Miller
parent
da7115d94a
commit
68fd26b598
@@ -150,22 +150,34 @@ int register_qdisc(struct Qdisc_ops *qops)
|
|||||||
if (qops->enqueue == NULL)
|
if (qops->enqueue == NULL)
|
||||||
qops->enqueue = noop_qdisc_ops.enqueue;
|
qops->enqueue = noop_qdisc_ops.enqueue;
|
||||||
if (qops->peek == NULL) {
|
if (qops->peek == NULL) {
|
||||||
if (qops->dequeue == NULL) {
|
if (qops->dequeue == NULL)
|
||||||
qops->peek = noop_qdisc_ops.peek;
|
qops->peek = noop_qdisc_ops.peek;
|
||||||
} else {
|
else
|
||||||
rc = -EINVAL;
|
goto out_einval;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (qops->dequeue == NULL)
|
if (qops->dequeue == NULL)
|
||||||
qops->dequeue = noop_qdisc_ops.dequeue;
|
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;
|
qops->next = NULL;
|
||||||
*qp = qops;
|
*qp = qops;
|
||||||
rc = 0;
|
rc = 0;
|
||||||
out:
|
out:
|
||||||
write_unlock(&qdisc_mod_lock);
|
write_unlock(&qdisc_mod_lock);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
out_einval:
|
||||||
|
rc = -EINVAL;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(register_qdisc);
|
EXPORT_SYMBOL(register_qdisc);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user