From nobody Mon Nov 13 09:35:30 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 4STPRl2CHjz50pqt; Mon, 13 Nov 2023 09:35:31 +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 4STPRl0ZsZz3cBm; Mon, 13 Nov 2023 09:35:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699868131; 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=vDsvs3GagEFNBi9pvsgAm92w0fAgysi6VrUtrU86+eU=; b=R+wut97oODxn0ld2YlE9s91/qc8J5mIl6F/GGpFHd8Ip29rjCmMa7NIL7YSaMmXUHX6p3R 0dc8lqqyJMd6Wj4+i8M6hu3lqFaYS8emsFUE9IqxhGkaVu3rs5cW1s2/cPDe8pjdrWC4kl j7LWP5xtSPi7Vsmp91e6gbklpFLe+jgXfVbp5sKf3vZKMWkxrgXJyg7KeC1M7BhjXmahKM AujpJCKmjnqEmxOOW80uM63qhju9El6MZMkH/b2G6KFwlXmuWhM+0QSw03y/dVHKy+AyQx DWvPLUrYNaiww1Z9klm81cCilBKF6v3Pagksv4brL70acOPK8PzIWYikXnC3Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699868131; 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=vDsvs3GagEFNBi9pvsgAm92w0fAgysi6VrUtrU86+eU=; b=DLqI8WAL+y+30mzwLaYnJKq1TvWxs4VwM45WYwTInC+AziaN1NVsovfmqlqlfLiLIVDTTg ELMou9cu1lV5/G/2lmTB8hP3q4lYf8Q9PxrY+VrKjOmTU5OcT6k6qLHZBoYqWEClGE6ykS veVI4Vs3zry+mMGZ13ISP07t0k0aeS8yvce05DgHLa+vYPd9UQX1lBgRUzIe67oENAs/nA BEe50T9F8UjCaSuUWJgJHjck+xy9LwaGQGcsuUc8B3zDfRATqsM1MKWVGCfuoeNbbvUA0D eMJcdeO78L8yP8ly99Vk/4Lk5An6SJpbUqmtw3KrY2afBE/ZgnH/ToYiaOtb2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699868131; a=rsa-sha256; cv=none; b=LnQFE3c2kWlz7vz1GEWwc+2EUXcvLatfTDv9CWiVte4ug+TfanZaaZeE+DvZC1B7uXpm+F PITSbxFXRUcvi2WnPYiqIFsi49agE8KwYYdiZZ2ctCmM9HWQOZWy1kdhhHVZXOhWCHwYD/ JBdzuJ7nOrwOV5D+TwJjDcBtk2ylmGkufqtMiu09xO4p3Y9FlAJKFe1Wv//3qfgbGByEAc 4HaJMH5Q3RV3p9E1nBzNrAV0lWCGfHfjeYxUIF6VafUguD9DVVKDeBRWTGhJx3H6/+/MCL m4urmZLvQERamM3rWfknVJCVCKtiqc5BONqT1Uqgx+4WKBnRiQk0VfpqBKsAdw== 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 4STPRk6mVlz10XB; Mon, 13 Nov 2023 09:35:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AD9ZUd6075942; Mon, 13 Nov 2023 09:35:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AD9ZUEd075939; Mon, 13 Nov 2023 09:35:30 GMT (envelope-from git) Date: Mon, 13 Nov 2023 09:35:30 GMT Message-Id: <202311130935.3AD9ZUEd075939@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 221a60a426d7 - stable/13 - pf: expose more syncookie state information to userspace 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 221a60a426d7f73dc4ef021821bf81dd269ba943 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=221a60a426d7f73dc4ef021821bf81dd269ba943 commit 221a60a426d7f73dc4ef021821bf81dd269ba943 Author: Kristof Provost AuthorDate: 2023-11-06 21:20:32 +0000 Commit: Kristof Provost CommitDate: 2023-11-13 07:10:47 +0000 pf: expose more syncookie state information to userspace Allow userspace to retrieve low and high water marks, as well as the current number of half open states. MFC after: 1 week Sponsored by: Modirum MDPay (cherry picked from commit a6173e94635b03aa7aab90a67785c8c3e7c6247b) --- lib/libpfctl/libpfctl.c | 1 + lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/pfctl_parser.c | 5 +++++ sys/netpfil/pf/pf_ioctl.c | 1 + sys/netpfil/pf/pf_syncookies.c | 2 ++ 5 files changed, 10 insertions(+) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 4dec539e250b..7fc22734994b 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -1145,6 +1145,7 @@ pfctl_get_syncookies(int dev, struct pfctl_syncookies *s) s->highwater = nvlist_get_number(nvl, "highwater") * 100 / state_limit; s->lowwater = nvlist_get_number(nvl, "lowwater") * 100 / state_limit; + s->halfopen_states = nvlist_get_number(nvl, "halfopen_states"); nvlist_destroy(nvl); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 32cd408c5919..78d981c2d769 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -286,6 +286,7 @@ struct pfctl_syncookies { enum pfctl_syncookies_mode mode; uint8_t highwater; /* Percent */ uint8_t lowwater; /* Percent */ + uint32_t halfopen_states; }; struct pfctl_status* pfctl_get_status(int dev); diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index ed152eca0010..74cb365d2370 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -627,6 +627,11 @@ print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts) PFCTL_SYNCOOKIES_MODE_NAMES[cookies->mode]); printf(" %-25s %s\n", "active", s->syncookies_active ? "active" : "inactive"); + if (opts & PF_OPT_VERBOSE2) { + printf(" %-25s %d %%\n", "highwater", cookies->highwater); + printf(" %-25s %d %%\n", "lowwater", cookies->lowwater); + printf(" %-25s %d\n", "halfopen states", cookies->halfopen_states); + } } } diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 44b0bccc7489..639c2462fe75 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -4979,6 +4979,7 @@ pf_getstatus(struct pfioc_nv *nv) nvlist_add_number(nvl, "src_nodes", V_pf_status.src_nodes); nvlist_add_bool(nvl, "syncookies_active", V_pf_status.syncookies_active); + nvlist_add_number(nvl, "halfopen_states", V_pf_status.states_halfopen); /* counters */ error = pf_add_status_counters(nvl, "counters", V_pf_status.counters, diff --git a/sys/netpfil/pf/pf_syncookies.c b/sys/netpfil/pf/pf_syncookies.c index fb81f59097fb..17f5803e18f5 100644 --- a/sys/netpfil/pf/pf_syncookies.c +++ b/sys/netpfil/pf/pf_syncookies.c @@ -155,6 +155,8 @@ pf_get_syncookies(struct pfioc_nv *nv) V_pf_status.syncookies_mode == PF_SYNCOOKIES_ADAPTIVE); nvlist_add_number(nvl, "highwater", V_pf_syncookie_status.hiwat); nvlist_add_number(nvl, "lowwater", V_pf_syncookie_status.lowat); + nvlist_add_number(nvl, "halfopen_states", + atomic_load_32(&V_pf_status.states_halfopen)); nvlpacked = nvlist_pack(nvl, &nv->len); if (nvlpacked == NULL)