ipsec: prohibit unknown directions in key_havesp

Eliminates a branch checking for its validity.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36485
This commit is contained in:
Mateusz Guzik 2022-09-07 22:27:15 +02:00
parent 1ffc369aa3
commit 86104d3ebb

View File

@ -806,8 +806,9 @@ int
key_havesp(u_int dir)
{
return (dir == IPSEC_DIR_INBOUND || dir == IPSEC_DIR_OUTBOUND ?
TAILQ_FIRST(&V_sptree[dir]) != NULL : 1);
IPSEC_ASSERT(dir == IPSEC_DIR_INBOUND || dir == IPSEC_DIR_OUTBOUND,
("invalid direction %u", dir));
return (TAILQ_FIRST(&V_sptree[dir]) != NULL);
}
/* %%% IPsec policy management */