sch_api.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. /*
  2. * net/sched/sch_api.c Packet scheduler API.
  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. *
  11. * Fixes:
  12. *
  13. * Rani Assaf <rani@magic.metawire.com> :980802: JIFFIES and CPU clock sources are repaired.
  14. * Eduardo J. Blanco <ejbs@netlabs.com.uy> :990222: kmod support
  15. * Jamal Hadi Salim <hadi@nortelnetworks.com>: 990601: ingress support
  16. */
  17. #include <linux/config.h>
  18. #include <linux/module.h>
  19. #include <linux/types.h>
  20. #include <linux/kernel.h>
  21. #include <linux/sched.h>
  22. #include <linux/string.h>
  23. #include <linux/mm.h>
  24. #include <linux/socket.h>
  25. #include <linux/sockios.h>
  26. #include <linux/in.h>
  27. #include <linux/errno.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/netdevice.h>
  30. #include <linux/skbuff.h>
  31. #include <linux/rtnetlink.h>
  32. #include <linux/init.h>
  33. #include <linux/proc_fs.h>
  34. #include <linux/seq_file.h>
  35. #include <linux/kmod.h>
  36. #include <linux/list.h>
  37. #include <linux/bitops.h>
  38. #include <net/sock.h>
  39. #include <net/pkt_sched.h>
  40. #include <asm/processor.h>
  41. #include <asm/uaccess.h>
  42. #include <asm/system.h>
  43. static int qdisc_notify(struct sk_buff *oskb, struct nlmsghdr *n, u32 clid,
  44. struct Qdisc *old, struct Qdisc *new);
  45. static int tclass_notify(struct sk_buff *oskb, struct nlmsghdr *n,
  46. struct Qdisc *q, unsigned long cl, int event);
  47. /*
  48. Short review.
  49. -------------
  50. This file consists of two interrelated parts:
  51. 1. queueing disciplines manager frontend.
  52. 2. traffic classes manager frontend.
  53. Generally, queueing discipline ("qdisc") is a black box,
  54. which is able to enqueue packets and to dequeue them (when
  55. device is ready to send something) in order and at times
  56. determined by algorithm hidden in it.
  57. qdisc's are divided to two categories:
  58. - "queues", which have no internal structure visible from outside.
  59. - "schedulers", which split all the packets to "traffic classes",
  60. using "packet classifiers" (look at cls_api.c)
  61. In turn, classes may have child qdiscs (as rule, queues)
  62. attached to them etc. etc. etc.
  63. The goal of the routines in this file is to translate
  64. information supplied by user in the form of handles
  65. to more intelligible for kernel form, to make some sanity
  66. checks and part of work, which is common to all qdiscs
  67. and to provide rtnetlink notifications.
  68. All real intelligent work is done inside qdisc modules.
  69. Every discipline has two major routines: enqueue and dequeue.
  70. ---dequeue
  71. dequeue usually returns a skb to send. It is allowed to return NULL,
  72. but it does not mean that queue is empty, it just means that
  73. discipline does not want to send anything this time.
  74. Queue is really empty if q->q.qlen == 0.
  75. For complicated disciplines with multiple queues q->q is not
  76. real packet queue, but however q->q.qlen must be valid.
  77. ---enqueue
  78. enqueue returns 0, if packet was enqueued successfully.
  79. If packet (this one or another one) was dropped, it returns
  80. not zero error code.
  81. NET_XMIT_DROP - this packet dropped
  82. Expected action: do not backoff, but wait until queue will clear.
  83. NET_XMIT_CN - probably this packet enqueued, but another one dropped.
  84. Expected action: backoff or ignore
  85. NET_XMIT_POLICED - dropped by police.
  86. Expected action: backoff or error to real-time apps.
  87. Auxiliary routines:
  88. ---requeue
  89. requeues once dequeued packet. It is used for non-standard or
  90. just buggy devices, which can defer output even if dev->tbusy=0.
  91. ---reset
  92. returns qdisc to initial state: purge all buffers, clear all
  93. timers, counters (except for statistics) etc.
  94. ---init
  95. initializes newly created qdisc.
  96. ---destroy
  97. destroys resources allocated by init and during lifetime of qdisc.
  98. ---change
  99. changes qdisc parameters.
  100. */
  101. /* Protects list of registered TC modules. It is pure SMP lock. */
  102. static DEFINE_RWLOCK(qdisc_mod_lock);
  103. /************************************************
  104. * Queueing disciplines manipulation. *
  105. ************************************************/
  106. /* The list of all installed queueing disciplines. */
  107. static struct Qdisc_ops *qdisc_base;
  108. /* Register/uregister queueing discipline */
  109. int register_qdisc(struct Qdisc_ops *qops)
  110. {
  111. struct Qdisc_ops *q, **qp;
  112. int rc = -EEXIST;
  113. write_lock(&qdisc_mod_lock);
  114. for (qp = &qdisc_base; (q = *qp) != NULL; qp = &q->next)
  115. if (!strcmp(qops->id, q->id))
  116. goto out;
  117. if (qops->enqueue == NULL)
  118. qops->enqueue = noop_qdisc_ops.enqueue;
  119. if (qops->requeue == NULL)
  120. qops->requeue = noop_qdisc_ops.requeue;
  121. if (qops->dequeue == NULL)
  122. qops->dequeue = noop_qdisc_ops.dequeue;
  123. qops->next = NULL;
  124. *qp = qops;
  125. rc = 0;
  126. out:
  127. write_unlock(&qdisc_mod_lock);
  128. return rc;
  129. }
  130. int unregister_qdisc(struct Qdisc_ops *qops)
  131. {
  132. struct Qdisc_ops *q, **qp;
  133. int err = -ENOENT;
  134. write_lock(&qdisc_mod_lock);
  135. for (qp = &qdisc_base; (q=*qp)!=NULL; qp = &q->next)
  136. if (q == qops)
  137. break;
  138. if (q) {
  139. *qp = q->next;
  140. q->next = NULL;
  141. err = 0;
  142. }
  143. write_unlock(&qdisc_mod_lock);
  144. return err;
  145. }
  146. /* We know handle. Find qdisc among all qdisc's attached to device
  147. (root qdisc, all its children, children of children etc.)
  148. */
  149. struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
  150. {
  151. struct Qdisc *q;
  152. read_lock_bh(&qdisc_tree_lock);
  153. list_for_each_entry(q, &dev->qdisc_list, list) {
  154. if (q->handle == handle) {
  155. read_unlock_bh(&qdisc_tree_lock);
  156. return q;
  157. }
  158. }
  159. read_unlock_bh(&qdisc_tree_lock);
  160. return NULL;
  161. }
  162. static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid)
  163. {
  164. unsigned long cl;
  165. struct Qdisc *leaf;
  166. struct Qdisc_class_ops *cops = p->ops->cl_ops;
  167. if (cops == NULL)
  168. return NULL;
  169. cl = cops->get(p, classid);
  170. if (cl == 0)
  171. return NULL;
  172. leaf = cops->leaf(p, cl);
  173. cops->put(p, cl);
  174. return leaf;
  175. }
  176. /* Find queueing discipline by name */
  177. static struct Qdisc_ops *qdisc_lookup_ops(struct rtattr *kind)
  178. {
  179. struct Qdisc_ops *q = NULL;
  180. if (kind) {
  181. read_lock(&qdisc_mod_lock);
  182. for (q = qdisc_base; q; q = q->next) {
  183. if (rtattr_strcmp(kind, q->id) == 0) {
  184. if (!try_module_get(q->owner))
  185. q = NULL;
  186. break;
  187. }
  188. }
  189. read_unlock(&qdisc_mod_lock);
  190. }
  191. return q;
  192. }
  193. static struct qdisc_rate_table *qdisc_rtab_list;
  194. struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct rtattr *tab)
  195. {
  196. struct qdisc_rate_table *rtab;
  197. for (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) {
  198. if (memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) == 0) {
  199. rtab->refcnt++;
  200. return rtab;
  201. }
  202. }
  203. if (tab == NULL || r->rate == 0 || r->cell_log == 0 || RTA_PAYLOAD(tab) != 1024)
  204. return NULL;
  205. rtab = kmalloc(sizeof(*rtab), GFP_KERNEL);
  206. if (rtab) {
  207. rtab->rate = *r;
  208. rtab->refcnt = 1;
  209. memcpy(rtab->data, RTA_DATA(tab), 1024);
  210. rtab->next = qdisc_rtab_list;
  211. qdisc_rtab_list = rtab;
  212. }
  213. return rtab;
  214. }
  215. void qdisc_put_rtab(struct qdisc_rate_table *tab)
  216. {
  217. struct qdisc_rate_table *rtab, **rtabp;
  218. if (!tab || --tab->refcnt)
  219. return;
  220. for (rtabp = &qdisc_rtab_list; (rtab=*rtabp) != NULL; rtabp = &rtab->next) {
  221. if (rtab == tab) {
  222. *rtabp = rtab->next;
  223. kfree(rtab);
  224. return;
  225. }
  226. }
  227. }
  228. /* Allocate an unique handle from space managed by kernel */
  229. static u32 qdisc_alloc_handle(struct net_device *dev)
  230. {
  231. int i = 0x10000;
  232. static u32 autohandle = TC_H_MAKE(0x80000000U, 0);
  233. do {
  234. autohandle += TC_H_MAKE(0x10000U, 0);
  235. if (autohandle == TC_H_MAKE(TC_H_ROOT, 0))
  236. autohandle = TC_H_MAKE(0x80000000U, 0);
  237. } while (qdisc_lookup(dev, autohandle) && --i > 0);
  238. return i>0 ? autohandle : 0;
  239. }
  240. /* Attach toplevel qdisc to device dev */
  241. static struct Qdisc *
  242. dev_graft_qdisc(struct net_device *dev, struct Qdisc *qdisc)
  243. {
  244. struct Qdisc *oqdisc;
  245. if (dev->flags & IFF_UP)
  246. dev_deactivate(dev);
  247. qdisc_lock_tree(dev);
  248. if (qdisc && qdisc->flags&TCQ_F_INGRESS) {
  249. oqdisc = dev->qdisc_ingress;
  250. /* Prune old scheduler */
  251. if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1) {
  252. /* delete */
  253. qdisc_reset(oqdisc);
  254. dev->qdisc_ingress = NULL;
  255. } else { /* new */
  256. dev->qdisc_ingress = qdisc;
  257. }
  258. } else {
  259. oqdisc = dev->qdisc_sleeping;
  260. /* Prune old scheduler */
  261. if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1)
  262. qdisc_reset(oqdisc);
  263. /* ... and graft new one */
  264. if (qdisc == NULL)
  265. qdisc = &noop_qdisc;
  266. dev->qdisc_sleeping = qdisc;
  267. dev->qdisc = &noop_qdisc;
  268. }
  269. qdisc_unlock_tree(dev);
  270. if (dev->flags & IFF_UP)
  271. dev_activate(dev);
  272. return oqdisc;
  273. }
  274. /* Graft qdisc "new" to class "classid" of qdisc "parent" or
  275. to device "dev".
  276. Old qdisc is not destroyed but returned in *old.
  277. */
  278. static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
  279. u32 classid,
  280. struct Qdisc *new, struct Qdisc **old)
  281. {
  282. int err = 0;
  283. struct Qdisc *q = *old;
  284. if (parent == NULL) {
  285. if (q && q->flags&TCQ_F_INGRESS) {
  286. *old = dev_graft_qdisc(dev, q);
  287. } else {
  288. *old = dev_graft_qdisc(dev, new);
  289. }
  290. } else {
  291. struct Qdisc_class_ops *cops = parent->ops->cl_ops;
  292. err = -EINVAL;
  293. if (cops) {
  294. unsigned long cl = cops->get(parent, classid);
  295. if (cl) {
  296. err = cops->graft(parent, cl, new, old);
  297. if (new)
  298. new->parent = classid;
  299. cops->put(parent, cl);
  300. }
  301. }
  302. }
  303. return err;
  304. }
  305. /*
  306. Allocate and initialize new qdisc.
  307. Parameters are passed via opt.
  308. */
  309. static struct Qdisc *
  310. qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
  311. {
  312. int err;
  313. struct rtattr *kind = tca[TCA_KIND-1];
  314. void *p = NULL;
  315. struct Qdisc *sch;
  316. struct Qdisc_ops *ops;
  317. int size;
  318. ops = qdisc_lookup_ops(kind);
  319. #ifdef CONFIG_KMOD
  320. if (ops == NULL && kind != NULL) {
  321. char name[IFNAMSIZ];
  322. if (rtattr_strlcpy(name, kind, IFNAMSIZ) < IFNAMSIZ) {
  323. /* We dropped the RTNL semaphore in order to
  324. * perform the module load. So, even if we
  325. * succeeded in loading the module we have to
  326. * tell the caller to replay the request. We
  327. * indicate this using -EAGAIN.
  328. * We replay the request because the device may
  329. * go away in the mean time.
  330. */
  331. rtnl_unlock();
  332. request_module("sch_%s", name);
  333. rtnl_lock();
  334. ops = qdisc_lookup_ops(kind);
  335. if (ops != NULL) {
  336. /* We will try again qdisc_lookup_ops,
  337. * so don't keep a reference.
  338. */
  339. module_put(ops->owner);
  340. err = -EAGAIN;
  341. goto err_out;
  342. }
  343. }
  344. }
  345. #endif
  346. err = -EINVAL;
  347. if (ops == NULL)
  348. goto err_out;
  349. /* ensure that the Qdisc and the private data are 32-byte aligned */
  350. size = ((sizeof(*sch) + QDISC_ALIGN_CONST) & ~QDISC_ALIGN_CONST);
  351. size += ops->priv_size + QDISC_ALIGN_CONST;
  352. p = kmalloc(size, GFP_KERNEL);
  353. err = -ENOBUFS;
  354. if (!p)
  355. goto err_out2;
  356. memset(p, 0, size);
  357. sch = (struct Qdisc *)(((unsigned long)p + QDISC_ALIGN_CONST)
  358. & ~QDISC_ALIGN_CONST);
  359. sch->padded = (char *)sch - (char *)p;
  360. INIT_LIST_HEAD(&sch->list);
  361. skb_queue_head_init(&sch->q);
  362. if (handle == TC_H_INGRESS)
  363. sch->flags |= TCQ_F_INGRESS;
  364. sch->ops = ops;
  365. sch->enqueue = ops->enqueue;
  366. sch->dequeue = ops->dequeue;
  367. sch->dev = dev;
  368. dev_hold(dev);
  369. atomic_set(&sch->refcnt, 1);
  370. sch->stats_lock = &dev->queue_lock;
  371. if (handle == 0) {
  372. handle = qdisc_alloc_handle(dev);
  373. err = -ENOMEM;
  374. if (handle == 0)
  375. goto err_out3;
  376. }
  377. if (handle == TC_H_INGRESS)
  378. sch->handle =TC_H_MAKE(TC_H_INGRESS, 0);
  379. else
  380. sch->handle = handle;
  381. if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS-1])) == 0) {
  382. qdisc_lock_tree(dev);
  383. list_add_tail(&sch->list, &dev->qdisc_list);
  384. qdisc_unlock_tree(dev);
  385. #ifdef CONFIG_NET_ESTIMATOR
  386. if (tca[TCA_RATE-1])
  387. gen_new_estimator(&sch->bstats, &sch->rate_est,
  388. sch->stats_lock, tca[TCA_RATE-1]);
  389. #endif
  390. return sch;
  391. }
  392. err_out3:
  393. dev_put(dev);
  394. err_out2:
  395. module_put(ops->owner);
  396. err_out:
  397. *errp = err;
  398. if (p)
  399. kfree(p);
  400. return NULL;
  401. }
  402. static int qdisc_change(struct Qdisc *sch, struct rtattr **tca)
  403. {
  404. if (tca[TCA_OPTIONS-1]) {
  405. int err;
  406. if (sch->ops->change == NULL)
  407. return -EINVAL;
  408. err = sch->ops->change(sch, tca[TCA_OPTIONS-1]);
  409. if (err)
  410. return err;
  411. }
  412. #ifdef CONFIG_NET_ESTIMATOR
  413. if (tca[TCA_RATE-1])
  414. gen_replace_estimator(&sch->bstats, &sch->rate_est,
  415. sch->stats_lock, tca[TCA_RATE-1]);
  416. #endif
  417. return 0;
  418. }
  419. struct check_loop_arg
  420. {
  421. struct qdisc_walker w;
  422. struct Qdisc *p;
  423. int depth;
  424. };
  425. static int check_loop_fn(struct Qdisc *q, unsigned long cl, struct qdisc_walker *w);
  426. static int check_loop(struct Qdisc *q, struct Qdisc *p, int depth)
  427. {
  428. struct check_loop_arg arg;
  429. if (q->ops->cl_ops == NULL)
  430. return 0;
  431. arg.w.stop = arg.w.skip = arg.w.count = 0;
  432. arg.w.fn = check_loop_fn;
  433. arg.depth = depth;
  434. arg.p = p;
  435. q->ops->cl_ops->walk(q, &arg.w);
  436. return arg.w.stop ? -ELOOP : 0;
  437. }
  438. static int
  439. check_loop_fn(struct Qdisc *q, unsigned long cl, struct qdisc_walker *w)
  440. {
  441. struct Qdisc *leaf;
  442. struct Qdisc_class_ops *cops = q->ops->cl_ops;
  443. struct check_loop_arg *arg = (struct check_loop_arg *)w;
  444. leaf = cops->leaf(q, cl);
  445. if (leaf) {
  446. if (leaf == arg->p || arg->depth > 7)
  447. return -ELOOP;
  448. return check_loop(leaf, arg->p, arg->depth + 1);
  449. }
  450. return 0;
  451. }
  452. /*
  453. * Delete/get qdisc.
  454. */
  455. static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
  456. {
  457. struct tcmsg *tcm = NLMSG_DATA(n);
  458. struct rtattr **tca = arg;
  459. struct net_device *dev;
  460. u32 clid = tcm->tcm_parent;
  461. struct Qdisc *q = NULL;
  462. struct Qdisc *p = NULL;
  463. int err;
  464. if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
  465. return -ENODEV;
  466. if (clid) {
  467. if (clid != TC_H_ROOT) {
  468. if (TC_H_MAJ(clid) != TC_H_MAJ(TC_H_INGRESS)) {
  469. if ((p = qdisc_lookup(dev, TC_H_MAJ(clid))) == NULL)
  470. return -ENOENT;
  471. q = qdisc_leaf(p, clid);
  472. } else { /* ingress */
  473. q = dev->qdisc_ingress;
  474. }
  475. } else {
  476. q = dev->qdisc_sleeping;
  477. }
  478. if (!q)
  479. return -ENOENT;
  480. if (tcm->tcm_handle && q->handle != tcm->tcm_handle)
  481. return -EINVAL;
  482. } else {
  483. if ((q = qdisc_lookup(dev, tcm->tcm_handle)) == NULL)
  484. return -ENOENT;
  485. }
  486. if (tca[TCA_KIND-1] && rtattr_strcmp(tca[TCA_KIND-1], q->ops->id))
  487. return -EINVAL;
  488. if (n->nlmsg_type == RTM_DELQDISC) {
  489. if (!clid)
  490. return -EINVAL;
  491. if (q->handle == 0)
  492. return -ENOENT;
  493. if ((err = qdisc_graft(dev, p, clid, NULL, &q)) != 0)
  494. return err;
  495. if (q) {
  496. qdisc_notify(skb, n, clid, q, NULL);
  497. spin_lock_bh(&dev->queue_lock);
  498. qdisc_destroy(q);
  499. spin_unlock_bh(&dev->queue_lock);
  500. }
  501. } else {
  502. qdisc_notify(skb, n, clid, NULL, q);
  503. }
  504. return 0;
  505. }
  506. /*
  507. Create/change qdisc.
  508. */
  509. static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
  510. {
  511. struct tcmsg *tcm;
  512. struct rtattr **tca;
  513. struct net_device *dev;
  514. u32 clid;
  515. struct Qdisc *q, *p;
  516. int err;
  517. replay:
  518. /* Reinit, just in case something touches this. */
  519. tcm = NLMSG_DATA(n);
  520. tca = arg;
  521. clid = tcm->tcm_parent;
  522. q = p = NULL;
  523. if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
  524. return -ENODEV;
  525. if (clid) {
  526. if (clid != TC_H_ROOT) {
  527. if (clid != TC_H_INGRESS) {
  528. if ((p = qdisc_lookup(dev, TC_H_MAJ(clid))) == NULL)
  529. return -ENOENT;
  530. q = qdisc_leaf(p, clid);
  531. } else { /*ingress */
  532. q = dev->qdisc_ingress;
  533. }
  534. } else {
  535. q = dev->qdisc_sleeping;
  536. }
  537. /* It may be default qdisc, ignore it */
  538. if (q && q->handle == 0)
  539. q = NULL;
  540. if (!q || !tcm->tcm_handle || q->handle != tcm->tcm_handle) {
  541. if (tcm->tcm_handle) {
  542. if (q && !(n->nlmsg_flags&NLM_F_REPLACE))
  543. return -EEXIST;
  544. if (TC_H_MIN(tcm->tcm_handle))
  545. return -EINVAL;
  546. if ((q = qdisc_lookup(dev, tcm->tcm_handle)) == NULL)
  547. goto create_n_graft;
  548. if (n->nlmsg_flags&NLM_F_EXCL)
  549. return -EEXIST;
  550. if (tca[TCA_KIND-1] && rtattr_strcmp(tca[TCA_KIND-1], q->ops->id))
  551. return -EINVAL;
  552. if (q == p ||
  553. (p && check_loop(q, p, 0)))
  554. return -ELOOP;
  555. atomic_inc(&q->refcnt);
  556. goto graft;
  557. } else {
  558. if (q == NULL)
  559. goto create_n_graft;
  560. /* This magic test requires explanation.
  561. *
  562. * We know, that some child q is already
  563. * attached to this parent and have choice:
  564. * either to change it or to create/graft new one.
  565. *
  566. * 1. We are allowed to create/graft only
  567. * if CREATE and REPLACE flags are set.
  568. *
  569. * 2. If EXCL is set, requestor wanted to say,
  570. * that qdisc tcm_handle is not expected
  571. * to exist, so that we choose create/graft too.
  572. *
  573. * 3. The last case is when no flags are set.
  574. * Alas, it is sort of hole in API, we
  575. * cannot decide what to do unambiguously.
  576. * For now we select create/graft, if
  577. * user gave KIND, which does not match existing.
  578. */
  579. if ((n->nlmsg_flags&NLM_F_CREATE) &&
  580. (n->nlmsg_flags&NLM_F_REPLACE) &&
  581. ((n->nlmsg_flags&NLM_F_EXCL) ||
  582. (tca[TCA_KIND-1] &&
  583. rtattr_strcmp(tca[TCA_KIND-1], q->ops->id))))
  584. goto create_n_graft;
  585. }
  586. }
  587. } else {
  588. if (!tcm->tcm_handle)
  589. return -EINVAL;
  590. q = qdisc_lookup(dev, tcm->tcm_handle);
  591. }
  592. /* Change qdisc parameters */
  593. if (q == NULL)
  594. return -ENOENT;
  595. if (n->nlmsg_flags&NLM_F_EXCL)
  596. return -EEXIST;
  597. if (tca[TCA_KIND-1] && rtattr_strcmp(tca[TCA_KIND-1], q->ops->id))
  598. return -EINVAL;
  599. err = qdisc_change(q, tca);
  600. if (err == 0)
  601. qdisc_notify(skb, n, clid, NULL, q);
  602. return err;
  603. create_n_graft:
  604. if (!(n->nlmsg_flags&NLM_F_CREATE))
  605. return -ENOENT;
  606. if (clid == TC_H_INGRESS)
  607. q = qdisc_create(dev, tcm->tcm_parent, tca, &err);
  608. else
  609. q = qdisc_create(dev, tcm->tcm_handle, tca, &err);
  610. if (q == NULL) {
  611. if (err == -EAGAIN)
  612. goto replay;
  613. return err;
  614. }
  615. graft:
  616. if (1) {
  617. struct Qdisc *old_q = NULL;
  618. err = qdisc_graft(dev, p, clid, q, &old_q);
  619. if (err) {
  620. if (q) {
  621. spin_lock_bh(&dev->queue_lock);
  622. qdisc_destroy(q);
  623. spin_unlock_bh(&dev->queue_lock);
  624. }
  625. return err;
  626. }
  627. qdisc_notify(skb, n, clid, old_q, q);
  628. if (old_q) {
  629. spin_lock_bh(&dev->queue_lock);
  630. qdisc_destroy(old_q);
  631. spin_unlock_bh(&dev->queue_lock);
  632. }
  633. }
  634. return 0;
  635. }
  636. static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
  637. u32 pid, u32 seq, u16 flags, int event)
  638. {
  639. struct tcmsg *tcm;
  640. struct nlmsghdr *nlh;
  641. unsigned char *b = skb->tail;
  642. struct gnet_dump d;
  643. nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags);
  644. tcm = NLMSG_DATA(nlh);
  645. tcm->tcm_family = AF_UNSPEC;
  646. tcm->tcm_ifindex = q->dev->ifindex;
  647. tcm->tcm_parent = clid;
  648. tcm->tcm_handle = q->handle;
  649. tcm->tcm_info = atomic_read(&q->refcnt);
  650. RTA_PUT(skb, TCA_KIND, IFNAMSIZ, q->ops->id);
  651. if (q->ops->dump && q->ops->dump(q, skb) < 0)
  652. goto rtattr_failure;
  653. q->qstats.qlen = q->q.qlen;
  654. if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
  655. TCA_XSTATS, q->stats_lock, &d) < 0)
  656. goto rtattr_failure;
  657. if (q->ops->dump_stats && q->ops->dump_stats(q, &d) < 0)
  658. goto rtattr_failure;
  659. if (gnet_stats_copy_basic(&d, &q->bstats) < 0 ||
  660. #ifdef CONFIG_NET_ESTIMATOR
  661. gnet_stats_copy_rate_est(&d, &q->rate_est) < 0 ||
  662. #endif
  663. gnet_stats_copy_queue(&d, &q->qstats) < 0)
  664. goto rtattr_failure;
  665. if (gnet_stats_finish_copy(&d) < 0)
  666. goto rtattr_failure;
  667. nlh->nlmsg_len = skb->tail - b;
  668. return skb->len;
  669. nlmsg_failure:
  670. rtattr_failure:
  671. skb_trim(skb, b - skb->data);
  672. return -1;
  673. }
  674. static int qdisc_notify(struct sk_buff *oskb, struct nlmsghdr *n,
  675. u32 clid, struct Qdisc *old, struct Qdisc *new)
  676. {
  677. struct sk_buff *skb;
  678. u32 pid = oskb ? NETLINK_CB(oskb).pid : 0;
  679. skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
  680. if (!skb)
  681. return -ENOBUFS;
  682. if (old && old->handle) {
  683. if (tc_fill_qdisc(skb, old, clid, pid, n->nlmsg_seq, 0, RTM_DELQDISC) < 0)
  684. goto err_out;
  685. }
  686. if (new) {
  687. if (tc_fill_qdisc(skb, new, clid, pid, n->nlmsg_seq, old ? NLM_F_REPLACE : 0, RTM_NEWQDISC) < 0)
  688. goto err_out;
  689. }
  690. if (skb->len)
  691. return rtnetlink_send(skb, pid, RTMGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
  692. err_out:
  693. kfree_skb(skb);
  694. return -EINVAL;
  695. }
  696. static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
  697. {
  698. int idx, q_idx;
  699. int s_idx, s_q_idx;
  700. struct net_device *dev;
  701. struct Qdisc *q;
  702. s_idx = cb->args[0];
  703. s_q_idx = q_idx = cb->args[1];
  704. read_lock(&dev_base_lock);
  705. for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
  706. if (idx < s_idx)
  707. continue;
  708. if (idx > s_idx)
  709. s_q_idx = 0;
  710. read_lock_bh(&qdisc_tree_lock);
  711. q_idx = 0;
  712. list_for_each_entry(q, &dev->qdisc_list, list) {
  713. if (q_idx < s_q_idx) {
  714. q_idx++;
  715. continue;
  716. }
  717. if (tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).pid,
  718. cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWQDISC) <= 0) {
  719. read_unlock_bh(&qdisc_tree_lock);
  720. goto done;
  721. }
  722. q_idx++;
  723. }
  724. read_unlock_bh(&qdisc_tree_lock);
  725. }
  726. done:
  727. read_unlock(&dev_base_lock);
  728. cb->args[0] = idx;
  729. cb->args[1] = q_idx;
  730. return skb->len;
  731. }
  732. /************************************************
  733. * Traffic classes manipulation. *
  734. ************************************************/
  735. static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
  736. {
  737. struct tcmsg *tcm = NLMSG_DATA(n);
  738. struct rtattr **tca = arg;
  739. struct net_device *dev;
  740. struct Qdisc *q = NULL;
  741. struct Qdisc_class_ops *cops;
  742. unsigned long cl = 0;
  743. unsigned long new_cl;
  744. u32 pid = tcm->tcm_parent;
  745. u32 clid = tcm->tcm_handle;
  746. u32 qid = TC_H_MAJ(clid);
  747. int err;
  748. if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
  749. return -ENODEV;
  750. /*
  751. parent == TC_H_UNSPEC - unspecified parent.
  752. parent == TC_H_ROOT - class is root, which has no parent.
  753. parent == X:0 - parent is root class.
  754. parent == X:Y - parent is a node in hierarchy.
  755. parent == 0:Y - parent is X:Y, where X:0 is qdisc.
  756. handle == 0:0 - generate handle from kernel pool.
  757. handle == 0:Y - class is X:Y, where X:0 is qdisc.
  758. handle == X:Y - clear.
  759. handle == X:0 - root class.
  760. */
  761. /* Step 1. Determine qdisc handle X:0 */
  762. if (pid != TC_H_ROOT) {
  763. u32 qid1 = TC_H_MAJ(pid);
  764. if (qid && qid1) {
  765. /* If both majors are known, they must be identical. */
  766. if (qid != qid1)
  767. return -EINVAL;
  768. } else if (qid1) {
  769. qid = qid1;
  770. } else if (qid == 0)
  771. qid = dev->qdisc_sleeping->handle;
  772. /* Now qid is genuine qdisc handle consistent
  773. both with parent and child.
  774. TC_H_MAJ(pid) still may be unspecified, complete it now.
  775. */
  776. if (pid)
  777. pid = TC_H_MAKE(qid, pid);
  778. } else {
  779. if (qid == 0)
  780. qid = dev->qdisc_sleeping->handle;
  781. }
  782. /* OK. Locate qdisc */
  783. if ((q = qdisc_lookup(dev, qid)) == NULL)
  784. return -ENOENT;
  785. /* An check that it supports classes */
  786. cops = q->ops->cl_ops;
  787. if (cops == NULL)
  788. return -EINVAL;
  789. /* Now try to get class */
  790. if (clid == 0) {
  791. if (pid == TC_H_ROOT)
  792. clid = qid;
  793. } else
  794. clid = TC_H_MAKE(qid, clid);
  795. if (clid)
  796. cl = cops->get(q, clid);
  797. if (cl == 0) {
  798. err = -ENOENT;
  799. if (n->nlmsg_type != RTM_NEWTCLASS || !(n->nlmsg_flags&NLM_F_CREATE))
  800. goto out;
  801. } else {
  802. switch (n->nlmsg_type) {
  803. case RTM_NEWTCLASS:
  804. err = -EEXIST;
  805. if (n->nlmsg_flags&NLM_F_EXCL)
  806. goto out;
  807. break;
  808. case RTM_DELTCLASS:
  809. err = cops->delete(q, cl);
  810. if (err == 0)
  811. tclass_notify(skb, n, q, cl, RTM_DELTCLASS);
  812. goto out;
  813. case RTM_GETTCLASS:
  814. err = tclass_notify(skb, n, q, cl, RTM_NEWTCLASS);
  815. goto out;
  816. default:
  817. err = -EINVAL;
  818. goto out;
  819. }
  820. }
  821. new_cl = cl;
  822. err = cops->change(q, clid, pid, tca, &new_cl);
  823. if (err == 0)
  824. tclass_notify(skb, n, q, new_cl, RTM_NEWTCLASS);
  825. out:
  826. if (cl)
  827. cops->put(q, cl);
  828. return err;
  829. }
  830. static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
  831. unsigned long cl,
  832. u32 pid, u32 seq, u16 flags, int event)
  833. {
  834. struct tcmsg *tcm;
  835. struct nlmsghdr *nlh;
  836. unsigned char *b = skb->tail;
  837. struct gnet_dump d;
  838. struct Qdisc_class_ops *cl_ops = q->ops->cl_ops;
  839. nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags);
  840. tcm = NLMSG_DATA(nlh);
  841. tcm->tcm_family = AF_UNSPEC;
  842. tcm->tcm_ifindex = q->dev->ifindex;
  843. tcm->tcm_parent = q->handle;
  844. tcm->tcm_handle = q->handle;
  845. tcm->tcm_info = 0;
  846. RTA_PUT(skb, TCA_KIND, IFNAMSIZ, q->ops->id);
  847. if (cl_ops->dump && cl_ops->dump(q, cl, skb, tcm) < 0)
  848. goto rtattr_failure;
  849. if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
  850. TCA_XSTATS, q->stats_lock, &d) < 0)
  851. goto rtattr_failure;
  852. if (cl_ops->dump_stats && cl_ops->dump_stats(q, cl, &d) < 0)
  853. goto rtattr_failure;
  854. if (gnet_stats_finish_copy(&d) < 0)
  855. goto rtattr_failure;
  856. nlh->nlmsg_len = skb->tail - b;
  857. return skb->len;
  858. nlmsg_failure:
  859. rtattr_failure:
  860. skb_trim(skb, b - skb->data);
  861. return -1;
  862. }
  863. static int tclass_notify(struct sk_buff *oskb, struct nlmsghdr *n,
  864. struct Qdisc *q, unsigned long cl, int event)
  865. {
  866. struct sk_buff *skb;
  867. u32 pid = oskb ? NETLINK_CB(oskb).pid : 0;
  868. skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
  869. if (!skb)
  870. return -ENOBUFS;
  871. if (tc_fill_tclass(skb, q, cl, pid, n->nlmsg_seq, 0, event) < 0) {
  872. kfree_skb(skb);
  873. return -EINVAL;
  874. }
  875. return rtnetlink_send(skb, pid, RTMGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
  876. }
  877. struct qdisc_dump_args
  878. {
  879. struct qdisc_walker w;
  880. struct sk_buff *skb;
  881. struct netlink_callback *cb;
  882. };
  883. static int qdisc_class_dump(struct Qdisc *q, unsigned long cl, struct qdisc_walker *arg)
  884. {
  885. struct qdisc_dump_args *a = (struct qdisc_dump_args *)arg;
  886. return tc_fill_tclass(a->skb, q, cl, NETLINK_CB(a->cb->skb).pid,
  887. a->cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWTCLASS);
  888. }
  889. static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
  890. {
  891. int t;
  892. int s_t;
  893. struct net_device *dev;
  894. struct Qdisc *q;
  895. struct tcmsg *tcm = (struct tcmsg*)NLMSG_DATA(cb->nlh);
  896. struct qdisc_dump_args arg;
  897. if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm)))
  898. return 0;
  899. if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL)
  900. return 0;
  901. s_t = cb->args[0];
  902. t = 0;
  903. read_lock_bh(&qdisc_tree_lock);
  904. list_for_each_entry(q, &dev->qdisc_list, list) {
  905. if (t < s_t || !q->ops->cl_ops ||
  906. (tcm->tcm_parent &&
  907. TC_H_MAJ(tcm->tcm_parent) != q->handle)) {
  908. t++;
  909. continue;
  910. }
  911. if (t > s_t)
  912. memset(&cb->args[1], 0, sizeof(cb->args)-sizeof(cb->args[0]));
  913. arg.w.fn = qdisc_class_dump;
  914. arg.skb = skb;
  915. arg.cb = cb;
  916. arg.w.stop = 0;
  917. arg.w.skip = cb->args[1];
  918. arg.w.count = 0;
  919. q->ops->cl_ops->walk(q, &arg.w);
  920. cb->args[1] = arg.w.count;
  921. if (arg.w.stop)
  922. break;
  923. t++;
  924. }
  925. read_unlock_bh(&qdisc_tree_lock);
  926. cb->args[0] = t;
  927. dev_put(dev);
  928. return skb->len;
  929. }
  930. /* Main classifier routine: scans classifier chain attached
  931. to this qdisc, (optionally) tests for protocol and asks
  932. specific classifiers.
  933. */
  934. int tc_classify(struct sk_buff *skb, struct tcf_proto *tp,
  935. struct tcf_result *res)
  936. {
  937. int err = 0;
  938. u32 protocol = skb->protocol;
  939. #ifdef CONFIG_NET_CLS_ACT
  940. struct tcf_proto *otp = tp;
  941. reclassify:
  942. #endif
  943. protocol = skb->protocol;
  944. for ( ; tp; tp = tp->next) {
  945. if ((tp->protocol == protocol ||
  946. tp->protocol == __constant_htons(ETH_P_ALL)) &&
  947. (err = tp->classify(skb, tp, res)) >= 0) {
  948. #ifdef CONFIG_NET_CLS_ACT
  949. if ( TC_ACT_RECLASSIFY == err) {
  950. __u32 verd = (__u32) G_TC_VERD(skb->tc_verd);
  951. tp = otp;
  952. if (MAX_REC_LOOP < verd++) {
  953. printk("rule prio %d protocol %02x reclassify is buggy packet dropped\n",
  954. tp->prio&0xffff, ntohs(tp->protocol));
  955. return TC_ACT_SHOT;
  956. }
  957. skb->tc_verd = SET_TC_VERD(skb->tc_verd,verd);
  958. goto reclassify;
  959. } else {
  960. if (skb->tc_verd)
  961. skb->tc_verd = SET_TC_VERD(skb->tc_verd,0);
  962. return err;
  963. }
  964. #else
  965. return err;
  966. #endif
  967. }
  968. }
  969. return -1;
  970. }
  971. static int psched_us_per_tick = 1;
  972. static int psched_tick_per_us = 1;
  973. #ifdef CONFIG_PROC_FS
  974. static int psched_show(struct seq_file *seq, void *v)
  975. {
  976. seq_printf(seq, "%08x %08x %08x %08x\n",
  977. psched_tick_per_us, psched_us_per_tick,
  978. 1000000, HZ);
  979. return 0;
  980. }
  981. static int psched_open(struct inode *inode, struct file *file)
  982. {
  983. return single_open(file, psched_show, PDE(inode)->data);
  984. }
  985. static struct file_operations psched_fops = {
  986. .owner = THIS_MODULE,
  987. .open = psched_open,
  988. .read = seq_read,
  989. .llseek = seq_lseek,
  990. .release = single_release,
  991. };
  992. #endif
  993. #ifdef CONFIG_NET_SCH_CLK_CPU
  994. psched_tdiff_t psched_clock_per_hz;
  995. int psched_clock_scale;
  996. EXPORT_SYMBOL(psched_clock_per_hz);
  997. EXPORT_SYMBOL(psched_clock_scale);
  998. psched_time_t psched_time_base;
  999. cycles_t psched_time_mark;
  1000. EXPORT_SYMBOL(psched_time_mark);
  1001. EXPORT_SYMBOL(psched_time_base);
  1002. /*
  1003. * Periodically adjust psched_time_base to avoid overflow
  1004. * with 32-bit get_cycles(). Safe up to 4GHz CPU.
  1005. */
  1006. static void psched_tick(unsigned long);
  1007. static struct timer_list psched_timer = TIMER_INITIALIZER(psched_tick, 0, 0);
  1008. static void psched_tick(unsigned long dummy)
  1009. {
  1010. if (sizeof(cycles_t) == sizeof(u32)) {
  1011. psched_time_t dummy_stamp;
  1012. PSCHED_GET_TIME(dummy_stamp);
  1013. psched_timer.expires = jiffies + 1*HZ;
  1014. add_timer(&psched_timer);
  1015. }
  1016. }
  1017. int __init psched_calibrate_clock(void)
  1018. {
  1019. psched_time_t stamp, stamp1;
  1020. struct timeval tv, tv1;
  1021. psched_tdiff_t delay;
  1022. long rdelay;
  1023. unsigned long stop;
  1024. psched_tick(0);
  1025. stop = jiffies + HZ/10;
  1026. PSCHED_GET_TIME(stamp);
  1027. do_gettimeofday(&tv);
  1028. while (time_before(jiffies, stop)) {
  1029. barrier();
  1030. cpu_relax();
  1031. }
  1032. PSCHED_GET_TIME(stamp1);
  1033. do_gettimeofday(&tv1);
  1034. delay = PSCHED_TDIFF(stamp1, stamp);
  1035. rdelay = tv1.tv_usec - tv.tv_usec;
  1036. rdelay += (tv1.tv_sec - tv.tv_sec)*1000000;
  1037. if (rdelay > delay)
  1038. return -1;
  1039. delay /= rdelay;
  1040. psched_tick_per_us = delay;
  1041. while ((delay>>=1) != 0)
  1042. psched_clock_scale++;
  1043. psched_us_per_tick = 1<<psched_clock_scale;
  1044. psched_clock_per_hz = (psched_tick_per_us*(1000000/HZ))>>psched_clock_scale;
  1045. return 0;
  1046. }
  1047. #endif
  1048. static int __init pktsched_init(void)
  1049. {
  1050. struct rtnetlink_link *link_p;
  1051. #ifdef CONFIG_NET_SCH_CLK_CPU
  1052. if (psched_calibrate_clock() < 0)
  1053. return -1;
  1054. #elif defined(CONFIG_NET_SCH_CLK_JIFFIES)
  1055. psched_tick_per_us = HZ<<PSCHED_JSCALE;
  1056. psched_us_per_tick = 1000000;
  1057. #endif
  1058. link_p = rtnetlink_links[PF_UNSPEC];
  1059. /* Setup rtnetlink links. It is made here to avoid
  1060. exporting large number of public symbols.
  1061. */
  1062. if (link_p) {
  1063. link_p[RTM_NEWQDISC-RTM_BASE].doit = tc_modify_qdisc;
  1064. link_p[RTM_DELQDISC-RTM_BASE].doit = tc_get_qdisc;
  1065. link_p[RTM_GETQDISC-RTM_BASE].doit = tc_get_qdisc;
  1066. link_p[RTM_GETQDISC-RTM_BASE].dumpit = tc_dump_qdisc;
  1067. link_p[RTM_NEWTCLASS-RTM_BASE].doit = tc_ctl_tclass;
  1068. link_p[RTM_DELTCLASS-RTM_BASE].doit = tc_ctl_tclass;
  1069. link_p[RTM_GETTCLASS-RTM_BASE].doit = tc_ctl_tclass;
  1070. link_p[RTM_GETTCLASS-RTM_BASE].dumpit = tc_dump_tclass;
  1071. }
  1072. register_qdisc(&pfifo_qdisc_ops);
  1073. register_qdisc(&bfifo_qdisc_ops);
  1074. proc_net_fops_create("psched", 0, &psched_fops);
  1075. return 0;
  1076. }
  1077. subsys_initcall(pktsched_init);
  1078. EXPORT_SYMBOL(qdisc_lookup);
  1079. EXPORT_SYMBOL(qdisc_get_rtab);
  1080. EXPORT_SYMBOL(qdisc_put_rtab);
  1081. EXPORT_SYMBOL(register_qdisc);
  1082. EXPORT_SYMBOL(unregister_qdisc);
  1083. EXPORT_SYMBOL(tc_classify);