ipv6.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. #include "u.h"
  2. #include "../port/lib.h"
  3. #include "mem.h"
  4. #include "dat.h"
  5. #include "fns.h"
  6. #include "../port/error.h"
  7. #include "ip.h"
  8. #include "ipv6.h"
  9. enum
  10. {
  11. IP6FHDR = 8, /* sizeof(Fraghdr6) */
  12. };
  13. #define IPV6CLASS(hdr) (((hdr)->vcf[0]&0x0F)<<2 | ((hdr)->vcf[1]&0xF0)>>2)
  14. #define BLKIPVER(xp) (((Ip6hdr*)((xp)->rp))->vcf[0] & 0xF0)
  15. /*
  16. * This sleazy macro is stolen shamelessly from ip.c, see comment there.
  17. */
  18. #define BKFG(xp) ((Ipfrag*)((xp)->base))
  19. typedef struct IP IP;
  20. typedef struct Fragment4 Fragment4;
  21. typedef struct Fragment6 Fragment6;
  22. typedef struct Ipfrag Ipfrag;
  23. Block* ip6reassemble(IP*, int, Block*, Ip6hdr*);
  24. Fragment6* ipfragallo6(IP*);
  25. void ipfragfree6(IP*, Fragment6*);
  26. Block* procopts(Block *bp);
  27. static Block* procxtns(IP *ip, Block *bp, int doreasm);
  28. int unfraglen(Block *bp, uchar *nexthdr, int setfh);
  29. /* MIB II counters */
  30. enum
  31. {
  32. Forwarding,
  33. DefaultTTL,
  34. InReceives,
  35. InHdrErrors,
  36. InAddrErrors,
  37. ForwDatagrams,
  38. InUnknownProtos,
  39. InDiscards,
  40. InDelivers,
  41. OutRequests,
  42. OutDiscards,
  43. OutNoRoutes,
  44. ReasmTimeout,
  45. ReasmReqds,
  46. ReasmOKs,
  47. ReasmFails,
  48. FragOKs,
  49. FragFails,
  50. FragCreates,
  51. Nstats,
  52. };
  53. static char *statnames[] =
  54. {
  55. [Forwarding] "Forwarding",
  56. [DefaultTTL] "DefaultTTL",
  57. [InReceives] "InReceives",
  58. [InHdrErrors] "InHdrErrors",
  59. [InAddrErrors] "InAddrErrors",
  60. [ForwDatagrams] "ForwDatagrams",
  61. [InUnknownProtos] "InUnknownProtos",
  62. [InDiscards] "InDiscards",
  63. [InDelivers] "InDelivers",
  64. [OutRequests] "OutRequests",
  65. [OutDiscards] "OutDiscards",
  66. [OutNoRoutes] "OutNoRoutes",
  67. [ReasmTimeout] "ReasmTimeout",
  68. [ReasmReqds] "ReasmReqds",
  69. [ReasmOKs] "ReasmOKs",
  70. [ReasmFails] "ReasmFails",
  71. [FragOKs] "FragOKs",
  72. [FragFails] "FragFails",
  73. [FragCreates] "FragCreates",
  74. };
  75. struct Fragment4
  76. {
  77. Block* blist;
  78. Fragment4* next;
  79. ulong src;
  80. ulong dst;
  81. ushort id;
  82. ulong age;
  83. };
  84. struct Fragment6
  85. {
  86. Block* blist;
  87. Fragment6* next;
  88. uchar src[IPaddrlen];
  89. uchar dst[IPaddrlen];
  90. uint id;
  91. ulong age;
  92. };
  93. struct Ipfrag
  94. {
  95. ushort foff;
  96. ushort flen;
  97. };
  98. /* an instance of IP */
  99. struct IP
  100. {
  101. ulong stats[Nstats];
  102. QLock fraglock4;
  103. Fragment4* flisthead4;
  104. Fragment4* fragfree4;
  105. Ref id4;
  106. QLock fraglock6;
  107. Fragment6* flisthead6;
  108. Fragment6* fragfree6;
  109. Ref id6;
  110. int iprouting; /* true if we route like a gateway */
  111. };
  112. int
  113. ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
  114. {
  115. int medialen, len, chunk, uflen, flen, seglen, lid, offset, fragoff;
  116. int morefrags, blklen, rv = 0, tentative;
  117. uchar *gate, nexthdr;
  118. Block *xp, *nb;
  119. Fraghdr6 fraghdr;
  120. IP *ip;
  121. Ip6hdr *eh;
  122. Ipifc *ifc;
  123. Route *r, *sr;
  124. ip = f->ip;
  125. /* Fill out the ip header */
  126. eh = (Ip6hdr*)(bp->rp);
  127. ip->stats[OutRequests]++;
  128. /* Number of uchars in data and ip header to write */
  129. len = blocklen(bp);
  130. tentative = iptentative(f, eh->src);
  131. if(tentative){
  132. netlog(f, Logip, "reject tx of packet with tentative src address %I\n",
  133. eh->src);
  134. goto free;
  135. }
  136. if(gating){
  137. chunk = nhgets(eh->ploadlen);
  138. if(chunk > len){
  139. ip->stats[OutDiscards]++;
  140. netlog(f, Logip, "short gated packet\n");
  141. goto free;
  142. }
  143. if(chunk + IP6HDR < len)
  144. len = chunk + IP6HDR;
  145. }
  146. if(len >= IP_MAX){
  147. ip->stats[OutDiscards]++;
  148. netlog(f, Logip, "exceeded ip max size %I\n", eh->dst);
  149. goto free;
  150. }
  151. r = v6lookup(f, eh->dst, c);
  152. if(r == nil){
  153. // print("no route for %I, src %I free\n", eh->dst, eh->src);
  154. ip->stats[OutNoRoutes]++;
  155. netlog(f, Logip, "no interface %I\n", eh->dst);
  156. rv = -1;
  157. goto free;
  158. }
  159. ifc = r->ifc;
  160. if(r->type & (Rifc|Runi))
  161. gate = eh->dst;
  162. else if(r->type & (Rbcast|Rmulti)) {
  163. gate = eh->dst;
  164. sr = v6lookup(f, eh->src, nil);
  165. if(sr && (sr->type & Runi))
  166. ifc = sr->ifc;
  167. }
  168. else
  169. gate = r->v6.gate;
  170. if(!gating)
  171. eh->vcf[0] = IP_VER6;
  172. eh->ttl = ttl;
  173. if(!gating) {
  174. eh->vcf[0] |= tos >> 4;
  175. eh->vcf[1] = tos << 4;
  176. }
  177. if(!canrlock(ifc))
  178. goto free;
  179. if(waserror()){
  180. runlock(ifc);
  181. nexterror();
  182. }
  183. if(ifc->m == nil)
  184. goto raise;
  185. /* If we dont need to fragment just send it */
  186. medialen = ifc->maxtu - ifc->m->hsize;
  187. if(len <= medialen) {
  188. hnputs(eh->ploadlen, len - IP6HDR);
  189. ifc->m->bwrite(ifc, bp, V6, gate);
  190. runlock(ifc);
  191. poperror();
  192. return 0;
  193. }
  194. if(gating && ifc->reassemble <= 0) {
  195. /*
  196. * v6 intermediate nodes are not supposed to fragment pkts;
  197. * we fragment if ifc->reassemble is turned on; an exception
  198. * needed for nat.
  199. */
  200. ip->stats[OutDiscards]++;
  201. icmppkttoobig6(f, ifc, bp);
  202. netlog(f, Logip, "%I: gated pkts not fragmented\n", eh->dst);
  203. goto raise;
  204. }
  205. /* start v6 fragmentation */
  206. uflen = unfraglen(bp, &nexthdr, 1);
  207. if(uflen > medialen) {
  208. ip->stats[FragFails]++;
  209. ip->stats[OutDiscards]++;
  210. netlog(f, Logip, "%I: unfragmentable part too big\n", eh->dst);
  211. goto raise;
  212. }
  213. flen = len - uflen;
  214. seglen = (medialen - (uflen + IP6FHDR)) & ~7;
  215. if(seglen < 8) {
  216. ip->stats[FragFails]++;
  217. ip->stats[OutDiscards]++;
  218. netlog(f, Logip, "%I: seglen < 8\n", eh->dst);
  219. goto raise;
  220. }
  221. lid = incref(&ip->id6);
  222. fraghdr.nexthdr = nexthdr;
  223. fraghdr.res = 0;
  224. hnputl(fraghdr.id, lid);
  225. xp = bp;
  226. offset = uflen;
  227. while (xp && offset && offset >= BLEN(xp)) {
  228. offset -= BLEN(xp);
  229. xp = xp->next;
  230. }
  231. xp->rp += offset;
  232. fragoff = 0;
  233. morefrags = 1;
  234. for(; fragoff < flen; fragoff += seglen) {
  235. nb = allocb(uflen + IP6FHDR + seglen);
  236. if(fragoff + seglen >= flen) {
  237. seglen = flen - fragoff;
  238. morefrags = 0;
  239. }
  240. hnputs(eh->ploadlen, seglen+IP6FHDR);
  241. memmove(nb->wp, eh, uflen);
  242. nb->wp += uflen;
  243. hnputs(fraghdr.offsetRM, fragoff); /* last 3 bits must be 0 */
  244. fraghdr.offsetRM[1] |= morefrags;
  245. memmove(nb->wp, &fraghdr, IP6FHDR);
  246. nb->wp += IP6FHDR;
  247. /* Copy data */
  248. chunk = seglen;
  249. while (chunk) {
  250. if(!xp) {
  251. ip->stats[OutDiscards]++;
  252. ip->stats[FragFails]++;
  253. freeblist(nb);
  254. netlog(f, Logip, "!xp: chunk in v6%d\n", chunk);
  255. goto raise;
  256. }
  257. blklen = chunk;
  258. if(BLEN(xp) < chunk)
  259. blklen = BLEN(xp);
  260. memmove(nb->wp, xp->rp, blklen);
  261. nb->wp += blklen;
  262. xp->rp += blklen;
  263. chunk -= blklen;
  264. if(xp->rp == xp->wp)
  265. xp = xp->next;
  266. }
  267. ifc->m->bwrite(ifc, nb, V6, gate);
  268. ip->stats[FragCreates]++;
  269. }
  270. ip->stats[FragOKs]++;
  271. raise:
  272. runlock(ifc);
  273. poperror();
  274. free:
  275. freeblist(bp);
  276. return rv;
  277. }
  278. void
  279. ipiput6(Fs *f, Ipifc *ifc, Block *bp)
  280. {
  281. int hl, hop, tos, notforme, tentative;
  282. uchar proto;
  283. uchar v6dst[IPaddrlen];
  284. IP *ip;
  285. Ip6hdr *h;
  286. Proto *p;
  287. Route *r, *sr;
  288. ip = f->ip;
  289. ip->stats[InReceives]++;
  290. /*
  291. * Ensure we have all the header info in the first
  292. * block. Make life easier for other protocols by
  293. * collecting up to the first 64 bytes in the first block.
  294. */
  295. if(BLEN(bp) < 64) {
  296. hl = blocklen(bp);
  297. if(hl < IP6HDR)
  298. hl = IP6HDR;
  299. if(hl > 64)
  300. hl = 64;
  301. bp = pullupblock(bp, hl);
  302. if(bp == nil)
  303. return;
  304. }
  305. h = (Ip6hdr *)bp->rp;
  306. memmove(&v6dst[0], &h->dst[0], IPaddrlen);
  307. notforme = ipforme(f, v6dst) == 0;
  308. tentative = iptentative(f, v6dst);
  309. if(tentative && h->proto != ICMPv6) {
  310. print("tentative addr, drop\n");
  311. freeblist(bp);
  312. return;
  313. }
  314. /* Check header version */
  315. if(BLKIPVER(bp) != IP_VER6) {
  316. ip->stats[InHdrErrors]++;
  317. netlog(f, Logip, "ip: bad version %ux\n", (h->vcf[0]&0xF0)>>2);
  318. freeblist(bp);
  319. return;
  320. }
  321. /* route */
  322. if(notforme) {
  323. if(!ip->iprouting){
  324. freeb(bp);
  325. return;
  326. }
  327. /* don't forward to link-local destinations */
  328. if(islinklocal(h->dst) ||
  329. (isv6mcast(h->dst) && (h->dst[1]&0xF) <= Link_local_scop)){
  330. ip->stats[OutDiscards]++;
  331. freeblist(bp);
  332. return;
  333. }
  334. /* don't forward to source's network */
  335. sr = v6lookup(f, h->src, nil);
  336. r = v6lookup(f, h->dst, nil);
  337. if(r == nil || sr == r){
  338. ip->stats[OutDiscards]++;
  339. freeblist(bp);
  340. return;
  341. }
  342. /* don't forward if packet has timed out */
  343. hop = h->ttl;
  344. if(hop < 1) {
  345. ip->stats[InHdrErrors]++;
  346. icmpttlexceeded6(f, ifc, bp);
  347. freeblist(bp);
  348. return;
  349. }
  350. /* process headers & reassemble if the interface expects it */
  351. bp = procxtns(ip, bp, r->ifc->reassemble);
  352. if(bp == nil)
  353. return;
  354. ip->stats[ForwDatagrams]++;
  355. h = (Ip6hdr *)bp->rp;
  356. tos = IPV6CLASS(h);
  357. hop = h->ttl;
  358. ipoput6(f, bp, 1, hop-1, tos, nil);
  359. return;
  360. }
  361. /* reassemble & process headers if needed */
  362. bp = procxtns(ip, bp, 1);
  363. if(bp == nil)
  364. return;
  365. h = (Ip6hdr *) (bp->rp);
  366. proto = h->proto;
  367. p = Fsrcvpcol(f, proto);
  368. if(p && p->rcv) {
  369. ip->stats[InDelivers]++;
  370. (*p->rcv)(p, ifc, bp);
  371. return;
  372. }
  373. ip->stats[InDiscards]++;
  374. ip->stats[InUnknownProtos]++;
  375. freeblist(bp);
  376. }
  377. /*
  378. * ipfragfree6 - copied from ipfragfree4 - assume hold fraglock6
  379. */
  380. void
  381. ipfragfree6(IP *ip, Fragment6 *frag)
  382. {
  383. Fragment6 *fl, **l;
  384. if(frag->blist)
  385. freeblist(frag->blist);
  386. memset(frag->src, 0, IPaddrlen);
  387. frag->id = 0;
  388. frag->blist = nil;
  389. l = &ip->flisthead6;
  390. for(fl = *l; fl; fl = fl->next) {
  391. if(fl == frag) {
  392. *l = frag->next;
  393. break;
  394. }
  395. l = &fl->next;
  396. }
  397. frag->next = ip->fragfree6;
  398. ip->fragfree6 = frag;
  399. }
  400. /*
  401. * ipfragallo6 - copied from ipfragalloc4
  402. */
  403. Fragment6*
  404. ipfragallo6(IP *ip)
  405. {
  406. Fragment6 *f;
  407. while(ip->fragfree6 == nil) {
  408. /* free last entry on fraglist */
  409. for(f = ip->flisthead6; f->next; f = f->next)
  410. ;
  411. ipfragfree6(ip, f);
  412. }
  413. f = ip->fragfree6;
  414. ip->fragfree6 = f->next;
  415. f->next = ip->flisthead6;
  416. ip->flisthead6 = f;
  417. f->age = NOW + 30000;
  418. return f;
  419. }
  420. static Block*
  421. procxtns(IP *ip, Block *bp, int doreasm)
  422. {
  423. int offset;
  424. uchar proto;
  425. Ip6hdr *h;
  426. h = (Ip6hdr *)bp->rp;
  427. offset = unfraglen(bp, &proto, 0);
  428. if(proto == FH && doreasm != 0) {
  429. bp = ip6reassemble(ip, offset, bp, h);
  430. if(bp == nil)
  431. return nil;
  432. offset = unfraglen(bp, &proto, 0);
  433. }
  434. if(proto == DOH || offset > IP6HDR)
  435. bp = procopts(bp);
  436. return bp;
  437. }
  438. /*
  439. * returns length of "Unfragmentable part", i.e., sum of lengths of ipv6 hdr,
  440. * hop-by-hop & routing headers if present; *nexthdr is set to nexthdr value
  441. * of the last header in the "Unfragmentable part"; if setfh != 0, nexthdr
  442. * field of the last header in the "Unfragmentable part" is set to FH.
  443. */
  444. int
  445. unfraglen(Block *bp, uchar *nexthdr, int setfh)
  446. {
  447. uchar *p, *q;
  448. int ufl, hs;
  449. p = bp->rp;
  450. q = p+6; /* proto, = p+sizeof(Ip6hdr.vcf)+sizeof(Ip6hdr.ploadlen) */
  451. *nexthdr = *q;
  452. ufl = IP6HDR;
  453. p += ufl;
  454. for(;;) {
  455. if(*nexthdr == HBH || *nexthdr == RH) {
  456. *nexthdr = *p;
  457. hs = ((int)*(p+1) + 1) * 8;
  458. ufl += hs;
  459. q = p;
  460. p += hs;
  461. }
  462. else
  463. break;
  464. }
  465. if(*nexthdr == FH)
  466. *q = *p;
  467. if(setfh)
  468. *q = FH;
  469. return ufl;
  470. }
  471. Block*
  472. procopts(Block *bp)
  473. {
  474. return bp;
  475. }
  476. Block*
  477. ip6reassemble(IP* ip, int uflen, Block* bp, Ip6hdr* ih)
  478. {
  479. int fend, offset, ovlap, len, fragsize, pktposn;
  480. uint id;
  481. uchar src[IPaddrlen], dst[IPaddrlen];
  482. Block *bl, **l, *last, *prev;
  483. Fraghdr6 *fraghdr;
  484. Fragment6 *f, *fnext;
  485. fraghdr = (Fraghdr6 *)(bp->rp + uflen);
  486. memmove(src, ih->src, IPaddrlen);
  487. memmove(dst, ih->dst, IPaddrlen);
  488. id = nhgetl(fraghdr->id);
  489. offset = nhgets(fraghdr->offsetRM) & ~7;
  490. /*
  491. * block lists are too hard, pullupblock into a single block
  492. */
  493. if(bp->next){
  494. bp = pullupblock(bp, blocklen(bp));
  495. ih = (Ip6hdr *)bp->rp;
  496. }
  497. qlock(&ip->fraglock6);
  498. /*
  499. * find a reassembly queue for this fragment
  500. */
  501. for(f = ip->flisthead6; f; f = fnext){
  502. fnext = f->next;
  503. if(ipcmp(f->src, src)==0 && ipcmp(f->dst, dst)==0 && f->id == id)
  504. break;
  505. if(f->age < NOW){
  506. ip->stats[ReasmTimeout]++;
  507. ipfragfree6(ip, f);
  508. }
  509. }
  510. /*
  511. * if this isn't a fragmented packet, accept it
  512. * and get rid of any fragments that might go
  513. * with it.
  514. */
  515. if(nhgets(fraghdr->offsetRM) == 0) { /* 1st frag is also last */
  516. if(f) {
  517. ipfragfree6(ip, f);
  518. ip->stats[ReasmFails]++;
  519. }
  520. qunlock(&ip->fraglock6);
  521. return bp;
  522. }
  523. if(bp->base+sizeof(Ipfrag) >= bp->rp){
  524. bp = padblock(bp, sizeof(Ipfrag));
  525. bp->rp += sizeof(Ipfrag);
  526. }
  527. BKFG(bp)->foff = offset;
  528. BKFG(bp)->flen = nhgets(ih->ploadlen) + IP6HDR - uflen - IP6FHDR;
  529. /* First fragment allocates a reassembly queue */
  530. if(f == nil) {
  531. f = ipfragallo6(ip);
  532. f->id = id;
  533. memmove(f->src, src, IPaddrlen);
  534. memmove(f->dst, dst, IPaddrlen);
  535. f->blist = bp;
  536. qunlock(&ip->fraglock6);
  537. ip->stats[ReasmReqds]++;
  538. return nil;
  539. }
  540. /*
  541. * find the new fragment's position in the queue
  542. */
  543. prev = nil;
  544. l = &f->blist;
  545. bl = f->blist;
  546. while(bl != nil && BKFG(bp)->foff > BKFG(bl)->foff) {
  547. prev = bl;
  548. l = &bl->next;
  549. bl = bl->next;
  550. }
  551. /* Check overlap of a previous fragment - trim away as necessary */
  552. if(prev) {
  553. ovlap = BKFG(prev)->foff + BKFG(prev)->flen - BKFG(bp)->foff;
  554. if(ovlap > 0) {
  555. if(ovlap >= BKFG(bp)->flen) {
  556. freeblist(bp);
  557. qunlock(&ip->fraglock6);
  558. return nil;
  559. }
  560. BKFG(prev)->flen -= ovlap;
  561. }
  562. }
  563. /* Link onto assembly queue */
  564. bp->next = *l;
  565. *l = bp;
  566. /* Check to see if succeeding segments overlap */
  567. if(bp->next) {
  568. l = &bp->next;
  569. fend = BKFG(bp)->foff + BKFG(bp)->flen;
  570. /* Take completely covered segments out */
  571. while(*l) {
  572. ovlap = fend - BKFG(*l)->foff;
  573. if(ovlap <= 0)
  574. break;
  575. if(ovlap < BKFG(*l)->flen) {
  576. BKFG(*l)->flen -= ovlap;
  577. BKFG(*l)->foff += ovlap;
  578. /* move up ih hdrs */
  579. memmove((*l)->rp + ovlap, (*l)->rp, uflen);
  580. (*l)->rp += ovlap;
  581. break;
  582. }
  583. last = (*l)->next;
  584. (*l)->next = nil;
  585. freeblist(*l);
  586. *l = last;
  587. }
  588. }
  589. /*
  590. * look for a complete packet. if we get to a fragment
  591. * with the trailing bit of fraghdr->offsetRM[1] set, we're done.
  592. */
  593. pktposn = 0;
  594. for(bl = f->blist; bl && BKFG(bl)->foff == pktposn; bl = bl->next) {
  595. fraghdr = (Fraghdr6 *)(bl->rp + uflen);
  596. if((fraghdr->offsetRM[1] & 1) == 0) {
  597. bl = f->blist;
  598. /* get rid of frag header in first fragment */
  599. memmove(bl->rp + IP6FHDR, bl->rp, uflen);
  600. bl->rp += IP6FHDR;
  601. len = nhgets(((Ip6hdr*)bl->rp)->ploadlen) - IP6FHDR;
  602. bl->wp = bl->rp + len + IP6HDR;
  603. /*
  604. * Pullup all the fragment headers and
  605. * return a complete packet
  606. */
  607. for(bl = bl->next; bl; bl = bl->next) {
  608. fragsize = BKFG(bl)->flen;
  609. len += fragsize;
  610. bl->rp += uflen + IP6FHDR;
  611. bl->wp = bl->rp + fragsize;
  612. }
  613. bl = f->blist;
  614. f->blist = nil;
  615. ipfragfree6(ip, f);
  616. ih = (Ip6hdr*)bl->rp;
  617. hnputs(ih->ploadlen, len);
  618. qunlock(&ip->fraglock6);
  619. ip->stats[ReasmOKs]++;
  620. return bl;
  621. }
  622. pktposn += BKFG(bl)->flen;
  623. }
  624. qunlock(&ip->fraglock6);
  625. return nil;
  626. }