* IPComp output callback from the crypto driver. */
| 522 | * IPComp output callback from the crypto driver. |
| 523 | */ |
| 524 | static int |
| 525 | ipcomp_output_cb(struct cryptop *crp) |
| 526 | { |
| 527 | IPSEC_DEBUG_DECLARE(char buf[IPSEC_ADDRSTRLEN]); |
| 528 | struct xform_data *xd; |
| 529 | struct secpolicy *sp; |
| 530 | struct secasvar *sav; |
| 531 | struct mbuf *m; |
| 532 | crypto_session_t cryptoid; |
| 533 | u_int idx; |
| 534 | int error, skip, protoff; |
| 535 | |
| 536 | m = crp->crp_buf.cb_mbuf; |
| 537 | xd = crp->crp_opaque; |
| 538 | CURVNET_SET(xd->vnet); |
| 539 | idx = xd->idx; |
| 540 | sp = xd->sp; |
| 541 | sav = xd->sav; |
| 542 | skip = xd->skip; |
| 543 | protoff = xd->protoff; |
| 544 | cryptoid = xd->cryptoid; |
| 545 | |
| 546 | /* Check for crypto errors */ |
| 547 | if (crp->crp_etype) { |
| 548 | if (crp->crp_etype == EAGAIN) { |
| 549 | /* Reset the session ID */ |
| 550 | if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0) |
| 551 | crypto_freesession(cryptoid); |
| 552 | xd->cryptoid = crp->crp_session; |
| 553 | CURVNET_RESTORE(); |
| 554 | return (crypto_dispatch(crp)); |
| 555 | } |
| 556 | IPCOMPSTAT_INC(ipcomps_noxform); |
| 557 | DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); |
| 558 | error = crp->crp_etype; |
| 559 | goto bad; |
| 560 | } |
| 561 | /* Shouldn't happen... */ |
| 562 | if (m == NULL) { |
| 563 | IPCOMPSTAT_INC(ipcomps_crypto); |
| 564 | DPRINTF(("%s: bogus return buffer from crypto\n", __func__)); |
| 565 | error = EINVAL; |
| 566 | goto bad; |
| 567 | } |
| 568 | IPCOMPSTAT_INC(ipcomps_hist[sav->alg_comp]); |
| 569 | |
| 570 | if (crp->crp_payload_length > crp->crp_olen) { |
| 571 | struct mbuf *mo; |
| 572 | struct ipcomp *ipcomp; |
| 573 | int roff; |
| 574 | uint8_t prot; |
| 575 | |
| 576 | /* Compression helped, inject IPCOMP header. */ |
| 577 | mo = m_makespace(m, skip, IPCOMP_HLENGTH, &roff); |
| 578 | if (mo == NULL) { |
| 579 | IPCOMPSTAT_INC(ipcomps_wrap); |
| 580 | DPRINTF(("%s: IPCOMP header inject failed " |
| 581 | "for IPCA %s/%08lx\n", |
nothing calls this directly
no test coverage detected