diff options
author | Moritz Buhl <mbuhl@cvs.openbsd.org> | 2022-11-18 18:56:40 +0000 |
---|---|---|
committer | Moritz Buhl <mbuhl@cvs.openbsd.org> | 2022-11-18 18:56:40 +0000 |
commit | 9ec4df861833cbd07262ba27bff2902c9b25a67d (patch) | |
tree | 2cc0bd9e851ce5f7ed917152729c07a320664910 /sbin/iked | |
parent | 5ab2ae8b7bcca1d55d6683c11dd7d6acc919abec (diff) |
Revert my last two changes.
If csa_bundled is set, exactly two csas exist and they point to
each other. Therefore childsa_free already sets the bundled csa
pointer to NULL and it shouldn't be done after calling childsa_free.
ok tobhe@
Diffstat (limited to 'sbin/iked')
-rw-r--r-- | sbin/iked/config.c | 17 | ||||
-rw-r--r-- | sbin/iked/ikev2.c | 27 |
2 files changed, 18 insertions, 26 deletions
diff --git a/sbin/iked/config.c b/sbin/iked/config.c index 353ccde4039..23ae676842c 100644 --- a/sbin/iked/config.c +++ b/sbin/iked/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.89 2022/11/13 21:19:40 mbuhl Exp $ */ +/* $OpenBSD: config.c,v 1.90 2022/11/18 18:56:39 mbuhl Exp $ */ /* * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de> @@ -314,7 +314,7 @@ void config_free_childsas(struct iked *env, struct iked_childsas *head, struct iked_spi *peerspi, struct iked_spi *localspi) { - struct iked_childsa *csa, *csatmp; + struct iked_childsa *csa, *csatmp, *ipcomp; if (localspi != NULL) bzero(localspi, sizeof(*localspi)); @@ -337,14 +337,11 @@ config_free_childsas(struct iked *env, struct iked_childsas *head, RB_REMOVE(iked_activesas, &env->sc_activesas, csa); (void)pfkey_sa_delete(env, csa); } - /* ipcomp */ - if (csa->csa_bundled != NULL) { - log_debug("%s: free IPCOMP %p", __func__, - csa->csa_bundled); - if (csa->csa_bundled->csa_loaded) - (void)pfkey_sa_delete(env, csa->csa_bundled); - childsa_free(csa->csa_bundled); - csa->csa_bundled = NULL; + if ((ipcomp = csa->csa_bundled) != NULL) { + log_debug("%s: free IPCOMP %p", __func__, ipcomp); + if (ipcomp->csa_loaded) + (void)pfkey_sa_delete(env, ipcomp); + childsa_free(ipcomp); } childsa_free(csa); ikestat_inc(env, ikes_csa_removed); diff --git a/sbin/iked/ikev2.c b/sbin/iked/ikev2.c index 798b923f15c..e6555b9f601 100644 --- a/sbin/iked/ikev2.c +++ b/sbin/iked/ikev2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev2.c,v 1.358 2022/11/11 17:58:14 mbuhl Exp $ */ +/* $OpenBSD: ikev2.c,v 1.359 2022/11/18 18:56:39 mbuhl Exp $ */ /* * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de> @@ -6592,7 +6592,7 @@ int ikev2_childsa_delete(struct iked *env, struct iked_sa *sa, uint8_t saproto, uint64_t spi, uint64_t *spiptr, int cleanup) { - struct iked_childsa *csa, *csatmp = NULL; + struct iked_childsa *csa, *csatmp = NULL, *ipcomp; uint64_t peerspi = 0; int found = 0; @@ -6619,26 +6619,21 @@ ikev2_childsa_delete(struct iked *env, struct iked_sa *sa, uint8_t saproto, if (spi && csa->csa_spi.spi == spi) peerspi = csa->csa_peerspi; - /* ipcomp */ - if (csa->csa_bundled) { - if (csa->csa_bundled->csa_loaded) { - if (pfkey_sa_delete(env, csa->csa_bundled) != 0) + ipcomp = csa->csa_bundled; + if (ipcomp) { + if (ipcomp->csa_loaded) { + if (pfkey_sa_delete(env, ipcomp) != 0) log_info("%s: failed to delete IPCOMP" " SA spi %s", SPI_SA(sa, __func__), - print_spi( - csa->csa_bundled->csa_spi.spi, - csa->csa_bundled->csa_spi.spi_size - )); + print_spi(ipcomp->csa_spi.spi, + ipcomp->csa_spi.spi_size)); else log_debug("%s: deleted IPCOMP SA spi %s", SPI_SA(sa, __func__), - print_spi( - csa->csa_bundled->csa_spi.spi, - csa->csa_bundled->csa_spi.spi_size - )); + print_spi(ipcomp->csa_spi.spi, + ipcomp->csa_spi.spi_size)); } - childsa_free(csa->csa_bundled); - csa->csa_bundled = NULL; + childsa_free(ipcomp); } TAILQ_REMOVE(&sa->sa_childsas, csa, csa_entry); ikestat_inc(env, ikes_csa_removed); |