Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 2 | /* net/sched/sch_ingress.c - Ingress and clsact qdisc |
| 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Authors: Jamal Hadi Salim 1999 |
| 5 | */ |
| 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/module.h> |
| 8 | #include <linux/types.h> |
Patrick McHardy | 0ba4805 | 2007-07-02 22:49:07 -0700 | [diff] [blame] | 9 | #include <linux/list.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/skbuff.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/rtnetlink.h> |
Daniel Borkmann | d2788d3 | 2015-05-09 22:51:32 +0200 | [diff] [blame] | 12 | |
Arnaldo Carvalho de Melo | dc5fc57 | 2007-03-25 23:06:12 -0700 | [diff] [blame] | 13 | #include <net/netlink.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <net/pkt_sched.h> |
Jiri Pirko | cf1facd | 2017-02-09 14:38:56 +0100 | [diff] [blame] | 15 | #include <net/pkt_cls.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 17 | struct ingress_sched_data { |
| 18 | struct tcf_block *block; |
Jiri Pirko | 6e40cf2 | 2017-10-19 15:50:30 +0200 | [diff] [blame] | 19 | struct tcf_block_ext_info block_info; |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 20 | struct mini_Qdisc_pair miniqp; |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 21 | }; |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg) |
| 24 | { |
| 25 | return NULL; |
| 26 | } |
| 27 | |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 28 | static unsigned long ingress_find(struct Qdisc *sch, u32 classid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | return TC_H_MIN(classid) + 1; |
| 31 | } |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | static unsigned long ingress_bind_filter(struct Qdisc *sch, |
Patrick McHardy | 58f4df4 | 2008-01-21 00:11:01 -0800 | [diff] [blame] | 34 | unsigned long parent, u32 classid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 36 | return ingress_find(sch, classid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 39 | static void ingress_unbind_filter(struct Qdisc *sch, unsigned long cl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | { |
| 41 | } |
| 42 | |
Patrick McHardy | 58f4df4 | 2008-01-21 00:11:01 -0800 | [diff] [blame] | 43 | static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Alexander Aring | cbaacc4 | 2017-12-20 12:35:16 -0500 | [diff] [blame] | 47 | static struct tcf_block *ingress_tcf_block(struct Qdisc *sch, unsigned long cl, |
| 48 | struct netlink_ext_ack *extack) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | { |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 50 | struct ingress_sched_data *q = qdisc_priv(sch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 52 | return q->block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Jiri Pirko | c7eb7d7 | 2017-11-03 11:46:24 +0100 | [diff] [blame] | 55 | static void clsact_chain_head_change(struct tcf_proto *tp_head, void *priv) |
| 56 | { |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 57 | struct mini_Qdisc_pair *miniqp = priv; |
Jiri Pirko | c7eb7d7 | 2017-11-03 11:46:24 +0100 | [diff] [blame] | 58 | |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 59 | mini_qdisc_pair_swap(miniqp, tp_head); |
Jiri Pirko | 51ab299 | 2018-01-17 11:46:53 +0100 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | static void ingress_ingress_block_set(struct Qdisc *sch, u32 block_index) |
| 63 | { |
| 64 | struct ingress_sched_data *q = qdisc_priv(sch); |
| 65 | |
| 66 | q->block_info.block_index = block_index; |
| 67 | } |
| 68 | |
| 69 | static u32 ingress_ingress_block_get(struct Qdisc *sch) |
| 70 | { |
| 71 | struct ingress_sched_data *q = qdisc_priv(sch); |
| 72 | |
| 73 | return q->block_info.block_index; |
Jiri Pirko | c7eb7d7 | 2017-11-03 11:46:24 +0100 | [diff] [blame] | 74 | } |
| 75 | |
Alexander Aring | e63d7df | 2017-12-20 12:35:13 -0500 | [diff] [blame] | 76 | static int ingress_init(struct Qdisc *sch, struct nlattr *opt, |
| 77 | struct netlink_ext_ack *extack) |
Daniel Borkmann | 4577139 | 2015-04-10 23:07:54 +0200 | [diff] [blame] | 78 | { |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 79 | struct ingress_sched_data *q = qdisc_priv(sch); |
| 80 | struct net_device *dev = qdisc_dev(sch); |
Paul Blakey | 7d17c54 | 2020-02-16 12:01:22 +0200 | [diff] [blame] | 81 | int err; |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 82 | |
Jiri Pirko | b59e697 | 2017-12-15 12:40:13 +0100 | [diff] [blame] | 83 | net_inc_ingress_queue(); |
| 84 | |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 85 | mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress); |
| 86 | |
Pablo Neira Ayuso | 32f8c40 | 2019-07-09 22:55:41 +0200 | [diff] [blame] | 87 | q->block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS; |
Jiri Pirko | c7eb7d7 | 2017-11-03 11:46:24 +0100 | [diff] [blame] | 88 | q->block_info.chain_head_change = clsact_chain_head_change; |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 89 | q->block_info.chain_head_change_priv = &q->miniqp; |
Jiri Pirko | 6e40cf2 | 2017-10-19 15:50:30 +0200 | [diff] [blame] | 90 | |
Paul Blakey | 7d17c54 | 2020-02-16 12:01:22 +0200 | [diff] [blame] | 91 | err = tcf_block_get_ext(&q->block, sch, &q->block_info, extack); |
| 92 | if (err) |
| 93 | return err; |
| 94 | |
| 95 | mini_qdisc_pair_block_init(&q->miniqp, q->block); |
| 96 | |
| 97 | return 0; |
Daniel Borkmann | 4577139 | 2015-04-10 23:07:54 +0200 | [diff] [blame] | 98 | } |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | static void ingress_destroy(struct Qdisc *sch) |
| 101 | { |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 102 | struct ingress_sched_data *q = qdisc_priv(sch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
Jiri Pirko | c7eb7d7 | 2017-11-03 11:46:24 +0100 | [diff] [blame] | 104 | tcf_block_put_ext(q->block, sch, &q->block_info); |
Daniel Borkmann | 4577139 | 2015-04-10 23:07:54 +0200 | [diff] [blame] | 105 | net_dec_ingress_queue(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb) |
| 109 | { |
Patrick McHardy | 4b3550ef | 2008-01-23 20:34:11 -0800 | [diff] [blame] | 110 | struct nlattr *nest; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
Michal Kubecek | ae0be8d | 2019-04-26 11:13:06 +0200 | [diff] [blame] | 112 | nest = nla_nest_start_noflag(skb, TCA_OPTIONS); |
Patrick McHardy | 4b3550ef | 2008-01-23 20:34:11 -0800 | [diff] [blame] | 113 | if (nest == NULL) |
| 114 | goto nla_put_failure; |
Daniel Borkmann | d2788d3 | 2015-05-09 22:51:32 +0200 | [diff] [blame] | 115 | |
Yang Yingliang | d59b7d8 | 2014-03-12 10:20:32 +0800 | [diff] [blame] | 116 | return nla_nest_end(skb, nest); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Patrick McHardy | 1e90474 | 2008-01-22 22:11:17 -0800 | [diff] [blame] | 118 | nla_put_failure: |
Patrick McHardy | 4b3550ef | 2008-01-23 20:34:11 -0800 | [diff] [blame] | 119 | nla_nest_cancel(skb, nest); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | return -1; |
| 121 | } |
| 122 | |
Eric Dumazet | 20fea08 | 2007-11-14 01:44:41 -0800 | [diff] [blame] | 123 | static const struct Qdisc_class_ops ingress_class_ops = { |
Vlad Buslov | 7a096d5 | 2019-06-12 10:14:35 +0300 | [diff] [blame] | 124 | .flags = QDISC_CLASS_OPS_DOIT_UNLOCKED, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | .leaf = ingress_leaf, |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 126 | .find = ingress_find, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | .walk = ingress_walk, |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 128 | .tcf_block = ingress_tcf_block, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | .bind_tcf = ingress_bind_filter, |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 130 | .unbind_tcf = ingress_unbind_filter, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
Eric Dumazet | 20fea08 | 2007-11-14 01:44:41 -0800 | [diff] [blame] | 133 | static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { |
Jiri Pirko | 51ab299 | 2018-01-17 11:46:53 +0100 | [diff] [blame] | 134 | .cl_ops = &ingress_class_ops, |
| 135 | .id = "ingress", |
| 136 | .priv_size = sizeof(struct ingress_sched_data), |
| 137 | .static_flags = TCQ_F_CPUSTATS, |
| 138 | .init = ingress_init, |
| 139 | .destroy = ingress_destroy, |
| 140 | .dump = ingress_dump, |
| 141 | .ingress_block_set = ingress_ingress_block_set, |
| 142 | .ingress_block_get = ingress_ingress_block_get, |
| 143 | .owner = THIS_MODULE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 146 | struct clsact_sched_data { |
| 147 | struct tcf_block *ingress_block; |
| 148 | struct tcf_block *egress_block; |
Jiri Pirko | 6e40cf2 | 2017-10-19 15:50:30 +0200 | [diff] [blame] | 149 | struct tcf_block_ext_info ingress_block_info; |
| 150 | struct tcf_block_ext_info egress_block_info; |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 151 | struct mini_Qdisc_pair miniqp_ingress; |
| 152 | struct mini_Qdisc_pair miniqp_egress; |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 153 | }; |
| 154 | |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 155 | static unsigned long clsact_find(struct Qdisc *sch, u32 classid) |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 156 | { |
| 157 | switch (TC_H_MIN(classid)) { |
| 158 | case TC_H_MIN(TC_H_MIN_INGRESS): |
| 159 | case TC_H_MIN(TC_H_MIN_EGRESS): |
| 160 | return TC_H_MIN(classid); |
| 161 | default: |
| 162 | return 0; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | static unsigned long clsact_bind_filter(struct Qdisc *sch, |
| 167 | unsigned long parent, u32 classid) |
| 168 | { |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 169 | return clsact_find(sch, classid); |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 170 | } |
| 171 | |
Alexander Aring | cbaacc4 | 2017-12-20 12:35:16 -0500 | [diff] [blame] | 172 | static struct tcf_block *clsact_tcf_block(struct Qdisc *sch, unsigned long cl, |
| 173 | struct netlink_ext_ack *extack) |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 174 | { |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 175 | struct clsact_sched_data *q = qdisc_priv(sch); |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 176 | |
| 177 | switch (cl) { |
| 178 | case TC_H_MIN(TC_H_MIN_INGRESS): |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 179 | return q->ingress_block; |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 180 | case TC_H_MIN(TC_H_MIN_EGRESS): |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 181 | return q->egress_block; |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 182 | default: |
| 183 | return NULL; |
| 184 | } |
| 185 | } |
| 186 | |
Jiri Pirko | 51ab299 | 2018-01-17 11:46:53 +0100 | [diff] [blame] | 187 | static void clsact_ingress_block_set(struct Qdisc *sch, u32 block_index) |
| 188 | { |
| 189 | struct clsact_sched_data *q = qdisc_priv(sch); |
| 190 | |
| 191 | q->ingress_block_info.block_index = block_index; |
| 192 | } |
| 193 | |
| 194 | static void clsact_egress_block_set(struct Qdisc *sch, u32 block_index) |
| 195 | { |
| 196 | struct clsact_sched_data *q = qdisc_priv(sch); |
| 197 | |
| 198 | q->egress_block_info.block_index = block_index; |
| 199 | } |
| 200 | |
| 201 | static u32 clsact_ingress_block_get(struct Qdisc *sch) |
| 202 | { |
| 203 | struct clsact_sched_data *q = qdisc_priv(sch); |
| 204 | |
| 205 | return q->ingress_block_info.block_index; |
| 206 | } |
| 207 | |
| 208 | static u32 clsact_egress_block_get(struct Qdisc *sch) |
| 209 | { |
| 210 | struct clsact_sched_data *q = qdisc_priv(sch); |
| 211 | |
| 212 | return q->egress_block_info.block_index; |
| 213 | } |
| 214 | |
Alexander Aring | e63d7df | 2017-12-20 12:35:13 -0500 | [diff] [blame] | 215 | static int clsact_init(struct Qdisc *sch, struct nlattr *opt, |
| 216 | struct netlink_ext_ack *extack) |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 217 | { |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 218 | struct clsact_sched_data *q = qdisc_priv(sch); |
| 219 | struct net_device *dev = qdisc_dev(sch); |
| 220 | int err; |
| 221 | |
Jiri Pirko | b59e697 | 2017-12-15 12:40:13 +0100 | [diff] [blame] | 222 | net_inc_ingress_queue(); |
| 223 | net_inc_egress_queue(); |
| 224 | |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 225 | mini_qdisc_pair_init(&q->miniqp_ingress, sch, &dev->miniq_ingress); |
| 226 | |
Pablo Neira Ayuso | 32f8c40 | 2019-07-09 22:55:41 +0200 | [diff] [blame] | 227 | q->ingress_block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS; |
Jiri Pirko | c7eb7d7 | 2017-11-03 11:46:24 +0100 | [diff] [blame] | 228 | q->ingress_block_info.chain_head_change = clsact_chain_head_change; |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 229 | q->ingress_block_info.chain_head_change_priv = &q->miniqp_ingress; |
Jiri Pirko | 6e40cf2 | 2017-10-19 15:50:30 +0200 | [diff] [blame] | 230 | |
Alexander Aring | 8d1a77f | 2017-12-20 12:35:19 -0500 | [diff] [blame] | 231 | err = tcf_block_get_ext(&q->ingress_block, sch, &q->ingress_block_info, |
| 232 | extack); |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 233 | if (err) |
| 234 | return err; |
| 235 | |
Paul Blakey | 7d17c54 | 2020-02-16 12:01:22 +0200 | [diff] [blame] | 236 | mini_qdisc_pair_block_init(&q->miniqp_ingress, q->ingress_block); |
| 237 | |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 238 | mini_qdisc_pair_init(&q->miniqp_egress, sch, &dev->miniq_egress); |
| 239 | |
Pablo Neira Ayuso | 32f8c40 | 2019-07-09 22:55:41 +0200 | [diff] [blame] | 240 | q->egress_block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS; |
Jiri Pirko | c7eb7d7 | 2017-11-03 11:46:24 +0100 | [diff] [blame] | 241 | q->egress_block_info.chain_head_change = clsact_chain_head_change; |
Jiri Pirko | 4620940 | 2017-11-03 11:46:25 +0100 | [diff] [blame] | 242 | q->egress_block_info.chain_head_change_priv = &q->miniqp_egress; |
Jiri Pirko | 6e40cf2 | 2017-10-19 15:50:30 +0200 | [diff] [blame] | 243 | |
David S. Miller | c02b374 | 2018-01-17 00:00:25 -0500 | [diff] [blame] | 244 | return tcf_block_get_ext(&q->egress_block, sch, &q->egress_block_info, extack); |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static void clsact_destroy(struct Qdisc *sch) |
| 248 | { |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 249 | struct clsact_sched_data *q = qdisc_priv(sch); |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 250 | |
Jiri Pirko | c7eb7d7 | 2017-11-03 11:46:24 +0100 | [diff] [blame] | 251 | tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info); |
| 252 | tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info); |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 253 | |
| 254 | net_dec_ingress_queue(); |
| 255 | net_dec_egress_queue(); |
| 256 | } |
| 257 | |
| 258 | static const struct Qdisc_class_ops clsact_class_ops = { |
Vlad Buslov | 87f3739 | 2019-06-13 19:12:05 +0300 | [diff] [blame] | 259 | .flags = QDISC_CLASS_OPS_DOIT_UNLOCKED, |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 260 | .leaf = ingress_leaf, |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 261 | .find = clsact_find, |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 262 | .walk = ingress_walk, |
Jiri Pirko | 6529eab | 2017-05-17 11:07:55 +0200 | [diff] [blame] | 263 | .tcf_block = clsact_tcf_block, |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 264 | .bind_tcf = clsact_bind_filter, |
WANG Cong | 143976c | 2017-08-24 16:51:29 -0700 | [diff] [blame] | 265 | .unbind_tcf = ingress_unbind_filter, |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 266 | }; |
| 267 | |
| 268 | static struct Qdisc_ops clsact_qdisc_ops __read_mostly = { |
Jiri Pirko | 51ab299 | 2018-01-17 11:46:53 +0100 | [diff] [blame] | 269 | .cl_ops = &clsact_class_ops, |
| 270 | .id = "clsact", |
| 271 | .priv_size = sizeof(struct clsact_sched_data), |
| 272 | .static_flags = TCQ_F_CPUSTATS, |
| 273 | .init = clsact_init, |
| 274 | .destroy = clsact_destroy, |
| 275 | .dump = ingress_dump, |
| 276 | .ingress_block_set = clsact_ingress_block_set, |
| 277 | .egress_block_set = clsact_egress_block_set, |
| 278 | .ingress_block_get = clsact_ingress_block_get, |
| 279 | .egress_block_get = clsact_egress_block_get, |
| 280 | .owner = THIS_MODULE, |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 281 | }; |
| 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | static int __init ingress_module_init(void) |
| 284 | { |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 285 | int ret; |
| 286 | |
| 287 | ret = register_qdisc(&ingress_qdisc_ops); |
| 288 | if (!ret) { |
| 289 | ret = register_qdisc(&clsact_qdisc_ops); |
| 290 | if (ret) |
| 291 | unregister_qdisc(&ingress_qdisc_ops); |
| 292 | } |
| 293 | |
| 294 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } |
Patrick McHardy | 58f4df4 | 2008-01-21 00:11:01 -0800 | [diff] [blame] | 296 | |
YOSHIFUJI Hideaki | 10297b9 | 2007-02-09 23:25:16 +0900 | [diff] [blame] | 297 | static void __exit ingress_module_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | { |
| 299 | unregister_qdisc(&ingress_qdisc_ops); |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 300 | unregister_qdisc(&clsact_qdisc_ops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
Patrick McHardy | 58f4df4 | 2008-01-21 00:11:01 -0800 | [diff] [blame] | 302 | |
Daniel Borkmann | d2788d3 | 2015-05-09 22:51:32 +0200 | [diff] [blame] | 303 | module_init(ingress_module_init); |
| 304 | module_exit(ingress_module_exit); |
| 305 | |
Daniel Borkmann | 1f211a1 | 2016-01-07 22:29:47 +0100 | [diff] [blame] | 306 | MODULE_ALIAS("sch_clsact"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | MODULE_LICENSE("GPL"); |