cls_flow.c 15 KB

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