be2net: Fix memset() arg ordering.
[linux-2.6/mini2440.git] / net / sched / sch_ingress.c
bloba9e646bdb605138ce8d5ec1435c8acb36c1c4667
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.
7 * Authors: Jamal Hadi Salim 1999
8 */
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/list.h>
13 #include <linux/skbuff.h>
14 #include <linux/rtnetlink.h>
15 #include <net/netlink.h>
16 #include <net/pkt_sched.h>
19 struct ingress_qdisc_data {
20 struct tcf_proto *filter_list;
23 /* ------------------------- Class/flow operations ------------------------- */
25 static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
27 return NULL;
30 static unsigned long ingress_get(struct Qdisc *sch, u32 classid)
32 return TC_H_MIN(classid) + 1;
35 static unsigned long ingress_bind_filter(struct Qdisc *sch,
36 unsigned long parent, u32 classid)
38 return ingress_get(sch, classid);
41 static void ingress_put(struct Qdisc *sch, unsigned long cl)
45 static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker)
47 return;
50 static struct tcf_proto **ingress_find_tcf(struct Qdisc *sch, unsigned long cl)
52 struct ingress_qdisc_data *p = qdisc_priv(sch);
54 return &p->filter_list;
57 /* --------------------------- Qdisc operations ---------------------------- */
59 static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
61 struct ingress_qdisc_data *p = qdisc_priv(sch);
62 struct tcf_result res;
63 int result;
65 result = tc_classify(skb, p->filter_list, &res);
67 sch->bstats.packets++;
68 sch->bstats.bytes += qdisc_pkt_len(skb);
69 switch (result) {
70 case TC_ACT_SHOT:
71 result = TC_ACT_SHOT;
72 sch->qstats.drops++;
73 break;
74 case TC_ACT_STOLEN:
75 case TC_ACT_QUEUED:
76 result = TC_ACT_STOLEN;
77 break;
78 case TC_ACT_RECLASSIFY:
79 case TC_ACT_OK:
80 skb->tc_index = TC_H_MIN(res.classid);
81 default:
82 result = TC_ACT_OK;
83 break;
86 return result;
89 /* ------------------------------------------------------------- */
91 static void ingress_destroy(struct Qdisc *sch)
93 struct ingress_qdisc_data *p = qdisc_priv(sch);
95 tcf_destroy_chain(&p->filter_list);
98 static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb)
100 struct nlattr *nest;
102 nest = nla_nest_start(skb, TCA_OPTIONS);
103 if (nest == NULL)
104 goto nla_put_failure;
105 nla_nest_end(skb, nest);
106 return skb->len;
108 nla_put_failure:
109 nla_nest_cancel(skb, nest);
110 return -1;
113 static const struct Qdisc_class_ops ingress_class_ops = {
114 .leaf = ingress_leaf,
115 .get = ingress_get,
116 .put = ingress_put,
117 .walk = ingress_walk,
118 .tcf_chain = ingress_find_tcf,
119 .bind_tcf = ingress_bind_filter,
120 .unbind_tcf = ingress_put,
123 static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
124 .cl_ops = &ingress_class_ops,
125 .id = "ingress",
126 .priv_size = sizeof(struct ingress_qdisc_data),
127 .enqueue = ingress_enqueue,
128 .destroy = ingress_destroy,
129 .dump = ingress_dump,
130 .owner = THIS_MODULE,
133 static int __init ingress_module_init(void)
135 return register_qdisc(&ingress_qdisc_ops);
138 static void __exit ingress_module_exit(void)
140 unregister_qdisc(&ingress_qdisc_ops);
143 module_init(ingress_module_init)
144 module_exit(ingress_module_exit)
145 MODULE_LICENSE("GPL");