From nobody Tue Nov 22 12:23:32 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NGk1w4SSRz4hWBT; Tue, 22 Nov 2022 12:23:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NGk1w3v6Mz43bT; Tue, 22 Nov 2022 12:23:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669119812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rFY8XN8w7SJrhn2trwViqtERSO0CJTt8q6qWfdbc5U8=; b=t5phc3tOw+S0AlR9RocnKgq9H+NsyNRNBda6YlAbUEa8etyJN8UWMohiYOctlzFB04L/F6 Lx2Xu79L8oA3jLBf8TlcE6iVq8wCwlnIfuFhIQaxdyP0PeqYeG/2StBmf1Ahlk0Y4QkXw5 G3zCpMZkePqtTQgHPp+4THBWD+EtOq85umcGapJ/6zTdC66WxBHPnD9ivhyzquHrLmmLQ9 fksd8uXbW8MLge+oVrUdiph2BzcxqcR0OmIfMU+2ao4ryPI0Rp3ZtarbNxZZWkZIss0CiQ ZD5P09oBzEbjzJ/5nriQIrNihlYENBaEbLF1mmhnkU99qVHodpMV/lVyaLTwyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669119812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rFY8XN8w7SJrhn2trwViqtERSO0CJTt8q6qWfdbc5U8=; b=K8ws/21brDk6+6zT3SQ9i63mmFUyP3dROZuc1SI9FFhEDNAaysDj2TJD3KYSh5Gbt/f9Lv dBE16mVvCfHt/7B9BdyaUQrmlEvD+iQ4U32e3I0KDDjmSi7GqdRunE/fi/UR2HTjQbYUpB jLRvlmhnHsVX9+A5l6at7QoXKNSb14aznrMSYfQYS6Xjc14nJZCcsbV3eRGpNigr0SThvr QA2rPpuw8OCmmNOkiwo+BRN+TS0+P8gZuDe6D7STZGz0m2xiVHsPza6wbJ6lYSpQ4/taE4 f9OGojWdm7d4xsLXJZEULJRXmWQQ5gvce92g+Ds7uHmssaRU4CFxEby+W43imA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669119812; a=rsa-sha256; cv=none; b=S2q3ykB/KQ2EbXawY6aEvXvWNUM1yqedN/rPUuIRsBceh1nW6pHITKPb3xzRX8CE6nmsYp //sBYVW80YOtbnd6nG4UND2S1Zl4wUDAewMXaoPDNIcjXN9ysgLJBvX1ChoEOAy8jhTv0D Kf3XvROX/cmnLiO+U1b0jzSExt3E09RD+qixn207l/Bd5jvyRvHkKBLd7m3Jy3Z4wi1ZCG w5oS7f5+2Tu2xxzo1vIt30wIrRLHa4Wb+J8L/cewp2VUDQQE8CtE6trw/exjpej7k8o0z8 dZpobHQZyqVGv38pcetErBmZS8Q7vakkgyhuZf//4bBexVMa3z3SmbCiMNim7w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NGk1w2vkhzj6b; Tue, 22 Nov 2022 12:23:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AMCNWrM099164; Tue, 22 Nov 2022 12:23:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AMCNWsQ099163; Tue, 22 Nov 2022 12:23:32 GMT (envelope-from git) Date: Tue, 22 Nov 2022 12:23:32 GMT Message-Id: <202211221223.2AMCNWsQ099163@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 86104d3ebb35 - main - ipsec: prohibit unknown directions in key_havesp List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 86104d3ebb3525c2773b3d3881104725b3f0f3cf Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=86104d3ebb3525c2773b3d3881104725b3f0f3cf commit 86104d3ebb3525c2773b3d3881104725b3f0f3cf Author: Mateusz Guzik AuthorDate: 2022-09-07 20:27:15 +0000 Commit: Mateusz Guzik 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 */