MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ipcomp_input_cb

Function ipcomp_input_cb

freebsd/netipsec/xform_ipcomp.c:278–389  ·  view source on GitHub ↗

* IPComp input callback from the crypto driver. */

Source from the content-addressed store, hash-verified

276 * IPComp input callback from the crypto driver.
277 */
278static int
279ipcomp_input_cb(struct cryptop *crp)
280{
281 IPSEC_DEBUG_DECLARE(char buf[IPSEC_ADDRSTRLEN]);
282 struct xform_data *xd;
283 struct mbuf *m;
284 struct secasvar *sav;
285 struct secasindex *saidx;
286 caddr_t addr;
287 crypto_session_t cryptoid;
288 int hlen = IPCOMP_HLENGTH, error, clen;
289 int skip, protoff;
290 uint8_t nproto;
291
292 m = crp->crp_buf.cb_mbuf;
293 xd = crp->crp_opaque;
294 CURVNET_SET(xd->vnet);
295 sav = xd->sav;
296 skip = xd->skip;
297 protoff = xd->protoff;
298 cryptoid = xd->cryptoid;
299 saidx = &sav->sah->saidx;
300 IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET ||
301 saidx->dst.sa.sa_family == AF_INET6,
302 ("unexpected protocol family %u", saidx->dst.sa.sa_family));
303
304 /* Check for crypto errors */
305 if (crp->crp_etype) {
306 if (crp->crp_etype == EAGAIN) {
307 /* Reset the session ID */
308 if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0)
309 crypto_freesession(cryptoid);
310 xd->cryptoid = crp->crp_session;
311 CURVNET_RESTORE();
312 return (crypto_dispatch(crp));
313 }
314 IPCOMPSTAT_INC(ipcomps_noxform);
315 DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
316 error = crp->crp_etype;
317 goto bad;
318 }
319 /* Shouldn't happen... */
320 if (m == NULL) {
321 IPCOMPSTAT_INC(ipcomps_crypto);
322 DPRINTF(("%s: null mbuf returned from crypto\n", __func__));
323 error = EINVAL;
324 goto bad;
325 }
326 IPCOMPSTAT_INC(ipcomps_hist[sav->alg_comp]);
327
328 clen = crp->crp_olen; /* Length of data after processing */
329
330 /* Release the crypto descriptors */
331 free(xd, M_XDATA), xd = NULL;
332 crypto_freereq(crp), crp = NULL;
333
334 /* In case it's not done already, adjust the size of the mbuf chain */
335 m->m_pkthdr.len = clen + hlen + skip;

Callers

nothing calls this directly

Calls 14

ipsec_updateidFunction · 0.85
crypto_freesessionFunction · 0.85
crypto_dispatchFunction · 0.85
crypto_freereqFunction · 0.85
m_pullupFunction · 0.85
m_striphdrFunction · 0.85
ipsec_addressFunction · 0.85
m_copybackFunction · 0.85
ipsec6_common_input_cbFunction · 0.85
ipsec4_common_input_cbFunction · 0.85
key_freesavFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected