* AH input callback from the crypto driver. */
| 682 | * AH input callback from the crypto driver. |
| 683 | */ |
| 684 | static int |
| 685 | ah_input_cb(struct cryptop *crp) |
| 686 | { |
| 687 | IPSEC_DEBUG_DECLARE(char buf[IPSEC_ADDRSTRLEN]); |
| 688 | unsigned char calc[AH_ALEN_MAX]; |
| 689 | struct mbuf *m; |
| 690 | struct xform_data *xd; |
| 691 | struct secasvar *sav; |
| 692 | struct secasindex *saidx; |
| 693 | caddr_t ptr; |
| 694 | crypto_session_t cryptoid; |
| 695 | int authsize, rplen, ahsize, error, skip, protoff; |
| 696 | uint8_t nxt; |
| 697 | |
| 698 | m = crp->crp_buf.cb_mbuf; |
| 699 | xd = crp->crp_opaque; |
| 700 | CURVNET_SET(xd->vnet); |
| 701 | sav = xd->sav; |
| 702 | skip = xd->skip; |
| 703 | nxt = xd->nxt; |
| 704 | protoff = xd->protoff; |
| 705 | cryptoid = xd->cryptoid; |
| 706 | saidx = &sav->sah->saidx; |
| 707 | IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET || |
| 708 | saidx->dst.sa.sa_family == AF_INET6, |
| 709 | ("unexpected protocol family %u", saidx->dst.sa.sa_family)); |
| 710 | |
| 711 | /* Check for crypto errors. */ |
| 712 | if (crp->crp_etype) { |
| 713 | if (crp->crp_etype == EAGAIN) { |
| 714 | /* Reset the session ID */ |
| 715 | if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0) |
| 716 | crypto_freesession(cryptoid); |
| 717 | xd->cryptoid = crp->crp_session; |
| 718 | CURVNET_RESTORE(); |
| 719 | return (crypto_dispatch(crp)); |
| 720 | } |
| 721 | AHSTAT_INC(ahs_noxform); |
| 722 | DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); |
| 723 | error = crp->crp_etype; |
| 724 | goto bad; |
| 725 | } else { |
| 726 | AHSTAT_INC(ahs_hist[sav->alg_auth]); |
| 727 | crypto_freereq(crp); /* No longer needed. */ |
| 728 | crp = NULL; |
| 729 | } |
| 730 | |
| 731 | /* Shouldn't happen... */ |
| 732 | if (m == NULL) { |
| 733 | AHSTAT_INC(ahs_crypto); |
| 734 | DPRINTF(("%s: bogus returned buffer from crypto\n", __func__)); |
| 735 | error = EINVAL; |
| 736 | goto bad; |
| 737 | } |
| 738 | |
| 739 | /* Figure out header size. */ |
| 740 | rplen = HDRSIZE(sav); |
| 741 | authsize = AUTHSIZE(sav); |
nothing calls this directly
no test coverage detected