act_police.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /*
  2. * net/sched/police.c Input police filter.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. *
  9. * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
  10. * J Hadi Salim (action changes)
  11. */
  12. #include <asm/uaccess.h>
  13. #include <asm/system.h>
  14. #include <linux/bitops.h>
  15. #include <linux/module.h>
  16. #include <linux/types.h>
  17. #include <linux/kernel.h>
  18. #include <linux/sched.h>
  19. #include <linux/string.h>
  20. #include <linux/mm.h>
  21. #include <linux/socket.h>
  22. #include <linux/sockios.h>
  23. #include <linux/in.h>
  24. #include <linux/errno.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/netdevice.h>
  27. #include <linux/skbuff.h>
  28. #include <linux/module.h>
  29. #include <linux/rtnetlink.h>
  30. #include <linux/init.h>
  31. #include <net/sock.h>
  32. #include <net/act_api.h>
  33. #define L2T(p,L) ((p)->tcfp_R_tab->data[(L)>>(p)->tcfp_R_tab->rate.cell_log])
  34. #define L2T_P(p,L) ((p)->tcfp_P_tab->data[(L)>>(p)->tcfp_P_tab->rate.cell_log])
  35. #define POL_TAB_MASK 15
  36. static struct tcf_common *tcf_police_ht[POL_TAB_MASK + 1];
  37. static u32 police_idx_gen;
  38. static DEFINE_RWLOCK(police_lock);
  39. static struct tcf_hashinfo police_hash_info = {
  40. .htab = tcf_police_ht,
  41. .hmask = POL_TAB_MASK,
  42. .lock = &police_lock,
  43. };
  44. /* Each policer is serialized by its individual spinlock */
  45. #ifdef CONFIG_NET_CLS_ACT
  46. static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *cb,
  47. int type, struct tc_action *a)
  48. {
  49. struct tcf_common *p;
  50. int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
  51. struct rtattr *r;
  52. read_lock(&police_lock);
  53. s_i = cb->args[0];
  54. for (i = 0; i < (POL_TAB_MASK + 1); i++) {
  55. p = tcf_police_ht[tcf_hash(i, POL_TAB_MASK)];
  56. for (; p; p = p->tcfc_next) {
  57. index++;
  58. if (index < s_i)
  59. continue;
  60. a->priv = p;
  61. a->order = index;
  62. r = (struct rtattr*) skb->tail;
  63. RTA_PUT(skb, a->order, 0, NULL);
  64. if (type == RTM_DELACTION)
  65. err = tcf_action_dump_1(skb, a, 0, 1);
  66. else
  67. err = tcf_action_dump_1(skb, a, 0, 0);
  68. if (err < 0) {
  69. index--;
  70. skb_trim(skb, (u8*)r - skb->data);
  71. goto done;
  72. }
  73. r->rta_len = skb->tail - (u8*)r;
  74. n_i++;
  75. }
  76. }
  77. done:
  78. read_unlock(&police_lock);
  79. if (n_i)
  80. cb->args[0] += n_i;
  81. return n_i;
  82. rtattr_failure:
  83. skb_trim(skb, (u8*)r - skb->data);
  84. goto done;
  85. }
  86. #endif
  87. void tcf_police_destroy(struct tcf_police *p)
  88. {
  89. unsigned int h = tcf_hash(p->tcf_index, POL_TAB_MASK);
  90. struct tcf_common **p1p;
  91. for (p1p = &tcf_police_ht[h]; *p1p; p1p = &(*p1p)->tcfc_next) {
  92. if (*p1p == &p->common) {
  93. write_lock_bh(&police_lock);
  94. *p1p = p->tcf_next;
  95. write_unlock_bh(&police_lock);
  96. #ifdef CONFIG_NET_ESTIMATOR
  97. gen_kill_estimator(&p->tcf_bstats,
  98. &p->tcf_rate_est);
  99. #endif
  100. if (p->tcfp_R_tab)
  101. qdisc_put_rtab(p->tcfp_R_tab);
  102. if (p->tcfp_P_tab)
  103. qdisc_put_rtab(p->tcfp_P_tab);
  104. kfree(p);
  105. return;
  106. }
  107. }
  108. BUG_TRAP(0);
  109. }
  110. #ifdef CONFIG_NET_CLS_ACT
  111. static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,
  112. struct tc_action *a, int ovr, int bind)
  113. {
  114. unsigned h;
  115. int ret = 0, err;
  116. struct rtattr *tb[TCA_POLICE_MAX];
  117. struct tc_police *parm;
  118. struct tcf_police *police;
  119. struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
  120. if (rta == NULL || rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0)
  121. return -EINVAL;
  122. if (tb[TCA_POLICE_TBF-1] == NULL ||
  123. RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]) != sizeof(*parm))
  124. return -EINVAL;
  125. parm = RTA_DATA(tb[TCA_POLICE_TBF-1]);
  126. if (tb[TCA_POLICE_RESULT-1] != NULL &&
  127. RTA_PAYLOAD(tb[TCA_POLICE_RESULT-1]) != sizeof(u32))
  128. return -EINVAL;
  129. if (tb[TCA_POLICE_RESULT-1] != NULL &&
  130. RTA_PAYLOAD(tb[TCA_POLICE_RESULT-1]) != sizeof(u32))
  131. return -EINVAL;
  132. if (parm->index) {
  133. struct tcf_common *pc;
  134. pc = tcf_hash_lookup(parm->index, &police_hash_info);
  135. if (pc != NULL) {
  136. a->priv = pc;
  137. police = to_police(pc);
  138. if (bind) {
  139. police->tcf_bindcnt += 1;
  140. police->tcf_refcnt += 1;
  141. }
  142. if (ovr)
  143. goto override;
  144. return ret;
  145. }
  146. }
  147. police = kzalloc(sizeof(*police), GFP_KERNEL);
  148. if (police == NULL)
  149. return -ENOMEM;
  150. ret = ACT_P_CREATED;
  151. police->tcf_refcnt = 1;
  152. spin_lock_init(&police->tcf_lock);
  153. police->tcf_stats_lock = &police->tcf_lock;
  154. if (bind)
  155. police->tcf_bindcnt = 1;
  156. override:
  157. if (parm->rate.rate) {
  158. err = -ENOMEM;
  159. R_tab = qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE-1]);
  160. if (R_tab == NULL)
  161. goto failure;
  162. if (parm->peakrate.rate) {
  163. P_tab = qdisc_get_rtab(&parm->peakrate,
  164. tb[TCA_POLICE_PEAKRATE-1]);
  165. if (P_tab == NULL) {
  166. qdisc_put_rtab(R_tab);
  167. goto failure;
  168. }
  169. }
  170. }
  171. /* No failure allowed after this point */
  172. spin_lock_bh(&police->tcf_lock);
  173. if (R_tab != NULL) {
  174. qdisc_put_rtab(police->tcfp_R_tab);
  175. police->tcfp_R_tab = R_tab;
  176. }
  177. if (P_tab != NULL) {
  178. qdisc_put_rtab(police->tcfp_P_tab);
  179. police->tcfp_P_tab = P_tab;
  180. }
  181. if (tb[TCA_POLICE_RESULT-1])
  182. police->tcfp_result = *(u32*)RTA_DATA(tb[TCA_POLICE_RESULT-1]);
  183. police->tcfp_toks = police->tcfp_burst = parm->burst;
  184. police->tcfp_mtu = parm->mtu;
  185. if (police->tcfp_mtu == 0) {
  186. police->tcfp_mtu = ~0;
  187. if (police->tcfp_R_tab)
  188. police->tcfp_mtu = 255<<police->tcfp_R_tab->rate.cell_log;
  189. }
  190. if (police->tcfp_P_tab)
  191. police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu);
  192. police->tcf_action = parm->action;
  193. #ifdef CONFIG_NET_ESTIMATOR
  194. if (tb[TCA_POLICE_AVRATE-1])
  195. police->tcfp_ewma_rate =
  196. *(u32*)RTA_DATA(tb[TCA_POLICE_AVRATE-1]);
  197. if (est)
  198. gen_replace_estimator(&police->tcf_bstats,
  199. &police->tcf_rate_est,
  200. police->tcf_stats_lock, est);
  201. #endif
  202. spin_unlock_bh(&police->tcf_lock);
  203. if (ret != ACT_P_CREATED)
  204. return ret;
  205. PSCHED_GET_TIME(police->tcfp_t_c);
  206. police->tcf_index = parm->index ? parm->index :
  207. tcf_hash_new_index(&police_idx_gen, &police_hash_info);
  208. h = tcf_hash(police->tcf_index, POL_TAB_MASK);
  209. write_lock_bh(&police_lock);
  210. police->tcf_next = tcf_police_ht[h];
  211. tcf_police_ht[h] = &police->common;
  212. write_unlock_bh(&police_lock);
  213. a->priv = police;
  214. return ret;
  215. failure:
  216. if (ret == ACT_P_CREATED)
  217. kfree(police);
  218. return err;
  219. }
  220. static int tcf_act_police_cleanup(struct tc_action *a, int bind)
  221. {
  222. struct tcf_police *p = a->priv;
  223. if (p != NULL)
  224. return tcf_police_release(p, bind);
  225. return 0;
  226. }
  227. static int tcf_act_police(struct sk_buff *skb, struct tc_action *a,
  228. struct tcf_result *res)
  229. {
  230. struct tcf_police *police = a->priv;
  231. psched_time_t now;
  232. long toks;
  233. long ptoks = 0;
  234. spin_lock(&police->tcf_lock);
  235. police->tcf_bstats.bytes += skb->len;
  236. police->tcf_bstats.packets++;
  237. #ifdef CONFIG_NET_ESTIMATOR
  238. if (police->tcfp_ewma_rate &&
  239. police->tcf_rate_est.bps >= police->tcfp_ewma_rate) {
  240. police->tcf_qstats.overlimits++;
  241. spin_unlock(&police->tcf_lock);
  242. return police->tcf_action;
  243. }
  244. #endif
  245. if (skb->len <= police->tcfp_mtu) {
  246. if (police->tcfp_R_tab == NULL) {
  247. spin_unlock(&police->tcf_lock);
  248. return police->tcfp_result;
  249. }
  250. PSCHED_GET_TIME(now);
  251. toks = PSCHED_TDIFF_SAFE(now, police->tcfp_t_c,
  252. police->tcfp_burst);
  253. if (police->tcfp_P_tab) {
  254. ptoks = toks + police->tcfp_ptoks;
  255. if (ptoks > (long)L2T_P(police, police->tcfp_mtu))
  256. ptoks = (long)L2T_P(police, police->tcfp_mtu);
  257. ptoks -= L2T_P(police, skb->len);
  258. }
  259. toks += police->tcfp_toks;
  260. if (toks > (long)police->tcfp_burst)
  261. toks = police->tcfp_burst;
  262. toks -= L2T(police, skb->len);
  263. if ((toks|ptoks) >= 0) {
  264. police->tcfp_t_c = now;
  265. police->tcfp_toks = toks;
  266. police->tcfp_ptoks = ptoks;
  267. spin_unlock(&police->tcf_lock);
  268. return police->tcfp_result;
  269. }
  270. }
  271. police->tcf_qstats.overlimits++;
  272. spin_unlock(&police->tcf_lock);
  273. return police->tcf_action;
  274. }
  275. static int
  276. tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
  277. {
  278. unsigned char *b = skb->tail;
  279. struct tcf_police *police = a->priv;
  280. struct tc_police opt;
  281. opt.index = police->tcf_index;
  282. opt.action = police->tcf_action;
  283. opt.mtu = police->tcfp_mtu;
  284. opt.burst = police->tcfp_burst;
  285. opt.refcnt = police->tcf_refcnt - ref;
  286. opt.bindcnt = police->tcf_bindcnt - bind;
  287. if (police->tcfp_R_tab)
  288. opt.rate = police->tcfp_R_tab->rate;
  289. else
  290. memset(&opt.rate, 0, sizeof(opt.rate));
  291. if (police->tcfp_P_tab)
  292. opt.peakrate = police->tcfp_P_tab->rate;
  293. else
  294. memset(&opt.peakrate, 0, sizeof(opt.peakrate));
  295. RTA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt);
  296. if (police->tcfp_result)
  297. RTA_PUT(skb, TCA_POLICE_RESULT, sizeof(int),
  298. &police->tcfp_result);
  299. #ifdef CONFIG_NET_ESTIMATOR
  300. if (police->tcfp_ewma_rate)
  301. RTA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate);
  302. #endif
  303. return skb->len;
  304. rtattr_failure:
  305. skb_trim(skb, b - skb->data);
  306. return -1;
  307. }
  308. MODULE_AUTHOR("Alexey Kuznetsov");
  309. MODULE_DESCRIPTION("Policing actions");
  310. MODULE_LICENSE("GPL");
  311. static struct tc_action_ops act_police_ops = {
  312. .kind = "police",
  313. .hinfo = &police_hash_info,
  314. .type = TCA_ID_POLICE,
  315. .capab = TCA_CAP_NONE,
  316. .owner = THIS_MODULE,
  317. .act = tcf_act_police,
  318. .dump = tcf_act_police_dump,
  319. .cleanup = tcf_act_police_cleanup,
  320. .lookup = tcf_hash_search,
  321. .init = tcf_act_police_locate,
  322. .walk = tcf_act_police_walker
  323. };
  324. static int __init
  325. police_init_module(void)
  326. {
  327. return tcf_register_action(&act_police_ops);
  328. }
  329. static void __exit
  330. police_cleanup_module(void)
  331. {
  332. tcf_unregister_action(&act_police_ops);
  333. }
  334. module_init(police_init_module);
  335. module_exit(police_cleanup_module);
  336. #else /* CONFIG_NET_CLS_ACT */
  337. static struct tcf_common *tcf_police_lookup(u32 index)
  338. {
  339. struct tcf_hashinfo *hinfo = &police_hash_info;
  340. struct tcf_common *p;
  341. read_lock(hinfo->lock);
  342. for (p = hinfo->htab[tcf_hash(index, hinfo->hmask)]; p;
  343. p = p->tcfc_next) {
  344. if (p->tcfc_index == index)
  345. break;
  346. }
  347. read_unlock(hinfo->lock);
  348. return p;
  349. }
  350. static u32 tcf_police_new_index(void)
  351. {
  352. u32 *idx_gen = &police_idx_gen;
  353. u32 val = *idx_gen;
  354. do {
  355. if (++val == 0)
  356. val = 1;
  357. } while (tcf_police_lookup(val));
  358. return (*idx_gen = val);
  359. }
  360. struct tcf_police *tcf_police_locate(struct rtattr *rta, struct rtattr *est)
  361. {
  362. unsigned int h;
  363. struct tcf_police *police;
  364. struct rtattr *tb[TCA_POLICE_MAX];
  365. struct tc_police *parm;
  366. if (rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0)
  367. return NULL;
  368. if (tb[TCA_POLICE_TBF-1] == NULL ||
  369. RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]) != sizeof(*parm))
  370. return NULL;
  371. parm = RTA_DATA(tb[TCA_POLICE_TBF-1]);
  372. if (parm->index) {
  373. struct tcf_common *pc;
  374. pc = tcf_police_lookup(parm->index);
  375. if (pc) {
  376. police = to_police(pc);
  377. police->tcf_refcnt++;
  378. return police;
  379. }
  380. }
  381. police = kzalloc(sizeof(*police), GFP_KERNEL);
  382. if (unlikely(!police))
  383. return NULL;
  384. police->tcf_refcnt = 1;
  385. spin_lock_init(&police->tcf_lock);
  386. police->tcf_stats_lock = &police->tcf_lock;
  387. if (parm->rate.rate) {
  388. police->tcfp_R_tab =
  389. qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE-1]);
  390. if (police->tcfp_R_tab == NULL)
  391. goto failure;
  392. if (parm->peakrate.rate) {
  393. police->tcfp_P_tab =
  394. qdisc_get_rtab(&parm->peakrate,
  395. tb[TCA_POLICE_PEAKRATE-1]);
  396. if (police->tcfp_P_tab == NULL)
  397. goto failure;
  398. }
  399. }
  400. if (tb[TCA_POLICE_RESULT-1]) {
  401. if (RTA_PAYLOAD(tb[TCA_POLICE_RESULT-1]) != sizeof(u32))
  402. goto failure;
  403. police->tcfp_result = *(u32*)RTA_DATA(tb[TCA_POLICE_RESULT-1]);
  404. }
  405. #ifdef CONFIG_NET_ESTIMATOR
  406. if (tb[TCA_POLICE_AVRATE-1]) {
  407. if (RTA_PAYLOAD(tb[TCA_POLICE_AVRATE-1]) != sizeof(u32))
  408. goto failure;
  409. police->tcfp_ewma_rate =
  410. *(u32*)RTA_DATA(tb[TCA_POLICE_AVRATE-1]);
  411. }
  412. #endif
  413. police->tcfp_toks = police->tcfp_burst = parm->burst;
  414. police->tcfp_mtu = parm->mtu;
  415. if (police->tcfp_mtu == 0) {
  416. police->tcfp_mtu = ~0;
  417. if (police->tcfp_R_tab)
  418. police->tcfp_mtu = 255<<police->tcfp_R_tab->rate.cell_log;
  419. }
  420. if (police->tcfp_P_tab)
  421. police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu);
  422. PSCHED_GET_TIME(police->tcfp_t_c);
  423. police->tcf_index = parm->index ? parm->index :
  424. tcf_police_new_index();
  425. police->tcf_action = parm->action;
  426. #ifdef CONFIG_NET_ESTIMATOR
  427. if (est)
  428. gen_new_estimator(&police->tcf_bstats, &police->tcf_rate_est,
  429. police->tcf_stats_lock, est);
  430. #endif
  431. h = tcf_hash(police->tcf_index, POL_TAB_MASK);
  432. write_lock_bh(&police_lock);
  433. police->tcf_next = tcf_police_ht[h];
  434. tcf_police_ht[h] = &police->common;
  435. write_unlock_bh(&police_lock);
  436. return police;
  437. failure:
  438. if (police->tcfp_R_tab)
  439. qdisc_put_rtab(police->tcfp_R_tab);
  440. kfree(police);
  441. return NULL;
  442. }
  443. int tcf_police(struct sk_buff *skb, struct tcf_police *police)
  444. {
  445. psched_time_t now;
  446. long toks;
  447. long ptoks = 0;
  448. spin_lock(&police->tcf_lock);
  449. police->tcf_bstats.bytes += skb->len;
  450. police->tcf_bstats.packets++;
  451. #ifdef CONFIG_NET_ESTIMATOR
  452. if (police->tcfp_ewma_rate &&
  453. police->tcf_rate_est.bps >= police->tcfp_ewma_rate) {
  454. police->tcf_qstats.overlimits++;
  455. spin_unlock(&police->tcf_lock);
  456. return police->tcf_action;
  457. }
  458. #endif
  459. if (skb->len <= police->tcfp_mtu) {
  460. if (police->tcfp_R_tab == NULL) {
  461. spin_unlock(&police->tcf_lock);
  462. return police->tcfp_result;
  463. }
  464. PSCHED_GET_TIME(now);
  465. toks = PSCHED_TDIFF_SAFE(now, police->tcfp_t_c,
  466. police->tcfp_burst);
  467. if (police->tcfp_P_tab) {
  468. ptoks = toks + police->tcfp_ptoks;
  469. if (ptoks > (long)L2T_P(police, police->tcfp_mtu))
  470. ptoks = (long)L2T_P(police, police->tcfp_mtu);
  471. ptoks -= L2T_P(police, skb->len);
  472. }
  473. toks += police->tcfp_toks;
  474. if (toks > (long)police->tcfp_burst)
  475. toks = police->tcfp_burst;
  476. toks -= L2T(police, skb->len);
  477. if ((toks|ptoks) >= 0) {
  478. police->tcfp_t_c = now;
  479. police->tcfp_toks = toks;
  480. police->tcfp_ptoks = ptoks;
  481. spin_unlock(&police->tcf_lock);
  482. return police->tcfp_result;
  483. }
  484. }
  485. police->tcf_qstats.overlimits++;
  486. spin_unlock(&police->tcf_lock);
  487. return police->tcf_action;
  488. }
  489. EXPORT_SYMBOL(tcf_police);
  490. int tcf_police_dump(struct sk_buff *skb, struct tcf_police *police)
  491. {
  492. unsigned char *b = skb->tail;
  493. struct tc_police opt;
  494. opt.index = police->tcf_index;
  495. opt.action = police->tcf_action;
  496. opt.mtu = police->tcfp_mtu;
  497. opt.burst = police->tcfp_burst;
  498. if (police->tcfp_R_tab)
  499. opt.rate = police->tcfp_R_tab->rate;
  500. else
  501. memset(&opt.rate, 0, sizeof(opt.rate));
  502. if (police->tcfp_P_tab)
  503. opt.peakrate = police->tcfp_P_tab->rate;
  504. else
  505. memset(&opt.peakrate, 0, sizeof(opt.peakrate));
  506. RTA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt);
  507. if (police->tcfp_result)
  508. RTA_PUT(skb, TCA_POLICE_RESULT, sizeof(int),
  509. &police->tcfp_result);
  510. #ifdef CONFIG_NET_ESTIMATOR
  511. if (police->tcfp_ewma_rate)
  512. RTA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate);
  513. #endif
  514. return skb->len;
  515. rtattr_failure:
  516. skb_trim(skb, b - skb->data);
  517. return -1;
  518. }
  519. int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *police)
  520. {
  521. struct gnet_dump d;
  522. if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
  523. TCA_XSTATS, police->tcf_stats_lock,
  524. &d) < 0)
  525. goto errout;
  526. if (gnet_stats_copy_basic(&d, &police->tcf_bstats) < 0 ||
  527. #ifdef CONFIG_NET_ESTIMATOR
  528. gnet_stats_copy_rate_est(&d, &police->tcf_rate_est) < 0 ||
  529. #endif
  530. gnet_stats_copy_queue(&d, &police->tcf_qstats) < 0)
  531. goto errout;
  532. if (gnet_stats_finish_copy(&d) < 0)
  533. goto errout;
  534. return 0;
  535. errout:
  536. return -1;
  537. }
  538. #endif /* CONFIG_NET_CLS_ACT */