Commit | Line | Data |
---|---|---|
10297b99 | 1 | /* net/sched/sch_ingress.c - Ingress qdisc |
1da177e4 LT |
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 | ||
1da177e4 LT |
10 | #include <linux/module.h> |
11 | #include <linux/types.h> | |
0ba48053 | 12 | #include <linux/list.h> |
1da177e4 | 13 | #include <linux/skbuff.h> |
1da177e4 | 14 | #include <linux/rtnetlink.h> |
d2788d34 | 15 | |
dc5fc579 | 16 | #include <net/netlink.h> |
1da177e4 | 17 | #include <net/pkt_sched.h> |
1da177e4 | 18 | |
1da177e4 LT |
19 | static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg) |
20 | { | |
21 | return NULL; | |
22 | } | |
23 | ||
58f4df42 | 24 | static unsigned long ingress_get(struct Qdisc *sch, u32 classid) |
1da177e4 | 25 | { |
1da177e4 LT |
26 | return TC_H_MIN(classid) + 1; |
27 | } | |
28 | ||
1da177e4 | 29 | static unsigned long ingress_bind_filter(struct Qdisc *sch, |
58f4df42 | 30 | unsigned long parent, u32 classid) |
1da177e4 LT |
31 | { |
32 | return ingress_get(sch, classid); | |
33 | } | |
34 | ||
1da177e4 LT |
35 | static void ingress_put(struct Qdisc *sch, unsigned long cl) |
36 | { | |
37 | } | |
38 | ||
58f4df42 | 39 | static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker) |
1da177e4 | 40 | { |
1da177e4 LT |
41 | } |
42 | ||
25d8c0d5 JF |
43 | static struct tcf_proto __rcu **ingress_find_tcf(struct Qdisc *sch, |
44 | unsigned long cl) | |
1da177e4 | 45 | { |
d2788d34 | 46 | struct net_device *dev = qdisc_dev(sch); |
1da177e4 | 47 | |
d2788d34 | 48 | return &dev->ingress_cl_list; |
1da177e4 LT |
49 | } |
50 | ||
4577139b DB |
51 | static int ingress_init(struct Qdisc *sch, struct nlattr *opt) |
52 | { | |
53 | net_inc_ingress_queue(); | |
087c1a60 | 54 | sch->flags |= TCQ_F_CPUSTATS; |
4577139b DB |
55 | |
56 | return 0; | |
57 | } | |
58 | ||
1da177e4 LT |
59 | static void ingress_destroy(struct Qdisc *sch) |
60 | { | |
d2788d34 | 61 | struct net_device *dev = qdisc_dev(sch); |
1da177e4 | 62 | |
d2788d34 | 63 | tcf_destroy_chain(&dev->ingress_cl_list); |
4577139b | 64 | net_dec_ingress_queue(); |
1da177e4 LT |
65 | } |
66 | ||
1da177e4 LT |
67 | static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb) |
68 | { | |
4b3550ef | 69 | struct nlattr *nest; |
1da177e4 | 70 | |
4b3550ef PM |
71 | nest = nla_nest_start(skb, TCA_OPTIONS); |
72 | if (nest == NULL) | |
73 | goto nla_put_failure; | |
d2788d34 | 74 | |
d59b7d80 | 75 | return nla_nest_end(skb, nest); |
1da177e4 | 76 | |
1e90474c | 77 | nla_put_failure: |
4b3550ef | 78 | nla_nest_cancel(skb, nest); |
1da177e4 LT |
79 | return -1; |
80 | } | |
81 | ||
20fea08b | 82 | static const struct Qdisc_class_ops ingress_class_ops = { |
1da177e4 LT |
83 | .leaf = ingress_leaf, |
84 | .get = ingress_get, | |
85 | .put = ingress_put, | |
1da177e4 LT |
86 | .walk = ingress_walk, |
87 | .tcf_chain = ingress_find_tcf, | |
88 | .bind_tcf = ingress_bind_filter, | |
89 | .unbind_tcf = ingress_put, | |
1da177e4 LT |
90 | }; |
91 | ||
20fea08b | 92 | static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { |
1da177e4 LT |
93 | .cl_ops = &ingress_class_ops, |
94 | .id = "ingress", | |
4577139b | 95 | .init = ingress_init, |
1da177e4 | 96 | .destroy = ingress_destroy, |
1da177e4 LT |
97 | .dump = ingress_dump, |
98 | .owner = THIS_MODULE, | |
99 | }; | |
100 | ||
101 | static int __init ingress_module_init(void) | |
102 | { | |
89168764 | 103 | return register_qdisc(&ingress_qdisc_ops); |
1da177e4 | 104 | } |
58f4df42 | 105 | |
10297b99 | 106 | static void __exit ingress_module_exit(void) |
1da177e4 LT |
107 | { |
108 | unregister_qdisc(&ingress_qdisc_ops); | |
1da177e4 | 109 | } |
58f4df42 | 110 | |
d2788d34 DB |
111 | module_init(ingress_module_init); |
112 | module_exit(ingress_module_exit); | |
113 | ||
1da177e4 | 114 | MODULE_LICENSE("GPL"); |