dn_route.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812
  1. /*
  2. * DECnet An implementation of the DECnet protocol suite for the LINUX
  3. * operating system. DECnet is implemented using the BSD Socket
  4. * interface as the means of communication with the user level.
  5. *
  6. * DECnet Routing Functions (Endnode and Router)
  7. *
  8. * Authors: Steve Whitehouse <SteveW@ACM.org>
  9. * Eduardo Marcelo Serrat <emserrat@geocities.com>
  10. *
  11. * Changes:
  12. * Steve Whitehouse : Fixes to allow "intra-ethernet" and
  13. * "return-to-sender" bits on outgoing
  14. * packets.
  15. * Steve Whitehouse : Timeouts for cached routes.
  16. * Steve Whitehouse : Use dst cache for input routes too.
  17. * Steve Whitehouse : Fixed error values in dn_send_skb.
  18. * Steve Whitehouse : Rework routing functions to better fit
  19. * DECnet routing design
  20. * Alexey Kuznetsov : New SMP locking
  21. * Steve Whitehouse : More SMP locking changes & dn_cache_dump()
  22. * Steve Whitehouse : Prerouting NF hook, now really is prerouting.
  23. * Fixed possible skb leak in rtnetlink funcs.
  24. * Steve Whitehouse : Dave Miller's dynamic hash table sizing and
  25. * Alexey Kuznetsov's finer grained locking
  26. * from ipv4/route.c.
  27. * Steve Whitehouse : Routing is now starting to look like a
  28. * sensible set of code now, mainly due to
  29. * my copying the IPv4 routing code. The
  30. * hooks here are modified and will continue
  31. * to evolve for a while.
  32. * Steve Whitehouse : Real SMP at last :-) Also new netfilter
  33. * stuff. Look out raw sockets your days
  34. * are numbered!
  35. * Steve Whitehouse : Added return-to-sender functions. Added
  36. * backlog congestion level return codes.
  37. * Steve Whitehouse : Fixed bug where routes were set up with
  38. * no ref count on net devices.
  39. * Steve Whitehouse : RCU for the route cache
  40. * Steve Whitehouse : Preparations for the flow cache
  41. * Steve Whitehouse : Prepare for nonlinear skbs
  42. */
  43. /******************************************************************************
  44. (c) 1995-1998 E.M. Serrat emserrat@geocities.com
  45. This program is free software; you can redistribute it and/or modify
  46. it under the terms of the GNU General Public License as published by
  47. the Free Software Foundation; either version 2 of the License, or
  48. any later version.
  49. This program is distributed in the hope that it will be useful,
  50. but WITHOUT ANY WARRANTY; without even the implied warranty of
  51. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  52. GNU General Public License for more details.
  53. *******************************************************************************/
  54. #include <linux/errno.h>
  55. #include <linux/types.h>
  56. #include <linux/socket.h>
  57. #include <linux/in.h>
  58. #include <linux/kernel.h>
  59. #include <linux/sockios.h>
  60. #include <linux/net.h>
  61. #include <linux/netdevice.h>
  62. #include <linux/inet.h>
  63. #include <linux/route.h>
  64. #include <linux/in_route.h>
  65. #include <net/sock.h>
  66. #include <linux/mm.h>
  67. #include <linux/proc_fs.h>
  68. #include <linux/seq_file.h>
  69. #include <linux/init.h>
  70. #include <linux/rtnetlink.h>
  71. #include <linux/string.h>
  72. #include <linux/netfilter_decnet.h>
  73. #include <linux/rcupdate.h>
  74. #include <linux/times.h>
  75. #include <asm/errno.h>
  76. #include <net/net_namespace.h>
  77. #include <net/netlink.h>
  78. #include <net/neighbour.h>
  79. #include <net/dst.h>
  80. #include <net/flow.h>
  81. #include <net/fib_rules.h>
  82. #include <net/dn.h>
  83. #include <net/dn_dev.h>
  84. #include <net/dn_nsp.h>
  85. #include <net/dn_route.h>
  86. #include <net/dn_neigh.h>
  87. #include <net/dn_fib.h>
  88. struct dn_rt_hash_bucket
  89. {
  90. struct dn_route *chain;
  91. spinlock_t lock;
  92. };
  93. extern struct neigh_table dn_neigh_table;
  94. static unsigned char dn_hiord_addr[6] = {0xAA,0x00,0x04,0x00,0x00,0x00};
  95. static const int dn_rt_min_delay = 2 * HZ;
  96. static const int dn_rt_max_delay = 10 * HZ;
  97. static const int dn_rt_mtu_expires = 10 * 60 * HZ;
  98. static unsigned long dn_rt_deadline;
  99. static int dn_dst_gc(struct dst_ops *ops);
  100. static struct dst_entry *dn_dst_check(struct dst_entry *, __u32);
  101. static struct dst_entry *dn_dst_negative_advice(struct dst_entry *);
  102. static void dn_dst_link_failure(struct sk_buff *);
  103. static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu);
  104. static int dn_route_input(struct sk_buff *);
  105. static void dn_run_flush(unsigned long dummy);
  106. static struct dn_rt_hash_bucket *dn_rt_hash_table;
  107. static unsigned dn_rt_hash_mask;
  108. static struct timer_list dn_route_timer;
  109. static DEFINE_TIMER(dn_rt_flush_timer, dn_run_flush, 0, 0);
  110. int decnet_dst_gc_interval = 2;
  111. static struct dst_ops dn_dst_ops = {
  112. .family = PF_DECnet,
  113. .protocol = __constant_htons(ETH_P_DNA_RT),
  114. .gc_thresh = 128,
  115. .gc = dn_dst_gc,
  116. .check = dn_dst_check,
  117. .negative_advice = dn_dst_negative_advice,
  118. .link_failure = dn_dst_link_failure,
  119. .update_pmtu = dn_dst_update_pmtu,
  120. .entry_size = sizeof(struct dn_route),
  121. .entries = ATOMIC_INIT(0),
  122. };
  123. static __inline__ unsigned dn_hash(__le16 src, __le16 dst)
  124. {
  125. __u16 tmp = (__u16 __force)(src ^ dst);
  126. tmp ^= (tmp >> 3);
  127. tmp ^= (tmp >> 5);
  128. tmp ^= (tmp >> 10);
  129. return dn_rt_hash_mask & (unsigned)tmp;
  130. }
  131. static inline void dnrt_free(struct dn_route *rt)
  132. {
  133. call_rcu_bh(&rt->u.dst.rcu_head, dst_rcu_free);
  134. }
  135. static inline void dnrt_drop(struct dn_route *rt)
  136. {
  137. dst_release(&rt->u.dst);
  138. call_rcu_bh(&rt->u.dst.rcu_head, dst_rcu_free);
  139. }
  140. static void dn_dst_check_expire(unsigned long dummy)
  141. {
  142. int i;
  143. struct dn_route *rt, **rtp;
  144. unsigned long now = jiffies;
  145. unsigned long expire = 120 * HZ;
  146. for(i = 0; i <= dn_rt_hash_mask; i++) {
  147. rtp = &dn_rt_hash_table[i].chain;
  148. spin_lock(&dn_rt_hash_table[i].lock);
  149. while((rt=*rtp) != NULL) {
  150. if (atomic_read(&rt->u.dst.__refcnt) ||
  151. (now - rt->u.dst.lastuse) < expire) {
  152. rtp = &rt->u.dst.dn_next;
  153. continue;
  154. }
  155. *rtp = rt->u.dst.dn_next;
  156. rt->u.dst.dn_next = NULL;
  157. dnrt_free(rt);
  158. }
  159. spin_unlock(&dn_rt_hash_table[i].lock);
  160. if ((jiffies - now) > 0)
  161. break;
  162. }
  163. mod_timer(&dn_route_timer, now + decnet_dst_gc_interval * HZ);
  164. }
  165. static int dn_dst_gc(struct dst_ops *ops)
  166. {
  167. struct dn_route *rt, **rtp;
  168. int i;
  169. unsigned long now = jiffies;
  170. unsigned long expire = 10 * HZ;
  171. for(i = 0; i <= dn_rt_hash_mask; i++) {
  172. spin_lock_bh(&dn_rt_hash_table[i].lock);
  173. rtp = &dn_rt_hash_table[i].chain;
  174. while((rt=*rtp) != NULL) {
  175. if (atomic_read(&rt->u.dst.__refcnt) ||
  176. (now - rt->u.dst.lastuse) < expire) {
  177. rtp = &rt->u.dst.dn_next;
  178. continue;
  179. }
  180. *rtp = rt->u.dst.dn_next;
  181. rt->u.dst.dn_next = NULL;
  182. dnrt_drop(rt);
  183. break;
  184. }
  185. spin_unlock_bh(&dn_rt_hash_table[i].lock);
  186. }
  187. return 0;
  188. }
  189. /*
  190. * The decnet standards don't impose a particular minimum mtu, what they
  191. * do insist on is that the routing layer accepts a datagram of at least
  192. * 230 bytes long. Here we have to subtract the routing header length from
  193. * 230 to get the minimum acceptable mtu. If there is no neighbour, then we
  194. * assume the worst and use a long header size.
  195. *
  196. * We update both the mtu and the advertised mss (i.e. the segment size we
  197. * advertise to the other end).
  198. */
  199. static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu)
  200. {
  201. u32 min_mtu = 230;
  202. struct dn_dev *dn = dst->neighbour ?
  203. (struct dn_dev *)dst->neighbour->dev->dn_ptr : NULL;
  204. if (dn && dn->use_long == 0)
  205. min_mtu -= 6;
  206. else
  207. min_mtu -= 21;
  208. if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= min_mtu) {
  209. if (!(dst_metric_locked(dst, RTAX_MTU))) {
  210. dst->metrics[RTAX_MTU-1] = mtu;
  211. dst_set_expires(dst, dn_rt_mtu_expires);
  212. }
  213. if (!(dst_metric_locked(dst, RTAX_ADVMSS))) {
  214. u32 mss = mtu - DN_MAX_NSP_DATA_HEADER;
  215. if (dst_metric(dst, RTAX_ADVMSS) > mss)
  216. dst->metrics[RTAX_ADVMSS-1] = mss;
  217. }
  218. }
  219. }
  220. /*
  221. * When a route has been marked obsolete. (e.g. routing cache flush)
  222. */
  223. static struct dst_entry *dn_dst_check(struct dst_entry *dst, __u32 cookie)
  224. {
  225. return NULL;
  226. }
  227. static struct dst_entry *dn_dst_negative_advice(struct dst_entry *dst)
  228. {
  229. dst_release(dst);
  230. return NULL;
  231. }
  232. static void dn_dst_link_failure(struct sk_buff *skb)
  233. {
  234. return;
  235. }
  236. static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
  237. {
  238. return ((fl1->nl_u.dn_u.daddr ^ fl2->nl_u.dn_u.daddr) |
  239. (fl1->nl_u.dn_u.saddr ^ fl2->nl_u.dn_u.saddr) |
  240. (fl1->mark ^ fl2->mark) |
  241. (fl1->nl_u.dn_u.scope ^ fl2->nl_u.dn_u.scope) |
  242. (fl1->oif ^ fl2->oif) |
  243. (fl1->iif ^ fl2->iif)) == 0;
  244. }
  245. static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route **rp)
  246. {
  247. struct dn_route *rth, **rthp;
  248. unsigned long now = jiffies;
  249. rthp = &dn_rt_hash_table[hash].chain;
  250. spin_lock_bh(&dn_rt_hash_table[hash].lock);
  251. while((rth = *rthp) != NULL) {
  252. if (compare_keys(&rth->fl, &rt->fl)) {
  253. /* Put it first */
  254. *rthp = rth->u.dst.dn_next;
  255. rcu_assign_pointer(rth->u.dst.dn_next,
  256. dn_rt_hash_table[hash].chain);
  257. rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth);
  258. dst_use(&rth->u.dst, now);
  259. spin_unlock_bh(&dn_rt_hash_table[hash].lock);
  260. dnrt_drop(rt);
  261. *rp = rth;
  262. return 0;
  263. }
  264. rthp = &rth->u.dst.dn_next;
  265. }
  266. rcu_assign_pointer(rt->u.dst.dn_next, dn_rt_hash_table[hash].chain);
  267. rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt);
  268. dst_use(&rt->u.dst, now);
  269. spin_unlock_bh(&dn_rt_hash_table[hash].lock);
  270. *rp = rt;
  271. return 0;
  272. }
  273. void dn_run_flush(unsigned long dummy)
  274. {
  275. int i;
  276. struct dn_route *rt, *next;
  277. for(i = 0; i < dn_rt_hash_mask; i++) {
  278. spin_lock_bh(&dn_rt_hash_table[i].lock);
  279. if ((rt = xchg(&dn_rt_hash_table[i].chain, NULL)) == NULL)
  280. goto nothing_to_declare;
  281. for(; rt; rt=next) {
  282. next = rt->u.dst.dn_next;
  283. rt->u.dst.dn_next = NULL;
  284. dst_free((struct dst_entry *)rt);
  285. }
  286. nothing_to_declare:
  287. spin_unlock_bh(&dn_rt_hash_table[i].lock);
  288. }
  289. }
  290. static DEFINE_SPINLOCK(dn_rt_flush_lock);
  291. void dn_rt_cache_flush(int delay)
  292. {
  293. unsigned long now = jiffies;
  294. int user_mode = !in_interrupt();
  295. if (delay < 0)
  296. delay = dn_rt_min_delay;
  297. spin_lock_bh(&dn_rt_flush_lock);
  298. if (del_timer(&dn_rt_flush_timer) && delay > 0 && dn_rt_deadline) {
  299. long tmo = (long)(dn_rt_deadline - now);
  300. if (user_mode && tmo < dn_rt_max_delay - dn_rt_min_delay)
  301. tmo = 0;
  302. if (delay > tmo)
  303. delay = tmo;
  304. }
  305. if (delay <= 0) {
  306. spin_unlock_bh(&dn_rt_flush_lock);
  307. dn_run_flush(0);
  308. return;
  309. }
  310. if (dn_rt_deadline == 0)
  311. dn_rt_deadline = now + dn_rt_max_delay;
  312. dn_rt_flush_timer.expires = now + delay;
  313. add_timer(&dn_rt_flush_timer);
  314. spin_unlock_bh(&dn_rt_flush_lock);
  315. }
  316. /**
  317. * dn_return_short - Return a short packet to its sender
  318. * @skb: The packet to return
  319. *
  320. */
  321. static int dn_return_short(struct sk_buff *skb)
  322. {
  323. struct dn_skb_cb *cb;
  324. unsigned char *ptr;
  325. __le16 *src;
  326. __le16 *dst;
  327. __le16 tmp;
  328. /* Add back headers */
  329. skb_push(skb, skb->data - skb_network_header(skb));
  330. if ((skb = skb_unshare(skb, GFP_ATOMIC)) == NULL)
  331. return NET_RX_DROP;
  332. cb = DN_SKB_CB(skb);
  333. /* Skip packet length and point to flags */
  334. ptr = skb->data + 2;
  335. *ptr++ = (cb->rt_flags & ~DN_RT_F_RQR) | DN_RT_F_RTS;
  336. dst = (__le16 *)ptr;
  337. ptr += 2;
  338. src = (__le16 *)ptr;
  339. ptr += 2;
  340. *ptr = 0; /* Zero hop count */
  341. /* Swap source and destination */
  342. tmp = *src;
  343. *src = *dst;
  344. *dst = tmp;
  345. skb->pkt_type = PACKET_OUTGOING;
  346. dn_rt_finish_output(skb, NULL, NULL);
  347. return NET_RX_SUCCESS;
  348. }
  349. /**
  350. * dn_return_long - Return a long packet to its sender
  351. * @skb: The long format packet to return
  352. *
  353. */
  354. static int dn_return_long(struct sk_buff *skb)
  355. {
  356. struct dn_skb_cb *cb;
  357. unsigned char *ptr;
  358. unsigned char *src_addr, *dst_addr;
  359. unsigned char tmp[ETH_ALEN];
  360. /* Add back all headers */
  361. skb_push(skb, skb->data - skb_network_header(skb));
  362. if ((skb = skb_unshare(skb, GFP_ATOMIC)) == NULL)
  363. return NET_RX_DROP;
  364. cb = DN_SKB_CB(skb);
  365. /* Ignore packet length and point to flags */
  366. ptr = skb->data + 2;
  367. /* Skip padding */
  368. if (*ptr & DN_RT_F_PF) {
  369. char padlen = (*ptr & ~DN_RT_F_PF);
  370. ptr += padlen;
  371. }
  372. *ptr++ = (cb->rt_flags & ~DN_RT_F_RQR) | DN_RT_F_RTS;
  373. ptr += 2;
  374. dst_addr = ptr;
  375. ptr += 8;
  376. src_addr = ptr;
  377. ptr += 6;
  378. *ptr = 0; /* Zero hop count */
  379. /* Swap source and destination */
  380. memcpy(tmp, src_addr, ETH_ALEN);
  381. memcpy(src_addr, dst_addr, ETH_ALEN);
  382. memcpy(dst_addr, tmp, ETH_ALEN);
  383. skb->pkt_type = PACKET_OUTGOING;
  384. dn_rt_finish_output(skb, dst_addr, src_addr);
  385. return NET_RX_SUCCESS;
  386. }
  387. /**
  388. * dn_route_rx_packet - Try and find a route for an incoming packet
  389. * @skb: The packet to find a route for
  390. *
  391. * Returns: result of input function if route is found, error code otherwise
  392. */
  393. static int dn_route_rx_packet(struct sk_buff *skb)
  394. {
  395. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  396. int err;
  397. if ((err = dn_route_input(skb)) == 0)
  398. return dst_input(skb);
  399. if (decnet_debug_level & 4) {
  400. char *devname = skb->dev ? skb->dev->name : "???";
  401. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  402. printk(KERN_DEBUG
  403. "DECnet: dn_route_rx_packet: rt_flags=0x%02x dev=%s len=%d src=0x%04hx dst=0x%04hx err=%d type=%d\n",
  404. (int)cb->rt_flags, devname, skb->len,
  405. dn_ntohs(cb->src), dn_ntohs(cb->dst),
  406. err, skb->pkt_type);
  407. }
  408. if ((skb->pkt_type == PACKET_HOST) && (cb->rt_flags & DN_RT_F_RQR)) {
  409. switch(cb->rt_flags & DN_RT_PKT_MSK) {
  410. case DN_RT_PKT_SHORT:
  411. return dn_return_short(skb);
  412. case DN_RT_PKT_LONG:
  413. return dn_return_long(skb);
  414. }
  415. }
  416. kfree_skb(skb);
  417. return NET_RX_DROP;
  418. }
  419. static int dn_route_rx_long(struct sk_buff *skb)
  420. {
  421. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  422. unsigned char *ptr = skb->data;
  423. if (!pskb_may_pull(skb, 21)) /* 20 for long header, 1 for shortest nsp */
  424. goto drop_it;
  425. skb_pull(skb, 20);
  426. skb_reset_transport_header(skb);
  427. /* Destination info */
  428. ptr += 2;
  429. cb->dst = dn_eth2dn(ptr);
  430. if (memcmp(ptr, dn_hiord_addr, 4) != 0)
  431. goto drop_it;
  432. ptr += 6;
  433. /* Source info */
  434. ptr += 2;
  435. cb->src = dn_eth2dn(ptr);
  436. if (memcmp(ptr, dn_hiord_addr, 4) != 0)
  437. goto drop_it;
  438. ptr += 6;
  439. /* Other junk */
  440. ptr++;
  441. cb->hops = *ptr++; /* Visit Count */
  442. return NF_HOOK(PF_DECnet, NF_DN_PRE_ROUTING, skb, skb->dev, NULL, dn_route_rx_packet);
  443. drop_it:
  444. kfree_skb(skb);
  445. return NET_RX_DROP;
  446. }
  447. static int dn_route_rx_short(struct sk_buff *skb)
  448. {
  449. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  450. unsigned char *ptr = skb->data;
  451. if (!pskb_may_pull(skb, 6)) /* 5 for short header + 1 for shortest nsp */
  452. goto drop_it;
  453. skb_pull(skb, 5);
  454. skb_reset_transport_header(skb);
  455. cb->dst = *(__le16 *)ptr;
  456. ptr += 2;
  457. cb->src = *(__le16 *)ptr;
  458. ptr += 2;
  459. cb->hops = *ptr & 0x3f;
  460. return NF_HOOK(PF_DECnet, NF_DN_PRE_ROUTING, skb, skb->dev, NULL, dn_route_rx_packet);
  461. drop_it:
  462. kfree_skb(skb);
  463. return NET_RX_DROP;
  464. }
  465. static int dn_route_discard(struct sk_buff *skb)
  466. {
  467. /*
  468. * I know we drop the packet here, but thats considered success in
  469. * this case
  470. */
  471. kfree_skb(skb);
  472. return NET_RX_SUCCESS;
  473. }
  474. static int dn_route_ptp_hello(struct sk_buff *skb)
  475. {
  476. dn_dev_hello(skb);
  477. dn_neigh_pointopoint_hello(skb);
  478. return NET_RX_SUCCESS;
  479. }
  480. int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
  481. {
  482. struct dn_skb_cb *cb;
  483. unsigned char flags = 0;
  484. __u16 len = dn_ntohs(*(__le16 *)skb->data);
  485. struct dn_dev *dn = (struct dn_dev *)dev->dn_ptr;
  486. unsigned char padlen = 0;
  487. if (!net_eq(dev_net(dev), &init_net))
  488. goto dump_it;
  489. if (dn == NULL)
  490. goto dump_it;
  491. if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
  492. goto out;
  493. if (!pskb_may_pull(skb, 3))
  494. goto dump_it;
  495. skb_pull(skb, 2);
  496. if (len > skb->len)
  497. goto dump_it;
  498. skb_trim(skb, len);
  499. flags = *skb->data;
  500. cb = DN_SKB_CB(skb);
  501. cb->stamp = jiffies;
  502. cb->iif = dev->ifindex;
  503. /*
  504. * If we have padding, remove it.
  505. */
  506. if (flags & DN_RT_F_PF) {
  507. padlen = flags & ~DN_RT_F_PF;
  508. if (!pskb_may_pull(skb, padlen + 1))
  509. goto dump_it;
  510. skb_pull(skb, padlen);
  511. flags = *skb->data;
  512. }
  513. skb_reset_network_header(skb);
  514. /*
  515. * Weed out future version DECnet
  516. */
  517. if (flags & DN_RT_F_VER)
  518. goto dump_it;
  519. cb->rt_flags = flags;
  520. if (decnet_debug_level & 1)
  521. printk(KERN_DEBUG
  522. "dn_route_rcv: got 0x%02x from %s [%d %d %d]\n",
  523. (int)flags, (dev) ? dev->name : "???", len, skb->len,
  524. padlen);
  525. if (flags & DN_RT_PKT_CNTL) {
  526. if (unlikely(skb_linearize(skb)))
  527. goto dump_it;
  528. switch(flags & DN_RT_CNTL_MSK) {
  529. case DN_RT_PKT_INIT:
  530. dn_dev_init_pkt(skb);
  531. break;
  532. case DN_RT_PKT_VERI:
  533. dn_dev_veri_pkt(skb);
  534. break;
  535. }
  536. if (dn->parms.state != DN_DEV_S_RU)
  537. goto dump_it;
  538. switch(flags & DN_RT_CNTL_MSK) {
  539. case DN_RT_PKT_HELO:
  540. return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_route_ptp_hello);
  541. case DN_RT_PKT_L1RT:
  542. case DN_RT_PKT_L2RT:
  543. return NF_HOOK(PF_DECnet, NF_DN_ROUTE, skb, skb->dev, NULL, dn_route_discard);
  544. case DN_RT_PKT_ERTH:
  545. return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_neigh_router_hello);
  546. case DN_RT_PKT_EEDH:
  547. return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_neigh_endnode_hello);
  548. }
  549. } else {
  550. if (dn->parms.state != DN_DEV_S_RU)
  551. goto dump_it;
  552. skb_pull(skb, 1); /* Pull flags */
  553. switch(flags & DN_RT_PKT_MSK) {
  554. case DN_RT_PKT_LONG:
  555. return dn_route_rx_long(skb);
  556. case DN_RT_PKT_SHORT:
  557. return dn_route_rx_short(skb);
  558. }
  559. }
  560. dump_it:
  561. kfree_skb(skb);
  562. out:
  563. return NET_RX_DROP;
  564. }
  565. static int dn_output(struct sk_buff *skb)
  566. {
  567. struct dst_entry *dst = skb->dst;
  568. struct dn_route *rt = (struct dn_route *)dst;
  569. struct net_device *dev = dst->dev;
  570. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  571. struct neighbour *neigh;
  572. int err = -EINVAL;
  573. if ((neigh = dst->neighbour) == NULL)
  574. goto error;
  575. skb->dev = dev;
  576. cb->src = rt->rt_saddr;
  577. cb->dst = rt->rt_daddr;
  578. /*
  579. * Always set the Intra-Ethernet bit on all outgoing packets
  580. * originated on this node. Only valid flag from upper layers
  581. * is return-to-sender-requested. Set hop count to 0 too.
  582. */
  583. cb->rt_flags &= ~DN_RT_F_RQR;
  584. cb->rt_flags |= DN_RT_F_IE;
  585. cb->hops = 0;
  586. return NF_HOOK(PF_DECnet, NF_DN_LOCAL_OUT, skb, NULL, dev, neigh->output);
  587. error:
  588. if (net_ratelimit())
  589. printk(KERN_DEBUG "dn_output: This should not happen\n");
  590. kfree_skb(skb);
  591. return err;
  592. }
  593. static int dn_forward(struct sk_buff *skb)
  594. {
  595. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  596. struct dst_entry *dst = skb->dst;
  597. struct dn_dev *dn_db = dst->dev->dn_ptr;
  598. struct dn_route *rt;
  599. struct neighbour *neigh = dst->neighbour;
  600. int header_len;
  601. #ifdef CONFIG_NETFILTER
  602. struct net_device *dev = skb->dev;
  603. #endif
  604. if (skb->pkt_type != PACKET_HOST)
  605. goto drop;
  606. /* Ensure that we have enough space for headers */
  607. rt = (struct dn_route *)skb->dst;
  608. header_len = dn_db->use_long ? 21 : 6;
  609. if (skb_cow(skb, LL_RESERVED_SPACE(rt->u.dst.dev)+header_len))
  610. goto drop;
  611. /*
  612. * Hop count exceeded.
  613. */
  614. if (++cb->hops > 30)
  615. goto drop;
  616. skb->dev = rt->u.dst.dev;
  617. /*
  618. * If packet goes out same interface it came in on, then set
  619. * the Intra-Ethernet bit. This has no effect for short
  620. * packets, so we don't need to test for them here.
  621. */
  622. cb->rt_flags &= ~DN_RT_F_IE;
  623. if (rt->rt_flags & RTCF_DOREDIRECT)
  624. cb->rt_flags |= DN_RT_F_IE;
  625. return NF_HOOK(PF_DECnet, NF_DN_FORWARD, skb, dev, skb->dev, neigh->output);
  626. drop:
  627. kfree_skb(skb);
  628. return NET_RX_DROP;
  629. }
  630. /*
  631. * Used to catch bugs. This should never normally get
  632. * called.
  633. */
  634. static int dn_rt_bug(struct sk_buff *skb)
  635. {
  636. if (net_ratelimit()) {
  637. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  638. printk(KERN_DEBUG "dn_rt_bug: skb from:%04x to:%04x\n",
  639. dn_ntohs(cb->src), dn_ntohs(cb->dst));
  640. }
  641. kfree_skb(skb);
  642. return NET_RX_BAD;
  643. }
  644. static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
  645. {
  646. struct dn_fib_info *fi = res->fi;
  647. struct net_device *dev = rt->u.dst.dev;
  648. struct neighbour *n;
  649. unsigned mss;
  650. if (fi) {
  651. if (DN_FIB_RES_GW(*res) &&
  652. DN_FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK)
  653. rt->rt_gateway = DN_FIB_RES_GW(*res);
  654. memcpy(rt->u.dst.metrics, fi->fib_metrics,
  655. sizeof(rt->u.dst.metrics));
  656. }
  657. rt->rt_type = res->type;
  658. if (dev != NULL && rt->u.dst.neighbour == NULL) {
  659. n = __neigh_lookup_errno(&dn_neigh_table, &rt->rt_gateway, dev);
  660. if (IS_ERR(n))
  661. return PTR_ERR(n);
  662. rt->u.dst.neighbour = n;
  663. }
  664. if (dst_metric(&rt->u.dst, RTAX_MTU) == 0 ||
  665. dst_metric(&rt->u.dst, RTAX_MTU) > rt->u.dst.dev->mtu)
  666. rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu;
  667. mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst));
  668. if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0 ||
  669. dst_metric(&rt->u.dst, RTAX_ADVMSS) > mss)
  670. rt->u.dst.metrics[RTAX_ADVMSS-1] = mss;
  671. return 0;
  672. }
  673. static inline int dn_match_addr(__le16 addr1, __le16 addr2)
  674. {
  675. __u16 tmp = dn_ntohs(addr1) ^ dn_ntohs(addr2);
  676. int match = 16;
  677. while(tmp) {
  678. tmp >>= 1;
  679. match--;
  680. }
  681. return match;
  682. }
  683. static __le16 dnet_select_source(const struct net_device *dev, __le16 daddr, int scope)
  684. {
  685. __le16 saddr = 0;
  686. struct dn_dev *dn_db = dev->dn_ptr;
  687. struct dn_ifaddr *ifa;
  688. int best_match = 0;
  689. int ret;
  690. read_lock(&dev_base_lock);
  691. for(ifa = dn_db->ifa_list; ifa; ifa = ifa->ifa_next) {
  692. if (ifa->ifa_scope > scope)
  693. continue;
  694. if (!daddr) {
  695. saddr = ifa->ifa_local;
  696. break;
  697. }
  698. ret = dn_match_addr(daddr, ifa->ifa_local);
  699. if (ret > best_match)
  700. saddr = ifa->ifa_local;
  701. if (best_match == 0)
  702. saddr = ifa->ifa_local;
  703. }
  704. read_unlock(&dev_base_lock);
  705. return saddr;
  706. }
  707. static inline __le16 __dn_fib_res_prefsrc(struct dn_fib_res *res)
  708. {
  709. return dnet_select_source(DN_FIB_RES_DEV(*res), DN_FIB_RES_GW(*res), res->scope);
  710. }
  711. static inline __le16 dn_fib_rules_map_destination(__le16 daddr, struct dn_fib_res *res)
  712. {
  713. __le16 mask = dnet_make_mask(res->prefixlen);
  714. return (daddr&~mask)|res->fi->fib_nh->nh_gw;
  715. }
  716. static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *oldflp, int try_hard)
  717. {
  718. struct flowi fl = { .nl_u = { .dn_u =
  719. { .daddr = oldflp->fld_dst,
  720. .saddr = oldflp->fld_src,
  721. .scope = RT_SCOPE_UNIVERSE,
  722. } },
  723. .mark = oldflp->mark,
  724. .iif = init_net.loopback_dev->ifindex,
  725. .oif = oldflp->oif };
  726. struct dn_route *rt = NULL;
  727. struct net_device *dev_out = NULL, *dev;
  728. struct neighbour *neigh = NULL;
  729. unsigned hash;
  730. unsigned flags = 0;
  731. struct dn_fib_res res = { .fi = NULL, .type = RTN_UNICAST };
  732. int err;
  733. int free_res = 0;
  734. __le16 gateway = 0;
  735. if (decnet_debug_level & 16)
  736. printk(KERN_DEBUG
  737. "dn_route_output_slow: dst=%04x src=%04x mark=%d"
  738. " iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst),
  739. dn_ntohs(oldflp->fld_src),
  740. oldflp->mark, init_net.loopback_dev->ifindex, oldflp->oif);
  741. /* If we have an output interface, verify its a DECnet device */
  742. if (oldflp->oif) {
  743. dev_out = dev_get_by_index(&init_net, oldflp->oif);
  744. err = -ENODEV;
  745. if (dev_out && dev_out->dn_ptr == NULL) {
  746. dev_put(dev_out);
  747. dev_out = NULL;
  748. }
  749. if (dev_out == NULL)
  750. goto out;
  751. }
  752. /* If we have a source address, verify that its a local address */
  753. if (oldflp->fld_src) {
  754. err = -EADDRNOTAVAIL;
  755. if (dev_out) {
  756. if (dn_dev_islocal(dev_out, oldflp->fld_src))
  757. goto source_ok;
  758. dev_put(dev_out);
  759. goto out;
  760. }
  761. read_lock(&dev_base_lock);
  762. for_each_netdev(&init_net, dev) {
  763. if (!dev->dn_ptr)
  764. continue;
  765. if (!dn_dev_islocal(dev, oldflp->fld_src))
  766. continue;
  767. if ((dev->flags & IFF_LOOPBACK) &&
  768. oldflp->fld_dst &&
  769. !dn_dev_islocal(dev, oldflp->fld_dst))
  770. continue;
  771. dev_out = dev;
  772. break;
  773. }
  774. read_unlock(&dev_base_lock);
  775. if (dev_out == NULL)
  776. goto out;
  777. dev_hold(dev_out);
  778. source_ok:
  779. ;
  780. }
  781. /* No destination? Assume its local */
  782. if (!fl.fld_dst) {
  783. fl.fld_dst = fl.fld_src;
  784. err = -EADDRNOTAVAIL;
  785. if (dev_out)
  786. dev_put(dev_out);
  787. dev_out = init_net.loopback_dev;
  788. dev_hold(dev_out);
  789. if (!fl.fld_dst) {
  790. fl.fld_dst =
  791. fl.fld_src = dnet_select_source(dev_out, 0,
  792. RT_SCOPE_HOST);
  793. if (!fl.fld_dst)
  794. goto out;
  795. }
  796. fl.oif = init_net.loopback_dev->ifindex;
  797. res.type = RTN_LOCAL;
  798. goto make_route;
  799. }
  800. if (decnet_debug_level & 16)
  801. printk(KERN_DEBUG
  802. "dn_route_output_slow: initial checks complete."
  803. " dst=%o4x src=%04x oif=%d try_hard=%d\n",
  804. dn_ntohs(fl.fld_dst), dn_ntohs(fl.fld_src),
  805. fl.oif, try_hard);
  806. /*
  807. * N.B. If the kernel is compiled without router support then
  808. * dn_fib_lookup() will evaluate to non-zero so this if () block
  809. * will always be executed.
  810. */
  811. err = -ESRCH;
  812. if (try_hard || (err = dn_fib_lookup(&fl, &res)) != 0) {
  813. struct dn_dev *dn_db;
  814. if (err != -ESRCH)
  815. goto out;
  816. /*
  817. * Here the fallback is basically the standard algorithm for
  818. * routing in endnodes which is described in the DECnet routing
  819. * docs
  820. *
  821. * If we are not trying hard, look in neighbour cache.
  822. * The result is tested to ensure that if a specific output
  823. * device/source address was requested, then we honour that
  824. * here
  825. */
  826. if (!try_hard) {
  827. neigh = neigh_lookup_nodev(&dn_neigh_table, &init_net, &fl.fld_dst);
  828. if (neigh) {
  829. if ((oldflp->oif &&
  830. (neigh->dev->ifindex != oldflp->oif)) ||
  831. (oldflp->fld_src &&
  832. (!dn_dev_islocal(neigh->dev,
  833. oldflp->fld_src)))) {
  834. neigh_release(neigh);
  835. neigh = NULL;
  836. } else {
  837. if (dev_out)
  838. dev_put(dev_out);
  839. if (dn_dev_islocal(neigh->dev, fl.fld_dst)) {
  840. dev_out = init_net.loopback_dev;
  841. res.type = RTN_LOCAL;
  842. } else {
  843. dev_out = neigh->dev;
  844. }
  845. dev_hold(dev_out);
  846. goto select_source;
  847. }
  848. }
  849. }
  850. /* Not there? Perhaps its a local address */
  851. if (dev_out == NULL)
  852. dev_out = dn_dev_get_default();
  853. err = -ENODEV;
  854. if (dev_out == NULL)
  855. goto out;
  856. dn_db = dev_out->dn_ptr;
  857. /* Possible improvement - check all devices for local addr */
  858. if (dn_dev_islocal(dev_out, fl.fld_dst)) {
  859. dev_put(dev_out);
  860. dev_out = init_net.loopback_dev;
  861. dev_hold(dev_out);
  862. res.type = RTN_LOCAL;
  863. goto select_source;
  864. }
  865. /* Not local either.... try sending it to the default router */
  866. neigh = neigh_clone(dn_db->router);
  867. BUG_ON(neigh && neigh->dev != dev_out);
  868. /* Ok then, we assume its directly connected and move on */
  869. select_source:
  870. if (neigh)
  871. gateway = ((struct dn_neigh *)neigh)->addr;
  872. if (gateway == 0)
  873. gateway = fl.fld_dst;
  874. if (fl.fld_src == 0) {
  875. fl.fld_src = dnet_select_source(dev_out, gateway,
  876. res.type == RTN_LOCAL ?
  877. RT_SCOPE_HOST :
  878. RT_SCOPE_LINK);
  879. if (fl.fld_src == 0 && res.type != RTN_LOCAL)
  880. goto e_addr;
  881. }
  882. fl.oif = dev_out->ifindex;
  883. goto make_route;
  884. }
  885. free_res = 1;
  886. if (res.type == RTN_NAT)
  887. goto e_inval;
  888. if (res.type == RTN_LOCAL) {
  889. if (!fl.fld_src)
  890. fl.fld_src = fl.fld_dst;
  891. if (dev_out)
  892. dev_put(dev_out);
  893. dev_out = init_net.loopback_dev;
  894. dev_hold(dev_out);
  895. fl.oif = dev_out->ifindex;
  896. if (res.fi)
  897. dn_fib_info_put(res.fi);
  898. res.fi = NULL;
  899. goto make_route;
  900. }
  901. if (res.fi->fib_nhs > 1 && fl.oif == 0)
  902. dn_fib_select_multipath(&fl, &res);
  903. /*
  904. * We could add some logic to deal with default routes here and
  905. * get rid of some of the special casing above.
  906. */
  907. if (!fl.fld_src)
  908. fl.fld_src = DN_FIB_RES_PREFSRC(res);
  909. if (dev_out)
  910. dev_put(dev_out);
  911. dev_out = DN_FIB_RES_DEV(res);
  912. dev_hold(dev_out);
  913. fl.oif = dev_out->ifindex;
  914. gateway = DN_FIB_RES_GW(res);
  915. make_route:
  916. if (dev_out->flags & IFF_LOOPBACK)
  917. flags |= RTCF_LOCAL;
  918. rt = dst_alloc(&dn_dst_ops);
  919. if (rt == NULL)
  920. goto e_nobufs;
  921. atomic_set(&rt->u.dst.__refcnt, 1);
  922. rt->u.dst.flags = DST_HOST;
  923. rt->fl.fld_src = oldflp->fld_src;
  924. rt->fl.fld_dst = oldflp->fld_dst;
  925. rt->fl.oif = oldflp->oif;
  926. rt->fl.iif = 0;
  927. rt->fl.mark = oldflp->mark;
  928. rt->rt_saddr = fl.fld_src;
  929. rt->rt_daddr = fl.fld_dst;
  930. rt->rt_gateway = gateway ? gateway : fl.fld_dst;
  931. rt->rt_local_src = fl.fld_src;
  932. rt->rt_dst_map = fl.fld_dst;
  933. rt->rt_src_map = fl.fld_src;
  934. rt->u.dst.dev = dev_out;
  935. dev_hold(dev_out);
  936. rt->u.dst.neighbour = neigh;
  937. neigh = NULL;
  938. rt->u.dst.lastuse = jiffies;
  939. rt->u.dst.output = dn_output;
  940. rt->u.dst.input = dn_rt_bug;
  941. rt->rt_flags = flags;
  942. if (flags & RTCF_LOCAL)
  943. rt->u.dst.input = dn_nsp_rx;
  944. err = dn_rt_set_next_hop(rt, &res);
  945. if (err)
  946. goto e_neighbour;
  947. hash = dn_hash(rt->fl.fld_src, rt->fl.fld_dst);
  948. dn_insert_route(rt, hash, (struct dn_route **)pprt);
  949. done:
  950. if (neigh)
  951. neigh_release(neigh);
  952. if (free_res)
  953. dn_fib_res_put(&res);
  954. if (dev_out)
  955. dev_put(dev_out);
  956. out:
  957. return err;
  958. e_addr:
  959. err = -EADDRNOTAVAIL;
  960. goto done;
  961. e_inval:
  962. err = -EINVAL;
  963. goto done;
  964. e_nobufs:
  965. err = -ENOBUFS;
  966. goto done;
  967. e_neighbour:
  968. dst_free(&rt->u.dst);
  969. goto e_nobufs;
  970. }
  971. /*
  972. * N.B. The flags may be moved into the flowi at some future stage.
  973. */
  974. static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *flp, int flags)
  975. {
  976. unsigned hash = dn_hash(flp->fld_src, flp->fld_dst);
  977. struct dn_route *rt = NULL;
  978. if (!(flags & MSG_TRYHARD)) {
  979. rcu_read_lock_bh();
  980. for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt;
  981. rt = rcu_dereference(rt->u.dst.dn_next)) {
  982. if ((flp->fld_dst == rt->fl.fld_dst) &&
  983. (flp->fld_src == rt->fl.fld_src) &&
  984. (flp->mark == rt->fl.mark) &&
  985. (rt->fl.iif == 0) &&
  986. (rt->fl.oif == flp->oif)) {
  987. dst_use(&rt->u.dst, jiffies);
  988. rcu_read_unlock_bh();
  989. *pprt = &rt->u.dst;
  990. return 0;
  991. }
  992. }
  993. rcu_read_unlock_bh();
  994. }
  995. return dn_route_output_slow(pprt, flp, flags);
  996. }
  997. static int dn_route_output_key(struct dst_entry **pprt, struct flowi *flp, int flags)
  998. {
  999. int err;
  1000. err = __dn_route_output_key(pprt, flp, flags);
  1001. if (err == 0 && flp->proto) {
  1002. err = xfrm_lookup(pprt, flp, NULL, 0);
  1003. }
  1004. return err;
  1005. }
  1006. int dn_route_output_sock(struct dst_entry **pprt, struct flowi *fl, struct sock *sk, int flags)
  1007. {
  1008. int err;
  1009. err = __dn_route_output_key(pprt, fl, flags & MSG_TRYHARD);
  1010. if (err == 0 && fl->proto) {
  1011. err = xfrm_lookup(pprt, fl, sk, (flags & MSG_DONTWAIT) ?
  1012. 0 : XFRM_LOOKUP_WAIT);
  1013. }
  1014. return err;
  1015. }
  1016. static int dn_route_input_slow(struct sk_buff *skb)
  1017. {
  1018. struct dn_route *rt = NULL;
  1019. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  1020. struct net_device *in_dev = skb->dev;
  1021. struct net_device *out_dev = NULL;
  1022. struct dn_dev *dn_db;
  1023. struct neighbour *neigh = NULL;
  1024. unsigned hash;
  1025. int flags = 0;
  1026. __le16 gateway = 0;
  1027. __le16 local_src = 0;
  1028. struct flowi fl = { .nl_u = { .dn_u =
  1029. { .daddr = cb->dst,
  1030. .saddr = cb->src,
  1031. .scope = RT_SCOPE_UNIVERSE,
  1032. } },
  1033. .mark = skb->mark,
  1034. .iif = skb->dev->ifindex };
  1035. struct dn_fib_res res = { .fi = NULL, .type = RTN_UNREACHABLE };
  1036. int err = -EINVAL;
  1037. int free_res = 0;
  1038. dev_hold(in_dev);
  1039. if ((dn_db = in_dev->dn_ptr) == NULL)
  1040. goto out;
  1041. /* Zero source addresses are not allowed */
  1042. if (fl.fld_src == 0)
  1043. goto out;
  1044. /*
  1045. * In this case we've just received a packet from a source
  1046. * outside ourselves pretending to come from us. We don't
  1047. * allow it any further to prevent routing loops, spoofing and
  1048. * other nasties. Loopback packets already have the dst attached
  1049. * so this only affects packets which have originated elsewhere.
  1050. */
  1051. err = -ENOTUNIQ;
  1052. if (dn_dev_islocal(in_dev, cb->src))
  1053. goto out;
  1054. err = dn_fib_lookup(&fl, &res);
  1055. if (err) {
  1056. if (err != -ESRCH)
  1057. goto out;
  1058. /*
  1059. * Is the destination us ?
  1060. */
  1061. if (!dn_dev_islocal(in_dev, cb->dst))
  1062. goto e_inval;
  1063. res.type = RTN_LOCAL;
  1064. } else {
  1065. __le16 src_map = fl.fld_src;
  1066. free_res = 1;
  1067. out_dev = DN_FIB_RES_DEV(res);
  1068. if (out_dev == NULL) {
  1069. if (net_ratelimit())
  1070. printk(KERN_CRIT "Bug in dn_route_input_slow() "
  1071. "No output device\n");
  1072. goto e_inval;
  1073. }
  1074. dev_hold(out_dev);
  1075. if (res.r)
  1076. src_map = fl.fld_src; /* no NAT support for now */
  1077. gateway = DN_FIB_RES_GW(res);
  1078. if (res.type == RTN_NAT) {
  1079. fl.fld_dst = dn_fib_rules_map_destination(fl.fld_dst, &res);
  1080. dn_fib_res_put(&res);
  1081. free_res = 0;
  1082. if (dn_fib_lookup(&fl, &res))
  1083. goto e_inval;
  1084. free_res = 1;
  1085. if (res.type != RTN_UNICAST)
  1086. goto e_inval;
  1087. flags |= RTCF_DNAT;
  1088. gateway = fl.fld_dst;
  1089. }
  1090. fl.fld_src = src_map;
  1091. }
  1092. switch(res.type) {
  1093. case RTN_UNICAST:
  1094. /*
  1095. * Forwarding check here, we only check for forwarding
  1096. * being turned off, if you want to only forward intra
  1097. * area, its up to you to set the routing tables up
  1098. * correctly.
  1099. */
  1100. if (dn_db->parms.forwarding == 0)
  1101. goto e_inval;
  1102. if (res.fi->fib_nhs > 1 && fl.oif == 0)
  1103. dn_fib_select_multipath(&fl, &res);
  1104. /*
  1105. * Check for out_dev == in_dev. We use the RTCF_DOREDIRECT
  1106. * flag as a hint to set the intra-ethernet bit when
  1107. * forwarding. If we've got NAT in operation, we don't do
  1108. * this optimisation.
  1109. */
  1110. if (out_dev == in_dev && !(flags & RTCF_NAT))
  1111. flags |= RTCF_DOREDIRECT;
  1112. local_src = DN_FIB_RES_PREFSRC(res);
  1113. case RTN_BLACKHOLE:
  1114. case RTN_UNREACHABLE:
  1115. break;
  1116. case RTN_LOCAL:
  1117. flags |= RTCF_LOCAL;
  1118. fl.fld_src = cb->dst;
  1119. fl.fld_dst = cb->src;
  1120. /* Routing tables gave us a gateway */
  1121. if (gateway)
  1122. goto make_route;
  1123. /* Packet was intra-ethernet, so we know its on-link */
  1124. if (cb->rt_flags & DN_RT_F_IE) {
  1125. gateway = cb->src;
  1126. flags |= RTCF_DIRECTSRC;
  1127. goto make_route;
  1128. }
  1129. /* Use the default router if there is one */
  1130. neigh = neigh_clone(dn_db->router);
  1131. if (neigh) {
  1132. gateway = ((struct dn_neigh *)neigh)->addr;
  1133. goto make_route;
  1134. }
  1135. /* Close eyes and pray */
  1136. gateway = cb->src;
  1137. flags |= RTCF_DIRECTSRC;
  1138. goto make_route;
  1139. default:
  1140. goto e_inval;
  1141. }
  1142. make_route:
  1143. rt = dst_alloc(&dn_dst_ops);
  1144. if (rt == NULL)
  1145. goto e_nobufs;
  1146. rt->rt_saddr = fl.fld_src;
  1147. rt->rt_daddr = fl.fld_dst;
  1148. rt->rt_gateway = fl.fld_dst;
  1149. if (gateway)
  1150. rt->rt_gateway = gateway;
  1151. rt->rt_local_src = local_src ? local_src : rt->rt_saddr;
  1152. rt->rt_dst_map = fl.fld_dst;
  1153. rt->rt_src_map = fl.fld_src;
  1154. rt->fl.fld_src = cb->src;
  1155. rt->fl.fld_dst = cb->dst;
  1156. rt->fl.oif = 0;
  1157. rt->fl.iif = in_dev->ifindex;
  1158. rt->fl.mark = fl.mark;
  1159. rt->u.dst.flags = DST_HOST;
  1160. rt->u.dst.neighbour = neigh;
  1161. rt->u.dst.dev = out_dev;
  1162. rt->u.dst.lastuse = jiffies;
  1163. rt->u.dst.output = dn_rt_bug;
  1164. switch(res.type) {
  1165. case RTN_UNICAST:
  1166. rt->u.dst.input = dn_forward;
  1167. break;
  1168. case RTN_LOCAL:
  1169. rt->u.dst.output = dn_output;
  1170. rt->u.dst.input = dn_nsp_rx;
  1171. rt->u.dst.dev = in_dev;
  1172. flags |= RTCF_LOCAL;
  1173. break;
  1174. default:
  1175. case RTN_UNREACHABLE:
  1176. case RTN_BLACKHOLE:
  1177. rt->u.dst.input = dst_discard;
  1178. }
  1179. rt->rt_flags = flags;
  1180. if (rt->u.dst.dev)
  1181. dev_hold(rt->u.dst.dev);
  1182. err = dn_rt_set_next_hop(rt, &res);
  1183. if (err)
  1184. goto e_neighbour;
  1185. hash = dn_hash(rt->fl.fld_src, rt->fl.fld_dst);
  1186. dn_insert_route(rt, hash, (struct dn_route **)&skb->dst);
  1187. done:
  1188. if (neigh)
  1189. neigh_release(neigh);
  1190. if (free_res)
  1191. dn_fib_res_put(&res);
  1192. dev_put(in_dev);
  1193. if (out_dev)
  1194. dev_put(out_dev);
  1195. out:
  1196. return err;
  1197. e_inval:
  1198. err = -EINVAL;
  1199. goto done;
  1200. e_nobufs:
  1201. err = -ENOBUFS;
  1202. goto done;
  1203. e_neighbour:
  1204. dst_free(&rt->u.dst);
  1205. goto done;
  1206. }
  1207. int dn_route_input(struct sk_buff *skb)
  1208. {
  1209. struct dn_route *rt;
  1210. struct dn_skb_cb *cb = DN_SKB_CB(skb);
  1211. unsigned hash = dn_hash(cb->src, cb->dst);
  1212. if (skb->dst)
  1213. return 0;
  1214. rcu_read_lock();
  1215. for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL;
  1216. rt = rcu_dereference(rt->u.dst.dn_next)) {
  1217. if ((rt->fl.fld_src == cb->src) &&
  1218. (rt->fl.fld_dst == cb->dst) &&
  1219. (rt->fl.oif == 0) &&
  1220. (rt->fl.mark == skb->mark) &&
  1221. (rt->fl.iif == cb->iif)) {
  1222. dst_use(&rt->u.dst, jiffies);
  1223. rcu_read_unlock();
  1224. skb->dst = (struct dst_entry *)rt;
  1225. return 0;
  1226. }
  1227. }
  1228. rcu_read_unlock();
  1229. return dn_route_input_slow(skb);
  1230. }
  1231. static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
  1232. int event, int nowait, unsigned int flags)
  1233. {
  1234. struct dn_route *rt = (struct dn_route *)skb->dst;
  1235. struct rtmsg *r;
  1236. struct nlmsghdr *nlh;
  1237. unsigned char *b = skb_tail_pointer(skb);
  1238. long expires;
  1239. nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*r), flags);
  1240. r = NLMSG_DATA(nlh);
  1241. r->rtm_family = AF_DECnet;
  1242. r->rtm_dst_len = 16;
  1243. r->rtm_src_len = 0;
  1244. r->rtm_tos = 0;
  1245. r->rtm_table = RT_TABLE_MAIN;
  1246. RTA_PUT_U32(skb, RTA_TABLE, RT_TABLE_MAIN);
  1247. r->rtm_type = rt->rt_type;
  1248. r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED;
  1249. r->rtm_scope = RT_SCOPE_UNIVERSE;
  1250. r->rtm_protocol = RTPROT_UNSPEC;
  1251. if (rt->rt_flags & RTCF_NOTIFY)
  1252. r->rtm_flags |= RTM_F_NOTIFY;
  1253. RTA_PUT(skb, RTA_DST, 2, &rt->rt_daddr);
  1254. if (rt->fl.fld_src) {
  1255. r->rtm_src_len = 16;
  1256. RTA_PUT(skb, RTA_SRC, 2, &rt->fl.fld_src);
  1257. }
  1258. if (rt->u.dst.dev)
  1259. RTA_PUT(skb, RTA_OIF, sizeof(int), &rt->u.dst.dev->ifindex);
  1260. /*
  1261. * Note to self - change this if input routes reverse direction when
  1262. * they deal only with inputs and not with replies like they do
  1263. * currently.
  1264. */
  1265. RTA_PUT(skb, RTA_PREFSRC, 2, &rt->rt_local_src);
  1266. if (rt->rt_daddr != rt->rt_gateway)
  1267. RTA_PUT(skb, RTA_GATEWAY, 2, &rt->rt_gateway);
  1268. if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0)
  1269. goto rtattr_failure;
  1270. expires = rt->u.dst.expires ? rt->u.dst.expires - jiffies : 0;
  1271. if (rtnl_put_cacheinfo(skb, &rt->u.dst, 0, 0, 0, expires,
  1272. rt->u.dst.error) < 0)
  1273. goto rtattr_failure;
  1274. if (rt->fl.iif)
  1275. RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->fl.iif);
  1276. nlh->nlmsg_len = skb_tail_pointer(skb) - b;
  1277. return skb->len;
  1278. nlmsg_failure:
  1279. rtattr_failure:
  1280. nlmsg_trim(skb, b);
  1281. return -1;
  1282. }
  1283. /*
  1284. * This is called by both endnodes and routers now.
  1285. */
  1286. static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void *arg)
  1287. {
  1288. struct net *net = sock_net(in_skb->sk);
  1289. struct rtattr **rta = arg;
  1290. struct rtmsg *rtm = NLMSG_DATA(nlh);
  1291. struct dn_route *rt = NULL;
  1292. struct dn_skb_cb *cb;
  1293. int err;
  1294. struct sk_buff *skb;
  1295. struct flowi fl;
  1296. if (net != &init_net)
  1297. return -EINVAL;
  1298. memset(&fl, 0, sizeof(fl));
  1299. fl.proto = DNPROTO_NSP;
  1300. skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
  1301. if (skb == NULL)
  1302. return -ENOBUFS;
  1303. skb_reset_mac_header(skb);
  1304. cb = DN_SKB_CB(skb);
  1305. if (rta[RTA_SRC-1])
  1306. memcpy(&fl.fld_src, RTA_DATA(rta[RTA_SRC-1]), 2);
  1307. if (rta[RTA_DST-1])
  1308. memcpy(&fl.fld_dst, RTA_DATA(rta[RTA_DST-1]), 2);
  1309. if (rta[RTA_IIF-1])
  1310. memcpy(&fl.iif, RTA_DATA(rta[RTA_IIF-1]), sizeof(int));
  1311. if (fl.iif) {
  1312. struct net_device *dev;
  1313. if ((dev = dev_get_by_index(&init_net, fl.iif)) == NULL) {
  1314. kfree_skb(skb);
  1315. return -ENODEV;
  1316. }
  1317. if (!dev->dn_ptr) {
  1318. dev_put(dev);
  1319. kfree_skb(skb);
  1320. return -ENODEV;
  1321. }
  1322. skb->protocol = htons(ETH_P_DNA_RT);
  1323. skb->dev = dev;
  1324. cb->src = fl.fld_src;
  1325. cb->dst = fl.fld_dst;
  1326. local_bh_disable();
  1327. err = dn_route_input(skb);
  1328. local_bh_enable();
  1329. memset(cb, 0, sizeof(struct dn_skb_cb));
  1330. rt = (struct dn_route *)skb->dst;
  1331. if (!err && -rt->u.dst.error)
  1332. err = rt->u.dst.error;
  1333. } else {
  1334. int oif = 0;
  1335. if (rta[RTA_OIF - 1])
  1336. memcpy(&oif, RTA_DATA(rta[RTA_OIF - 1]), sizeof(int));
  1337. fl.oif = oif;
  1338. err = dn_route_output_key((struct dst_entry **)&rt, &fl, 0);
  1339. }
  1340. if (skb->dev)
  1341. dev_put(skb->dev);
  1342. skb->dev = NULL;
  1343. if (err)
  1344. goto out_free;
  1345. skb->dst = &rt->u.dst;
  1346. if (rtm->rtm_flags & RTM_F_NOTIFY)
  1347. rt->rt_flags |= RTCF_NOTIFY;
  1348. err = dn_rt_fill_info(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq, RTM_NEWROUTE, 0, 0);
  1349. if (err == 0)
  1350. goto out_free;
  1351. if (err < 0) {
  1352. err = -EMSGSIZE;
  1353. goto out_free;
  1354. }
  1355. return rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid);
  1356. out_free:
  1357. kfree_skb(skb);
  1358. return err;
  1359. }
  1360. /*
  1361. * For routers, this is called from dn_fib_dump, but for endnodes its
  1362. * called directly from the rtnetlink dispatch table.
  1363. */
  1364. int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb)
  1365. {
  1366. struct net *net = sock_net(skb->sk);
  1367. struct dn_route *rt;
  1368. int h, s_h;
  1369. int idx, s_idx;
  1370. if (net != &init_net)
  1371. return 0;
  1372. if (NLMSG_PAYLOAD(cb->nlh, 0) < sizeof(struct rtmsg))
  1373. return -EINVAL;
  1374. if (!(((struct rtmsg *)NLMSG_DATA(cb->nlh))->rtm_flags&RTM_F_CLONED))
  1375. return 0;
  1376. s_h = cb->args[0];
  1377. s_idx = idx = cb->args[1];
  1378. for(h = 0; h <= dn_rt_hash_mask; h++) {
  1379. if (h < s_h)
  1380. continue;
  1381. if (h > s_h)
  1382. s_idx = 0;
  1383. rcu_read_lock_bh();
  1384. for(rt = rcu_dereference(dn_rt_hash_table[h].chain), idx = 0;
  1385. rt;
  1386. rt = rcu_dereference(rt->u.dst.dn_next), idx++) {
  1387. if (idx < s_idx)
  1388. continue;
  1389. skb->dst = dst_clone(&rt->u.dst);
  1390. if (dn_rt_fill_info(skb, NETLINK_CB(cb->skb).pid,
  1391. cb->nlh->nlmsg_seq, RTM_NEWROUTE,
  1392. 1, NLM_F_MULTI) <= 0) {
  1393. dst_release(xchg(&skb->dst, NULL));
  1394. rcu_read_unlock_bh();
  1395. goto done;
  1396. }
  1397. dst_release(xchg(&skb->dst, NULL));
  1398. }
  1399. rcu_read_unlock_bh();
  1400. }
  1401. done:
  1402. cb->args[0] = h;
  1403. cb->args[1] = idx;
  1404. return skb->len;
  1405. }
  1406. #ifdef CONFIG_PROC_FS
  1407. struct dn_rt_cache_iter_state {
  1408. int bucket;
  1409. };
  1410. static struct dn_route *dn_rt_cache_get_first(struct seq_file *seq)
  1411. {
  1412. struct dn_route *rt = NULL;
  1413. struct dn_rt_cache_iter_state *s = seq->private;
  1414. for(s->bucket = dn_rt_hash_mask; s->bucket >= 0; --s->bucket) {
  1415. rcu_read_lock_bh();
  1416. rt = dn_rt_hash_table[s->bucket].chain;
  1417. if (rt)
  1418. break;
  1419. rcu_read_unlock_bh();
  1420. }
  1421. return rcu_dereference(rt);
  1422. }
  1423. static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt)
  1424. {
  1425. struct dn_rt_cache_iter_state *s = seq->private;
  1426. rt = rt->u.dst.dn_next;
  1427. while(!rt) {
  1428. rcu_read_unlock_bh();
  1429. if (--s->bucket < 0)
  1430. break;
  1431. rcu_read_lock_bh();
  1432. rt = dn_rt_hash_table[s->bucket].chain;
  1433. }
  1434. return rcu_dereference(rt);
  1435. }
  1436. static void *dn_rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
  1437. {
  1438. struct dn_route *rt = dn_rt_cache_get_first(seq);
  1439. if (rt) {
  1440. while(*pos && (rt = dn_rt_cache_get_next(seq, rt)))
  1441. --*pos;
  1442. }
  1443. return *pos ? NULL : rt;
  1444. }
  1445. static void *dn_rt_cache_seq_next(struct seq_file *seq, void *v, loff_t *pos)
  1446. {
  1447. struct dn_route *rt = dn_rt_cache_get_next(seq, v);
  1448. ++*pos;
  1449. return rt;
  1450. }
  1451. static void dn_rt_cache_seq_stop(struct seq_file *seq, void *v)
  1452. {
  1453. if (v)
  1454. rcu_read_unlock_bh();
  1455. }
  1456. static int dn_rt_cache_seq_show(struct seq_file *seq, void *v)
  1457. {
  1458. struct dn_route *rt = v;
  1459. char buf1[DN_ASCBUF_LEN], buf2[DN_ASCBUF_LEN];
  1460. seq_printf(seq, "%-8s %-7s %-7s %04d %04d %04d\n",
  1461. rt->u.dst.dev ? rt->u.dst.dev->name : "*",
  1462. dn_addr2asc(dn_ntohs(rt->rt_daddr), buf1),
  1463. dn_addr2asc(dn_ntohs(rt->rt_saddr), buf2),
  1464. atomic_read(&rt->u.dst.__refcnt),
  1465. rt->u.dst.__use,
  1466. (int) dst_metric(&rt->u.dst, RTAX_RTT));
  1467. return 0;
  1468. }
  1469. static const struct seq_operations dn_rt_cache_seq_ops = {
  1470. .start = dn_rt_cache_seq_start,
  1471. .next = dn_rt_cache_seq_next,
  1472. .stop = dn_rt_cache_seq_stop,
  1473. .show = dn_rt_cache_seq_show,
  1474. };
  1475. static int dn_rt_cache_seq_open(struct inode *inode, struct file *file)
  1476. {
  1477. return seq_open_private(file, &dn_rt_cache_seq_ops,
  1478. sizeof(struct dn_rt_cache_iter_state));
  1479. }
  1480. static const struct file_operations dn_rt_cache_seq_fops = {
  1481. .owner = THIS_MODULE,
  1482. .open = dn_rt_cache_seq_open,
  1483. .read = seq_read,
  1484. .llseek = seq_lseek,
  1485. .release = seq_release_private,
  1486. };
  1487. #endif /* CONFIG_PROC_FS */
  1488. void __init dn_route_init(void)
  1489. {
  1490. int i, goal, order;
  1491. dn_dst_ops.kmem_cachep =
  1492. kmem_cache_create("dn_dst_cache", sizeof(struct dn_route), 0,
  1493. SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
  1494. setup_timer(&dn_route_timer, dn_dst_check_expire, 0);
  1495. dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ;
  1496. add_timer(&dn_route_timer);
  1497. goal = num_physpages >> (26 - PAGE_SHIFT);
  1498. for(order = 0; (1UL << order) < goal; order++)
  1499. /* NOTHING */;
  1500. /*
  1501. * Only want 1024 entries max, since the table is very, very unlikely
  1502. * to be larger than that.
  1503. */
  1504. while(order && ((((1UL << order) * PAGE_SIZE) /
  1505. sizeof(struct dn_rt_hash_bucket)) >= 2048))
  1506. order--;
  1507. do {
  1508. dn_rt_hash_mask = (1UL << order) * PAGE_SIZE /
  1509. sizeof(struct dn_rt_hash_bucket);
  1510. while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
  1511. dn_rt_hash_mask--;
  1512. dn_rt_hash_table = (struct dn_rt_hash_bucket *)
  1513. __get_free_pages(GFP_ATOMIC, order);
  1514. } while (dn_rt_hash_table == NULL && --order > 0);
  1515. if (!dn_rt_hash_table)
  1516. panic("Failed to allocate DECnet route cache hash table\n");
  1517. printk(KERN_INFO
  1518. "DECnet: Routing cache hash table of %u buckets, %ldKbytes\n",
  1519. dn_rt_hash_mask,
  1520. (long)(dn_rt_hash_mask*sizeof(struct dn_rt_hash_bucket))/1024);
  1521. dn_rt_hash_mask--;
  1522. for(i = 0; i <= dn_rt_hash_mask; i++) {
  1523. spin_lock_init(&dn_rt_hash_table[i].lock);
  1524. dn_rt_hash_table[i].chain = NULL;
  1525. }
  1526. dn_dst_ops.gc_thresh = (dn_rt_hash_mask + 1);
  1527. proc_net_fops_create(&init_net, "decnet_cache", S_IRUGO, &dn_rt_cache_seq_fops);
  1528. #ifdef CONFIG_DECNET_ROUTER
  1529. rtnl_register(PF_DECnet, RTM_GETROUTE, dn_cache_getroute, dn_fib_dump);
  1530. #else
  1531. rtnl_register(PF_DECnet, RTM_GETROUTE, dn_cache_getroute,
  1532. dn_cache_dump);
  1533. #endif
  1534. }
  1535. void __exit dn_route_cleanup(void)
  1536. {
  1537. del_timer(&dn_route_timer);
  1538. dn_run_flush(0);
  1539. proc_net_remove(&init_net, "decnet_cache");
  1540. }