* SADB_EXPIRE processing * send * * to KMD by PF_KEY. * NOTE: We send only soft lifetime extension. * * OUT: 0 : succeed * others : error number */
| 7257 | * others : error number |
| 7258 | */ |
| 7259 | static int |
| 7260 | key_expire(struct secasvar *sav, int hard) |
| 7261 | { |
| 7262 | struct mbuf *result = NULL, *m; |
| 7263 | struct sadb_lifetime *lt; |
| 7264 | uint32_t replay_count; |
| 7265 | int error, len; |
| 7266 | uint8_t satype; |
| 7267 | |
| 7268 | IPSEC_ASSERT (sav != NULL, ("null sav")); |
| 7269 | IPSEC_ASSERT (sav->sah != NULL, ("null sa header")); |
| 7270 | |
| 7271 | KEYDBG(KEY_STAMP, |
| 7272 | printf("%s: SA(%p) expired %s lifetime\n", __func__, |
| 7273 | sav, hard ? "hard": "soft")); |
| 7274 | KEYDBG(KEY_DATA, kdebug_secasv(sav)); |
| 7275 | /* set msg header */ |
| 7276 | satype = key_proto2satype(sav->sah->saidx.proto); |
| 7277 | IPSEC_ASSERT(satype != 0, ("invalid proto, satype %u", satype)); |
| 7278 | m = key_setsadbmsg(SADB_EXPIRE, 0, satype, sav->seq, 0, sav->refcnt); |
| 7279 | if (!m) { |
| 7280 | error = ENOBUFS; |
| 7281 | goto fail; |
| 7282 | } |
| 7283 | result = m; |
| 7284 | |
| 7285 | /* create SA extension */ |
| 7286 | m = key_setsadbsa(sav); |
| 7287 | if (!m) { |
| 7288 | error = ENOBUFS; |
| 7289 | goto fail; |
| 7290 | } |
| 7291 | m_cat(result, m); |
| 7292 | |
| 7293 | /* create SA extension */ |
| 7294 | SECASVAR_LOCK(sav); |
| 7295 | replay_count = sav->replay ? sav->replay->count : 0; |
| 7296 | SECASVAR_UNLOCK(sav); |
| 7297 | |
| 7298 | m = key_setsadbxsa2(sav->sah->saidx.mode, replay_count, |
| 7299 | sav->sah->saidx.reqid); |
| 7300 | if (!m) { |
| 7301 | error = ENOBUFS; |
| 7302 | goto fail; |
| 7303 | } |
| 7304 | m_cat(result, m); |
| 7305 | |
| 7306 | if (sav->replay && sav->replay->wsize > UINT8_MAX) { |
| 7307 | m = key_setsadbxsareplay(sav->replay->wsize); |
| 7308 | if (!m) { |
| 7309 | error = ENOBUFS; |
| 7310 | goto fail; |
| 7311 | } |
| 7312 | m_cat(result, m); |
| 7313 | } |
| 7314 | |
| 7315 | /* create lifetime extension (current and soft) */ |
| 7316 | len = PFKEY_ALIGN8(sizeof(*lt)) * 2; |
no test coverage detected