act_police.c 15 KB

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