Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 May 2025 22:16:18 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 94db776fa234 - main - pf: use __func__ rather than hardcoded function names
Message-ID:  <202505092216.549MGIGp062945@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=94db776fa2346e4bce082a481760fcc2cdb3660a

commit 94db776fa2346e4bce082a481760fcc2cdb3660a
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-05-08 15:04:08 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-05-09 20:49:29 +0000

    pf: use __func__ rather than hardcoded function names
    
    Replace function names with __func__ in debug prints to make grep
    happy.
    
    Obtained from:  OpenBSD, bluhm <bluhm@openbsd.org>, 68d5ab4417
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/pf.c         | 20 +++++++++++---------
 sys/netpfil/pf/pf_ioctl.c   | 23 ++++++++++++-----------
 sys/netpfil/pf/pf_ruleset.c |  8 ++++----
 3 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 2f69f36e2db3..e9082da193e6 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -4597,7 +4597,7 @@ pf_match_rcvif(struct mbuf *m, struct pf_krule *r)
 
 	if (kif == NULL) {
 		DPFPRINTF(PF_DEBUG_URGENT,
-		    ("pf_test_via: kif == NULL, @%d via %s\n", r->nr,
+		    ("%s: kif == NULL, @%d via %s\n", __func__, r->nr,
 			r->rcv_ifname));
 		return (0);
 	}
@@ -5255,8 +5255,8 @@ pf_test_eth_rule(int dir, struct pfi_kkif *kif, struct mbuf **m0)
 	if (__predict_false(m->m_len < sizeof(struct ether_header)) &&
 	    (m = *m0 = m_pullup(*m0, sizeof(struct ether_header))) == NULL) {
 		DPFPRINTF(PF_DEBUG_URGENT,
-		    ("pf_test_eth_rule: m_len < sizeof(struct ether_header)"
-		     ", pullup failed\n"));
+		    ("%s: m_len < sizeof(struct ether_header)"
+		     ", pullup failed\n", __func__));
 		return (PF_DROP);
 	}
 	e = mtod(m, struct ether_header *);
@@ -6133,8 +6133,8 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a,
 		    &s->src, &s->dst, rewrite)) {
 			/* This really shouldn't happen!!! */
 			DPFPRINTF(PF_DEBUG_URGENT,
-			    ("pf_normalize_tcp_stateful failed on first "
-			     "pkt\n"));
+			    ("%s: tcp normalize failed on first "
+			     "pkt\n", __func__));
 			goto csfailed;
 		}
 	} else if (pd->proto == IPPROTO_SCTP) {
@@ -9935,7 +9935,8 @@ pf_setup_pdesc(sa_family_t af, int dir, struct pf_pdesc *pd, struct mbuf **m0,
 		if (__predict_false((*m0)->m_len < sizeof(struct ip)) &&
 		    (pd->m = *m0 = m_pullup(*m0, sizeof(struct ip))) == NULL) {
 			DPFPRINTF(PF_DEBUG_URGENT,
-			    ("pf_test: m_len < sizeof(struct ip), pullup failed\n"));
+			    ("%s: m_len < sizeof(struct ip), pullup failed\n",
+			    __func__));
 			*action = PF_DROP;
 			REASON_SET(reason, PFRES_SHORT);
 			return (-1);
@@ -9984,8 +9985,8 @@ pf_setup_pdesc(sa_family_t af, int dir, struct pf_pdesc *pd, struct mbuf **m0,
 		if (__predict_false((*m0)->m_len < sizeof(struct ip6_hdr)) &&
 		    (pd->m = *m0 = m_pullup(*m0, sizeof(struct ip6_hdr))) == NULL) {
 			DPFPRINTF(PF_DEBUG_URGENT,
-			    ("pf_test6: m_len < sizeof(struct ip6_hdr)"
-			     ", pullup failed\n"));
+			    ("%s: m_len < sizeof(struct ip6_hdr)"
+			     ", pullup failed\n", __func__));
 			*action = PF_DROP;
 			REASON_SET(reason, PFRES_SHORT);
 			return (-1);
@@ -10333,7 +10334,8 @@ pf_test(sa_family_t af, int dir, int pflags, struct ifnet *ifp, struct mbuf **m0
 
 	if (__predict_false(kif == NULL)) {
 		DPFPRINTF(PF_DEBUG_URGENT,
-		    ("pf_test: kif == NULL, if_xname %s\n", ifp->if_xname));
+		    ("%s: kif == NULL, if_xname %s\n",
+		    __func__, ifp->if_xname));
 		PF_RULES_RUNLOCK();
 		return (PF_DROP);
 	}
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index bd3c2b93c954..cfa17b9925aa 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -6391,9 +6391,9 @@ shutdown_pf(void)
 			for (rs_num = 0; rs_num < PF_RULESET_MAX; ++rs_num) {
 				if ((error = pf_begin_rules(&t[rs_num], rs_num,
 				    anchor->path)) != 0) {
-					DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: "
+					DPFPRINTF(PF_DEBUG_MISC, ("%s: "
 					    "anchor.path=%s rs_num=%d\n",
-					    anchor->path, rs_num));
+					    __func__, anchor->path, rs_num));
 					goto error;	/* XXX: rollback? */
 				}
 			}
@@ -6415,8 +6415,9 @@ shutdown_pf(void)
 				eth_anchor->refcnt = 1;
 			if ((error = pf_begin_eth(&t[0], eth_anchor->path))
 			    != 0) {
-				DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: eth "
-				    "anchor.path=%s\n", eth_anchor->path));
+				DPFPRINTF(PF_DEBUG_MISC, ("%s: eth "
+				    "anchor.path=%s\n", __func__,
+				    eth_anchor->path));
 				goto error;
 			}
 			error = pf_commit_eth(t[0], eth_anchor->path);
