load-tester: Fix race condition issuing same SPI
Due to an unprotected incrementation, two load-tester initiators occasionally use the same SPI under high load, and hence generate 2 IPsec SAs with the same identifier. The responder IPsec stack will refuse to configure the second SA. Use an atomic incrementation to avoid this race condition. Signed-off-by: Christophe Gouault <[email protected]>
This commit is contained in:
committed by
Tobias Brunner
parent
2cbaa63295
commit
7b08063e70
@@ -31,14 +31,14 @@ struct private_load_tester_ipsec_t {
|
|||||||
/**
|
/**
|
||||||
* faked SPI counter
|
* faked SPI counter
|
||||||
*/
|
*/
|
||||||
u_int32_t spi;
|
refcount_t spi;
|
||||||
};
|
};
|
||||||
|
|
||||||
METHOD(kernel_ipsec_t, get_spi, status_t,
|
METHOD(kernel_ipsec_t, get_spi, status_t,
|
||||||
private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
|
private_load_tester_ipsec_t *this, host_t *src, host_t *dst,
|
||||||
u_int8_t protocol, u_int32_t reqid, u_int32_t *spi)
|
u_int8_t protocol, u_int32_t reqid, u_int32_t *spi)
|
||||||
{
|
{
|
||||||
*spi = ++this->spi;
|
*spi = (uint32_t)ref_get(&this->spi);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user