cls_flow.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * net/sched/cls_flow.c Generic flow classifier
  3. *
  4. * Copyright (c) 2007, 2008 Patrick McHardy <kaber@trash.net>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/list.h>
  14. #include <linux/jhash.h>
  15. #include <linux/random.h>
  16. #include <linux/pkt_cls.h>
  17. #include <linux/skbuff.h>
  18. #include <linux/in.h>
  19. #include <linux/ip.h>
  20. #include <linux/ipv6.h>
  21. #include <linux/if_vlan.h>
  22. #include <net/pkt_cls.h>
  23. #include <net/ip.h>
  24. #include <net/route.h>
  25. #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
  26. #include <net/netfilter/nf_conntrack.h>
  27. #endif
  28. struct flow_head {
  29. struct list_head filters;
  30. };
  31. struct flow_filter {
  32. struct list_head list;
  33. struct tcf_exts exts;
  34. struct tcf_ematch_tree ematches;
  35. u32 handle;
  36. u32 nkeys;
  37. u32 keymask;
  38. u32 mode;
  39. u32 mask;
  40. u32 xor;
  41. u32 rshift;
  42. u32 addend;
  43. u32 divisor;
  44. u32 baseclass;
  45. };
  46. static u32 flow_hashrnd __read_mostly;
  47. static int flow_hashrnd_initted __read_mostly;
  48. static const struct tcf_ext_map flow_ext_map = {
  49. .action = TCA_FLOW_ACT,
  50. .police = TCA_FLOW_POLICE,
  51. };
  52. static inline u32 addr_fold(void *addr)
  53. {
  54. unsigned long a = (unsigned long)addr;
  55. return (a & 0xFFFFFFFF) ^ (BITS_PER_LONG > 32 ? a >> 32 : 0);
  56. }
  57. static u32 flow_get_src(const struct sk_buff *skb)
  58. {
  59. switch (skb->protocol) {
  60. case __constant_htons(ETH_P_IP):
  61. return ntohl(ip_hdr(skb)->saddr);
  62. case __constant_htons(ETH_P_IPV6):
  63. return ntohl(ipv6_hdr(skb)->saddr.s6_addr32[3]);
  64. default:
  65. return addr_fold(skb->sk);
  66. }
  67. }
  68. static u32 flow_get_dst(const struct sk_buff *skb)
  69. {
  70. switch (skb->protocol) {
  71. case __constant_htons(ETH_P_IP):
  72. return ntohl(ip_hdr(skb)->daddr);
  73. case __constant_htons(ETH_P_IPV6):
  74. return ntohl(ipv6_hdr(skb)->daddr.s6_addr32[3]);
  75. default:
  76. return addr_fold(skb->dst) ^ (__force u16)skb->protocol;
  77. }
  78. }
  79. static u32 flow_get_proto(const struct sk_buff *skb)
  80. {
  81. switch (skb->protocol) {
  82. case __constant_htons(ETH_P_IP):
  83. return ip_hdr(skb)->protocol;
  84. case __constant_htons(ETH_P_IPV6):
  85. return ipv6_hdr(skb)->nexthdr;
  86. default:
  87. return 0;
  88. }
  89. }
  90. static int has_ports(u8 protocol)
  91. {
  92. switch (protocol) {
  93. case IPPROTO_TCP:
  94. case IPPROTO_UDP:
  95. case IPPROTO_UDPLITE:
  96. case IPPROTO_SCTP:
  97. case IPPROTO_DCCP:
  98. case IPPROTO_ESP:
  99. return 1;
  100. default:
  101. return 0;
  102. }
  103. }
  104. static u32 flow_get_proto_src(const struct sk_buff *skb)
  105. {
  106. u32 res = 0;
  107. switch (skb->protocol) {
  108. case __constant_htons(ETH_P_IP): {
  109. struct iphdr *iph = ip_hdr(skb);
  110. if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
  111. has_ports(iph->protocol))
  112. res = ntohs(*(__be16 *)((void *)iph + iph->ihl * 4));
  113. break;
  114. }
  115. case __constant_htons(ETH_P_IPV6): {
  116. struct ipv6hdr *iph = ipv6_hdr(skb);
  117. if (has_ports(iph->nexthdr))
  118. res = ntohs(*(__be16 *)&iph[1]);
  119. break;
  120. }
  121. default:
  122. res = addr_fold(skb->sk);
  123. }
  124. return res;
  125. }
  126. static u32 flow_get_proto_dst(const struct sk_buff *skb)
  127. {
  128. u32 res = 0;
  129. switch (skb->protocol) {
  130. case __constant_htons(ETH_P_IP): {
  131. struct iphdr *iph = ip_hdr(skb);
  132. if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
  133. has_ports(iph->protocol))
  134. res = ntohs(*(__be16 *)((void *)iph + iph->ihl * 4 + 2));
  135. break;
  136. }
  137. case __constant_htons(ETH_P_IPV6): {
  138. struct ipv6hdr *iph = ipv6_hdr(skb);
  139. if (has_ports(iph->nexthdr))
  140. res = ntohs(*(__be16 *)((void *)&iph[1] + 2));
  141. break;
  142. }
  143. default:
  144. res = addr_fold(skb->dst) ^ (__force u16)skb->protocol;
  145. }
  146. return res;
  147. }
  148. static u32 flow_get_iif(const struct sk_buff *skb)
  149. {
  150. return skb->iif;
  151. }
  152. static u32 flow_get_priority(const struct sk_buff *skb)
  153. {
  154. return skb->priority;
  155. }
  156. static u32 flow_get_mark(const struct sk_buff *skb)
  157. {
  158. return skb->mark;
  159. }
  160. static u32 flow_get_nfct(const struct sk_buff *skb)
  161. {
  162. #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
  163. return addr_fold(skb->nfct);
  164. #else
  165. return 0;
  166. #endif
  167. }
  168. #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
  169. #define CTTUPLE(skb, member) \
  170. ({ \
  171. enum ip_conntrack_info ctinfo; \
  172. struct nf_conn *ct = nf_ct_get(skb, &ctinfo); \
  173. if (ct == NULL) \
  174. goto fallback; \
  175. ct->tuplehash[CTINFO2DIR(ctinfo)].tuple.member; \
  176. })
  177. #else
  178. #define CTTUPLE(skb, member) \
  179. ({ \
  180. goto fallback; \
  181. 0; \
  182. })
  183. #endif
  184. static u32 flow_get_nfct_src(const struct sk_buff *skb)
  185. {
  186. switch (skb->protocol) {
  187. case __constant_htons(ETH_P_IP):
  188. return ntohl(CTTUPLE(skb, src.u3.ip));
  189. case __constant_htons(ETH_P_IPV6):
  190. return ntohl(CTTUPLE(skb, src.u3.ip6[3]));
  191. }
  192. fallback:
  193. return flow_get_src(skb);
  194. }
  195. static u32 flow_get_nfct_dst(const struct sk_buff *skb)
  196. {
  197. switch (skb->protocol) {
  198. case __constant_htons(ETH_P_IP):
  199. return ntohl(CTTUPLE(skb, dst.u3.ip));
  200. case __constant_htons(ETH_P_IPV6):
  201. return ntohl(CTTUPLE(skb, dst.u3.ip6[3]));
  202. }
  203. fallback:
  204. return flow_get_dst(skb);
  205. }
  206. static u32 flow_get_nfct_proto_src(const struct sk_buff *skb)
  207. {
  208. return ntohs(CTTUPLE(skb, src.u.all));
  209. fallback:
  210. return flow_get_proto_src(skb);
  211. }
  212. static u32 flow_get_nfct_proto_dst(const struct sk_buff *skb)
  213. {
  214. return ntohs(CTTUPLE(skb, dst.u.all));
  215. fallback:
  216. return flow_get_proto_dst(skb);
  217. }
  218. static u32 flow_get_rtclassid(const struct sk_buff *skb)
  219. {
  220. #ifdef CONFIG_NET_CLS_ROUTE
  221. if (skb->dst)
  222. return skb->dst->tclassid;
  223. #endif
  224. return 0;
  225. }
  226. static u32 flow_get_skuid(const struct sk_buff *skb)
  227. {
  228. if (skb->sk && skb->sk->sk_socket && skb->sk->sk_socket->file)
  229. return skb->sk->sk_socket->file->f_uid;
  230. return 0;
  231. }
  232. static u32 flow_get_skgid(const struct sk_buff *skb)
  233. {
  234. if (skb->sk && skb->sk->sk_socket && skb->sk->sk_socket->file)
  235. return skb->sk->sk_socket->file->f_gid;
  236. return 0;
  237. }
  238. static u32 flow_get_vlan_tag(const struct sk_buff *skb)
  239. {
  240. u16 uninitialized_var(tag);
  241. if (vlan_get_tag(skb, &tag) < 0)
  242. return 0;
  243. return tag & VLAN_VID_MASK;
  244. }
  245. static u32 flow_key_get(const struct sk_buff *skb, int key)
  246. {
  247. switch (key) {
  248. case FLOW_KEY_SRC:
  249. return flow_get_src(skb);
  250. case FLOW_KEY_DST:
  251. return flow_get_dst(skb);
  252. case FLOW_KEY_PROTO:
  253. return flow_get_proto(skb);
  254. case FLOW_KEY_PROTO_SRC:
  255. return flow_get_proto_src(skb);
  256. case FLOW_KEY_PROTO_DST:
  257. return flow_get_proto_dst(skb);
  258. case FLOW_KEY_IIF:
  259. return flow_get_iif(skb);
  260. case FLOW_KEY_PRIORITY:
  261. return flow_get_priority(skb);
  262. case FLOW_KEY_MARK:
  263. return flow_get_mark(skb);
  264. case FLOW_KEY_NFCT:
  265. return flow_get_nfct(skb);
  266. case FLOW_KEY_NFCT_SRC:
  267. return flow_get_nfct_src(skb);
  268. case FLOW_KEY_NFCT_DST:
  269. return flow_get_nfct_dst(skb);
  270. case FLOW_KEY_NFCT_PROTO_SRC:
  271. return flow_get_nfct_proto_src(skb);
  272. case FLOW_KEY_NFCT_PROTO_DST:
  273. return flow_get_nfct_proto_dst(skb);
  274. case FLOW_KEY_RTCLASSID:
  275. return flow_get_rtclassid(skb);
  276. case FLOW_KEY_SKUID:
  277. return flow_get_skuid(skb);
  278. case FLOW_KEY_SKGID:
  279. return flow_get_skgid(skb);
  280. case FLOW_KEY_VLAN_TAG:
  281. return flow_get_vlan_tag(skb);
  282. default:
  283. WARN_ON(1);
  284. return 0;
  285. }
  286. }
  287. static int flow_classify(struct sk_buff *skb, struct tcf_proto *tp,
  288. struct tcf_result *res)
  289. {
  290. struct flow_head *head = tp->root;
  291. struct flow_filter *f;
  292. u32 keymask;
  293. u32 classid;
  294. unsigned int n, key;
  295. int r;
  296. list_for_each_entry(f, &head->filters, list) {
  297. u32 keys[f->nkeys];
  298. if (!tcf_em_tree_match(skb, &f->ematches, NULL))
  299. continue;
  300. keymask = f->keymask;
  301. for (n = 0; n < f->nkeys; n++) {
  302. key = ffs(keymask) - 1;
  303. keymask &= ~(1 << key);
  304. keys[n] = flow_key_get(skb, key);
  305. }
  306. if (f->mode == FLOW_MODE_HASH)
  307. classid = jhash2(keys, f->nkeys, flow_hashrnd);
  308. else {
  309. classid = keys[0];
  310. classid = (classid & f->mask) ^ f->xor;
  311. classid = (classid >> f->rshift) + f->addend;
  312. }
  313. if (f->divisor)
  314. classid %= f->divisor;
  315. res->class = 0;
  316. res->classid = TC_H_MAKE(f->baseclass, f->baseclass + classid);
  317. r = tcf_exts_exec(skb, &f->exts, res);
  318. if (r < 0)
  319. continue;
  320. return r;
  321. }
  322. return -1;
  323. }
  324. static const struct nla_policy flow_policy[TCA_FLOW_MAX + 1] = {
  325. [TCA_FLOW_KEYS] = { .type = NLA_U32 },
  326. [TCA_FLOW_MODE] = { .type = NLA_U32 },
  327. [TCA_FLOW_BASECLASS] = { .type = NLA_U32 },
  328. [TCA_FLOW_RSHIFT] = { .type = NLA_U32 },
  329. [TCA_FLOW_ADDEND] = { .type = NLA_U32 },
  330. [TCA_FLOW_MASK] = { .type = NLA_U32 },
  331. [TCA_FLOW_XOR] = { .type = NLA_U32 },
  332. [TCA_FLOW_DIVISOR] = { .type = NLA_U32 },
  333. [TCA_FLOW_ACT] = { .type = NLA_NESTED },
  334. [TCA_FLOW_POLICE] = { .type = NLA_NESTED },
  335. [TCA_FLOW_EMATCHES] = { .type = NLA_NESTED },
  336. };
  337. static int flow_change(struct tcf_proto *tp, unsigned long base,
  338. u32 handle, struct nlattr **tca,
  339. unsigned long *arg)
  340. {
  341. struct flow_head *head = tp->root;
  342. struct flow_filter *f;
  343. struct nlattr *opt = tca[TCA_OPTIONS];
  344. struct nlattr *tb[TCA_FLOW_MAX + 1];
  345. struct tcf_exts e;
  346. struct tcf_ematch_tree t;
  347. unsigned int nkeys = 0;
  348. u32 baseclass = 0;
  349. u32 keymask = 0;
  350. u32 mode;
  351. int err;
  352. if (opt == NULL)
  353. return -EINVAL;
  354. err = nla_parse_nested(tb, TCA_FLOW_MAX, opt, flow_policy);
  355. if (err < 0)
  356. return err;
  357. if (tb[TCA_FLOW_BASECLASS]) {
  358. baseclass = nla_get_u32(tb[TCA_FLOW_BASECLASS]);
  359. if (TC_H_MIN(baseclass) == 0)
  360. return -EINVAL;
  361. }
  362. if (tb[TCA_FLOW_KEYS]) {
  363. keymask = nla_get_u32(tb[TCA_FLOW_KEYS]);
  364. nkeys = hweight32(keymask);
  365. if (nkeys == 0)
  366. return -EINVAL;
  367. if (fls(keymask) - 1 > FLOW_KEY_MAX)
  368. return -EOPNOTSUPP;
  369. }
  370. err = tcf_exts_validate(tp, tb, tca[TCA_RATE], &e, &flow_ext_map);
  371. if (err < 0)
  372. return err;
  373. err = tcf_em_tree_validate(tp, tb[TCA_FLOW_EMATCHES], &t);
  374. if (err < 0)
  375. goto err1;
  376. f = (struct flow_filter *)*arg;
  377. if (f != NULL) {
  378. err = -EINVAL;
  379. if (f->handle != handle && handle)
  380. goto err2;
  381. mode = f->mode;
  382. if (tb[TCA_FLOW_MODE])
  383. mode = nla_get_u32(tb[TCA_FLOW_MODE]);
  384. if (mode != FLOW_MODE_HASH && nkeys > 1)
  385. goto err2;
  386. } else {
  387. err = -EINVAL;
  388. if (!handle)
  389. goto err2;
  390. if (!tb[TCA_FLOW_KEYS])
  391. goto err2;
  392. mode = FLOW_MODE_MAP;
  393. if (tb[TCA_FLOW_MODE])
  394. mode = nla_get_u32(tb[TCA_FLOW_MODE]);
  395. if (mode != FLOW_MODE_HASH && nkeys > 1)
  396. goto err2;
  397. if (TC_H_MAJ(baseclass) == 0)
  398. baseclass = TC_H_MAKE(tp->q->handle, baseclass);
  399. if (TC_H_MIN(baseclass) == 0)
  400. baseclass = TC_H_MAKE(baseclass, 1);
  401. err = -ENOBUFS;
  402. f = kzalloc(sizeof(*f), GFP_KERNEL);
  403. if (f == NULL)
  404. goto err2;
  405. f->handle = handle;
  406. f->mask = ~0U;
  407. }
  408. tcf_exts_change(tp, &f->exts, &e);
  409. tcf_em_tree_change(tp, &f->ematches, &t);
  410. tcf_tree_lock(tp);
  411. if (tb[TCA_FLOW_KEYS]) {
  412. f->keymask = keymask;
  413. f->nkeys = nkeys;
  414. }
  415. f->mode = mode;
  416. if (tb[TCA_FLOW_MASK])
  417. f->mask = nla_get_u32(tb[TCA_FLOW_MASK]);
  418. if (tb[TCA_FLOW_XOR])
  419. f->xor = nla_get_u32(tb[TCA_FLOW_XOR]);
  420. if (tb[TCA_FLOW_RSHIFT])
  421. f->rshift = nla_get_u32(tb[TCA_FLOW_RSHIFT]);
  422. if (tb[TCA_FLOW_ADDEND])
  423. f->addend = nla_get_u32(tb[TCA_FLOW_ADDEND]);
  424. if (tb[TCA_FLOW_DIVISOR])
  425. f->divisor = nla_get_u32(tb[TCA_FLOW_DIVISOR]);
  426. if (baseclass)
  427. f->baseclass = baseclass;
  428. if (*arg == 0)
  429. list_add_tail(&f->list, &head->filters);
  430. tcf_tree_unlock(tp);
  431. *arg = (unsigned long)f;
  432. return 0;
  433. err2:
  434. tcf_em_tree_destroy(tp, &t);
  435. err1:
  436. tcf_exts_destroy(tp, &e);
  437. return err;
  438. }
  439. static void flow_destroy_filter(struct tcf_proto *tp, struct flow_filter *f)
  440. {
  441. tcf_exts_destroy(tp, &f->exts);
  442. tcf_em_tree_destroy(tp, &f->ematches);
  443. kfree(f);
  444. }
  445. static int flow_delete(struct tcf_proto *tp, unsigned long arg)
  446. {
  447. struct flow_filter *f = (struct flow_filter *)arg;
  448. tcf_tree_lock(tp);
  449. list_del(&f->list);
  450. tcf_tree_unlock(tp);
  451. flow_destroy_filter(tp, f);
  452. return 0;
  453. }
  454. static int flow_init(struct tcf_proto *tp)
  455. {
  456. struct flow_head *head;
  457. if (!flow_hashrnd_initted) {
  458. get_random_bytes(&flow_hashrnd, 4);
  459. flow_hashrnd_initted = 1;
  460. }
  461. head = kzalloc(sizeof(*head), GFP_KERNEL);
  462. if (head == NULL)
  463. return -ENOBUFS;
  464. INIT_LIST_HEAD(&head->filters);
  465. tp->root = head;
  466. return 0;
  467. }
  468. static void flow_destroy(struct tcf_proto *tp)
  469. {
  470. struct flow_head *head = tp->root;
  471. struct flow_filter *f, *next;
  472. list_for_each_entry_safe(f, next, &head->filters, list) {
  473. list_del(&f->list);
  474. flow_destroy_filter(tp, f);
  475. }
  476. kfree(head);
  477. }
  478. static unsigned long flow_get(struct tcf_proto *tp, u32 handle)
  479. {
  480. struct flow_head *head = tp->root;
  481. struct flow_filter *f;
  482. list_for_each_entry(f, &head->filters, list)
  483. if (f->handle == handle)
  484. return (unsigned long)f;
  485. return 0;
  486. }
  487. static void flow_put(struct tcf_proto *tp, unsigned long f)
  488. {
  489. return;
  490. }
  491. static int flow_dump(struct tcf_proto *tp, unsigned long fh,
  492. struct sk_buff *skb, struct tcmsg *t)
  493. {
  494. struct flow_filter *f = (struct flow_filter *)fh;
  495. struct nlattr *nest;
  496. if (f == NULL)
  497. return skb->len;
  498. t->tcm_handle = f->handle;
  499. nest = nla_nest_start(skb, TCA_OPTIONS);
  500. if (nest == NULL)
  501. goto nla_put_failure;
  502. NLA_PUT_U32(skb, TCA_FLOW_KEYS, f->keymask);
  503. NLA_PUT_U32(skb, TCA_FLOW_MODE, f->mode);
  504. if (f->mask != ~0 || f->xor != 0) {
  505. NLA_PUT_U32(skb, TCA_FLOW_MASK, f->mask);
  506. NLA_PUT_U32(skb, TCA_FLOW_XOR, f->xor);
  507. }
  508. if (f->rshift)
  509. NLA_PUT_U32(skb, TCA_FLOW_RSHIFT, f->rshift);
  510. if (f->addend)
  511. NLA_PUT_U32(skb, TCA_FLOW_ADDEND, f->addend);
  512. if (f->divisor)
  513. NLA_PUT_U32(skb, TCA_FLOW_DIVISOR, f->divisor);
  514. if (f->baseclass)
  515. NLA_PUT_U32(skb, TCA_FLOW_BASECLASS, f->baseclass);
  516. if (tcf_exts_dump(skb, &f->exts, &flow_ext_map) < 0)
  517. goto nla_put_failure;
  518. #ifdef CONFIG_NET_EMATCH
  519. if (f->ematches.hdr.nmatches &&
  520. tcf_em_tree_dump(skb, &f->ematches, TCA_FLOW_EMATCHES) < 0)
  521. goto nla_put_failure;
  522. #endif
  523. nla_nest_end(skb, nest);
  524. if (tcf_exts_dump_stats(skb, &f->exts, &flow_ext_map) < 0)
  525. goto nla_put_failure;
  526. return skb->len;
  527. nla_put_failure:
  528. nlmsg_trim(skb, nest);
  529. return -1;
  530. }
  531. static void flow_walk(struct tcf_proto *tp, struct tcf_walker *arg)
  532. {
  533. struct flow_head *head = tp->root;
  534. struct flow_filter *f;
  535. list_for_each_entry(f, &head->filters, list) {
  536. if (arg->count < arg->skip)
  537. goto skip;
  538. if (arg->fn(tp, (unsigned long)f, arg) < 0) {
  539. arg->stop = 1;
  540. break;
  541. }
  542. skip:
  543. arg->count++;
  544. }
  545. }
  546. static struct tcf_proto_ops cls_flow_ops __read_mostly = {
  547. .kind = "flow",
  548. .classify = flow_classify,
  549. .init = flow_init,
  550. .destroy = flow_destroy,
  551. .change = flow_change,
  552. .delete = flow_delete,
  553. .get = flow_get,
  554. .put = flow_put,
  555. .dump = flow_dump,
  556. .walk = flow_walk,
  557. .owner = THIS_MODULE,
  558. };
  559. static int __init cls_flow_init(void)
  560. {
  561. return register_tcf_proto_ops(&cls_flow_ops);
  562. }
  563. static void __exit cls_flow_exit(void)
  564. {
  565. unregister_tcf_proto_ops(&cls_flow_ops);
  566. }
  567. module_init(cls_flow_init);
  568. module_exit(cls_flow_exit);
  569. MODULE_LICENSE("GPL");
  570. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  571. MODULE_DESCRIPTION("TC flow classifier");