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

Function ipsec_updateid

freebsd/netipsec/ipsec.c:1450–1495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1448 return (0);
1449}
1450int
1451ipsec_updateid(struct secasvar *sav, crypto_session_t *new,
1452 crypto_session_t *old)
1453{
1454 crypto_session_t tmp;
1455
1456 /*
1457 * tdb_cryptoid is initialized by xform_init().
1458 * Then it can be changed only when some crypto error occurred or
1459 * when SA is deleted. We stored used cryptoid in the xform_data
1460 * structure. In case when crypto error occurred and crypto
1461 * subsystem has reinited the session, it returns new cryptoid
1462 * and EAGAIN error code.
1463 *
1464 * This function will be called when we got EAGAIN from crypto
1465 * subsystem.
1466 * *new is cryptoid that was returned by crypto subsystem in
1467 * the crp_sid.
1468 * *old is the original cryptoid that we stored in xform_data.
1469 *
1470 * For first failed request *old == sav->tdb_cryptoid, then
1471 * we update sav->tdb_cryptoid and redo crypto_dispatch().
1472 * For next failed request *old != sav->tdb_cryptoid, then
1473 * we store cryptoid from first request into the *new variable
1474 * and crp_sid from this second session will be returned via
1475 * *old pointer, so caller can release second session.
1476 *
1477 * XXXAE: check this more carefully.
1478 */
1479 KEYDBG(IPSEC_STAMP,
1480 printf("%s: SA(%p) moves cryptoid %p -> %p\n",
1481 __func__, sav, *old, *new));
1482 KEYDBG(IPSEC_DATA, kdebug_secasv(sav));
1483 SECASVAR_LOCK(sav);
1484 if (sav->tdb_cryptoid != *old) {
1485 /* cryptoid was already updated */
1486 tmp = *new;
1487 *new = sav->tdb_cryptoid;
1488 *old = tmp;
1489 SECASVAR_UNLOCK(sav);
1490 return (1);
1491 }
1492 sav->tdb_cryptoid = *new;
1493 SECASVAR_UNLOCK(sav);
1494 return (0);
1495}
1496
1497int
1498ipsec_initialized(void)

Callers 6

ipcomp_input_cbFunction · 0.85
ipcomp_output_cbFunction · 0.85
ah_input_cbFunction · 0.85
ah_output_cbFunction · 0.85
esp_input_cbFunction · 0.85
esp_output_cbFunction · 0.85

Calls 2

kdebug_secasvFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected