diff options
Diffstat (limited to 'net/sched')
| -rw-r--r-- | net/sched/Kconfig | 37 | ||||
| -rw-r--r-- | net/sched/Makefile | 2 | ||||
| -rw-r--r-- | net/sched/em_meta.c | 6 | ||||
| -rw-r--r-- | net/sched/sch_api.c | 63 | ||||
| -rw-r--r-- | net/sched/sch_blackhole.c | 54 | ||||
| -rw-r--r-- | net/sched/sch_generic.c | 35 | ||||
| -rw-r--r-- | net/sched/sch_red.c | 2 |
7 files changed, 143 insertions, 56 deletions
diff --git a/net/sched/Kconfig b/net/sched/Kconfig index 7bac249258e3..59d3e71f8b85 100644 --- a/net/sched/Kconfig +++ b/net/sched/Kconfig | |||
| @@ -1,6 +1,43 @@ | |||
| 1 | # | 1 | # |
| 2 | # Traffic control configuration. | 2 | # Traffic control configuration. |
| 3 | # | 3 | # |
| 4 | |||
| 5 | menuconfig NET_SCHED | ||
| 6 | bool "QoS and/or fair queueing" | ||
| 7 | ---help--- | ||
| 8 | When the kernel has several packets to send out over a network | ||
| 9 | device, it has to decide which ones to send first, which ones to | ||
| 10 | delay, and which ones to drop. This is the job of the packet | ||
| 11 | scheduler, and several different algorithms for how to do this | ||
| 12 | "fairly" have been proposed. | ||
| 13 | |||
| 14 | If you say N here, you will get the standard packet scheduler, which | ||
| 15 | is a FIFO (first come, first served). If you say Y here, you will be | ||
| 16 | able to choose from among several alternative algorithms which can | ||
| 17 | then be attached to different network devices. This is useful for | ||
| 18 | example if some of your network devices are real time devices that | ||
| 19 | need a certain minimum data flow rate, or if you need to limit the | ||
| 20 | maximum data flow rate for traffic which matches specified criteria. | ||
| 21 | This code is considered to be experimental. | ||
| 22 | |||
| 23 | To administer these schedulers, you'll need the user-level utilities | ||
| 24 | from the package iproute2+tc at <ftp://ftp.tux.org/pub/net/ip-routing/>. | ||
| 25 | That package also contains some documentation; for more, check out | ||
| 26 | <http://snafu.freedom.org/linux2.2/iproute-notes.html>. | ||
| 27 | |||
| 28 | This Quality of Service (QoS) support will enable you to use | ||
| 29 | Differentiated Services (diffserv) and Resource Reservation Protocol | ||
| 30 | (RSVP) on your Linux router if you also say Y to "QoS support", | ||
| 31 | "Packet classifier API" and to some classifiers below. Documentation | ||
| 32 | and software is at <http://diffserv.sourceforge.net/>. | ||
| 33 | |||
| 34 | If you say Y here and to "/proc file system" below, you will be able | ||
| 35 | to read status information about packet schedulers from the file | ||
| 36 | /proc/net/psched. | ||
| 37 | |||
| 38 | The available schedulers are listed in the following questions; you | ||
| 39 | can say Y to as many as you like. If unsure, say N now. | ||
| 40 | |||
| 4 | choice | 41 | choice |
| 5 | prompt "Packet scheduler clock source" | 42 | prompt "Packet scheduler clock source" |
| 6 | depends on NET_SCHED | 43 | depends on NET_SCHED |
diff --git a/net/sched/Makefile b/net/sched/Makefile index 8f58cecd6266..e48d0d456b3e 100644 --- a/net/sched/Makefile +++ b/net/sched/Makefile | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | obj-y := sch_generic.o | 5 | obj-y := sch_generic.o |
| 6 | 6 | ||
| 7 | obj-$(CONFIG_NET_SCHED) += sch_api.o sch_fifo.o | 7 | obj-$(CONFIG_NET_SCHED) += sch_api.o sch_fifo.o sch_blackhole.o |
| 8 | obj-$(CONFIG_NET_CLS) += cls_api.o | 8 | obj-$(CONFIG_NET_CLS) += cls_api.o |
| 9 | obj-$(CONFIG_NET_CLS_ACT) += act_api.o | 9 | obj-$(CONFIG_NET_CLS_ACT) += act_api.o |
| 10 | obj-$(CONFIG_NET_ACT_POLICE) += police.o | 10 | obj-$(CONFIG_NET_ACT_POLICE) += police.o |
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index 48bb23c2a35a..53d98f8d3d80 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c | |||
| @@ -205,11 +205,6 @@ META_COLLECTOR(int_protocol) | |||
| 205 | dst->value = skb->protocol; | 205 | dst->value = skb->protocol; |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | META_COLLECTOR(int_security) | ||
| 209 | { | ||
| 210 | dst->value = skb->security; | ||
| 211 | } | ||
| 212 | |||
| 213 | META_COLLECTOR(int_pkttype) | 208 | META_COLLECTOR(int_pkttype) |
| 214 | { | 209 | { |
| 215 | dst->value = skb->pkt_type; | 210 | dst->value = skb->pkt_type; |
| @@ -524,7 +519,6 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { | |||
| 524 | [META_ID(REALDEV)] = META_FUNC(int_realdev), | 519 | [META_ID(REALDEV)] = META_FUNC(int_realdev), |
| 525 | [META_ID(PRIORITY)] = META_FUNC(int_priority), | 520 | [META_ID(PRIORITY)] = META_FUNC(int_priority), |
| 526 | [META_ID(PROTOCOL)] = META_FUNC(int_protocol), | 521 | [META_ID(PROTOCOL)] = META_FUNC(int_protocol), |
| 527 | [META_ID(SECURITY)] = META_FUNC(int_security), | ||
| 528 | [META_ID(PKTTYPE)] = META_FUNC(int_pkttype), | 522 | [META_ID(PKTTYPE)] = META_FUNC(int_pkttype), |
| 529 | [META_ID(PKTLEN)] = META_FUNC(int_pktlen), | 523 | [META_ID(PKTLEN)] = META_FUNC(int_pktlen), |
| 530 | [META_ID(DATALEN)] = META_FUNC(int_datalen), | 524 | [META_ID(DATALEN)] = META_FUNC(int_datalen), |
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 05e6e0a799da..b9a069af4a02 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
| @@ -399,10 +399,8 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp) | |||
| 399 | { | 399 | { |
| 400 | int err; | 400 | int err; |
| 401 | struct rtattr *kind = tca[TCA_KIND-1]; | 401 | struct rtattr *kind = tca[TCA_KIND-1]; |
| 402 | void *p = NULL; | ||
| 403 | struct Qdisc *sch; | 402 | struct Qdisc *sch; |
| 404 | struct Qdisc_ops *ops; | 403 | struct Qdisc_ops *ops; |
| 405 | int size; | ||
| 406 | 404 | ||
| 407 | ops = qdisc_lookup_ops(kind); | 405 | ops = qdisc_lookup_ops(kind); |
| 408 | #ifdef CONFIG_KMOD | 406 | #ifdef CONFIG_KMOD |
| @@ -437,64 +435,55 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp) | |||
| 437 | if (ops == NULL) | 435 | if (ops == NULL) |
| 438 | goto err_out; | 436 | goto err_out; |
| 439 | 437 | ||
| 440 | /* ensure that the Qdisc and the private data are 32-byte aligned */ | 438 | sch = qdisc_alloc(dev, ops); |
| 441 | size = ((sizeof(*sch) + QDISC_ALIGN_CONST) & ~QDISC_ALIGN_CONST); | 439 | if (IS_ERR(sch)) { |
| 442 | size += ops->priv_size + QDISC_ALIGN_CONST; | 440 | err = PTR_ERR(sch); |
| 443 | |||
| 444 | p = kmalloc(size, GFP_KERNEL); | ||
| 445 | err = -ENOBUFS; | ||
| 446 | if (!p) | ||
| 447 | goto err_out2; | 441 | goto err_out2; |
| 448 | memset(p, 0, size); | 442 | } |
| 449 | sch = (struct Qdisc *)(((unsigned long)p + QDISC_ALIGN_CONST) | ||
| 450 | & ~QDISC_ALIGN_CONST); | ||
| 451 | sch->padded = (char *)sch - (char *)p; | ||
| 452 | |||
| 453 | INIT_LIST_HEAD(&sch->list); | ||
| 454 | skb_queue_head_init(&sch->q); | ||
| 455 | 443 | ||
| 456 | if (handle == TC_H_INGRESS) | 444 | if (handle == TC_H_INGRESS) { |
| 457 | sch->flags |= TCQ_F_INGRESS; | 445 | sch->flags |= TCQ_F_INGRESS; |
| 458 | 446 | handle = TC_H_MAKE(TC_H_INGRESS, 0); | |
| 459 | sch->ops = ops; | 447 | } else if (handle == 0) { |
| 460 | sch->enqueue = ops->enqueue; | ||
| 461 | sch->dequeue = ops->dequeue; | ||
| 462 | sch->dev = dev; | ||
| 463 | dev_hold(dev); | ||
| 464 | atomic_set(&sch->refcnt, 1); | ||
| 465 | sch->stats_lock = &dev->queue_lock; | ||
| 466 | if (handle == 0) { | ||
| 467 | handle = qdisc_alloc_handle(dev); | 448 | handle = qdisc_alloc_handle(dev); |
| 468 | err = -ENOMEM; | 449 | err = -ENOMEM; |
| 469 | if (handle == 0) | 450 | if (handle == 0) |
| 470 | goto err_out3; | 451 | goto err_out3; |
| 471 | } | 452 | } |
| 472 | 453 | ||
| 473 | if (handle == TC_H_INGRESS) | 454 | sch->handle = handle; |
| 474 | sch->handle =TC_H_MAKE(TC_H_INGRESS, 0); | ||
| 475 | else | ||
| 476 | sch->handle = handle; | ||
| 477 | 455 | ||
| 478 | if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS-1])) == 0) { | 456 | if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS-1])) == 0) { |
| 457 | #ifdef CONFIG_NET_ESTIMATOR | ||
| 458 | if (tca[TCA_RATE-1]) { | ||
| 459 | err = gen_new_estimator(&sch->bstats, &sch->rate_est, | ||
| 460 | sch->stats_lock, | ||
| 461 | tca[TCA_RATE-1]); | ||
| 462 | if (err) { | ||
| 463 | /* | ||
| 464 | * Any broken qdiscs that would require | ||
| 465 | * a ops->reset() here? The qdisc was never | ||
| 466 | * in action so it shouldn't be necessary. | ||
| 467 | */ | ||
| 468 | if (ops->destroy) | ||
| 469 | ops->destroy(sch); | ||
| 470 | goto err_out3; | ||
| 471 | } | ||
| 472 | } | ||
| 473 | #endif | ||
| 479 | qdisc_lock_tree(dev); | 474 | qdisc_lock_tree(dev); |
| 480 | list_add_tail(&sch->list, &dev->qdisc_list); | 475 | list_add_tail(&sch->list, &dev->qdisc_list); |
| 481 | qdisc_unlock_tree(dev); | 476 | qdisc_unlock_tree(dev); |
| 482 | 477 | ||
| 483 | #ifdef CONFIG_NET_ESTIMATOR | ||
| 484 | if (tca[TCA_RATE-1]) | ||
| 485 | gen_new_estimator(&sch->bstats, &sch->rate_est, | ||
| 486 | sch->stats_lock, tca[TCA_RATE-1]); | ||
| 487 | #endif | ||
| 488 | return sch; | 478 | return sch; |
| 489 | } | 479 | } |
| 490 | err_out3: | 480 | err_out3: |
| 491 | dev_put(dev); | 481 | dev_put(dev); |
| 482 | kfree((char *) sch - sch->padded); | ||
| 492 | err_out2: | 483 | err_out2: |
| 493 | module_put(ops->owner); | 484 | module_put(ops->owner); |
| 494 | err_out: | 485 | err_out: |
| 495 | *errp = err; | 486 | *errp = err; |
| 496 | if (p) | ||
| 497 | kfree(p); | ||
| 498 | return NULL; | 487 | return NULL; |
| 499 | } | 488 | } |
| 500 | 489 | ||
diff --git a/net/sched/sch_blackhole.c b/net/sched/sch_blackhole.c new file mode 100644 index 000000000000..81f0b8346d17 --- /dev/null +++ b/net/sched/sch_blackhole.c | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* | ||
| 2 | * net/sched/sch_blackhole.c Black hole queue | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU General Public License | ||
| 6 | * as published by the Free Software Foundation; either version | ||
| 7 | * 2 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * Authors: Thomas Graf <tgraf@suug.ch> | ||
| 10 | * | ||
| 11 | * Note: Quantum tunneling is not supported. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/config.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/types.h> | ||
| 17 | #include <linux/kernel.h> | ||
| 18 | #include <linux/netdevice.h> | ||
| 19 | #include <linux/skbuff.h> | ||
| 20 | #include <net/pkt_sched.h> | ||
| 21 | |||
| 22 | static int blackhole_enqueue(struct sk_buff *skb, struct Qdisc *sch) | ||
| 23 | { | ||
| 24 | qdisc_drop(skb, sch); | ||
| 25 | return NET_XMIT_SUCCESS; | ||
| 26 | } | ||
| 27 | |||
| 28 | static struct sk_buff *blackhole_dequeue(struct Qdisc *sch) | ||
| 29 | { | ||
| 30 | return NULL; | ||
| 31 | } | ||
| 32 | |||
| 33 | static struct Qdisc_ops blackhole_qdisc_ops = { | ||
| 34 | .id = "blackhole", | ||
| 35 | .priv_size = 0, | ||
| 36 | .enqueue = blackhole_enqueue, | ||
| 37 | .dequeue = blackhole_dequeue, | ||
| 38 | .owner = THIS_MODULE, | ||
| 39 | }; | ||
| 40 | |||
| 41 | static int __init blackhole_module_init(void) | ||
| 42 | { | ||
| 43 | return register_qdisc(&blackhole_qdisc_ops); | ||
| 44 | } | ||
| 45 | |||
| 46 | static void __exit blackhole_module_exit(void) | ||
| 47 | { | ||
| 48 | unregister_qdisc(&blackhole_qdisc_ops); | ||
| 49 | } | ||
| 50 | |||
| 51 | module_init(blackhole_module_init) | ||
| 52 | module_exit(blackhole_module_exit) | ||
| 53 | |||
| 54 | MODULE_LICENSE("GPL"); | ||
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 7683b34dc6a9..73e218e646ac 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c | |||
| @@ -395,24 +395,23 @@ static struct Qdisc_ops pfifo_fast_ops = { | |||
| 395 | .owner = THIS_MODULE, | 395 | .owner = THIS_MODULE, |
| 396 | }; | 396 | }; |
| 397 | 397 | ||
| 398 | struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops) | 398 | struct Qdisc *qdisc_alloc(struct net_device *dev, struct Qdisc_ops *ops) |
| 399 | { | 399 | { |
| 400 | void *p; | 400 | void *p; |
| 401 | struct Qdisc *sch; | 401 | struct Qdisc *sch; |
| 402 | int size; | 402 | unsigned int size; |
| 403 | int err = -ENOBUFS; | ||
| 403 | 404 | ||
| 404 | /* ensure that the Qdisc and the private data are 32-byte aligned */ | 405 | /* ensure that the Qdisc and the private data are 32-byte aligned */ |
| 405 | size = ((sizeof(*sch) + QDISC_ALIGN_CONST) & ~QDISC_ALIGN_CONST); | 406 | size = QDISC_ALIGN(sizeof(*sch)); |
| 406 | size += ops->priv_size + QDISC_ALIGN_CONST; | 407 | size += ops->priv_size + (QDISC_ALIGNTO - 1); |
| 407 | 408 | ||
| 408 | p = kmalloc(size, GFP_KERNEL); | 409 | p = kmalloc(size, GFP_KERNEL); |
| 409 | if (!p) | 410 | if (!p) |
| 410 | return NULL; | 411 | goto errout; |
| 411 | memset(p, 0, size); | 412 | memset(p, 0, size); |
| 412 | 413 | sch = (struct Qdisc *) QDISC_ALIGN((unsigned long) p); | |
| 413 | sch = (struct Qdisc *)(((unsigned long)p + QDISC_ALIGN_CONST) | 414 | sch->padded = (char *) sch - (char *) p; |
| 414 | & ~QDISC_ALIGN_CONST); | ||
| 415 | sch->padded = (char *)sch - (char *)p; | ||
| 416 | 415 | ||
| 417 | INIT_LIST_HEAD(&sch->list); | 416 | INIT_LIST_HEAD(&sch->list); |
| 418 | skb_queue_head_init(&sch->q); | 417 | skb_queue_head_init(&sch->q); |
| @@ -423,11 +422,24 @@ struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops) | |||
| 423 | dev_hold(dev); | 422 | dev_hold(dev); |
| 424 | sch->stats_lock = &dev->queue_lock; | 423 | sch->stats_lock = &dev->queue_lock; |
| 425 | atomic_set(&sch->refcnt, 1); | 424 | atomic_set(&sch->refcnt, 1); |
| 425 | |||
| 426 | return sch; | ||
| 427 | errout: | ||
| 428 | return ERR_PTR(-err); | ||
| 429 | } | ||
| 430 | |||
| 431 | struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops) | ||
| 432 | { | ||
| 433 | struct Qdisc *sch; | ||
| 434 | |||
| 435 | sch = qdisc_alloc(dev, ops); | ||
| 436 | if (IS_ERR(sch)) | ||
| 437 | goto errout; | ||
| 438 | |||
| 426 | if (!ops->init || ops->init(sch, NULL) == 0) | 439 | if (!ops->init || ops->init(sch, NULL) == 0) |
| 427 | return sch; | 440 | return sch; |
| 428 | 441 | ||
| 429 | dev_put(dev); | 442 | errout: |
| 430 | kfree(p); | ||
| 431 | return NULL; | 443 | return NULL; |
| 432 | } | 444 | } |
| 433 | 445 | ||
| @@ -591,6 +603,7 @@ EXPORT_SYMBOL(__netdev_watchdog_up); | |||
| 591 | EXPORT_SYMBOL(noop_qdisc); | 603 | EXPORT_SYMBOL(noop_qdisc); |
| 592 | EXPORT_SYMBOL(noop_qdisc_ops); | 604 | EXPORT_SYMBOL(noop_qdisc_ops); |
| 593 | EXPORT_SYMBOL(qdisc_create_dflt); | 605 | EXPORT_SYMBOL(qdisc_create_dflt); |
| 606 | EXPORT_SYMBOL(qdisc_alloc); | ||
| 594 | EXPORT_SYMBOL(qdisc_destroy); | 607 | EXPORT_SYMBOL(qdisc_destroy); |
| 595 | EXPORT_SYMBOL(qdisc_reset); | 608 | EXPORT_SYMBOL(qdisc_reset); |
| 596 | EXPORT_SYMBOL(qdisc_restart); | 609 | EXPORT_SYMBOL(qdisc_restart); |
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index 664d0e47374f..7845d045eec4 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c | |||
| @@ -385,7 +385,7 @@ static int red_change(struct Qdisc *sch, struct rtattr *opt) | |||
| 385 | memcpy(q->Stab, RTA_DATA(tb[TCA_RED_STAB-1]), 256); | 385 | memcpy(q->Stab, RTA_DATA(tb[TCA_RED_STAB-1]), 256); |
| 386 | 386 | ||
| 387 | q->qcount = -1; | 387 | q->qcount = -1; |
| 388 | if (skb_queue_len(&sch->q) == 0) | 388 | if (skb_queue_empty(&sch->q)) |
| 389 | PSCHED_SET_PASTPERFECT(q->qidlestart); | 389 | PSCHED_SET_PASTPERFECT(q->qidlestart); |
| 390 | sch_tree_unlock(sch); | 390 | sch_tree_unlock(sch); |
| 391 | return 0; | 391 | return 0; |
