git: 29273f6a2582 - main - pf: add SDT on REASON_SET()

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 15 Apr 2025 12:46:35 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=29273f6a258264ebc053da8e1a20e85d620b68aa

commit 29273f6a258264ebc053da8e1a20e85d620b68aa
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-04-14 11:41:30 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-04-15 07:47:48 +0000

    pf: add SDT on REASON_SET()
    
    Add a probe point in the REASON_SET macro. This can be halpful during debugging,
    letting us figure out exactly where PF made a decision.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/net/pfvar.h     | 2 ++
 sys/netpfil/pf/pf.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index e3a8412bde73..22b902532743 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -330,6 +330,7 @@ MALLOC_DECLARE(M_PFHASH);
 MALLOC_DECLARE(M_PF_RULE_ITEM);
 
 SDT_PROVIDER_DECLARE(pf);
+SDT_PROBE_DECLARE(pf, , test, reason_set);
 
 struct pfi_dynaddr {
 	TAILQ_ENTRY(pfi_dynaddr)	 entry;
@@ -1759,6 +1760,7 @@ struct pf_sctp_multihome_job {
 
 #define REASON_SET(a, x) \
 	do { \
+		SDT_PROBE2(pf, , test, reason_set, x, __LINE__); \
 		if ((a) != NULL) \
 			*(a) = (x); \
 		if (x < PFRES_MAX) \
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 9d965d583629..8c4b5a7ea2da 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -120,6 +120,7 @@
 #define	DPFPRINTF(n, x)	if (V_pf_status.debug >= (n)) printf x
 
 SDT_PROVIDER_DEFINE(pf);
+SDT_PROBE_DEFINE2(pf, , test, reason_set, "int", "int");
 SDT_PROBE_DEFINE4(pf, ip, test, done, "int", "int", "struct pf_krule *",
     "struct pf_kstate *");
 SDT_PROBE_DEFINE5(pf, ip, state, lookup, "struct pfi_kkif *",