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

Function ipcomp_output_cb

freebsd/netipsec/xform_ipcomp.c:524–660  ·  view source on GitHub ↗

* IPComp output callback from the crypto driver. */

Source from the content-addressed store, hash-verified

522 * IPComp output callback from the crypto driver.
523 */
524static int
525ipcomp_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",

Callers

nothing calls this directly

Calls 12

ipsec_updateidFunction · 0.85
crypto_freesessionFunction · 0.85
crypto_dispatchFunction · 0.85
m_makespaceFunction · 0.85
ipsec_addressFunction · 0.85
m_copybackFunction · 0.85
crypto_freereqFunction · 0.85
ipsec_process_doneFunction · 0.85
key_freesavFunction · 0.85
key_freespFunction · 0.85
freeFunction · 0.50
m_freemFunction · 0.50

Tested by

no test coverage detected