From nobody Fri Jan 13 10:16:06 2023 X-Original-To: dev-commits-src-all@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 4Ntckv0bVkz2p2bm; Fri, 13 Jan 2023 10:16:07 +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 4Ntckt65ywz3jy0; Fri, 13 Jan 2023 10:16:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673604966; 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=Sk02ZSi4YZoM4CMM7j8XY/5dLCvFCmuHSFGJWNRDS84=; b=bOHmuuWEPPUk1xX2spI5nAeMYN8B74deuLIEk4p07YxAdabJqrSiTAwwSM5aq4brYGRzqO gEtWWvAcMvlkiWmmQ0T9DZzABoSxmmkRNuuvsIuCSH6nKE2kQwd2gDuVG4jgkYUoSk/bMc KOVivY1zG9sXu3+b7mollC7rx02KlA333OA8tBTEGF5rzXHJbVgYcUkXKqudVMgKvjuVuv hEdosqDBh5MAfk/+69e2Kq+UwpGFRpD92p18VjzDzkyua37V9zAWx70uEx4t1OY5HxHKvl YexVgDrx7xLAtdhXE7qCqIv2bF0HmIKpUhh84wKoYDUKirCbbhEIYTBJVUgzoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673604966; 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=Sk02ZSi4YZoM4CMM7j8XY/5dLCvFCmuHSFGJWNRDS84=; b=X1M7PDYSolEGH1FiajS7aJ+zhfIJilh/lz6BSTN8wi4Muac8rJSEs3h2oVMu2D/3owIBov ZNlVL51e3vHMlnoyx+HamLW7rjXpAmVssOz9apHLX5jJHD6TN012SW31m21EvHD3zZ9Vuy jb7au28pOF2cbFIFwiHeYz+ixGjIO3lDh/FPMwtmfgDj/z0zCxou7at6a/iPyn8H2ctvao OrVJQ/7w+9C84LeXiZjBsstoDPGF5/BarE55FeB7AA0ZO8iHtYJH1HKrM/xq5BVOyqRl4s mre0w3XYnqlDtzNmwUie6tEk9JC+aURQCIuAbMsiTGB+2I7rIENX5a6ISUzxVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673604966; a=rsa-sha256; cv=none; b=MIomt9wVQRYQZGeDSWNueIyqe24la870ChiFyYKFm8CntpnmZG1oz5tgeI3z2SslKItPfj JWE8K8U3IrQCvTmsELCkxPDpuNDqc12Y9U9jb01l89h5jlXhH1qoR9wN32AFz9M10ijVHH QdvnorN4mHgOKAnByHhHPBYPy5BCvKIPROreyP84Y8OUv2+g3dFQiwtqSk3NHLNBcwVGff x6N65yfrRTt2+jx3M4bgJwRrFqgglmReFgdHx6CwDDwM2/t7Km0MDJpzqwAViv66U28D6r +t6xUJSJulN3hQ9g4WIuYiC3ARtKzqesmHQjOxTManfA20j0jtVGUPh8EMGQ7Q== 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 4Ntckt5BTxz140q; Fri, 13 Jan 2023 10:16:06 +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 30DAG6oH081362; Fri, 13 Jan 2023 10:16:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DAG6jd081361; Fri, 13 Jan 2023 10:16:06 GMT (envelope-from git) Date: Fri, 13 Jan 2023 10:16:06 GMT Message-Id: <202301131016.30DAG6jd081361@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 933be8d74b04 - main - pf: default syncookies to adaptive mode List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 933be8d74b0471c8578a6ec965299383bc65138b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=933be8d74b0471c8578a6ec965299383bc65138b commit 933be8d74b0471c8578a6ec965299383bc65138b Author: Kristof Provost AuthorDate: 2022-12-31 18:26:24 +0000 Commit: Kristof Provost CommitDate: 2023-01-13 22:14:25 +0000 pf: default syncookies to adaptive mode The cost of enabling syncookies in adaptive mode is very low (basically a single atomic add when we create a new half-open state), and the payoff when under SYN flood is huge. So, enable adaptive mode by default. Suggested by: Eirik Øverby --- sys/netpfil/pf/pf_ioctl.c | 3 ++- sys/netpfil/pf/pf_syncookies.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index ae53e40d66b6..dc62388f8da4 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -311,6 +311,8 @@ pfattach_vnet(void) { u_int32_t *my_timeout = V_pf_default_rule.timeout; + bzero(&V_pf_status, sizeof(V_pf_status)); + pf_initialize(); pfr_initialize(); pfi_initialize_vnet(); @@ -380,7 +382,6 @@ pfattach_vnet(void) my_timeout[PFTM_ADAPTIVE_START] = PFSTATE_ADAPT_START; my_timeout[PFTM_ADAPTIVE_END] = PFSTATE_ADAPT_END; - bzero(&V_pf_status, sizeof(V_pf_status)); V_pf_status.debug = PF_DEBUG_URGENT; V_pf_pfil_hooked = false; diff --git a/sys/netpfil/pf/pf_syncookies.c b/sys/netpfil/pf/pf_syncookies.c index db232579d595..cdfddadc3560 100644 --- a/sys/netpfil/pf/pf_syncookies.c +++ b/sys/netpfil/pf/pf_syncookies.c @@ -127,7 +127,13 @@ pf_syncookies_init(void) { callout_init(&V_pf_syncookie_status.keytimeout, 1); PF_RULES_WLOCK(); - pf_syncookies_setmode(PF_SYNCOOKIES_NEVER); + + V_pf_syncookie_status.hiwat = PF_SYNCOOKIES_HIWATPCT * + V_pf_limits[PF_LIMIT_STATES].limit / 100; + V_pf_syncookie_status.lowat = PF_SYNCOOKIES_LOWATPCT * + V_pf_limits[PF_LIMIT_STATES].limit / 100; + pf_syncookies_setmode(PF_SYNCOOKIES_ADAPTIVE); + PF_RULES_WUNLOCK(); }