From nobody Mon Nov 06 21:33:53 2023 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 4SPPjs48Z1z50FLV; Mon, 6 Nov 2023 21:33:53 +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 4SPPjs3f9kz3cM0; Mon, 6 Nov 2023 21:33:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699306433; 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=pYgebCJ7mjmlyVN43OKjhziDtvoiIs3Cqe4lCu1PmpU=; b=I4bvr2/JKrM7gjXnNOi6xNPPWl3D0PzMtKAMQwSmqDwvJZcU9f4Vsob80WOZQ679efnHwN 2WZ8P8fIKedm8GY1qHR4VlhKsXUF3VbD2ZIZQmsQcoM7EIEE5qYk6N7gS039fJMXe2hogD UAS9YTNQfFICJoGyDjrItP20ZswXkSNRc0ogMq6HHdoAbFWss0275bdO5z+R3lnqITwBVU 9Soz6fff2DRMD/pkb+ufnCMmpgYmmb9dSsfMi+CoqQMHsURpWF0u39aqOFodx+IifgT3az 615CfuWUa1kEDmIL3ZwcpZV7iRCaGRRb3vet7jt8ysRyfeBxmJEpsFtpdZFrNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699306433; 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=pYgebCJ7mjmlyVN43OKjhziDtvoiIs3Cqe4lCu1PmpU=; b=B7df1Sqiu/apbbM4WZneV1EY3M9NTA3HyBff9wCmUHEzLrmFZBOtdsV2MR5dZ2JDwy3pUp 6Pzl07UvYHsqc5fAX99w1x/ZavyzVfu0VZ1wfZqsAQxqXG1CPUI5RaxGy/OOrcQ1/cTpTR JdLIY48Uw1i/oCw/UK8iSSdaZNuelsn1ltZFbqitPODaBY9A0iNobAHKLK0QG0+b2Rsk3n 7Fx9gf8W1h7bjC6KyUGhUF3Ujyl8W8VYP36DIFWYIeB/vKtBYRzZM8dHODWRCNvOYyuhK9 Sd9qdohjsycw8SaHQgG9SH03SOv0oM1zXsQUGMbqN7duhgnX6ffTydMOsagKOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699306433; a=rsa-sha256; cv=none; b=tvLzTP5ud9Jc45ObCRjyPPF5LeDEsAGpi41afa6dUwF8LA+igWtxuZHlpWes/Cn9IzLsDn PWowaD4toJ2oHHtWdXO8MTTw4Xw7wJGjYFMr4PFPORWQEX87qIY68AlPGe7azhs70j3zgS nrEww42K26EZtilRMbvJyl4lHjLJeXmnRxTyaB3tSKcSQN97ksJzPWnLI0FjXAU46JB/OB ZRfz1+HbnJGFXMckXoTZCR8Q6tpEUuAJuZlu+/FkAEiubFTx+6noXFqrXcKgfdqfPWvmxZ kQSu3ZUG0VlVkxZ0fpXGD2Pkt50+B+IpGLHvF0YAsV5JAS2356dqwE6clJSdMQ== 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 4SPPjs2jXRz8Xn; Mon, 6 Nov 2023 21:33:53 +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 3A6LXrlw044670; Mon, 6 Nov 2023 21:33:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A6LXrxm044667; Mon, 6 Nov 2023 21:33:53 GMT (envelope-from git) Date: Mon, 6 Nov 2023 21:33:53 GMT Message-Id: <202311062133.3A6LXrxm044667@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: a6173e94635b - main - pf: expose more syncookie state information to userspace 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a6173e94635b03aa7aab90a67785c8c3e7c6247b Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a6173e94635b03aa7aab90a67785c8c3e7c6247b commit a6173e94635b03aa7aab90a67785c8c3e7c6247b Author: Kristof Provost AuthorDate: 2023-11-06 21:20:32 +0000 Commit: Kristof Provost CommitDate: 2023-11-06 21:22:24 +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 --- 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 12b7c1df7ee8..41ac2892a5a6 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -1694,6 +1694,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 31b4b444ba64..7f3b1b600db7 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -382,6 +382,7 @@ struct pfctl_syncookies { enum pfctl_syncookies_mode mode; uint8_t highwater; /* Percent */ uint8_t lowwater; /* Percent */ + uint32_t halfopen_states; }; int pfctl_startstop(int start); diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 0268d1b07c79..cb307cd6ede5 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -628,6 +628,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); + } printf("Reassemble %24s %s\n", s->reass & PF_REASS_ENABLED ? "yes" : "no", s->reass & PF_REASS_NODF ? "no-df" : "" diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 65d4b45afd79..1598939c2375 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -5691,6 +5691,7 @@ pf_getstatus(struct pfioc_nv *nv) nvlist_add_number(nvl, "reass", V_pf_status.reass); 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 b5e59178e7e8..c5ee64c6aed0 100644 --- a/sys/netpfil/pf/pf_syncookies.c +++ b/sys/netpfil/pf/pf_syncookies.c @@ -162,6 +162,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)