git: 86104d3ebb35 - main - ipsec: prohibit unknown directions in key_havesp
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 22 Nov 2022 12:23:32 UTC
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=86104d3ebb3525c2773b3d3881104725b3f0f3cf commit 86104d3ebb3525c2773b3d3881104725b3f0f3cf Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2022-09-07 20:27:15 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2022-11-22 12:23:03 +0000 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 --- sys/netipsec/key.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index b8a47a6a678b..093db4fb9126 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -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 */