ip_options.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. * INET An implementation of the TCP/IP protocol suite for the LINUX
  3. * operating system. INET is implemented using the BSD Socket
  4. * interface as the means of communication with the user level.
  5. *
  6. * The options processing module for ip.c
  7. *
  8. * Version: $Id: ip_options.c,v 1.1.1.1 2007/06/12 07:27:14 eyryu Exp $
  9. *
  10. * Authors: A.N.Kuznetsov
  11. *
  12. */
  13. #include <linux/capability.h>
  14. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <asm/uaccess.h>
  17. #include <linux/skbuff.h>
  18. #include <linux/ip.h>
  19. #include <linux/icmp.h>
  20. #include <linux/netdevice.h>
  21. #include <linux/rtnetlink.h>
  22. #include <net/sock.h>
  23. #include <net/ip.h>
  24. #include <net/icmp.h>
  25. #include <net/route.h>
  26. #include <net/cipso_ipv4.h>
  27. /*
  28. * Write options to IP header, record destination address to
  29. * source route option, address of outgoing interface
  30. * (we should already know it, so that this function is allowed be
  31. * called only after routing decision) and timestamp,
  32. * if we originate this datagram.
  33. *
  34. * daddr is real destination address, next hop is recorded in IP header.
  35. * saddr is address of outgoing interface.
  36. */
  37. void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
  38. __be32 daddr, struct rtable *rt, int is_frag)
  39. {
  40. unsigned char * iph = skb->nh.raw;
  41. memcpy(&(IPCB(skb)->opt), opt, sizeof(struct ip_options));
  42. memcpy(iph+sizeof(struct iphdr), opt->__data, opt->optlen);
  43. opt = &(IPCB(skb)->opt);
  44. opt->is_data = 0;
  45. if (opt->srr)
  46. memcpy(iph+opt->srr+iph[opt->srr+1]-4, &daddr, 4);
  47. if (!is_frag) {
  48. if (opt->rr_needaddr)
  49. ip_rt_get_source(iph+opt->rr+iph[opt->rr+2]-5, rt);
  50. if (opt->ts_needaddr)
  51. ip_rt_get_source(iph+opt->ts+iph[opt->ts+2]-9, rt);
  52. if (opt->ts_needtime) {
  53. struct timeval tv;
  54. __be32 midtime;
  55. do_gettimeofday(&tv);
  56. midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000);
  57. memcpy(iph+opt->ts+iph[opt->ts+2]-5, &midtime, 4);
  58. }
  59. return;
  60. }
  61. if (opt->rr) {
  62. memset(iph+opt->rr, IPOPT_NOP, iph[opt->rr+1]);
  63. opt->rr = 0;
  64. opt->rr_needaddr = 0;
  65. }
  66. if (opt->ts) {
  67. memset(iph+opt->ts, IPOPT_NOP, iph[opt->ts+1]);
  68. opt->ts = 0;
  69. opt->ts_needaddr = opt->ts_needtime = 0;
  70. }
  71. }
  72. /*
  73. * Provided (sopt, skb) points to received options,
  74. * build in dopt compiled option set appropriate for answering.
  75. * i.e. invert SRR option, copy anothers,
  76. * and grab room in RR/TS options.
  77. *
  78. * NOTE: dopt cannot point to skb.
  79. */
  80. int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
  81. {
  82. struct ip_options *sopt;
  83. unsigned char *sptr, *dptr;
  84. int soffset, doffset;
  85. int optlen;
  86. __be32 daddr;
  87. memset(dopt, 0, sizeof(struct ip_options));
  88. dopt->is_data = 1;
  89. sopt = &(IPCB(skb)->opt);
  90. if (sopt->optlen == 0) {
  91. dopt->optlen = 0;
  92. return 0;
  93. }
  94. sptr = skb->nh.raw;
  95. dptr = dopt->__data;
  96. if (skb->dst)
  97. daddr = ((struct rtable*)skb->dst)->rt_spec_dst;
  98. else
  99. daddr = skb->nh.iph->daddr;
  100. if (sopt->rr) {
  101. optlen = sptr[sopt->rr+1];
  102. soffset = sptr[sopt->rr+2];
  103. dopt->rr = dopt->optlen + sizeof(struct iphdr);
  104. memcpy(dptr, sptr+sopt->rr, optlen);
  105. if (sopt->rr_needaddr && soffset <= optlen) {
  106. if (soffset + 3 > optlen)
  107. return -EINVAL;
  108. dptr[2] = soffset + 4;
  109. dopt->rr_needaddr = 1;
  110. }
  111. dptr += optlen;
  112. dopt->optlen += optlen;
  113. }
  114. if (sopt->ts) {
  115. optlen = sptr[sopt->ts+1];
  116. soffset = sptr[sopt->ts+2];
  117. dopt->ts = dopt->optlen + sizeof(struct iphdr);
  118. memcpy(dptr, sptr+sopt->ts, optlen);
  119. if (soffset <= optlen) {
  120. if (sopt->ts_needaddr) {
  121. if (soffset + 3 > optlen)
  122. return -EINVAL;
  123. dopt->ts_needaddr = 1;
  124. soffset += 4;
  125. }
  126. if (sopt->ts_needtime) {
  127. if (soffset + 3 > optlen)
  128. return -EINVAL;
  129. if ((dptr[3]&0xF) != IPOPT_TS_PRESPEC) {
  130. dopt->ts_needtime = 1;
  131. soffset += 4;
  132. } else {
  133. dopt->ts_needtime = 0;
  134. if (soffset + 8 <= optlen) {
  135. __be32 addr;
  136. memcpy(&addr, sptr+soffset-1, 4);
  137. if (inet_addr_type(addr) != RTN_LOCAL) {
  138. dopt->ts_needtime = 1;
  139. soffset += 8;
  140. }
  141. }
  142. }
  143. }
  144. dptr[2] = soffset;
  145. }
  146. dptr += optlen;
  147. dopt->optlen += optlen;
  148. }
  149. if (sopt->srr) {
  150. unsigned char * start = sptr+sopt->srr;
  151. __be32 faddr;
  152. optlen = start[1];
  153. soffset = start[2];
  154. doffset = 0;
  155. if (soffset > optlen)
  156. soffset = optlen + 1;
  157. soffset -= 4;
  158. if (soffset > 3) {
  159. memcpy(&faddr, &start[soffset-1], 4);
  160. for (soffset-=4, doffset=4; soffset > 3; soffset-=4, doffset+=4)
  161. memcpy(&dptr[doffset-1], &start[soffset-1], 4);
  162. /*
  163. * RFC1812 requires to fix illegal source routes.
  164. */
  165. if (memcmp(&skb->nh.iph->saddr, &start[soffset+3], 4) == 0)
  166. doffset -= 4;
  167. }
  168. if (doffset > 3) {
  169. memcpy(&start[doffset-1], &daddr, 4);
  170. dopt->faddr = faddr;
  171. dptr[0] = start[0];
  172. dptr[1] = doffset+3;
  173. dptr[2] = 4;
  174. dptr += doffset+3;
  175. dopt->srr = dopt->optlen + sizeof(struct iphdr);
  176. dopt->optlen += doffset+3;
  177. dopt->is_strictroute = sopt->is_strictroute;
  178. }
  179. }
  180. if (sopt->cipso) {
  181. optlen = sptr[sopt->cipso+1];
  182. dopt->cipso = dopt->optlen+sizeof(struct iphdr);
  183. memcpy(dptr, sptr+sopt->cipso, optlen);
  184. dptr += optlen;
  185. dopt->optlen += optlen;
  186. }
  187. while (dopt->optlen & 3) {
  188. *dptr++ = IPOPT_END;
  189. dopt->optlen++;
  190. }
  191. return 0;
  192. }
  193. /*
  194. * Options "fragmenting", just fill options not
  195. * allowed in fragments with NOOPs.
  196. * Simple and stupid 8), but the most efficient way.
  197. */
  198. void ip_options_fragment(struct sk_buff * skb)
  199. {
  200. unsigned char * optptr = skb->nh.raw + sizeof(struct iphdr);
  201. struct ip_options * opt = &(IPCB(skb)->opt);
  202. int l = opt->optlen;
  203. int optlen;
  204. while (l > 0) {
  205. switch (*optptr) {
  206. case IPOPT_END:
  207. return;
  208. case IPOPT_NOOP:
  209. l--;
  210. optptr++;
  211. continue;
  212. }
  213. optlen = optptr[1];
  214. if (optlen<2 || optlen>l)
  215. return;
  216. if (!IPOPT_COPIED(*optptr))
  217. memset(optptr, IPOPT_NOOP, optlen);
  218. l -= optlen;
  219. optptr += optlen;
  220. }
  221. opt->ts = 0;
  222. opt->rr = 0;
  223. opt->rr_needaddr = 0;
  224. opt->ts_needaddr = 0;
  225. opt->ts_needtime = 0;
  226. return;
  227. }
  228. /*
  229. * Verify options and fill pointers in struct options.
  230. * Caller should clear *opt, and set opt->data.
  231. * If opt == NULL, then skb->data should point to IP header.
  232. */
  233. int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
  234. {
  235. int l;
  236. unsigned char * iph;
  237. unsigned char * optptr;
  238. int optlen;
  239. unsigned char * pp_ptr = NULL;
  240. struct rtable *rt = skb ? (struct rtable*)skb->dst : NULL;
  241. if (!opt) {
  242. opt = &(IPCB(skb)->opt);
  243. iph = skb->nh.raw;
  244. opt->optlen = ((struct iphdr *)iph)->ihl*4 - sizeof(struct iphdr);
  245. optptr = iph + sizeof(struct iphdr);
  246. opt->is_data = 0;
  247. } else {
  248. optptr = opt->is_data ? opt->__data : (unsigned char*)&(skb->nh.iph[1]);
  249. iph = optptr - sizeof(struct iphdr);
  250. }
  251. for (l = opt->optlen; l > 0; ) {
  252. switch (*optptr) {
  253. case IPOPT_END:
  254. for (optptr++, l--; l>0; optptr++, l--) {
  255. if (*optptr != IPOPT_END) {
  256. *optptr = IPOPT_END;
  257. opt->is_changed = 1;
  258. }
  259. }
  260. goto eol;
  261. case IPOPT_NOOP:
  262. l--;
  263. optptr++;
  264. continue;
  265. }
  266. optlen = optptr[1];
  267. if (optlen<2 || optlen>l) {
  268. pp_ptr = optptr;
  269. goto error;
  270. }
  271. switch (*optptr) {
  272. case IPOPT_SSRR:
  273. case IPOPT_LSRR:
  274. if (optlen < 3) {
  275. pp_ptr = optptr + 1;
  276. goto error;
  277. }
  278. if (optptr[2] < 4) {
  279. pp_ptr = optptr + 2;
  280. goto error;
  281. }
  282. /* NB: cf RFC-1812 5.2.4.1 */
  283. if (opt->srr) {
  284. pp_ptr = optptr;
  285. goto error;
  286. }
  287. if (!skb) {
  288. if (optptr[2] != 4 || optlen < 7 || ((optlen-3) & 3)) {
  289. pp_ptr = optptr + 1;
  290. goto error;
  291. }
  292. memcpy(&opt->faddr, &optptr[3], 4);
  293. if (optlen > 7)
  294. memmove(&optptr[3], &optptr[7], optlen-7);
  295. }
  296. opt->is_strictroute = (optptr[0] == IPOPT_SSRR);
  297. opt->srr = optptr - iph;
  298. break;
  299. case IPOPT_RR:
  300. if (opt->rr) {
  301. pp_ptr = optptr;
  302. goto error;
  303. }
  304. if (optlen < 3) {
  305. pp_ptr = optptr + 1;
  306. goto error;
  307. }
  308. if (optptr[2] < 4) {
  309. pp_ptr = optptr + 2;
  310. goto error;
  311. }
  312. if (optptr[2] <= optlen) {
  313. if (optptr[2]+3 > optlen) {
  314. pp_ptr = optptr + 2;
  315. goto error;
  316. }
  317. if (skb) {
  318. memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4);
  319. opt->is_changed = 1;
  320. }
  321. optptr[2] += 4;
  322. opt->rr_needaddr = 1;
  323. }
  324. opt->rr = optptr - iph;
  325. break;
  326. case IPOPT_TIMESTAMP:
  327. if (opt->ts) {
  328. pp_ptr = optptr;
  329. goto error;
  330. }
  331. if (optlen < 4) {
  332. pp_ptr = optptr + 1;
  333. goto error;
  334. }
  335. if (optptr[2] < 5) {
  336. pp_ptr = optptr + 2;
  337. goto error;
  338. }
  339. if (optptr[2] <= optlen) {
  340. __be32 *timeptr = NULL;
  341. if (optptr[2]+3 > optptr[1]) {
  342. pp_ptr = optptr + 2;
  343. goto error;
  344. }
  345. switch (optptr[3]&0xF) {
  346. case IPOPT_TS_TSONLY:
  347. opt->ts = optptr - iph;
  348. if (skb)
  349. timeptr = (__be32*)&optptr[optptr[2]-1];
  350. opt->ts_needtime = 1;
  351. optptr[2] += 4;
  352. break;
  353. case IPOPT_TS_TSANDADDR:
  354. if (optptr[2]+7 > optptr[1]) {
  355. pp_ptr = optptr + 2;
  356. goto error;
  357. }
  358. opt->ts = optptr - iph;
  359. if (skb) {
  360. memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4);
  361. timeptr = (__be32*)&optptr[optptr[2]+3];
  362. }
  363. opt->ts_needaddr = 1;
  364. opt->ts_needtime = 1;
  365. optptr[2] += 8;
  366. break;
  367. case IPOPT_TS_PRESPEC:
  368. if (optptr[2]+7 > optptr[1]) {
  369. pp_ptr = optptr + 2;
  370. goto error;
  371. }
  372. opt->ts = optptr - iph;
  373. {
  374. __be32 addr;
  375. memcpy(&addr, &optptr[optptr[2]-1], 4);
  376. if (inet_addr_type(addr) == RTN_UNICAST)
  377. break;
  378. if (skb)
  379. timeptr = (__be32*)&optptr[optptr[2]+3];
  380. }
  381. opt->ts_needtime = 1;
  382. optptr[2] += 8;
  383. break;
  384. default:
  385. if (!skb && !capable(CAP_NET_RAW)) {
  386. pp_ptr = optptr + 3;
  387. goto error;
  388. }
  389. break;
  390. }
  391. if (timeptr) {
  392. struct timeval tv;
  393. __be32 midtime;
  394. do_gettimeofday(&tv);
  395. midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000);
  396. memcpy(timeptr, &midtime, sizeof(__be32));
  397. opt->is_changed = 1;
  398. }
  399. } else {
  400. unsigned overflow = optptr[3]>>4;
  401. if (overflow == 15) {
  402. pp_ptr = optptr + 3;
  403. goto error;
  404. }
  405. opt->ts = optptr - iph;
  406. if (skb) {
  407. optptr[3] = (optptr[3]&0xF)|((overflow+1)<<4);
  408. opt->is_changed = 1;
  409. }
  410. }
  411. break;
  412. case IPOPT_RA:
  413. if (optlen < 4) {
  414. pp_ptr = optptr + 1;
  415. goto error;
  416. }
  417. if (optptr[2] == 0 && optptr[3] == 0)
  418. opt->router_alert = optptr - iph;
  419. break;
  420. case IPOPT_CIPSO:
  421. if ((!skb && !capable(CAP_NET_RAW)) || opt->cipso) {
  422. pp_ptr = optptr;
  423. goto error;
  424. }
  425. opt->cipso = optptr - iph;
  426. if (cipso_v4_validate(&optptr)) {
  427. pp_ptr = optptr;
  428. goto error;
  429. }
  430. break;
  431. case IPOPT_SEC:
  432. case IPOPT_SID:
  433. default:
  434. if (!skb && !capable(CAP_NET_RAW)) {
  435. pp_ptr = optptr;
  436. goto error;
  437. }
  438. break;
  439. }
  440. l -= optlen;
  441. optptr += optlen;
  442. }
  443. eol:
  444. if (!pp_ptr)
  445. return 0;
  446. error:
  447. if (skb) {
  448. icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl((pp_ptr-iph)<<24));
  449. }
  450. return -EINVAL;
  451. }
  452. /*
  453. * Undo all the changes done by ip_options_compile().
  454. */
  455. void ip_options_undo(struct ip_options * opt)
  456. {
  457. if (opt->srr) {
  458. unsigned char * optptr = opt->__data+opt->srr-sizeof(struct iphdr);
  459. memmove(optptr+7, optptr+3, optptr[1]-7);
  460. memcpy(optptr+3, &opt->faddr, 4);
  461. }
  462. if (opt->rr_needaddr) {
  463. unsigned char * optptr = opt->__data+opt->rr-sizeof(struct iphdr);
  464. optptr[2] -= 4;
  465. memset(&optptr[optptr[2]-1], 0, 4);
  466. }
  467. if (opt->ts) {
  468. unsigned char * optptr = opt->__data+opt->ts-sizeof(struct iphdr);
  469. if (opt->ts_needtime) {
  470. optptr[2] -= 4;
  471. memset(&optptr[optptr[2]-1], 0, 4);
  472. if ((optptr[3]&0xF) == IPOPT_TS_PRESPEC)
  473. optptr[2] -= 4;
  474. }
  475. if (opt->ts_needaddr) {
  476. optptr[2] -= 4;
  477. memset(&optptr[optptr[2]-1], 0, 4);
  478. }
  479. }
  480. }
  481. static struct ip_options *ip_options_get_alloc(const int optlen)
  482. {
  483. struct ip_options *opt = kmalloc(sizeof(*opt) + ((optlen + 3) & ~3),
  484. GFP_KERNEL);
  485. if (opt)
  486. memset(opt, 0, sizeof(*opt));
  487. return opt;
  488. }
  489. static int ip_options_get_finish(struct ip_options **optp,
  490. struct ip_options *opt, int optlen)
  491. {
  492. while (optlen & 3)
  493. opt->__data[optlen++] = IPOPT_END;
  494. opt->optlen = optlen;
  495. opt->is_data = 1;
  496. if (optlen && ip_options_compile(opt, NULL)) {
  497. kfree(opt);
  498. return -EINVAL;
  499. }
  500. kfree(*optp);
  501. *optp = opt;
  502. return 0;
  503. }
  504. int ip_options_get_from_user(struct ip_options **optp, unsigned char __user *data, int optlen)
  505. {
  506. struct ip_options *opt = ip_options_get_alloc(optlen);
  507. if (!opt)
  508. return -ENOMEM;
  509. if (optlen && copy_from_user(opt->__data, data, optlen)) {
  510. kfree(opt);
  511. return -EFAULT;
  512. }
  513. return ip_options_get_finish(optp, opt, optlen);
  514. }
  515. int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen)
  516. {
  517. struct ip_options *opt = ip_options_get_alloc(optlen);
  518. if (!opt)
  519. return -ENOMEM;
  520. if (optlen)
  521. memcpy(opt->__data, data, optlen);
  522. return ip_options_get_finish(optp, opt, optlen);
  523. }
  524. void ip_forward_options(struct sk_buff *skb)
  525. {
  526. struct ip_options * opt = &(IPCB(skb)->opt);
  527. unsigned char * optptr;
  528. struct rtable *rt = (struct rtable*)skb->dst;
  529. unsigned char *raw = skb->nh.raw;
  530. if (opt->rr_needaddr) {
  531. optptr = (unsigned char *)raw + opt->rr;
  532. ip_rt_get_source(&optptr[optptr[2]-5], rt);
  533. opt->is_changed = 1;
  534. }
  535. if (opt->srr_is_hit) {
  536. int srrptr, srrspace;
  537. optptr = raw + opt->srr;
  538. for ( srrptr=optptr[2], srrspace = optptr[1];
  539. srrptr <= srrspace;
  540. srrptr += 4
  541. ) {
  542. if (srrptr + 3 > srrspace)
  543. break;
  544. if (memcmp(&rt->rt_dst, &optptr[srrptr-1], 4) == 0)
  545. break;
  546. }
  547. if (srrptr + 3 <= srrspace) {
  548. opt->is_changed = 1;
  549. ip_rt_get_source(&optptr[srrptr-1], rt);
  550. skb->nh.iph->daddr = rt->rt_dst;
  551. optptr[2] = srrptr+4;
  552. } else if (net_ratelimit())
  553. printk(KERN_CRIT "ip_forward(): Argh! Destination lost!\n");
  554. if (opt->ts_needaddr) {
  555. optptr = raw + opt->ts;
  556. ip_rt_get_source(&optptr[optptr[2]-9], rt);
  557. opt->is_changed = 1;
  558. }
  559. }
  560. if (opt->is_changed) {
  561. opt->is_changed = 0;
  562. ip_send_check(skb->nh.iph);
  563. }
  564. }
  565. int ip_options_rcv_srr(struct sk_buff *skb)
  566. {
  567. struct ip_options *opt = &(IPCB(skb)->opt);
  568. int srrspace, srrptr;
  569. __be32 nexthop;
  570. struct iphdr *iph = skb->nh.iph;
  571. unsigned char * optptr = skb->nh.raw + opt->srr;
  572. struct rtable *rt = (struct rtable*)skb->dst;
  573. struct rtable *rt2;
  574. int err;
  575. if (!opt->srr)
  576. return 0;
  577. if (skb->pkt_type != PACKET_HOST)
  578. return -EINVAL;
  579. if (rt->rt_type == RTN_UNICAST) {
  580. if (!opt->is_strictroute)
  581. return 0;
  582. icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl(16<<24));
  583. return -EINVAL;
  584. }
  585. if (rt->rt_type != RTN_LOCAL)
  586. return -EINVAL;
  587. for (srrptr=optptr[2], srrspace = optptr[1]; srrptr <= srrspace; srrptr += 4) {
  588. if (srrptr + 3 > srrspace) {
  589. icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl((opt->srr+2)<<24));
  590. return -EINVAL;
  591. }
  592. memcpy(&nexthop, &optptr[srrptr-1], 4);
  593. rt = (struct rtable*)skb->dst;
  594. skb->dst = NULL;
  595. err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev);
  596. rt2 = (struct rtable*)skb->dst;
  597. if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) {
  598. ip_rt_put(rt2);
  599. skb->dst = &rt->u.dst;
  600. return -EINVAL;
  601. }
  602. ip_rt_put(rt);
  603. if (rt2->rt_type != RTN_LOCAL)
  604. break;
  605. /* Superfast 8) loopback forward */
  606. memcpy(&iph->daddr, &optptr[srrptr-1], 4);
  607. opt->is_changed = 1;
  608. }
  609. if (srrptr <= srrspace) {
  610. opt->srr_is_hit = 1;
  611. opt->is_changed = 1;
  612. }
  613. return 0;
  614. }