diff options
Diffstat (limited to 'net/sched/sch_api.c')
| -rw-r--r-- | net/sched/sch_api.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 51b968d3febb..2adda7fa2d39 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
| @@ -200,6 +200,58 @@ int unregister_qdisc(struct Qdisc_ops *qops) | |||
| 200 | } | 200 | } |
| 201 | EXPORT_SYMBOL(unregister_qdisc); | 201 | EXPORT_SYMBOL(unregister_qdisc); |
| 202 | 202 | ||
| 203 | /* Get default qdisc if not otherwise specified */ | ||
| 204 | void qdisc_get_default(char *name, size_t len) | ||
| 205 | { | ||
| 206 | read_lock(&qdisc_mod_lock); | ||
| 207 | strlcpy(name, default_qdisc_ops->id, len); | ||
| 208 | read_unlock(&qdisc_mod_lock); | ||
| 209 | } | ||
| 210 | |||
| 211 | static struct Qdisc_ops *qdisc_lookup_default(const char *name) | ||
| 212 | { | ||
| 213 | struct Qdisc_ops *q = NULL; | ||
| 214 | |||
| 215 | for (q = qdisc_base; q; q = q->next) { | ||
| 216 | if (!strcmp(name, q->id)) { | ||
| 217 | if (!try_module_get(q->owner)) | ||
| 218 | q = NULL; | ||
| 219 | break; | ||
| 220 | } | ||
| 221 | } | ||
| 222 | |||
| 223 | return q; | ||
| 224 | } | ||
| 225 | |||
| 226 | /* Set new default qdisc to use */ | ||
| 227 | int qdisc_set_default(const char *name) | ||
| 228 | { | ||
| 229 | const struct Qdisc_ops *ops; | ||
| 230 | |||
| 231 | if (!capable(CAP_NET_ADMIN)) | ||
| 232 | return -EPERM; | ||
| 233 | |||
| 234 | write_lock(&qdisc_mod_lock); | ||
| 235 | ops = qdisc_lookup_default(name); | ||
| 236 | if (!ops) { | ||
| 237 | /* Not found, drop lock and try to load module */ | ||
| 238 | write_unlock(&qdisc_mod_lock); | ||
| 239 | request_module("sch_%s", name); | ||
| 240 | write_lock(&qdisc_mod_lock); | ||
| 241 | |||
| 242 | ops = qdisc_lookup_default(name); | ||
| 243 | } | ||
| 244 | |||
| 245 | if (ops) { | ||
| 246 | /* Set new default */ | ||
| 247 | module_put(default_qdisc_ops->owner); | ||
| 248 | default_qdisc_ops = ops; | ||
| 249 | } | ||
| 250 | write_unlock(&qdisc_mod_lock); | ||
| 251 | |||
| 252 | return ops ? 0 : -ENOENT; | ||
| 253 | } | ||
| 254 | |||
| 203 | /* We know handle. Find qdisc among all qdisc's attached to device | 255 | /* We know handle. Find qdisc among all qdisc's attached to device |
| 204 | (root qdisc, all its children, children of children etc.) | 256 | (root qdisc, all its children, children of children etc.) |
| 205 | */ | 257 | */ |
| @@ -1854,6 +1906,7 @@ static int __init pktsched_init(void) | |||
| 1854 | return err; | 1906 | return err; |
| 1855 | } | 1907 | } |
| 1856 | 1908 | ||
| 1909 | register_qdisc(&pfifo_fast_ops); | ||
| 1857 | register_qdisc(&pfifo_qdisc_ops); | 1910 | register_qdisc(&pfifo_qdisc_ops); |
| 1858 | register_qdisc(&bfifo_qdisc_ops); | 1911 | register_qdisc(&bfifo_qdisc_ops); |
| 1859 | register_qdisc(&pfifo_head_drop_qdisc_ops); | 1912 | register_qdisc(&pfifo_head_drop_qdisc_ops); |
