|
@@ -131,6 +131,11 @@ static DEFINE_RWLOCK(qdisc_mod_lock);
|
|
|
************************************************/
|
|
|
|
|
|
|
|
|
+/* Qdisc to use by default */
|
|
|
+
|
|
|
+const struct Qdisc_ops *default_qdisc_ops = &pfifo_fast_ops;
|
|
|
+EXPORT_SYMBOL(default_qdisc_ops);
|
|
|
+
|
|
|
/* The list of all installed queueing disciplines. */
|
|
|
|
|
|
static struct Qdisc_ops *qdisc_base;
|
|
@@ -200,6 +205,58 @@ int unregister_qdisc(struct Qdisc_ops *qops)
|
|
|
}
|
|
|
EXPORT_SYMBOL(unregister_qdisc);
|
|
|
|
|
|
+/* Get default qdisc if not otherwise specified */
|
|
|
+void qdisc_get_default(char *name, size_t len)
|
|
|
+{
|
|
|
+ read_lock(&qdisc_mod_lock);
|
|
|
+ strlcpy(name, default_qdisc_ops->id, len);
|
|
|
+ read_unlock(&qdisc_mod_lock);
|
|
|
+}
|
|
|
+
|
|
|
+static struct Qdisc_ops *qdisc_lookup_default(const char *name)
|
|
|
+{
|
|
|
+ struct Qdisc_ops *q = NULL;
|
|
|
+
|
|
|
+ for (q = qdisc_base; q; q = q->next) {
|
|
|
+ if (!strcmp(name, q->id)) {
|
|
|
+ if (!try_module_get(q->owner))
|
|
|
+ q = NULL;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return q;
|
|
|
+}
|
|
|
+
|
|
|
+/* Set new default qdisc to use */
|
|
|
+int qdisc_set_default(const char *name)
|
|
|
+{
|
|
|
+ const struct Qdisc_ops *ops;
|
|
|
+
|
|
|
+ if (!capable(CAP_NET_ADMIN))
|
|
|
+ return -EPERM;
|
|
|
+
|
|
|
+ write_lock(&qdisc_mod_lock);
|
|
|
+ ops = qdisc_lookup_default(name);
|
|
|
+ if (!ops) {
|
|
|
+ /* Not found, drop lock and try to load module */
|
|
|
+ write_unlock(&qdisc_mod_lock);
|
|
|
+ request_module("sch_%s", name);
|
|
|
+ write_lock(&qdisc_mod_lock);
|
|
|
+
|
|
|
+ ops = qdisc_lookup_default(name);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ops) {
|
|
|
+ /* Set new default */
|
|
|
+ module_put(default_qdisc_ops->owner);
|
|
|
+ default_qdisc_ops = ops;
|
|
|
+ }
|
|
|
+ write_unlock(&qdisc_mod_lock);
|
|
|
+
|
|
|
+ return ops ? 0 : -ENOENT;
|
|
|
+}
|
|
|
+
|
|
|
/* We know handle. Find qdisc among all qdisc's attached to device
|
|
|
(root qdisc, all its children, children of children etc.)
|
|
|
*/
|
|
@@ -1854,6 +1911,7 @@ static int __init pktsched_init(void)
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
+ register_qdisc(&pfifo_fast_ops);
|
|
|
register_qdisc(&pfifo_qdisc_ops);
|
|
|
register_qdisc(&bfifo_qdisc_ops);
|
|
|
register_qdisc(&pfifo_head_drop_qdisc_ops);
|