* AH output callback from the crypto driver. */
| 1068 | * AH output callback from the crypto driver. |
| 1069 | */ |
| 1070 | static int |
| 1071 | ah_output_cb(struct cryptop *crp) |
| 1072 | { |
| 1073 | struct xform_data *xd; |
| 1074 | struct secpolicy *sp; |
| 1075 | struct secasvar *sav; |
| 1076 | struct mbuf *m; |
| 1077 | crypto_session_t cryptoid; |
| 1078 | caddr_t ptr; |
| 1079 | u_int idx; |
| 1080 | int skip, error; |
| 1081 | |
| 1082 | m = crp->crp_buf.cb_mbuf; |
| 1083 | xd = (struct xform_data *) crp->crp_opaque; |
| 1084 | CURVNET_SET(xd->vnet); |
| 1085 | sp = xd->sp; |
| 1086 | sav = xd->sav; |
| 1087 | skip = xd->skip; |
| 1088 | idx = xd->idx; |
| 1089 | cryptoid = xd->cryptoid; |
| 1090 | ptr = (caddr_t) (xd + 1); |
| 1091 | |
| 1092 | /* Check for crypto errors. */ |
| 1093 | if (crp->crp_etype) { |
| 1094 | if (crp->crp_etype == EAGAIN) { |
| 1095 | /* Reset the session ID */ |
| 1096 | if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0) |
| 1097 | crypto_freesession(cryptoid); |
| 1098 | xd->cryptoid = crp->crp_session; |
| 1099 | CURVNET_RESTORE(); |
| 1100 | return (crypto_dispatch(crp)); |
| 1101 | } |
| 1102 | AHSTAT_INC(ahs_noxform); |
| 1103 | DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); |
| 1104 | error = crp->crp_etype; |
| 1105 | m_freem(m); |
| 1106 | goto bad; |
| 1107 | } |
| 1108 | |
| 1109 | /* Shouldn't happen... */ |
| 1110 | if (m == NULL) { |
| 1111 | AHSTAT_INC(ahs_crypto); |
| 1112 | DPRINTF(("%s: bogus returned buffer from crypto\n", __func__)); |
| 1113 | error = EINVAL; |
| 1114 | goto bad; |
| 1115 | } |
| 1116 | /* |
| 1117 | * Copy original headers (with the new protocol number) back |
| 1118 | * in place. |
| 1119 | */ |
| 1120 | m_copyback(m, 0, skip, ptr); |
| 1121 | |
| 1122 | free(xd, M_XDATA); |
| 1123 | crypto_freereq(crp); |
| 1124 | AHSTAT_INC(ahs_hist[sav->alg_auth]); |
| 1125 | #ifdef REGRESSION |
| 1126 | /* Emulate man-in-the-middle attack when ipsec_integrity is TRUE. */ |
| 1127 | if (V_ipsec_integrity) { |
nothing calls this directly
no test coverage detected