sch_ingress.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* net/sched/sch_ingress.c - Ingress qdisc
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version
  5. * 2 of the License, or (at your option) any later version.
  6. *
  7. * Authors: Jamal Hadi Salim 1999
  8. */
  9. #include <linux/module.h>
  10. #include <linux/types.h>
  11. #include <linux/list.h>
  12. #include <linux/skbuff.h>
  13. #include <linux/rtnetlink.h>
  14. #include <net/netlink.h>
  15. #include <net/pkt_sched.h>
  16. static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
  17. {
  18. return NULL;
  19. }
  20. static unsigned long ingress_get(struct Qdisc *sch, u32 classid)
  21. {
  22. return TC_H_MIN(classid) + 1;
  23. }
  24. static unsigned long ingress_bind_filter(struct Qdisc *sch,
  25. unsigned long parent, u32 classid)
  26. {
  27. return ingress_get(sch, classid);
  28. }
  29. static void ingress_put(struct Qdisc *sch, unsigned long cl)
  30. {
  31. }
  32. static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker)
  33. {
  34. }
  35. static struct tcf_proto __rcu **ingress_find_tcf(struct Qdisc *sch,
  36. unsigned long cl)
  37. {
  38. struct net_device *dev = qdisc_dev(sch);
  39. return &dev->ingress_cl_list;
  40. }
  41. static int ingress_init(struct Qdisc *sch, struct nlattr *opt)
  42. {
  43. net_inc_ingress_queue();
  44. sch->flags |= TCQ_F_CPUSTATS;
  45. return 0;
  46. }
  47. static void ingress_destroy(struct Qdisc *sch)
  48. {
  49. struct net_device *dev = qdisc_dev(sch);
  50. tcf_destroy_chain(&dev->ingress_cl_list);
  51. net_dec_ingress_queue();
  52. }
  53. static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb)
  54. {
  55. struct nlattr *nest;
  56. nest = nla_nest_start(skb, TCA_OPTIONS);
  57. if (nest == NULL)
  58. goto nla_put_failure;
  59. return nla_nest_end(skb, nest);
  60. nla_put_failure:
  61. nla_nest_cancel(skb, nest);
  62. return -1;
  63. }
  64. static const struct Qdisc_class_ops ingress_class_ops = {
  65. .leaf = ingress_leaf,
  66. .get = ingress_get,
  67. .put = ingress_put,
  68. .walk = ingress_walk,
  69. .tcf_chain = ingress_find_tcf,
  70. .bind_tcf = ingress_bind_filter,
  71. .unbind_tcf = ingress_put,
  72. };
  73. static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
  74. .cl_ops = &ingress_class_ops,
  75. .id = "ingress",
  76. .init = ingress_init,
  77. .destroy = ingress_destroy,
  78. .dump = ingress_dump,
  79. .owner = THIS_MODULE,
  80. };
  81. static int __init ingress_module_init(void)
  82. {
  83. return register_qdisc(&ingress_qdisc_ops);
  84. }
  85. static void __exit ingress_module_exit(void)
  86. {
  87. unregister_qdisc(&ingress_qdisc_ops);
  88. }
  89. module_init(ingress_module_init);
  90. module_exit(ingress_module_exit);
  91. MODULE_LICENSE("GPL");