blob: 5c4171c5d2bd367188344186f424782bc8baba63 [file] [log] [blame]
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +01001/*
2 * Berkeley Packet Filter based traffic classifier
3 *
4 * Might be used to classify traffic through flexible, user-defined and
5 * possibly JIT-ed BPF filters for traffic control as an alternative to
6 * ematches.
7 *
8 * (C) 2013 Daniel Borkmann <dborkman@redhat.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/module.h>
16#include <linux/types.h>
17#include <linux/skbuff.h>
18#include <linux/filter.h>
Daniel Borkmanne2e9b652015-03-01 12:31:48 +010019#include <linux/bpf.h>
20
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010021#include <net/rtnetlink.h>
22#include <net/pkt_cls.h>
23#include <net/sock.h>
24
25MODULE_LICENSE("GPL");
26MODULE_AUTHOR("Daniel Borkmann <dborkman@redhat.com>");
27MODULE_DESCRIPTION("TC BPF based classifier");
28
Daniel Borkmanne2e9b652015-03-01 12:31:48 +010029#define CLS_BPF_NAME_LEN 256
30
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010031struct cls_bpf_head {
32 struct list_head plist;
33 u32 hgen;
John Fastabend1f947bf2014-09-12 20:10:24 -070034 struct rcu_head rcu;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010035};
36
37struct cls_bpf_prog {
Alexei Starovoitov7ae457c2014-07-30 20:34:16 -070038 struct bpf_prog *filter;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010039 struct list_head link;
Daniel Borkmanne2e9b652015-03-01 12:31:48 +010040 struct tcf_result res;
41 struct tcf_exts exts;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010042 u32 handle;
Daniel Borkmanne2e9b652015-03-01 12:31:48 +010043 union {
44 u32 bpf_fd;
45 u16 bpf_num_ops;
46 };
47 struct sock_filter *bpf_ops;
48 const char *bpf_name;
John Fastabend1f947bf2014-09-12 20:10:24 -070049 struct tcf_proto *tp;
50 struct rcu_head rcu;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010051};
52
53static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = {
54 [TCA_BPF_CLASSID] = { .type = NLA_U32 },
Daniel Borkmanne2e9b652015-03-01 12:31:48 +010055 [TCA_BPF_FD] = { .type = NLA_U32 },
56 [TCA_BPF_NAME] = { .type = NLA_NUL_STRING, .len = CLS_BPF_NAME_LEN },
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010057 [TCA_BPF_OPS_LEN] = { .type = NLA_U16 },
58 [TCA_BPF_OPS] = { .type = NLA_BINARY,
59 .len = sizeof(struct sock_filter) * BPF_MAXINSNS },
60};
61
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010062static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
63 struct tcf_result *res)
64{
WANG Cong80dcbd12014-09-15 14:21:50 -070065 struct cls_bpf_head *head = rcu_dereference_bh(tp->root);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010066 struct cls_bpf_prog *prog;
Daniel Borkmann54720df2015-03-12 20:03:12 +010067 int ret = -1;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010068
Daniel Borkmann54720df2015-03-12 20:03:12 +010069 /* Needed here for accessing maps. */
70 rcu_read_lock();
John Fastabend1f947bf2014-09-12 20:10:24 -070071 list_for_each_entry_rcu(prog, &head->plist, link) {
Alexei Starovoitov7ae457c2014-07-30 20:34:16 -070072 int filter_res = BPF_PROG_RUN(prog->filter, skb);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010073
74 if (filter_res == 0)
75 continue;
76
77 *res = prog->res;
78 if (filter_res != -1)
79 res->classid = filter_res;
80
81 ret = tcf_exts_exec(skb, &prog->exts, res);
82 if (ret < 0)
83 continue;
84
Daniel Borkmann54720df2015-03-12 20:03:12 +010085 break;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010086 }
Daniel Borkmann54720df2015-03-12 20:03:12 +010087 rcu_read_unlock();
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010088
Daniel Borkmann54720df2015-03-12 20:03:12 +010089 return ret;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010090}
91
Daniel Borkmanne2e9b652015-03-01 12:31:48 +010092static bool cls_bpf_is_ebpf(const struct cls_bpf_prog *prog)
93{
94 return !prog->bpf_ops;
95}
96
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +010097static int cls_bpf_init(struct tcf_proto *tp)
98{
99 struct cls_bpf_head *head;
100
101 head = kzalloc(sizeof(*head), GFP_KERNEL);
102 if (head == NULL)
103 return -ENOBUFS;
104
John Fastabend1f947bf2014-09-12 20:10:24 -0700105 INIT_LIST_HEAD_RCU(&head->plist);
106 rcu_assign_pointer(tp->root, head);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100107
108 return 0;
109}
110
111static void cls_bpf_delete_prog(struct tcf_proto *tp, struct cls_bpf_prog *prog)
112{
WANG Cong18d02642014-09-25 10:26:37 -0700113 tcf_exts_destroy(&prog->exts);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100114
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100115 if (cls_bpf_is_ebpf(prog))
116 bpf_prog_put(prog->filter);
117 else
118 bpf_prog_destroy(prog->filter);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100119
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100120 kfree(prog->bpf_name);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100121 kfree(prog->bpf_ops);
122 kfree(prog);
123}
124
John Fastabend1f947bf2014-09-12 20:10:24 -0700125static void __cls_bpf_delete_prog(struct rcu_head *rcu)
126{
127 struct cls_bpf_prog *prog = container_of(rcu, struct cls_bpf_prog, rcu);
128
129 cls_bpf_delete_prog(prog->tp, prog);
130}
131
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100132static int cls_bpf_delete(struct tcf_proto *tp, unsigned long arg)
133{
Jiri Pirko472f5832014-12-02 18:00:32 +0100134 struct cls_bpf_prog *prog = (struct cls_bpf_prog *) arg;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100135
Jiri Pirko472f5832014-12-02 18:00:32 +0100136 list_del_rcu(&prog->link);
137 tcf_unbind_filter(tp, &prog->res);
138 call_rcu(&prog->rcu, __cls_bpf_delete_prog);
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100139
Jiri Pirko472f5832014-12-02 18:00:32 +0100140 return 0;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100141}
142
Cong Wang1e052be2015-03-06 11:47:59 -0800143static bool cls_bpf_destroy(struct tcf_proto *tp, bool force)
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100144{
John Fastabend1f947bf2014-09-12 20:10:24 -0700145 struct cls_bpf_head *head = rtnl_dereference(tp->root);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100146 struct cls_bpf_prog *prog, *tmp;
147
Cong Wang1e052be2015-03-06 11:47:59 -0800148 if (!force && !list_empty(&head->plist))
149 return false;
150
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100151 list_for_each_entry_safe(prog, tmp, &head->plist, link) {
John Fastabend1f947bf2014-09-12 20:10:24 -0700152 list_del_rcu(&prog->link);
John Fastabend18cdb372014-10-05 21:28:52 -0700153 tcf_unbind_filter(tp, &prog->res);
John Fastabend1f947bf2014-09-12 20:10:24 -0700154 call_rcu(&prog->rcu, __cls_bpf_delete_prog);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100155 }
156
John Fastabend1f947bf2014-09-12 20:10:24 -0700157 RCU_INIT_POINTER(tp->root, NULL);
158 kfree_rcu(head, rcu);
Cong Wang1e052be2015-03-06 11:47:59 -0800159 return true;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100160}
161
162static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
163{
John Fastabend1f947bf2014-09-12 20:10:24 -0700164 struct cls_bpf_head *head = rtnl_dereference(tp->root);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100165 struct cls_bpf_prog *prog;
166 unsigned long ret = 0UL;
167
168 if (head == NULL)
169 return 0UL;
170
Jiri Pirko3fe6b492014-12-02 18:00:33 +0100171 list_for_each_entry(prog, &head->plist, link) {
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100172 if (prog->handle == handle) {
173 ret = (unsigned long) prog;
174 break;
175 }
176 }
177
178 return ret;
179}
180
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100181static int cls_bpf_prog_from_ops(struct nlattr **tb,
182 struct cls_bpf_prog *prog, u32 classid)
183{
184 struct sock_filter *bpf_ops;
185 struct sock_fprog_kern fprog_tmp;
186 struct bpf_prog *fp;
187 u16 bpf_size, bpf_num_ops;
188 int ret;
189
190 bpf_num_ops = nla_get_u16(tb[TCA_BPF_OPS_LEN]);
191 if (bpf_num_ops > BPF_MAXINSNS || bpf_num_ops == 0)
192 return -EINVAL;
193
194 bpf_size = bpf_num_ops * sizeof(*bpf_ops);
195 if (bpf_size != nla_len(tb[TCA_BPF_OPS]))
196 return -EINVAL;
197
198 bpf_ops = kzalloc(bpf_size, GFP_KERNEL);
199 if (bpf_ops == NULL)
200 return -ENOMEM;
201
202 memcpy(bpf_ops, nla_data(tb[TCA_BPF_OPS]), bpf_size);
203
204 fprog_tmp.len = bpf_num_ops;
205 fprog_tmp.filter = bpf_ops;
206
207 ret = bpf_prog_create(&fp, &fprog_tmp);
208 if (ret < 0) {
209 kfree(bpf_ops);
210 return ret;
211 }
212
213 prog->bpf_ops = bpf_ops;
214 prog->bpf_num_ops = bpf_num_ops;
215 prog->bpf_name = NULL;
216
217 prog->filter = fp;
218 prog->res.classid = classid;
219
220 return 0;
221}
222
223static int cls_bpf_prog_from_efd(struct nlattr **tb,
224 struct cls_bpf_prog *prog, u32 classid)
225{
226 struct bpf_prog *fp;
227 char *name = NULL;
228 u32 bpf_fd;
229
230 bpf_fd = nla_get_u32(tb[TCA_BPF_FD]);
231
232 fp = bpf_prog_get(bpf_fd);
233 if (IS_ERR(fp))
234 return PTR_ERR(fp);
235
236 if (fp->type != BPF_PROG_TYPE_SCHED_CLS) {
237 bpf_prog_put(fp);
238 return -EINVAL;
239 }
240
241 if (tb[TCA_BPF_NAME]) {
242 name = kmemdup(nla_data(tb[TCA_BPF_NAME]),
243 nla_len(tb[TCA_BPF_NAME]),
244 GFP_KERNEL);
245 if (!name) {
246 bpf_prog_put(fp);
247 return -ENOMEM;
248 }
249 }
250
251 prog->bpf_ops = NULL;
252 prog->bpf_fd = bpf_fd;
253 prog->bpf_name = name;
254
255 prog->filter = fp;
256 prog->res.classid = classid;
257
258 return 0;
259}
260
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100261static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
262 struct cls_bpf_prog *prog,
263 unsigned long base, struct nlattr **tb,
Cong Wang2f7ef2f2014-04-25 13:54:06 -0700264 struct nlattr *est, bool ovr)
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100265{
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100266 struct tcf_exts exts;
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100267 bool is_bpf, is_ebpf;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100268 u32 classid;
269 int ret;
270
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100271 is_bpf = tb[TCA_BPF_OPS_LEN] && tb[TCA_BPF_OPS];
272 is_ebpf = tb[TCA_BPF_FD];
273
274 if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf) ||
275 !tb[TCA_BPF_CLASSID])
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100276 return -EINVAL;
277
WANG Cong5da57f42013-12-15 20:15:07 -0800278 tcf_exts_init(&exts, TCA_BPF_ACT, TCA_BPF_POLICE);
Cong Wang2f7ef2f2014-04-25 13:54:06 -0700279 ret = tcf_exts_validate(net, tp, tb, est, &exts, ovr);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100280 if (ret < 0)
281 return ret;
282
283 classid = nla_get_u32(tb[TCA_BPF_CLASSID]);
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100284
285 ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog, classid) :
286 cls_bpf_prog_from_efd(tb, prog, classid);
287 if (ret < 0) {
288 tcf_exts_destroy(&exts);
289 return ret;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100290 }
291
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100292 tcf_bind_filter(tp, &prog->res, base);
293 tcf_exts_change(tp, &prog->exts, &exts);
294
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100295 return 0;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100296}
297
298static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp,
299 struct cls_bpf_head *head)
300{
301 unsigned int i = 0x80000000;
Daniel Borkmann3f2ab132015-01-22 10:41:02 +0100302 u32 handle;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100303
304 do {
305 if (++head->hgen == 0x7FFFFFFF)
306 head->hgen = 1;
307 } while (--i > 0 && cls_bpf_get(tp, head->hgen));
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100308
Daniel Borkmann3f2ab132015-01-22 10:41:02 +0100309 if (unlikely(i == 0)) {
310 pr_err("Insufficient number of handles\n");
311 handle = 0;
312 } else {
313 handle = head->hgen;
314 }
315
316 return handle;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100317}
318
319static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
320 struct tcf_proto *tp, unsigned long base,
321 u32 handle, struct nlattr **tca,
Cong Wang2f7ef2f2014-04-25 13:54:06 -0700322 unsigned long *arg, bool ovr)
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100323{
John Fastabend1f947bf2014-09-12 20:10:24 -0700324 struct cls_bpf_head *head = rtnl_dereference(tp->root);
325 struct cls_bpf_prog *oldprog = (struct cls_bpf_prog *) *arg;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100326 struct nlattr *tb[TCA_BPF_MAX + 1];
John Fastabend1f947bf2014-09-12 20:10:24 -0700327 struct cls_bpf_prog *prog;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100328 int ret;
329
330 if (tca[TCA_OPTIONS] == NULL)
331 return -EINVAL;
332
333 ret = nla_parse_nested(tb, TCA_BPF_MAX, tca[TCA_OPTIONS], bpf_policy);
334 if (ret < 0)
335 return ret;
336
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100337 prog = kzalloc(sizeof(*prog), GFP_KERNEL);
John Fastabend1f947bf2014-09-12 20:10:24 -0700338 if (!prog)
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100339 return -ENOBUFS;
340
WANG Cong5da57f42013-12-15 20:15:07 -0800341 tcf_exts_init(&prog->exts, TCA_BPF_ACT, TCA_BPF_POLICE);
John Fastabend1f947bf2014-09-12 20:10:24 -0700342
343 if (oldprog) {
344 if (handle && oldprog->handle != handle) {
345 ret = -EINVAL;
346 goto errout;
347 }
348 }
349
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100350 if (handle == 0)
351 prog->handle = cls_bpf_grab_new_handle(tp, head);
352 else
353 prog->handle = handle;
354 if (prog->handle == 0) {
355 ret = -EINVAL;
356 goto errout;
357 }
358
Cong Wang2f7ef2f2014-04-25 13:54:06 -0700359 ret = cls_bpf_modify_existing(net, tp, prog, base, tb, tca[TCA_RATE], ovr);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100360 if (ret < 0)
361 goto errout;
362
John Fastabend1f947bf2014-09-12 20:10:24 -0700363 if (oldprog) {
364 list_replace_rcu(&prog->link, &oldprog->link);
John Fastabend18cdb372014-10-05 21:28:52 -0700365 tcf_unbind_filter(tp, &oldprog->res);
John Fastabend1f947bf2014-09-12 20:10:24 -0700366 call_rcu(&oldprog->rcu, __cls_bpf_delete_prog);
367 } else {
368 list_add_rcu(&prog->link, &head->plist);
369 }
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100370
371 *arg = (unsigned long) prog;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100372 return 0;
373errout:
John Fastabend1f947bf2014-09-12 20:10:24 -0700374 kfree(prog);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100375
376 return ret;
377}
378
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100379static int cls_bpf_dump_bpf_info(const struct cls_bpf_prog *prog,
380 struct sk_buff *skb)
381{
382 struct nlattr *nla;
383
384 if (nla_put_u16(skb, TCA_BPF_OPS_LEN, prog->bpf_num_ops))
385 return -EMSGSIZE;
386
387 nla = nla_reserve(skb, TCA_BPF_OPS, prog->bpf_num_ops *
388 sizeof(struct sock_filter));
389 if (nla == NULL)
390 return -EMSGSIZE;
391
392 memcpy(nla_data(nla), prog->bpf_ops, nla_len(nla));
393
394 return 0;
395}
396
397static int cls_bpf_dump_ebpf_info(const struct cls_bpf_prog *prog,
398 struct sk_buff *skb)
399{
400 if (nla_put_u32(skb, TCA_BPF_FD, prog->bpf_fd))
401 return -EMSGSIZE;
402
403 if (prog->bpf_name &&
404 nla_put_string(skb, TCA_BPF_NAME, prog->bpf_name))
405 return -EMSGSIZE;
406
407 return 0;
408}
409
WANG Cong832d1d52014-01-09 16:14:01 -0800410static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100411 struct sk_buff *skb, struct tcmsg *tm)
412{
413 struct cls_bpf_prog *prog = (struct cls_bpf_prog *) fh;
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100414 struct nlattr *nest;
415 int ret;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100416
417 if (prog == NULL)
418 return skb->len;
419
420 tm->tcm_handle = prog->handle;
421
422 nest = nla_nest_start(skb, TCA_OPTIONS);
423 if (nest == NULL)
424 goto nla_put_failure;
425
426 if (nla_put_u32(skb, TCA_BPF_CLASSID, prog->res.classid))
427 goto nla_put_failure;
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100428
Daniel Borkmanne2e9b652015-03-01 12:31:48 +0100429 if (cls_bpf_is_ebpf(prog))
430 ret = cls_bpf_dump_ebpf_info(prog, skb);
431 else
432 ret = cls_bpf_dump_bpf_info(prog, skb);
433 if (ret)
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100434 goto nla_put_failure;
435
WANG Cong5da57f42013-12-15 20:15:07 -0800436 if (tcf_exts_dump(skb, &prog->exts) < 0)
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100437 goto nla_put_failure;
438
439 nla_nest_end(skb, nest);
440
WANG Cong5da57f42013-12-15 20:15:07 -0800441 if (tcf_exts_dump_stats(skb, &prog->exts) < 0)
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100442 goto nla_put_failure;
443
444 return skb->len;
445
446nla_put_failure:
447 nla_nest_cancel(skb, nest);
448 return -1;
449}
450
451static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg)
452{
John Fastabend1f947bf2014-09-12 20:10:24 -0700453 struct cls_bpf_head *head = rtnl_dereference(tp->root);
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100454 struct cls_bpf_prog *prog;
455
Jiri Pirko3fe6b492014-12-02 18:00:33 +0100456 list_for_each_entry(prog, &head->plist, link) {
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100457 if (arg->count < arg->skip)
458 goto skip;
459 if (arg->fn(tp, (unsigned long) prog, arg) < 0) {
460 arg->stop = 1;
461 break;
462 }
463skip:
464 arg->count++;
465 }
466}
467
468static struct tcf_proto_ops cls_bpf_ops __read_mostly = {
469 .kind = "bpf",
470 .owner = THIS_MODULE,
471 .classify = cls_bpf_classify,
472 .init = cls_bpf_init,
473 .destroy = cls_bpf_destroy,
474 .get = cls_bpf_get,
Daniel Borkmann7d1d65c2013-10-28 16:43:02 +0100475 .change = cls_bpf_change,
476 .delete = cls_bpf_delete,
477 .walk = cls_bpf_walk,
478 .dump = cls_bpf_dump,
479};
480
481static int __init cls_bpf_init_mod(void)
482{
483 return register_tcf_proto_ops(&cls_bpf_ops);
484}
485
486static void __exit cls_bpf_exit_mod(void)
487{
488 unregister_tcf_proto_ops(&cls_bpf_ops);
489}
490
491module_init(cls_bpf_init_mod);
492module_exit(cls_bpf_exit_mod);