1 /* net/sched/sch_ingress.c - Ingress and clsact qdisc
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version
6 * 2 of the License, or (at your option) any later version.
8 * Authors: Jamal Hadi Salim 1999
11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/list.h>
14 #include <linux/skbuff.h>
15 #include <linux/rtnetlink.h>
17 #include <net/netlink.h>
18 #include <net/pkt_sched.h>
20 static struct Qdisc
*ingress_leaf(struct Qdisc
*sch
, unsigned long arg
)
25 static unsigned long ingress_get(struct Qdisc
*sch
, u32 classid
)
27 return TC_H_MIN(classid
) + 1;
30 static unsigned long ingress_bind_filter(struct Qdisc
*sch
,
31 unsigned long parent
, u32 classid
)
33 return ingress_get(sch
, classid
);
36 static void ingress_put(struct Qdisc
*sch
, unsigned long cl
)
40 static void ingress_walk(struct Qdisc
*sch
, struct qdisc_walker
*walker
)
44 static struct tcf_proto __rcu
**ingress_find_tcf(struct Qdisc
*sch
,
47 struct net_device
*dev
= qdisc_dev(sch
);
49 return &dev
->ingress_cl_list
;
52 static int ingress_init(struct Qdisc
*sch
, struct nlattr
*opt
)
54 net_inc_ingress_queue();
55 sch
->flags
|= TCQ_F_CPUSTATS
;
60 static void ingress_destroy(struct Qdisc
*sch
)
62 struct net_device
*dev
= qdisc_dev(sch
);
64 tcf_destroy_chain(&dev
->ingress_cl_list
);
65 net_dec_ingress_queue();
68 static int ingress_dump(struct Qdisc
*sch
, struct sk_buff
*skb
)
72 nest
= nla_nest_start(skb
, TCA_OPTIONS
);
76 return nla_nest_end(skb
, nest
);
79 nla_nest_cancel(skb
, nest
);
83 static const struct Qdisc_class_ops ingress_class_ops
= {
88 .tcf_chain
= ingress_find_tcf
,
89 .bind_tcf
= ingress_bind_filter
,
90 .unbind_tcf
= ingress_put
,
93 static struct Qdisc_ops ingress_qdisc_ops __read_mostly
= {
94 .cl_ops
= &ingress_class_ops
,
97 .destroy
= ingress_destroy
,
102 static unsigned long clsact_get(struct Qdisc
*sch
, u32 classid
)
104 switch (TC_H_MIN(classid
)) {
105 case TC_H_MIN(TC_H_MIN_INGRESS
):
106 case TC_H_MIN(TC_H_MIN_EGRESS
):
107 return TC_H_MIN(classid
);
113 static unsigned long clsact_bind_filter(struct Qdisc
*sch
,
114 unsigned long parent
, u32 classid
)
116 return clsact_get(sch
, classid
);
119 static struct tcf_proto __rcu
**clsact_find_tcf(struct Qdisc
*sch
,
122 struct net_device
*dev
= qdisc_dev(sch
);
125 case TC_H_MIN(TC_H_MIN_INGRESS
):
126 return &dev
->ingress_cl_list
;
127 case TC_H_MIN(TC_H_MIN_EGRESS
):
128 return &dev
->egress_cl_list
;
134 static int clsact_init(struct Qdisc
*sch
, struct nlattr
*opt
)
136 net_inc_ingress_queue();
137 net_inc_egress_queue();
139 sch
->flags
|= TCQ_F_CPUSTATS
;
144 static void clsact_destroy(struct Qdisc
*sch
)
146 struct net_device
*dev
= qdisc_dev(sch
);
148 tcf_destroy_chain(&dev
->ingress_cl_list
);
149 tcf_destroy_chain(&dev
->egress_cl_list
);
151 net_dec_ingress_queue();
152 net_dec_egress_queue();
155 static const struct Qdisc_class_ops clsact_class_ops
= {
156 .leaf
= ingress_leaf
,
159 .walk
= ingress_walk
,
160 .tcf_chain
= clsact_find_tcf
,
161 .bind_tcf
= clsact_bind_filter
,
162 .unbind_tcf
= ingress_put
,
165 static struct Qdisc_ops clsact_qdisc_ops __read_mostly
= {
166 .cl_ops
= &clsact_class_ops
,
169 .destroy
= clsact_destroy
,
170 .dump
= ingress_dump
,
171 .owner
= THIS_MODULE
,
174 static int __init
ingress_module_init(void)
178 ret
= register_qdisc(&ingress_qdisc_ops
);
180 ret
= register_qdisc(&clsact_qdisc_ops
);
182 unregister_qdisc(&ingress_qdisc_ops
);
188 static void __exit
ingress_module_exit(void)
190 unregister_qdisc(&ingress_qdisc_ops
);
191 unregister_qdisc(&clsact_qdisc_ops
);
194 module_init(ingress_module_init
);
195 module_exit(ingress_module_exit
);
197 MODULE_ALIAS("sch_clsact");
198 MODULE_LICENSE("GPL");