ipv6.c 14 KB

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