git: 07579e2110b3 - main - pf: sprinkle const over function arguments
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 30 Dec 2024 20:44:54 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=07579e2110b3c00acafd1b692a3ce9a80fb3104b commit 07579e2110b3c00acafd1b692a3ce9a80fb3104b Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2024-12-28 16:04:24 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2024-12-30 20:42:13 +0000 pf: sprinkle const over function arguments Document that these are not supposed to modify their arguments. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/net/pfvar.h | 10 +++++----- sys/netpfil/pf/pf.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index d22f715d6a27..3432f8dc99e1 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -2376,7 +2376,7 @@ VNET_DECLARE(struct ifnet *, sync_ifp); #define V_sync_ifp VNET(sync_ifp); VNET_DECLARE(struct pf_krule, pf_default_rule); #define V_pf_default_rule VNET(pf_default_rule) -extern void pf_addrcpy(struct pf_addr *, struct pf_addr *, +extern void pf_addrcpy(struct pf_addr *, const struct pf_addr *, sa_family_t); void pf_free_rule(struct pf_krule *); @@ -2417,10 +2417,10 @@ void pf_patch_16_unaligned(struct mbuf *, u_int16_t *, void *, u_int16_t, void pf_patch_32_unaligned(struct mbuf *, u_int16_t *, void *, u_int32_t, bool, u_int8_t); void pf_send_deferred_syn(struct pf_kstate *); -int pf_match_addr(u_int8_t, struct pf_addr *, struct pf_addr *, - struct pf_addr *, sa_family_t); -int pf_match_addr_range(struct pf_addr *, struct pf_addr *, - struct pf_addr *, sa_family_t); +int pf_match_addr(u_int8_t, const struct pf_addr *, + const struct pf_addr *, const struct pf_addr *, sa_family_t); +int pf_match_addr_range(const struct pf_addr *, const struct pf_addr *, + const struct pf_addr *, sa_family_t); int pf_match_port(u_int8_t, u_int16_t, u_int16_t, u_int16_t); void pf_normalize_init(void); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 761839715011..2a0dd2c3933a 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -774,7 +774,7 @@ pf_set_protostate(struct pf_kstate *s, int which, u_int8_t newstate) #ifdef INET6 void -pf_addrcpy(struct pf_addr *dst, struct pf_addr *src, sa_family_t af) +pf_addrcpy(struct pf_addr *dst, const struct pf_addr *src, sa_family_t af) { switch (af) { #ifdef INET @@ -4365,8 +4365,8 @@ pf_send_icmp(struct mbuf *m, u_int8_t type, u_int8_t code, sa_family_t af, * are different. */ int -pf_match_addr(u_int8_t n, struct pf_addr *a, struct pf_addr *m, - struct pf_addr *b, sa_family_t af) +pf_match_addr(u_int8_t n, const struct pf_addr *a, const struct pf_addr *m, + const struct pf_addr *b, sa_family_t af) { int match = 0; @@ -4401,8 +4401,8 @@ pf_match_addr(u_int8_t n, struct pf_addr *a, struct pf_addr *m, * Return 1 if b <= a <= e, otherwise return 0. */ int -pf_match_addr_range(struct pf_addr *b, struct pf_addr *e, - struct pf_addr *a, sa_family_t af) +pf_match_addr_range(const struct pf_addr *b, const struct pf_addr *e, + const struct pf_addr *a, sa_family_t af) { switch (af) { #ifdef INET