@@ -6425,27 +6426,27 @@ shutdown_pf(void)
 
 		if ((error = pf_begin_rules(&t[0], PF_RULESET_SCRUB, &nn))
 		    != 0) {
-			DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: SCRUB\n"));
+			DPFPRINTF(PF_DEBUG_MISC, ("%s: SCRUB\n", __func__));
 			break;
 		}
 		if ((error = pf_begin_rules(&t[1], PF_RULESET_FILTER, &nn))
 		    != 0) {
-			DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: FILTER\n"));
+			DPFPRINTF(PF_DEBUG_MISC, ("%s: FILTER\n", __func__));
 			break;		/* XXX: rollback? */
 		}
 		if ((error = pf_begin_rules(&t[2], PF_RULESET_NAT, &nn))
 		    != 0) {
-			DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: NAT\n"));
+			DPFPRINTF(PF_DEBUG_MISC, ("%s: NAT\n", __func__));
 			break;		/* XXX: rollback? */
 		}
 		if ((error = pf_begin_rules(&t[3], PF_RULESET_BINAT, &nn))
 		    != 0) {
-			DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: BINAT\n"));
+			DPFPRINTF(PF_DEBUG_MISC, ("%s: BINAT\n", __func__));
 			break;		/* XXX: rollback? */
 		}
 		if ((error = pf_begin_rules(&t[4], PF_RULESET_RDR, &nn))
 		    != 0) {
-			DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: RDR\n"));
+			DPFPRINTF(PF_DEBUG_MISC, ("%s: RDR\n", __func__));
 			break;		/* XXX: rollback? */
 		}
 
@@ -6464,7 +6465,7 @@ shutdown_pf(void)
 			break;
 
 		if ((error = pf_begin_eth(&t[0], &nn)) != 0) {
-			DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: eth\n"));
+			DPFPRINTF(PF_DEBUG_MISC, ("%s: eth\n", __func__));
 			break;
 		}
 		error = pf_commit_eth(t[0], &nn);
@@ -6472,7 +6473,7 @@ shutdown_pf(void)
 
 #ifdef ALTQ
 		if ((error = pf_begin_altq(&t[0])) != 0) {
-			DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: ALTQ\n"));
+			DPFPRINTF(PF_DEBUG_MISC, ("%s: ALTQ\n", __func__));
 			break;
 		}
 		pf_commit_altq(t[0]);
diff --git a/sys/netpfil/pf/pf_ruleset.c b/sys/netpfil/pf/pf_ruleset.c
index fc0651f8a0e8..6fd92201439d 100644
--- a/sys/netpfil/pf/pf_ruleset.c
+++ b/sys/netpfil/pf/pf_ruleset.c
@@ -336,7 +336,7 @@ pf_kanchor_setup(struct pf_krule *r, const struct pf_kruleset *s,
 			strlcpy(path, s->anchor->path, MAXPATHLEN);
 		while (name[0] == '.' && name[1] == '.' && name[2] == '/') {
 			if (!path[0]) {
-				DPFPRINTF("pf_anchor_setup: .. beyond root\n");
+				DPFPRINTF("%s: .. beyond root\n", __func__);
 				rs_free(path);
 				return (1);
 			}
@@ -358,7 +358,7 @@ pf_kanchor_setup(struct pf_krule *r, const struct pf_kruleset *s,
 	ruleset = pf_find_or_create_kruleset(path);
 	rs_free(path);
 	if (ruleset == NULL || ruleset->anchor == NULL) {
-		DPFPRINTF("pf_anchor_setup: ruleset\n");
+		DPFPRINTF("%s: ruleset\n", __func__);
 		return (1);
 	}
 	r->anchor = ruleset->anchor;
@@ -643,7 +643,7 @@ pf_keth_anchor_setup(struct pf_keth_rule *r, const struct pf_keth_ruleset *s,
 			strlcpy(path, s->anchor->path, MAXPATHLEN);
 		while (name[0] == '.' && name[1] == '.' && name[2] == '/') {
 			if (!path[0]) {
-				DPFPRINTF("pf_anchor_setup: .. beyond root\n");
+				DPFPRINTF("%s: .. beyond root\n", __func__);
 				rs_free(path);
 				return (1);
 			}
@@ -665,7 +665,7 @@ pf_keth_anchor_setup(struct pf_keth_rule *r, const struct pf_keth_ruleset *s,
 	ruleset = pf_find_or_create_keth_ruleset(path);
 	rs_free(path);
 	if (ruleset == NULL || ruleset->anchor == NULL) {
-		DPFPRINTF("pf_anchor_setup: ruleset\n");
+		DPFPRINTF("%s: ruleset\n", __func__);
 		return (1);
 	}
 	r->anchor = ruleset->anchor;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505092216.549MGIGp062945>