rose_route.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
  8. * Copyright (C) Terry Dawson VK2KTJ (terry@animats.net)
  9. */
  10. #include <linux/errno.h>
  11. #include <linux/types.h>
  12. #include <linux/socket.h>
  13. #include <linux/in.h>
  14. #include <linux/kernel.h>
  15. #include <linux/timer.h>
  16. #include <linux/string.h>
  17. #include <linux/sockios.h>
  18. #include <linux/net.h>
  19. #include <linux/slab.h>
  20. #include <net/ax25.h>
  21. #include <linux/inet.h>
  22. #include <linux/netdevice.h>
  23. #include <net/arp.h>
  24. #include <linux/if_arp.h>
  25. #include <linux/skbuff.h>
  26. #include <net/sock.h>
  27. #include <net/tcp_states.h>
  28. #include <linux/uaccess.h>
  29. #include <linux/fcntl.h>
  30. #include <linux/termios.h> /* For TIOCINQ/OUTQ */
  31. #include <linux/mm.h>
  32. #include <linux/interrupt.h>
  33. #include <linux/notifier.h>
  34. #include <linux/init.h>
  35. #include <net/rose.h>
  36. #include <linux/seq_file.h>
  37. #include <linux/export.h>
  38. static unsigned int rose_neigh_no = 1;
  39. static struct rose_node *rose_node_list;
  40. static DEFINE_SPINLOCK(rose_node_list_lock);
  41. static struct rose_neigh *rose_neigh_list;
  42. static DEFINE_SPINLOCK(rose_neigh_list_lock);
  43. static struct rose_route *rose_route_list;
  44. static DEFINE_SPINLOCK(rose_route_list_lock);
  45. struct rose_neigh *rose_loopback_neigh;
  46. /*
  47. * Add a new route to a node, and in the process add the node and the
  48. * neighbour if it is new.
  49. */
  50. static int __must_check rose_add_node(struct rose_route_struct *rose_route,
  51. struct net_device *dev)
  52. {
  53. struct rose_node *rose_node, *rose_tmpn, *rose_tmpp;
  54. struct rose_neigh *rose_neigh;
  55. int i, res = 0;
  56. spin_lock_bh(&rose_node_list_lock);
  57. spin_lock_bh(&rose_neigh_list_lock);
  58. rose_node = rose_node_list;
  59. while (rose_node != NULL) {
  60. if ((rose_node->mask == rose_route->mask) &&
  61. (rosecmpm(&rose_route->address, &rose_node->address,
  62. rose_route->mask) == 0))
  63. break;
  64. rose_node = rose_node->next;
  65. }
  66. if (rose_node != NULL && rose_node->loopback) {
  67. res = -EINVAL;
  68. goto out;
  69. }
  70. rose_neigh = rose_neigh_list;
  71. while (rose_neigh != NULL) {
  72. if (ax25cmp(&rose_route->neighbour,
  73. &rose_neigh->callsign) == 0 &&
  74. rose_neigh->dev == dev)
  75. break;
  76. rose_neigh = rose_neigh->next;
  77. }
  78. if (rose_neigh == NULL) {
  79. rose_neigh = kmalloc(sizeof(*rose_neigh), GFP_ATOMIC);
  80. if (rose_neigh == NULL) {
  81. res = -ENOMEM;
  82. goto out;
  83. }
  84. rose_neigh->callsign = rose_route->neighbour;
  85. rose_neigh->digipeat = NULL;
  86. rose_neigh->ax25 = NULL;
  87. rose_neigh->dev = dev;
  88. rose_neigh->count = 0;
  89. rose_neigh->use = 0;
  90. rose_neigh->dce_mode = 0;
  91. rose_neigh->loopback = 0;
  92. rose_neigh->number = rose_neigh_no++;
  93. rose_neigh->restarted = 0;
  94. skb_queue_head_init(&rose_neigh->queue);
  95. timer_setup(&rose_neigh->ftimer, NULL, 0);
  96. timer_setup(&rose_neigh->t0timer, NULL, 0);
  97. if (rose_route->ndigis != 0) {
  98. rose_neigh->digipeat =
  99. kmalloc(sizeof(ax25_digi), GFP_ATOMIC);
  100. if (rose_neigh->digipeat == NULL) {
  101. kfree(rose_neigh);
  102. res = -ENOMEM;
  103. goto out;
  104. }
  105. rose_neigh->digipeat->ndigi = rose_route->ndigis;
  106. rose_neigh->digipeat->lastrepeat = -1;
  107. for (i = 0; i < rose_route->ndigis; i++) {
  108. rose_neigh->digipeat->calls[i] =
  109. rose_route->digipeaters[i];
  110. rose_neigh->digipeat->repeated[i] = 0;
  111. }
  112. }
  113. rose_neigh->next = rose_neigh_list;
  114. rose_neigh_list = rose_neigh;
  115. }
  116. /*
  117. * This is a new node to be inserted into the list. Find where it needs
  118. * to be inserted into the list, and insert it. We want to be sure
  119. * to order the list in descending order of mask size to ensure that
  120. * later when we are searching this list the first match will be the
  121. * best match.
  122. */
  123. if (rose_node == NULL) {
  124. rose_tmpn = rose_node_list;
  125. rose_tmpp = NULL;
  126. while (rose_tmpn != NULL) {
  127. if (rose_tmpn->mask > rose_route->mask) {
  128. rose_tmpp = rose_tmpn;
  129. rose_tmpn = rose_tmpn->next;
  130. } else {
  131. break;
  132. }
  133. }
  134. /* create new node */
  135. rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC);
  136. if (rose_node == NULL) {
  137. res = -ENOMEM;
  138. goto out;
  139. }
  140. rose_node->address = rose_route->address;
  141. rose_node->mask = rose_route->mask;
  142. rose_node->count = 1;
  143. rose_node->loopback = 0;
  144. rose_node->neighbour[0] = rose_neigh;
  145. if (rose_tmpn == NULL) {
  146. if (rose_tmpp == NULL) { /* Empty list */
  147. rose_node_list = rose_node;
  148. rose_node->next = NULL;
  149. } else {
  150. rose_tmpp->next = rose_node;
  151. rose_node->next = NULL;
  152. }
  153. } else {
  154. if (rose_tmpp == NULL) { /* 1st node */
  155. rose_node->next = rose_node_list;
  156. rose_node_list = rose_node;
  157. } else {
  158. rose_tmpp->next = rose_node;
  159. rose_node->next = rose_tmpn;
  160. }
  161. }
  162. rose_neigh->count++;
  163. goto out;
  164. }
  165. /* We have space, slot it in */
  166. if (rose_node->count < 3) {
  167. rose_node->neighbour[rose_node->count] = rose_neigh;
  168. rose_node->count++;
  169. rose_neigh->count++;
  170. }
  171. out:
  172. spin_unlock_bh(&rose_neigh_list_lock);
  173. spin_unlock_bh(&rose_node_list_lock);
  174. return res;
  175. }
  176. /*
  177. * Caller is holding rose_node_list_lock.
  178. */
  179. static void rose_remove_node(struct rose_node *rose_node)
  180. {
  181. struct rose_node *s;
  182. if ((s = rose_node_list) == rose_node) {
  183. rose_node_list = rose_node->next;
  184. kfree(rose_node);
  185. return;
  186. }
  187. while (s != NULL && s->next != NULL) {
  188. if (s->next == rose_node) {
  189. s->next = rose_node->next;
  190. kfree(rose_node);
  191. return;
  192. }
  193. s = s->next;
  194. }
  195. }
  196. /*
  197. * Caller is holding rose_neigh_list_lock.
  198. */
  199. static void rose_remove_neigh(struct rose_neigh *rose_neigh)
  200. {
  201. struct rose_neigh *s;
  202. rose_stop_ftimer(rose_neigh);
  203. rose_stop_t0timer(rose_neigh);
  204. skb_queue_purge(&rose_neigh->queue);
  205. if ((s = rose_neigh_list) == rose_neigh) {
  206. rose_neigh_list = rose_neigh->next;
  207. if (rose_neigh->ax25)
  208. ax25_cb_put(rose_neigh->ax25);
  209. kfree(rose_neigh->digipeat);
  210. kfree(rose_neigh);
  211. return;
  212. }
  213. while (s != NULL && s->next != NULL) {
  214. if (s->next == rose_neigh) {
  215. s->next = rose_neigh->next;
  216. if (rose_neigh->ax25)
  217. ax25_cb_put(rose_neigh->ax25);
  218. kfree(rose_neigh->digipeat);
  219. kfree(rose_neigh);
  220. return;
  221. }
  222. s = s->next;
  223. }
  224. }
  225. /*
  226. * Caller is holding rose_route_list_lock.
  227. */
  228. static void rose_remove_route(struct rose_route *rose_route)
  229. {
  230. struct rose_route *s;
  231. if (rose_route->neigh1 != NULL)
  232. rose_route->neigh1->use--;
  233. if (rose_route->neigh2 != NULL)
  234. rose_route->neigh2->use--;
  235. if ((s = rose_route_list) == rose_route) {
  236. rose_route_list = rose_route->next;
  237. kfree(rose_route);
  238. return;
  239. }
  240. while (s != NULL && s->next != NULL) {
  241. if (s->next == rose_route) {
  242. s->next = rose_route->next;
  243. kfree(rose_route);
  244. return;
  245. }
  246. s = s->next;
  247. }
  248. }
  249. /*
  250. * "Delete" a node. Strictly speaking remove a route to a node. The node
  251. * is only deleted if no routes are left to it.
  252. */
  253. static int rose_del_node(struct rose_route_struct *rose_route,
  254. struct net_device *dev)
  255. {
  256. struct rose_node *rose_node;
  257. struct rose_neigh *rose_neigh;
  258. int i, err = 0;
  259. spin_lock_bh(&rose_node_list_lock);
  260. spin_lock_bh(&rose_neigh_list_lock);
  261. rose_node = rose_node_list;
  262. while (rose_node != NULL) {
  263. if ((rose_node->mask == rose_route->mask) &&
  264. (rosecmpm(&rose_route->address, &rose_node->address,
  265. rose_route->mask) == 0))
  266. break;
  267. rose_node = rose_node->next;
  268. }
  269. if (rose_node == NULL || rose_node->loopback) {
  270. err = -EINVAL;
  271. goto out;
  272. }
  273. rose_neigh = rose_neigh_list;
  274. while (rose_neigh != NULL) {
  275. if (ax25cmp(&rose_route->neighbour,
  276. &rose_neigh->callsign) == 0 &&
  277. rose_neigh->dev == dev)
  278. break;
  279. rose_neigh = rose_neigh->next;
  280. }
  281. if (rose_neigh == NULL) {
  282. err = -EINVAL;
  283. goto out;
  284. }
  285. for (i = 0; i < rose_node->count; i++) {
  286. if (rose_node->neighbour[i] == rose_neigh) {
  287. rose_neigh->count--;
  288. if (rose_neigh->count == 0 && rose_neigh->use == 0)
  289. rose_remove_neigh(rose_neigh);
  290. rose_node->count--;
  291. if (rose_node->count == 0) {
  292. rose_remove_node(rose_node);
  293. } else {
  294. switch (i) {
  295. case 0:
  296. rose_node->neighbour[0] =
  297. rose_node->neighbour[1];
  298. case 1:
  299. rose_node->neighbour[1] =
  300. rose_node->neighbour[2];
  301. case 2:
  302. break;
  303. }
  304. }
  305. goto out;
  306. }
  307. }
  308. err = -EINVAL;
  309. out:
  310. spin_unlock_bh(&rose_neigh_list_lock);
  311. spin_unlock_bh(&rose_node_list_lock);
  312. return err;
  313. }
  314. /*
  315. * Add the loopback neighbour.
  316. */
  317. void rose_add_loopback_neigh(void)
  318. {
  319. struct rose_neigh *sn;
  320. rose_loopback_neigh = kmalloc(sizeof(struct rose_neigh), GFP_KERNEL);
  321. if (!rose_loopback_neigh)
  322. return;
  323. sn = rose_loopback_neigh;
  324. sn->callsign = null_ax25_address;
  325. sn->digipeat = NULL;
  326. sn->ax25 = NULL;
  327. sn->dev = NULL;
  328. sn->count = 0;
  329. sn->use = 0;
  330. sn->dce_mode = 1;
  331. sn->loopback = 1;
  332. sn->number = rose_neigh_no++;
  333. sn->restarted = 1;
  334. skb_queue_head_init(&sn->queue);
  335. timer_setup(&sn->ftimer, NULL, 0);
  336. timer_setup(&sn->t0timer, NULL, 0);
  337. spin_lock_bh(&rose_neigh_list_lock);
  338. sn->next = rose_neigh_list;
  339. rose_neigh_list = sn;
  340. spin_unlock_bh(&rose_neigh_list_lock);
  341. }
  342. /*
  343. * Add a loopback node.
  344. */
  345. int rose_add_loopback_node(rose_address *address)
  346. {
  347. struct rose_node *rose_node;
  348. int err = 0;
  349. spin_lock_bh(&rose_node_list_lock);
  350. rose_node = rose_node_list;
  351. while (rose_node != NULL) {
  352. if ((rose_node->mask == 10) &&
  353. (rosecmpm(address, &rose_node->address, 10) == 0) &&
  354. rose_node->loopback)
  355. break;
  356. rose_node = rose_node->next;
  357. }
  358. if (rose_node != NULL)
  359. goto out;
  360. if ((rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC)) == NULL) {
  361. err = -ENOMEM;
  362. goto out;
  363. }
  364. rose_node->address = *address;
  365. rose_node->mask = 10;
  366. rose_node->count = 1;
  367. rose_node->loopback = 1;
  368. rose_node->neighbour[0] = rose_loopback_neigh;
  369. /* Insert at the head of list. Address is always mask=10 */
  370. rose_node->next = rose_node_list;
  371. rose_node_list = rose_node;
  372. rose_loopback_neigh->count++;
  373. out:
  374. spin_unlock_bh(&rose_node_list_lock);
  375. return err;
  376. }
  377. /*
  378. * Delete a loopback node.
  379. */
  380. void rose_del_loopback_node(rose_address *address)
  381. {
  382. struct rose_node *rose_node;
  383. spin_lock_bh(&rose_node_list_lock);
  384. rose_node = rose_node_list;
  385. while (rose_node != NULL) {
  386. if ((rose_node->mask == 10) &&
  387. (rosecmpm(address, &rose_node->address, 10) == 0) &&
  388. rose_node->loopback)
  389. break;
  390. rose_node = rose_node->next;
  391. }
  392. if (rose_node == NULL)
  393. goto out;
  394. rose_remove_node(rose_node);
  395. rose_loopback_neigh->count--;
  396. out:
  397. spin_unlock_bh(&rose_node_list_lock);
  398. }
  399. /*
  400. * A device has been removed. Remove its routes and neighbours.
  401. */
  402. void rose_rt_device_down(struct net_device *dev)
  403. {
  404. struct rose_neigh *s, *rose_neigh;
  405. struct rose_node *t, *rose_node;
  406. int i;
  407. spin_lock_bh(&rose_node_list_lock);
  408. spin_lock_bh(&rose_neigh_list_lock);
  409. rose_neigh = rose_neigh_list;
  410. while (rose_neigh != NULL) {
  411. s = rose_neigh;
  412. rose_neigh = rose_neigh->next;
  413. if (s->dev != dev)
  414. continue;
  415. rose_node = rose_node_list;
  416. while (rose_node != NULL) {
  417. t = rose_node;
  418. rose_node = rose_node->next;
  419. for (i = 0; i < t->count; i++) {
  420. if (t->neighbour[i] != s)
  421. continue;
  422. t->count--;
  423. switch (i) {
  424. case 0:
  425. t->neighbour[0] = t->neighbour[1];
  426. case 1:
  427. t->neighbour[1] = t->neighbour[2];
  428. case 2:
  429. break;
  430. }
  431. }
  432. if (t->count <= 0)
  433. rose_remove_node(t);
  434. }
  435. rose_remove_neigh(s);
  436. }
  437. spin_unlock_bh(&rose_neigh_list_lock);
  438. spin_unlock_bh(&rose_node_list_lock);
  439. }
  440. #if 0 /* Currently unused */
  441. /*
  442. * A device has been removed. Remove its links.
  443. */
  444. void rose_route_device_down(struct net_device *dev)
  445. {
  446. struct rose_route *s, *rose_route;
  447. spin_lock_bh(&rose_route_list_lock);
  448. rose_route = rose_route_list;
  449. while (rose_route != NULL) {
  450. s = rose_route;
  451. rose_route = rose_route->next;
  452. if (s->neigh1->dev == dev || s->neigh2->dev == dev)
  453. rose_remove_route(s);
  454. }
  455. spin_unlock_bh(&rose_route_list_lock);
  456. }
  457. #endif
  458. /*
  459. * Clear all nodes and neighbours out, except for neighbours with
  460. * active connections going through them.
  461. * Do not clear loopback neighbour and nodes.
  462. */
  463. static int rose_clear_routes(void)
  464. {
  465. struct rose_neigh *s, *rose_neigh;
  466. struct rose_node *t, *rose_node;
  467. spin_lock_bh(&rose_node_list_lock);
  468. spin_lock_bh(&rose_neigh_list_lock);
  469. rose_neigh = rose_neigh_list;
  470. rose_node = rose_node_list;
  471. while (rose_node != NULL) {
  472. t = rose_node;
  473. rose_node = rose_node->next;
  474. if (!t->loopback)
  475. rose_remove_node(t);
  476. }
  477. while (rose_neigh != NULL) {
  478. s = rose_neigh;
  479. rose_neigh = rose_neigh->next;
  480. if (s->use == 0 && !s->loopback) {
  481. s->count = 0;
  482. rose_remove_neigh(s);
  483. }
  484. }
  485. spin_unlock_bh(&rose_neigh_list_lock);
  486. spin_unlock_bh(&rose_node_list_lock);
  487. return 0;
  488. }
  489. /*
  490. * Check that the device given is a valid AX.25 interface that is "up".
  491. * called with RTNL
  492. */
  493. static struct net_device *rose_ax25_dev_find(char *devname)
  494. {
  495. struct net_device *dev;
  496. if ((dev = __dev_get_by_name(&init_net, devname)) == NULL)
  497. return NULL;
  498. if ((dev->flags & IFF_UP) && dev->type == ARPHRD_AX25)
  499. return dev;
  500. return NULL;
  501. }
  502. /*
  503. * Find the first active ROSE device, usually "rose0".
  504. */
  505. struct net_device *rose_dev_first(void)
  506. {
  507. struct net_device *dev, *first = NULL;
  508. rcu_read_lock();
  509. for_each_netdev_rcu(&init_net, dev) {
  510. if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE)
  511. if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
  512. first = dev;
  513. }
  514. rcu_read_unlock();
  515. return first;
  516. }
  517. /*
  518. * Find the ROSE device for the given address.
  519. */
  520. struct net_device *rose_dev_get(rose_address *addr)
  521. {
  522. struct net_device *dev;
  523. rcu_read_lock();
  524. for_each_netdev_rcu(&init_net, dev) {
  525. if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) {
  526. dev_hold(dev);
  527. goto out;
  528. }
  529. }
  530. dev = NULL;
  531. out:
  532. rcu_read_unlock();
  533. return dev;
  534. }
  535. static int rose_dev_exists(rose_address *addr)
  536. {
  537. struct net_device *dev;
  538. rcu_read_lock();
  539. for_each_netdev_rcu(&init_net, dev) {
  540. if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0)
  541. goto out;
  542. }
  543. dev = NULL;
  544. out:
  545. rcu_read_unlock();
  546. return dev != NULL;
  547. }
  548. struct rose_route *rose_route_free_lci(unsigned int lci, struct rose_neigh *neigh)
  549. {
  550. struct rose_route *rose_route;
  551. for (rose_route = rose_route_list; rose_route != NULL; rose_route = rose_route->next)
  552. if ((rose_route->neigh1 == neigh && rose_route->lci1 == lci) ||
  553. (rose_route->neigh2 == neigh && rose_route->lci2 == lci))
  554. return rose_route;
  555. return NULL;
  556. }
  557. /*
  558. * Find a neighbour or a route given a ROSE address.
  559. */
  560. struct rose_neigh *rose_get_neigh(rose_address *addr, unsigned char *cause,
  561. unsigned char *diagnostic, int route_frame)
  562. {
  563. struct rose_neigh *res = NULL;
  564. struct rose_node *node;
  565. int failed = 0;
  566. int i;
  567. if (!route_frame) spin_lock_bh(&rose_node_list_lock);
  568. for (node = rose_node_list; node != NULL; node = node->next) {
  569. if (rosecmpm(addr, &node->address, node->mask) == 0) {
  570. for (i = 0; i < node->count; i++) {
  571. if (node->neighbour[i]->restarted) {
  572. res = node->neighbour[i];
  573. goto out;
  574. }
  575. }
  576. }
  577. }
  578. if (!route_frame) { /* connect request */
  579. for (node = rose_node_list; node != NULL; node = node->next) {
  580. if (rosecmpm(addr, &node->address, node->mask) == 0) {
  581. for (i = 0; i < node->count; i++) {
  582. if (!rose_ftimer_running(node->neighbour[i])) {
  583. res = node->neighbour[i];
  584. failed = 0;
  585. goto out;
  586. }
  587. failed = 1;
  588. }
  589. }
  590. }
  591. }
  592. if (failed) {
  593. *cause = ROSE_OUT_OF_ORDER;
  594. *diagnostic = 0;
  595. } else {
  596. *cause = ROSE_NOT_OBTAINABLE;
  597. *diagnostic = 0;
  598. }
  599. out:
  600. if (!route_frame) spin_unlock_bh(&rose_node_list_lock);
  601. return res;
  602. }
  603. /*
  604. * Handle the ioctls that control the routing functions.
  605. */
  606. int rose_rt_ioctl(unsigned int cmd, void __user *arg)
  607. {
  608. struct rose_route_struct rose_route;
  609. struct net_device *dev;
  610. int err;
  611. switch (cmd) {
  612. case SIOCADDRT:
  613. if (copy_from_user(&rose_route, arg, sizeof(struct rose_route_struct)))
  614. return -EFAULT;
  615. if ((dev = rose_ax25_dev_find(rose_route.device)) == NULL)
  616. return -EINVAL;
  617. if (rose_dev_exists(&rose_route.address)) /* Can't add routes to ourself */
  618. return -EINVAL;
  619. if (rose_route.mask > 10) /* Mask can't be more than 10 digits */
  620. return -EINVAL;
  621. if (rose_route.ndigis > AX25_MAX_DIGIS)
  622. return -EINVAL;
  623. err = rose_add_node(&rose_route, dev);
  624. return err;
  625. case SIOCDELRT:
  626. if (copy_from_user(&rose_route, arg, sizeof(struct rose_route_struct)))
  627. return -EFAULT;
  628. if ((dev = rose_ax25_dev_find(rose_route.device)) == NULL)
  629. return -EINVAL;
  630. err = rose_del_node(&rose_route, dev);
  631. return err;
  632. case SIOCRSCLRRT:
  633. return rose_clear_routes();
  634. default:
  635. return -EINVAL;
  636. }
  637. return 0;
  638. }
  639. static void rose_del_route_by_neigh(struct rose_neigh *rose_neigh)
  640. {
  641. struct rose_route *rose_route, *s;
  642. rose_neigh->restarted = 0;
  643. rose_stop_t0timer(rose_neigh);
  644. rose_start_ftimer(rose_neigh);
  645. skb_queue_purge(&rose_neigh->queue);
  646. spin_lock_bh(&rose_route_list_lock);
  647. rose_route = rose_route_list;
  648. while (rose_route != NULL) {
  649. if ((rose_route->neigh1 == rose_neigh && rose_route->neigh2 == rose_neigh) ||
  650. (rose_route->neigh1 == rose_neigh && rose_route->neigh2 == NULL) ||
  651. (rose_route->neigh2 == rose_neigh && rose_route->neigh1 == NULL)) {
  652. s = rose_route->next;
  653. rose_remove_route(rose_route);
  654. rose_route = s;
  655. continue;
  656. }
  657. if (rose_route->neigh1 == rose_neigh) {
  658. rose_route->neigh1->use--;
  659. rose_route->neigh1 = NULL;
  660. rose_transmit_clear_request(rose_route->neigh2, rose_route->lci2, ROSE_OUT_OF_ORDER, 0);
  661. }
  662. if (rose_route->neigh2 == rose_neigh) {
  663. rose_route->neigh2->use--;
  664. rose_route->neigh2 = NULL;
  665. rose_transmit_clear_request(rose_route->neigh1, rose_route->lci1, ROSE_OUT_OF_ORDER, 0);
  666. }
  667. rose_route = rose_route->next;
  668. }
  669. spin_unlock_bh(&rose_route_list_lock);
  670. }
  671. /*
  672. * A level 2 link has timed out, therefore it appears to be a poor link,
  673. * then don't use that neighbour until it is reset. Blow away all through
  674. * routes and connections using this route.
  675. */
  676. void rose_link_failed(ax25_cb *ax25, int reason)
  677. {
  678. struct rose_neigh *rose_neigh;
  679. spin_lock_bh(&rose_neigh_list_lock);
  680. rose_neigh = rose_neigh_list;
  681. while (rose_neigh != NULL) {
  682. if (rose_neigh->ax25 == ax25)
  683. break;
  684. rose_neigh = rose_neigh->next;
  685. }
  686. if (rose_neigh != NULL) {
  687. rose_neigh->ax25 = NULL;
  688. ax25_cb_put(ax25);
  689. rose_del_route_by_neigh(rose_neigh);
  690. rose_kill_by_neigh(rose_neigh);
  691. }
  692. spin_unlock_bh(&rose_neigh_list_lock);
  693. }
  694. /*
  695. * A device has been "downed" remove its link status. Blow away all
  696. * through routes and connections that use this device.
  697. */
  698. void rose_link_device_down(struct net_device *dev)
  699. {
  700. struct rose_neigh *rose_neigh;
  701. for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next) {
  702. if (rose_neigh->dev == dev) {
  703. rose_del_route_by_neigh(rose_neigh);
  704. rose_kill_by_neigh(rose_neigh);
  705. }
  706. }
  707. }
  708. /*
  709. * Route a frame to an appropriate AX.25 connection.
  710. * A NULL ax25_cb indicates an internally generated frame.
  711. */
  712. int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
  713. {
  714. struct rose_neigh *rose_neigh, *new_neigh;
  715. struct rose_route *rose_route;
  716. struct rose_facilities_struct facilities;
  717. rose_address *src_addr, *dest_addr;
  718. struct sock *sk;
  719. unsigned short frametype;
  720. unsigned int lci, new_lci;
  721. unsigned char cause, diagnostic;
  722. struct net_device *dev;
  723. int res = 0;
  724. char buf[11];
  725. if (skb->len < ROSE_MIN_LEN)
  726. return res;
  727. if (!ax25)
  728. return rose_loopback_queue(skb, NULL);
  729. frametype = skb->data[2];
  730. lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
  731. if (frametype == ROSE_CALL_REQUEST &&
  732. (skb->len <= ROSE_CALL_REQ_FACILITIES_OFF ||
  733. skb->data[ROSE_CALL_REQ_ADDR_LEN_OFF] !=
  734. ROSE_CALL_REQ_ADDR_LEN_VAL))
  735. return res;
  736. src_addr = (rose_address *)(skb->data + ROSE_CALL_REQ_SRC_ADDR_OFF);
  737. dest_addr = (rose_address *)(skb->data + ROSE_CALL_REQ_DEST_ADDR_OFF);
  738. spin_lock_bh(&rose_neigh_list_lock);
  739. spin_lock_bh(&rose_route_list_lock);
  740. rose_neigh = rose_neigh_list;
  741. while (rose_neigh != NULL) {
  742. if (ax25cmp(&ax25->dest_addr, &rose_neigh->callsign) == 0 &&
  743. ax25->ax25_dev->dev == rose_neigh->dev)
  744. break;
  745. rose_neigh = rose_neigh->next;
  746. }
  747. if (rose_neigh == NULL) {
  748. printk("rose_route : unknown neighbour or device %s\n",
  749. ax2asc(buf, &ax25->dest_addr));
  750. goto out;
  751. }
  752. /*
  753. * Obviously the link is working, halt the ftimer.
  754. */
  755. rose_stop_ftimer(rose_neigh);
  756. /*
  757. * LCI of zero is always for us, and its always a restart
  758. * frame.
  759. */
  760. if (lci == 0) {
  761. rose_link_rx_restart(skb, rose_neigh, frametype);
  762. goto out;
  763. }
  764. /*
  765. * Find an existing socket.
  766. */
  767. if ((sk = rose_find_socket(lci, rose_neigh)) != NULL) {
  768. if (frametype == ROSE_CALL_REQUEST) {
  769. struct rose_sock *rose = rose_sk(sk);
  770. /* Remove an existing unused socket */
  771. rose_clear_queues(sk);
  772. rose->cause = ROSE_NETWORK_CONGESTION;
  773. rose->diagnostic = 0;
  774. rose->neighbour->use--;
  775. rose->neighbour = NULL;
  776. rose->lci = 0;
  777. rose->state = ROSE_STATE_0;
  778. sk->sk_state = TCP_CLOSE;
  779. sk->sk_err = 0;
  780. sk->sk_shutdown |= SEND_SHUTDOWN;
  781. if (!sock_flag(sk, SOCK_DEAD)) {
  782. sk->sk_state_change(sk);
  783. sock_set_flag(sk, SOCK_DEAD);
  784. }
  785. }
  786. else {
  787. skb_reset_transport_header(skb);
  788. res = rose_process_rx_frame(sk, skb);
  789. goto out;
  790. }
  791. }
  792. /*
  793. * Is is a Call Request and is it for us ?
  794. */
  795. if (frametype == ROSE_CALL_REQUEST)
  796. if ((dev = rose_dev_get(dest_addr)) != NULL) {
  797. res = rose_rx_call_request(skb, dev, rose_neigh, lci);
  798. dev_put(dev);
  799. goto out;
  800. }
  801. if (!sysctl_rose_routing_control) {
  802. rose_transmit_clear_request(rose_neigh, lci, ROSE_NOT_OBTAINABLE, 0);
  803. goto out;
  804. }
  805. /*
  806. * Route it to the next in line if we have an entry for it.
  807. */
  808. rose_route = rose_route_list;
  809. while (rose_route != NULL) {
  810. if (rose_route->lci1 == lci &&
  811. rose_route->neigh1 == rose_neigh) {
  812. if (frametype == ROSE_CALL_REQUEST) {
  813. /* F6FBB - Remove an existing unused route */
  814. rose_remove_route(rose_route);
  815. break;
  816. } else if (rose_route->neigh2 != NULL) {
  817. skb->data[0] &= 0xF0;
  818. skb->data[0] |= (rose_route->lci2 >> 8) & 0x0F;
  819. skb->data[1] = (rose_route->lci2 >> 0) & 0xFF;
  820. rose_transmit_link(skb, rose_route->neigh2);
  821. if (frametype == ROSE_CLEAR_CONFIRMATION)
  822. rose_remove_route(rose_route);
  823. res = 1;
  824. goto out;
  825. } else {
  826. if (frametype == ROSE_CLEAR_CONFIRMATION)
  827. rose_remove_route(rose_route);
  828. goto out;
  829. }
  830. }
  831. if (rose_route->lci2 == lci &&
  832. rose_route->neigh2 == rose_neigh) {
  833. if (frametype == ROSE_CALL_REQUEST) {
  834. /* F6FBB - Remove an existing unused route */
  835. rose_remove_route(rose_route);
  836. break;
  837. } else if (rose_route->neigh1 != NULL) {
  838. skb->data[0] &= 0xF0;
  839. skb->data[0] |= (rose_route->lci1 >> 8) & 0x0F;
  840. skb->data[1] = (rose_route->lci1 >> 0) & 0xFF;
  841. rose_transmit_link(skb, rose_route->neigh1);
  842. if (frametype == ROSE_CLEAR_CONFIRMATION)
  843. rose_remove_route(rose_route);
  844. res = 1;
  845. goto out;
  846. } else {
  847. if (frametype == ROSE_CLEAR_CONFIRMATION)
  848. rose_remove_route(rose_route);
  849. goto out;
  850. }
  851. }
  852. rose_route = rose_route->next;
  853. }
  854. /*
  855. * We know that:
  856. * 1. The frame isn't for us,
  857. * 2. It isn't "owned" by any existing route.
  858. */
  859. if (frametype != ROSE_CALL_REQUEST) { /* XXX */
  860. res = 0;
  861. goto out;
  862. }
  863. memset(&facilities, 0x00, sizeof(struct rose_facilities_struct));
  864. if (!rose_parse_facilities(skb->data + ROSE_CALL_REQ_FACILITIES_OFF,
  865. skb->len - ROSE_CALL_REQ_FACILITIES_OFF,
  866. &facilities)) {
  867. rose_transmit_clear_request(rose_neigh, lci, ROSE_INVALID_FACILITY, 76);
  868. goto out;
  869. }
  870. /*
  871. * Check for routing loops.
  872. */
  873. rose_route = rose_route_list;
  874. while (rose_route != NULL) {
  875. if (rose_route->rand == facilities.rand &&
  876. rosecmp(src_addr, &rose_route->src_addr) == 0 &&
  877. ax25cmp(&facilities.dest_call, &rose_route->src_call) == 0 &&
  878. ax25cmp(&facilities.source_call, &rose_route->dest_call) == 0) {
  879. rose_transmit_clear_request(rose_neigh, lci, ROSE_NOT_OBTAINABLE, 120);
  880. goto out;
  881. }
  882. rose_route = rose_route->next;
  883. }
  884. if ((new_neigh = rose_get_neigh(dest_addr, &cause, &diagnostic, 1)) == NULL) {
  885. rose_transmit_clear_request(rose_neigh, lci, cause, diagnostic);
  886. goto out;
  887. }
  888. if ((new_lci = rose_new_lci(new_neigh)) == 0) {
  889. rose_transmit_clear_request(rose_neigh, lci, ROSE_NETWORK_CONGESTION, 71);
  890. goto out;
  891. }
  892. if ((rose_route = kmalloc(sizeof(*rose_route), GFP_ATOMIC)) == NULL) {
  893. rose_transmit_clear_request(rose_neigh, lci, ROSE_NETWORK_CONGESTION, 120);
  894. goto out;
  895. }
  896. rose_route->lci1 = lci;
  897. rose_route->src_addr = *src_addr;
  898. rose_route->dest_addr = *dest_addr;
  899. rose_route->src_call = facilities.dest_call;
  900. rose_route->dest_call = facilities.source_call;
  901. rose_route->rand = facilities.rand;
  902. rose_route->neigh1 = rose_neigh;
  903. rose_route->lci2 = new_lci;
  904. rose_route->neigh2 = new_neigh;
  905. rose_route->neigh1->use++;
  906. rose_route->neigh2->use++;
  907. rose_route->next = rose_route_list;
  908. rose_route_list = rose_route;
  909. skb->data[0] &= 0xF0;
  910. skb->data[0] |= (rose_route->lci2 >> 8) & 0x0F;
  911. skb->data[1] = (rose_route->lci2 >> 0) & 0xFF;
  912. rose_transmit_link(skb, rose_route->neigh2);
  913. res = 1;
  914. out:
  915. spin_unlock_bh(&rose_route_list_lock);
  916. spin_unlock_bh(&rose_neigh_list_lock);
  917. return res;
  918. }
  919. #ifdef CONFIG_PROC_FS
  920. static void *rose_node_start(struct seq_file *seq, loff_t *pos)
  921. __acquires(rose_node_list_lock)
  922. {
  923. struct rose_node *rose_node;
  924. int i = 1;
  925. spin_lock_bh(&rose_node_list_lock);
  926. if (*pos == 0)
  927. return SEQ_START_TOKEN;
  928. for (rose_node = rose_node_list; rose_node && i < *pos;
  929. rose_node = rose_node->next, ++i);
  930. return (i == *pos) ? rose_node : NULL;
  931. }
  932. static void *rose_node_next(struct seq_file *seq, void *v, loff_t *pos)
  933. {
  934. ++*pos;
  935. return (v == SEQ_START_TOKEN) ? rose_node_list
  936. : ((struct rose_node *)v)->next;
  937. }
  938. static void rose_node_stop(struct seq_file *seq, void *v)
  939. __releases(rose_node_list_lock)
  940. {
  941. spin_unlock_bh(&rose_node_list_lock);
  942. }
  943. static int rose_node_show(struct seq_file *seq, void *v)
  944. {
  945. char rsbuf[11];
  946. int i;
  947. if (v == SEQ_START_TOKEN)
  948. seq_puts(seq, "address mask n neigh neigh neigh\n");
  949. else {
  950. const struct rose_node *rose_node = v;
  951. /* if (rose_node->loopback) {
  952. seq_printf(seq, "%-10s %04d 1 loopback\n",
  953. rose2asc(rsbuf, &rose_node->address),
  954. rose_node->mask);
  955. } else { */
  956. seq_printf(seq, "%-10s %04d %d",
  957. rose2asc(rsbuf, &rose_node->address),
  958. rose_node->mask,
  959. rose_node->count);
  960. for (i = 0; i < rose_node->count; i++)
  961. seq_printf(seq, " %05d",
  962. rose_node->neighbour[i]->number);
  963. seq_puts(seq, "\n");
  964. /* } */
  965. }
  966. return 0;
  967. }
  968. static const struct seq_operations rose_node_seqops = {
  969. .start = rose_node_start,
  970. .next = rose_node_next,
  971. .stop = rose_node_stop,
  972. .show = rose_node_show,
  973. };
  974. static int rose_nodes_open(struct inode *inode, struct file *file)
  975. {
  976. return seq_open(file, &rose_node_seqops);
  977. }
  978. const struct file_operations rose_nodes_fops = {
  979. .owner = THIS_MODULE,
  980. .open = rose_nodes_open,
  981. .read = seq_read,
  982. .llseek = seq_lseek,
  983. .release = seq_release,
  984. };
  985. static void *rose_neigh_start(struct seq_file *seq, loff_t *pos)
  986. __acquires(rose_neigh_list_lock)
  987. {
  988. struct rose_neigh *rose_neigh;
  989. int i = 1;
  990. spin_lock_bh(&rose_neigh_list_lock);
  991. if (*pos == 0)
  992. return SEQ_START_TOKEN;
  993. for (rose_neigh = rose_neigh_list; rose_neigh && i < *pos;
  994. rose_neigh = rose_neigh->next, ++i);
  995. return (i == *pos) ? rose_neigh : NULL;
  996. }
  997. static void *rose_neigh_next(struct seq_file *seq, void *v, loff_t *pos)
  998. {
  999. ++*pos;
  1000. return (v == SEQ_START_TOKEN) ? rose_neigh_list
  1001. : ((struct rose_neigh *)v)->next;
  1002. }
  1003. static void rose_neigh_stop(struct seq_file *seq, void *v)
  1004. __releases(rose_neigh_list_lock)
  1005. {
  1006. spin_unlock_bh(&rose_neigh_list_lock);
  1007. }
  1008. static int rose_neigh_show(struct seq_file *seq, void *v)
  1009. {
  1010. char buf[11];
  1011. int i;
  1012. if (v == SEQ_START_TOKEN)
  1013. seq_puts(seq,
  1014. "addr callsign dev count use mode restart t0 tf digipeaters\n");
  1015. else {
  1016. struct rose_neigh *rose_neigh = v;
  1017. /* if (!rose_neigh->loopback) { */
  1018. seq_printf(seq, "%05d %-9s %-4s %3d %3d %3s %3s %3lu %3lu",
  1019. rose_neigh->number,
  1020. (rose_neigh->loopback) ? "RSLOOP-0" : ax2asc(buf, &rose_neigh->callsign),
  1021. rose_neigh->dev ? rose_neigh->dev->name : "???",
  1022. rose_neigh->count,
  1023. rose_neigh->use,
  1024. (rose_neigh->dce_mode) ? "DCE" : "DTE",
  1025. (rose_neigh->restarted) ? "yes" : "no",
  1026. ax25_display_timer(&rose_neigh->t0timer) / HZ,
  1027. ax25_display_timer(&rose_neigh->ftimer) / HZ);
  1028. if (rose_neigh->digipeat != NULL) {
  1029. for (i = 0; i < rose_neigh->digipeat->ndigi; i++)
  1030. seq_printf(seq, " %s", ax2asc(buf, &rose_neigh->digipeat->calls[i]));
  1031. }
  1032. seq_puts(seq, "\n");
  1033. }
  1034. return 0;
  1035. }
  1036. static const struct seq_operations rose_neigh_seqops = {
  1037. .start = rose_neigh_start,
  1038. .next = rose_neigh_next,
  1039. .stop = rose_neigh_stop,
  1040. .show = rose_neigh_show,
  1041. };
  1042. static int rose_neigh_open(struct inode *inode, struct file *file)
  1043. {
  1044. return seq_open(file, &rose_neigh_seqops);
  1045. }
  1046. const struct file_operations rose_neigh_fops = {
  1047. .owner = THIS_MODULE,
  1048. .open = rose_neigh_open,
  1049. .read = seq_read,
  1050. .llseek = seq_lseek,
  1051. .release = seq_release,
  1052. };
  1053. static void *rose_route_start(struct seq_file *seq, loff_t *pos)
  1054. __acquires(rose_route_list_lock)
  1055. {
  1056. struct rose_route *rose_route;
  1057. int i = 1;
  1058. spin_lock_bh(&rose_route_list_lock);
  1059. if (*pos == 0)
  1060. return SEQ_START_TOKEN;
  1061. for (rose_route = rose_route_list; rose_route && i < *pos;
  1062. rose_route = rose_route->next, ++i);
  1063. return (i == *pos) ? rose_route : NULL;
  1064. }
  1065. static void *rose_route_next(struct seq_file *seq, void *v, loff_t *pos)
  1066. {
  1067. ++*pos;
  1068. return (v == SEQ_START_TOKEN) ? rose_route_list
  1069. : ((struct rose_route *)v)->next;
  1070. }
  1071. static void rose_route_stop(struct seq_file *seq, void *v)
  1072. __releases(rose_route_list_lock)
  1073. {
  1074. spin_unlock_bh(&rose_route_list_lock);
  1075. }
  1076. static int rose_route_show(struct seq_file *seq, void *v)
  1077. {
  1078. char buf[11], rsbuf[11];
  1079. if (v == SEQ_START_TOKEN)
  1080. seq_puts(seq,
  1081. "lci address callsign neigh <-> lci address callsign neigh\n");
  1082. else {
  1083. struct rose_route *rose_route = v;
  1084. if (rose_route->neigh1)
  1085. seq_printf(seq,
  1086. "%3.3X %-10s %-9s %05d ",
  1087. rose_route->lci1,
  1088. rose2asc(rsbuf, &rose_route->src_addr),
  1089. ax2asc(buf, &rose_route->src_call),
  1090. rose_route->neigh1->number);
  1091. else
  1092. seq_puts(seq,
  1093. "000 * * 00000 ");
  1094. if (rose_route->neigh2)
  1095. seq_printf(seq,
  1096. "%3.3X %-10s %-9s %05d\n",
  1097. rose_route->lci2,
  1098. rose2asc(rsbuf, &rose_route->dest_addr),
  1099. ax2asc(buf, &rose_route->dest_call),
  1100. rose_route->neigh2->number);
  1101. else
  1102. seq_puts(seq,
  1103. "000 * * 00000\n");
  1104. }
  1105. return 0;
  1106. }
  1107. static const struct seq_operations rose_route_seqops = {
  1108. .start = rose_route_start,
  1109. .next = rose_route_next,
  1110. .stop = rose_route_stop,
  1111. .show = rose_route_show,
  1112. };
  1113. static int rose_route_open(struct inode *inode, struct file *file)
  1114. {
  1115. return seq_open(file, &rose_route_seqops);
  1116. }
  1117. const struct file_operations rose_routes_fops = {
  1118. .owner = THIS_MODULE,
  1119. .open = rose_route_open,
  1120. .read = seq_read,
  1121. .llseek = seq_lseek,
  1122. .release = seq_release,
  1123. };
  1124. #endif /* CONFIG_PROC_FS */
  1125. /*
  1126. * Release all memory associated with ROSE routing structures.
  1127. */
  1128. void __exit rose_rt_free(void)
  1129. {
  1130. struct rose_neigh *s, *rose_neigh = rose_neigh_list;
  1131. struct rose_node *t, *rose_node = rose_node_list;
  1132. struct rose_route *u, *rose_route = rose_route_list;
  1133. while (rose_neigh != NULL) {
  1134. s = rose_neigh;
  1135. rose_neigh = rose_neigh->next;
  1136. rose_remove_neigh(s);
  1137. }
  1138. while (rose_node != NULL) {
  1139. t = rose_node;
  1140. rose_node = rose_node->next;
  1141. rose_remove_node(t);
  1142. }
  1143. while (rose_route != NULL) {
  1144. u = rose_route;
  1145. rose_route = rose_route->next;
  1146. rose_remove_route(u);
  1147. }
  1148. }