git: e7995c99f1e4 - main - pf: inline pf_addrcpy()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 31 Mar 2025 14:58:01 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=e7995c99f1e4b3ae001a4ce53c07fb97ada3d003
commit e7995c99f1e4b3ae001a4ce53c07fb97ada3d003
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-03-29 09:46:54 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-03-31 12:56:57 +0000
pf: inline pf_addrcpy()
Make it easier for the compiler to inline this in the many cases where the 'af'
is known at compile time.
Reviewed by: glebius, markj
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D49581
---
sys/net/pfvar.h | 19 +++++++++++++++++++
sys/netpfil/pf/pf.c | 17 -----------------
2 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index 156ffd22c07b..82967dc10d03 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -598,6 +598,25 @@ extern struct sx pf_end_lock;
#endif /* PF_INET6_ONLY */
#endif /* PF_INET_INET6 */
+#ifdef _KERNEL
+#ifdef INET6
+static void inline
+pf_addrcpy(struct pf_addr *dst, const struct pf_addr *src, sa_family_t af)
+{
+ switch (af) {
+#ifdef INET
+ case AF_INET:
+ memcpy(&dst->v4, &src->v4, sizeof(dst->v4));
+ break;
+#endif /* INET */
+ case AF_INET6:
+ memcpy(&dst->v6, &src->v6, sizeof(dst->v6));
+ break;
+ }
+}
+#endif /* INET6 */
+#endif
+
/*
* XXX callers not FIB-aware in our version of pf yet.
* OpenBSD fixed it later it seems, 2010/05/07 13:33:16 claudio.
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index d60b30057cbb..e4affb502d0e 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -798,23 +798,6 @@ pf_set_protostate(struct pf_kstate *s, int which, u_int8_t newstate)
s->src.state = newstate;
}
-#ifdef INET6
-void
-pf_addrcpy(struct pf_addr *dst, const struct pf_addr *src, sa_family_t af)
-{
- switch (af) {
-#ifdef INET
- case AF_INET:
- memcpy(&dst->v4, &src->v4, sizeof(dst->v4));
- break;
-#endif /* INET */
- case AF_INET6:
- memcpy(&dst->v6, &src->v6, sizeof(dst->v6));
- break;
- }
-}
-#endif /* INET6 */
-
static void
pf_init_threshold(struct pf_threshold *threshold,
u_int32_t limit, u_int32_t seconds)