cls_bpf.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  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. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <linux/skbuff.h>
  17. #include <linux/filter.h>
  18. #include <linux/bpf.h>
  19. #include <net/rtnetlink.h>
  20. #include <net/pkt_cls.h>
  21. #include <net/sock.h>
  22. MODULE_LICENSE("GPL");
  23. MODULE_AUTHOR("Daniel Borkmann <dborkman@redhat.com>");
  24. MODULE_DESCRIPTION("TC BPF based classifier");
  25. #define CLS_BPF_NAME_LEN 256
  26. #define CLS_BPF_SUPPORTED_GEN_FLAGS \
  27. (TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW)
  28. struct cls_bpf_head {
  29. struct list_head plist;
  30. u32 hgen;
  31. struct rcu_head rcu;
  32. };
  33. struct cls_bpf_prog {
  34. struct bpf_prog *filter;
  35. struct list_head link;
  36. struct tcf_result res;
  37. bool exts_integrated;
  38. bool offloaded;
  39. u32 gen_flags;
  40. struct tcf_exts exts;
  41. u32 handle;
  42. u16 bpf_num_ops;
  43. struct sock_filter *bpf_ops;
  44. const char *bpf_name;
  45. struct tcf_proto *tp;
  46. struct rcu_head rcu;
  47. };
  48. static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = {
  49. [TCA_BPF_CLASSID] = { .type = NLA_U32 },
  50. [TCA_BPF_FLAGS] = { .type = NLA_U32 },
  51. [TCA_BPF_FLAGS_GEN] = { .type = NLA_U32 },
  52. [TCA_BPF_FD] = { .type = NLA_U32 },
  53. [TCA_BPF_NAME] = { .type = NLA_NUL_STRING,
  54. .len = CLS_BPF_NAME_LEN },
  55. [TCA_BPF_OPS_LEN] = { .type = NLA_U16 },
  56. [TCA_BPF_OPS] = { .type = NLA_BINARY,
  57. .len = sizeof(struct sock_filter) * BPF_MAXINSNS },
  58. };
  59. static int cls_bpf_exec_opcode(int code)
  60. {
  61. switch (code) {
  62. case TC_ACT_OK:
  63. case TC_ACT_SHOT:
  64. case TC_ACT_STOLEN:
  65. case TC_ACT_REDIRECT:
  66. case TC_ACT_UNSPEC:
  67. return code;
  68. default:
  69. return TC_ACT_UNSPEC;
  70. }
  71. }
  72. static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
  73. struct tcf_result *res)
  74. {
  75. struct cls_bpf_head *head = rcu_dereference_bh(tp->root);
  76. bool at_ingress = skb_at_tc_ingress(skb);
  77. struct cls_bpf_prog *prog;
  78. int ret = -1;
  79. /* Needed here for accessing maps. */
  80. rcu_read_lock();
  81. list_for_each_entry_rcu(prog, &head->plist, link) {
  82. int filter_res;
  83. qdisc_skb_cb(skb)->tc_classid = prog->res.classid;
  84. if (tc_skip_sw(prog->gen_flags)) {
  85. filter_res = prog->exts_integrated ? TC_ACT_UNSPEC : 0;
  86. } else if (at_ingress) {
  87. /* It is safe to push/pull even if skb_shared() */
  88. __skb_push(skb, skb->mac_len);
  89. bpf_compute_data_end(skb);
  90. filter_res = BPF_PROG_RUN(prog->filter, skb);
  91. __skb_pull(skb, skb->mac_len);
  92. } else {
  93. bpf_compute_data_end(skb);
  94. filter_res = BPF_PROG_RUN(prog->filter, skb);
  95. }
  96. if (prog->exts_integrated) {
  97. res->class = 0;
  98. res->classid = TC_H_MAJ(prog->res.classid) |
  99. qdisc_skb_cb(skb)->tc_classid;
  100. ret = cls_bpf_exec_opcode(filter_res);
  101. if (ret == TC_ACT_UNSPEC)
  102. continue;
  103. break;
  104. }
  105. if (filter_res == 0)
  106. continue;
  107. if (filter_res != -1) {
  108. res->class = 0;
  109. res->classid = filter_res;
  110. } else {
  111. *res = prog->res;
  112. }
  113. ret = tcf_exts_exec(skb, &prog->exts, res);
  114. if (ret < 0)
  115. continue;
  116. break;
  117. }
  118. rcu_read_unlock();
  119. return ret;
  120. }
  121. static bool cls_bpf_is_ebpf(const struct cls_bpf_prog *prog)
  122. {
  123. return !prog->bpf_ops;
  124. }
  125. static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
  126. enum tc_clsbpf_command cmd)
  127. {
  128. struct net_device *dev = tp->q->dev_queue->dev;
  129. struct tc_cls_bpf_offload bpf_offload = {};
  130. struct tc_to_netdev offload;
  131. offload.type = TC_SETUP_CLSBPF;
  132. offload.cls_bpf = &bpf_offload;
  133. bpf_offload.command = cmd;
  134. bpf_offload.exts = &prog->exts;
  135. bpf_offload.prog = prog->filter;
  136. bpf_offload.name = prog->bpf_name;
  137. bpf_offload.exts_integrated = prog->exts_integrated;
  138. bpf_offload.gen_flags = prog->gen_flags;
  139. return dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle,
  140. tp->protocol, &offload);
  141. }
  142. static int cls_bpf_offload(struct tcf_proto *tp, struct cls_bpf_prog *prog,
  143. struct cls_bpf_prog *oldprog)
  144. {
  145. struct net_device *dev = tp->q->dev_queue->dev;
  146. struct cls_bpf_prog *obj = prog;
  147. enum tc_clsbpf_command cmd;
  148. bool skip_sw;
  149. int ret;
  150. skip_sw = tc_skip_sw(prog->gen_flags) ||
  151. (oldprog && tc_skip_sw(oldprog->gen_flags));
  152. if (oldprog && oldprog->offloaded) {
  153. if (tc_should_offload(dev, tp, prog->gen_flags)) {
  154. cmd = TC_CLSBPF_REPLACE;
  155. } else if (!tc_skip_sw(prog->gen_flags)) {
  156. obj = oldprog;
  157. cmd = TC_CLSBPF_DESTROY;
  158. } else {
  159. return -EINVAL;
  160. }
  161. } else {
  162. if (!tc_should_offload(dev, tp, prog->gen_flags))
  163. return skip_sw ? -EINVAL : 0;
  164. cmd = TC_CLSBPF_ADD;
  165. }
  166. ret = cls_bpf_offload_cmd(tp, obj, cmd);
  167. if (ret)
  168. return skip_sw ? ret : 0;
  169. obj->offloaded = true;
  170. if (oldprog)
  171. oldprog->offloaded = false;
  172. return 0;
  173. }
  174. static void cls_bpf_stop_offload(struct tcf_proto *tp,
  175. struct cls_bpf_prog *prog)
  176. {
  177. int err;
  178. if (!prog->offloaded)
  179. return;
  180. err = cls_bpf_offload_cmd(tp, prog, TC_CLSBPF_DESTROY);
  181. if (err) {
  182. pr_err("Stopping hardware offload failed: %d\n", err);
  183. return;
  184. }
  185. prog->offloaded = false;
  186. }
  187. static void cls_bpf_offload_update_stats(struct tcf_proto *tp,
  188. struct cls_bpf_prog *prog)
  189. {
  190. if (!prog->offloaded)
  191. return;
  192. cls_bpf_offload_cmd(tp, prog, TC_CLSBPF_STATS);
  193. }
  194. static int cls_bpf_init(struct tcf_proto *tp)
  195. {
  196. struct cls_bpf_head *head;
  197. head = kzalloc(sizeof(*head), GFP_KERNEL);
  198. if (head == NULL)
  199. return -ENOBUFS;
  200. INIT_LIST_HEAD_RCU(&head->plist);
  201. rcu_assign_pointer(tp->root, head);
  202. return 0;
  203. }
  204. static void __cls_bpf_delete_prog(struct cls_bpf_prog *prog)
  205. {
  206. tcf_exts_destroy(&prog->exts);
  207. if (cls_bpf_is_ebpf(prog))
  208. bpf_prog_put(prog->filter);
  209. else
  210. bpf_prog_destroy(prog->filter);
  211. kfree(prog->bpf_name);
  212. kfree(prog->bpf_ops);
  213. kfree(prog);
  214. }
  215. static void cls_bpf_delete_prog_rcu(struct rcu_head *rcu)
  216. {
  217. __cls_bpf_delete_prog(container_of(rcu, struct cls_bpf_prog, rcu));
  218. }
  219. static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog)
  220. {
  221. cls_bpf_stop_offload(tp, prog);
  222. list_del_rcu(&prog->link);
  223. tcf_unbind_filter(tp, &prog->res);
  224. call_rcu(&prog->rcu, cls_bpf_delete_prog_rcu);
  225. }
  226. static int cls_bpf_delete(struct tcf_proto *tp, unsigned long arg)
  227. {
  228. __cls_bpf_delete(tp, (struct cls_bpf_prog *) arg);
  229. return 0;
  230. }
  231. static bool cls_bpf_destroy(struct tcf_proto *tp, bool force)
  232. {
  233. struct cls_bpf_head *head = rtnl_dereference(tp->root);
  234. struct cls_bpf_prog *prog, *tmp;
  235. if (!force && !list_empty(&head->plist))
  236. return false;
  237. list_for_each_entry_safe(prog, tmp, &head->plist, link)
  238. __cls_bpf_delete(tp, prog);
  239. kfree_rcu(head, rcu);
  240. return true;
  241. }
  242. static unsigned long cls_bpf_get(struct tcf_proto *tp, u32 handle)
  243. {
  244. struct cls_bpf_head *head = rtnl_dereference(tp->root);
  245. struct cls_bpf_prog *prog;
  246. unsigned long ret = 0UL;
  247. list_for_each_entry(prog, &head->plist, link) {
  248. if (prog->handle == handle) {
  249. ret = (unsigned long) prog;
  250. break;
  251. }
  252. }
  253. return ret;
  254. }
  255. static int cls_bpf_prog_from_ops(struct nlattr **tb, struct cls_bpf_prog *prog)
  256. {
  257. struct sock_filter *bpf_ops;
  258. struct sock_fprog_kern fprog_tmp;
  259. struct bpf_prog *fp;
  260. u16 bpf_size, bpf_num_ops;
  261. int ret;
  262. bpf_num_ops = nla_get_u16(tb[TCA_BPF_OPS_LEN]);
  263. if (bpf_num_ops > BPF_MAXINSNS || bpf_num_ops == 0)
  264. return -EINVAL;
  265. bpf_size = bpf_num_ops * sizeof(*bpf_ops);
  266. if (bpf_size != nla_len(tb[TCA_BPF_OPS]))
  267. return -EINVAL;
  268. bpf_ops = kzalloc(bpf_size, GFP_KERNEL);
  269. if (bpf_ops == NULL)
  270. return -ENOMEM;
  271. memcpy(bpf_ops, nla_data(tb[TCA_BPF_OPS]), bpf_size);
  272. fprog_tmp.len = bpf_num_ops;
  273. fprog_tmp.filter = bpf_ops;
  274. ret = bpf_prog_create(&fp, &fprog_tmp);
  275. if (ret < 0) {
  276. kfree(bpf_ops);
  277. return ret;
  278. }
  279. prog->bpf_ops = bpf_ops;
  280. prog->bpf_num_ops = bpf_num_ops;
  281. prog->bpf_name = NULL;
  282. prog->filter = fp;
  283. return 0;
  284. }
  285. static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog,
  286. const struct tcf_proto *tp)
  287. {
  288. struct bpf_prog *fp;
  289. char *name = NULL;
  290. u32 bpf_fd;
  291. bpf_fd = nla_get_u32(tb[TCA_BPF_FD]);
  292. fp = bpf_prog_get_type(bpf_fd, BPF_PROG_TYPE_SCHED_CLS);
  293. if (IS_ERR(fp))
  294. return PTR_ERR(fp);
  295. if (tb[TCA_BPF_NAME]) {
  296. name = nla_memdup(tb[TCA_BPF_NAME], GFP_KERNEL);
  297. if (!name) {
  298. bpf_prog_put(fp);
  299. return -ENOMEM;
  300. }
  301. }
  302. prog->bpf_ops = NULL;
  303. prog->bpf_name = name;
  304. prog->filter = fp;
  305. if (fp->dst_needed && !(tp->q->flags & TCQ_F_INGRESS))
  306. netif_keep_dst(qdisc_dev(tp->q));
  307. return 0;
  308. }
  309. static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
  310. struct cls_bpf_prog *prog,
  311. unsigned long base, struct nlattr **tb,
  312. struct nlattr *est, bool ovr)
  313. {
  314. bool is_bpf, is_ebpf, have_exts = false;
  315. struct tcf_exts exts;
  316. u32 gen_flags = 0;
  317. int ret;
  318. is_bpf = tb[TCA_BPF_OPS_LEN] && tb[TCA_BPF_OPS];
  319. is_ebpf = tb[TCA_BPF_FD];
  320. if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf))
  321. return -EINVAL;
  322. ret = tcf_exts_init(&exts, TCA_BPF_ACT, TCA_BPF_POLICE);
  323. if (ret < 0)
  324. return ret;
  325. ret = tcf_exts_validate(net, tp, tb, est, &exts, ovr);
  326. if (ret < 0)
  327. goto errout;
  328. if (tb[TCA_BPF_FLAGS]) {
  329. u32 bpf_flags = nla_get_u32(tb[TCA_BPF_FLAGS]);
  330. if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT) {
  331. ret = -EINVAL;
  332. goto errout;
  333. }
  334. have_exts = bpf_flags & TCA_BPF_FLAG_ACT_DIRECT;
  335. }
  336. if (tb[TCA_BPF_FLAGS_GEN]) {
  337. gen_flags = nla_get_u32(tb[TCA_BPF_FLAGS_GEN]);
  338. if (gen_flags & ~CLS_BPF_SUPPORTED_GEN_FLAGS ||
  339. !tc_flags_valid(gen_flags)) {
  340. ret = -EINVAL;
  341. goto errout;
  342. }
  343. }
  344. prog->exts_integrated = have_exts;
  345. prog->gen_flags = gen_flags;
  346. ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) :
  347. cls_bpf_prog_from_efd(tb, prog, tp);
  348. if (ret < 0)
  349. goto errout;
  350. if (tb[TCA_BPF_CLASSID]) {
  351. prog->res.classid = nla_get_u32(tb[TCA_BPF_CLASSID]);
  352. tcf_bind_filter(tp, &prog->res, base);
  353. }
  354. tcf_exts_change(tp, &prog->exts, &exts);
  355. return 0;
  356. errout:
  357. tcf_exts_destroy(&exts);
  358. return ret;
  359. }
  360. static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp,
  361. struct cls_bpf_head *head)
  362. {
  363. unsigned int i = 0x80000000;
  364. u32 handle;
  365. do {
  366. if (++head->hgen == 0x7FFFFFFF)
  367. head->hgen = 1;
  368. } while (--i > 0 && cls_bpf_get(tp, head->hgen));
  369. if (unlikely(i == 0)) {
  370. pr_err("Insufficient number of handles\n");
  371. handle = 0;
  372. } else {
  373. handle = head->hgen;
  374. }
  375. return handle;
  376. }
  377. static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
  378. struct tcf_proto *tp, unsigned long base,
  379. u32 handle, struct nlattr **tca,
  380. unsigned long *arg, bool ovr)
  381. {
  382. struct cls_bpf_head *head = rtnl_dereference(tp->root);
  383. struct cls_bpf_prog *oldprog = (struct cls_bpf_prog *) *arg;
  384. struct nlattr *tb[TCA_BPF_MAX + 1];
  385. struct cls_bpf_prog *prog;
  386. int ret;
  387. if (tca[TCA_OPTIONS] == NULL)
  388. return -EINVAL;
  389. ret = nla_parse_nested(tb, TCA_BPF_MAX, tca[TCA_OPTIONS], bpf_policy);
  390. if (ret < 0)
  391. return ret;
  392. prog = kzalloc(sizeof(*prog), GFP_KERNEL);
  393. if (!prog)
  394. return -ENOBUFS;
  395. ret = tcf_exts_init(&prog->exts, TCA_BPF_ACT, TCA_BPF_POLICE);
  396. if (ret < 0)
  397. goto errout;
  398. if (oldprog) {
  399. if (handle && oldprog->handle != handle) {
  400. ret = -EINVAL;
  401. goto errout;
  402. }
  403. }
  404. if (handle == 0)
  405. prog->handle = cls_bpf_grab_new_handle(tp, head);
  406. else
  407. prog->handle = handle;
  408. if (prog->handle == 0) {
  409. ret = -EINVAL;
  410. goto errout;
  411. }
  412. ret = cls_bpf_modify_existing(net, tp, prog, base, tb, tca[TCA_RATE],
  413. ovr);
  414. if (ret < 0)
  415. goto errout;
  416. ret = cls_bpf_offload(tp, prog, oldprog);
  417. if (ret) {
  418. __cls_bpf_delete_prog(prog);
  419. return ret;
  420. }
  421. if (oldprog) {
  422. list_replace_rcu(&oldprog->link, &prog->link);
  423. tcf_unbind_filter(tp, &oldprog->res);
  424. call_rcu(&oldprog->rcu, cls_bpf_delete_prog_rcu);
  425. } else {
  426. list_add_rcu(&prog->link, &head->plist);
  427. }
  428. *arg = (unsigned long) prog;
  429. return 0;
  430. errout:
  431. tcf_exts_destroy(&prog->exts);
  432. kfree(prog);
  433. return ret;
  434. }
  435. static int cls_bpf_dump_bpf_info(const struct cls_bpf_prog *prog,
  436. struct sk_buff *skb)
  437. {
  438. struct nlattr *nla;
  439. if (nla_put_u16(skb, TCA_BPF_OPS_LEN, prog->bpf_num_ops))
  440. return -EMSGSIZE;
  441. nla = nla_reserve(skb, TCA_BPF_OPS, prog->bpf_num_ops *
  442. sizeof(struct sock_filter));
  443. if (nla == NULL)
  444. return -EMSGSIZE;
  445. memcpy(nla_data(nla), prog->bpf_ops, nla_len(nla));
  446. return 0;
  447. }
  448. static int cls_bpf_dump_ebpf_info(const struct cls_bpf_prog *prog,
  449. struct sk_buff *skb)
  450. {
  451. struct nlattr *nla;
  452. if (prog->bpf_name &&
  453. nla_put_string(skb, TCA_BPF_NAME, prog->bpf_name))
  454. return -EMSGSIZE;
  455. nla = nla_reserve(skb, TCA_BPF_TAG, sizeof(prog->filter->tag));
  456. if (nla == NULL)
  457. return -EMSGSIZE;
  458. memcpy(nla_data(nla), prog->filter->tag, nla_len(nla));
  459. return 0;
  460. }
  461. static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
  462. struct sk_buff *skb, struct tcmsg *tm)
  463. {
  464. struct cls_bpf_prog *prog = (struct cls_bpf_prog *) fh;
  465. struct nlattr *nest;
  466. u32 bpf_flags = 0;
  467. int ret;
  468. if (prog == NULL)
  469. return skb->len;
  470. tm->tcm_handle = prog->handle;
  471. cls_bpf_offload_update_stats(tp, prog);
  472. nest = nla_nest_start(skb, TCA_OPTIONS);
  473. if (nest == NULL)
  474. goto nla_put_failure;
  475. if (prog->res.classid &&
  476. nla_put_u32(skb, TCA_BPF_CLASSID, prog->res.classid))
  477. goto nla_put_failure;
  478. if (cls_bpf_is_ebpf(prog))
  479. ret = cls_bpf_dump_ebpf_info(prog, skb);
  480. else
  481. ret = cls_bpf_dump_bpf_info(prog, skb);
  482. if (ret)
  483. goto nla_put_failure;
  484. if (tcf_exts_dump(skb, &prog->exts) < 0)
  485. goto nla_put_failure;
  486. if (prog->exts_integrated)
  487. bpf_flags |= TCA_BPF_FLAG_ACT_DIRECT;
  488. if (bpf_flags && nla_put_u32(skb, TCA_BPF_FLAGS, bpf_flags))
  489. goto nla_put_failure;
  490. if (prog->gen_flags &&
  491. nla_put_u32(skb, TCA_BPF_FLAGS_GEN, prog->gen_flags))
  492. goto nla_put_failure;
  493. nla_nest_end(skb, nest);
  494. if (tcf_exts_dump_stats(skb, &prog->exts) < 0)
  495. goto nla_put_failure;
  496. return skb->len;
  497. nla_put_failure:
  498. nla_nest_cancel(skb, nest);
  499. return -1;
  500. }
  501. static void cls_bpf_walk(struct tcf_proto *tp, struct tcf_walker *arg)
  502. {
  503. struct cls_bpf_head *head = rtnl_dereference(tp->root);
  504. struct cls_bpf_prog *prog;
  505. list_for_each_entry(prog, &head->plist, link) {
  506. if (arg->count < arg->skip)
  507. goto skip;
  508. if (arg->fn(tp, (unsigned long) prog, arg) < 0) {
  509. arg->stop = 1;
  510. break;
  511. }
  512. skip:
  513. arg->count++;
  514. }
  515. }
  516. static struct tcf_proto_ops cls_bpf_ops __read_mostly = {
  517. .kind = "bpf",
  518. .owner = THIS_MODULE,
  519. .classify = cls_bpf_classify,
  520. .init = cls_bpf_init,
  521. .destroy = cls_bpf_destroy,
  522. .get = cls_bpf_get,
  523. .change = cls_bpf_change,
  524. .delete = cls_bpf_delete,
  525. .walk = cls_bpf_walk,
  526. .dump = cls_bpf_dump,
  527. };
  528. static int __init cls_bpf_init_mod(void)
  529. {
  530. return register_tcf_proto_ops(&cls_bpf_ops);
  531. }
  532. static void __exit cls_bpf_exit_mod(void)
  533. {
  534. unregister_tcf_proto_ops(&cls_bpf_ops);
  535. }
  536. module_init(cls_bpf_init_mod);
  537. module_exit(cls_bpf_exit_mod);