git: bafe022b1f31 - main - inpcb: add const qualifiers on functions that select address/port
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 17 Feb 2025 23:31:04 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=bafe022b1f31c6b61aedc1a36a416270038bd971
commit bafe022b1f31c6b61aedc1a36a416270038bd971
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-02-17 23:28:52 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-02-17 23:28:52 +0000
inpcb: add const qualifiers on functions that select address/port
There are several functions that keep database locked and do address
and port selection before a caller commits the changes to the inpcb.
Mark the inpcb argument with a good documenting const.
---
sys/netinet/in_pcb.c | 11 ++++++-----
sys/netinet/in_pcb.h | 6 +++---
sys/netinet/in_pcb_var.h | 2 +-
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index c34b4594c9b9..9d174dce9024 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -754,8 +754,9 @@ in_pcbbind(struct inpcb *inp, struct sockaddr_in *sin, int flags,
* lsa can be NULL for IPv6.
*/
int
-in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *lsa, u_short *lportp,
- struct sockaddr *fsa, u_short fport, struct ucred *cred, int lookupflags)
+in_pcb_lport_dest(const struct inpcb *inp, struct sockaddr *lsa,
+ u_short *lportp, struct sockaddr *fsa, u_short fport, struct ucred *cred,
+ int lookupflags)
{
struct inpcbinfo *pcbinfo;
struct inpcb *tmpinp;
@@ -1143,8 +1144,8 @@ in_pcbconnect(struct inpcb *inp, struct sockaddr_in *sin, struct ucred *cred)
* of connect. Take jails into account as well.
*/
int
-in_pcbladdr(struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr,
- struct ucred *cred)
+in_pcbladdr(const struct inpcb *inp, struct in_addr *faddr,
+ struct in_addr *laddr, struct ucred *cred)
{
struct ifaddr *ifa;
struct sockaddr *sa;
@@ -1360,7 +1361,7 @@ done:
* and port. These are not updated in the error case.
*/
int
-in_pcbconnect_setup(struct inpcb *inp, struct sockaddr_in *sin,
+in_pcbconnect_setup(const struct inpcb *inp, struct sockaddr_in *sin,
in_addr_t *laddrp, u_short *lportp, in_addr_t *faddrp, u_short *fportp,
struct ucred *cred)
{
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index dae34e94d6f9..b0c64cfbd7ea 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -645,13 +645,13 @@ int in_pcbbind(struct inpcb *, struct sockaddr_in *, int, struct ucred *);
int in_pcbbind_setup(struct inpcb *, struct sockaddr_in *, in_addr_t *,
u_short *, int, struct ucred *);
int in_pcbconnect(struct inpcb *, struct sockaddr_in *, struct ucred *);
-int in_pcbconnect_setup(struct inpcb *, struct sockaddr_in *, in_addr_t *,
- u_short *, in_addr_t *, u_short *, struct ucred *);
+int in_pcbconnect_setup(const struct inpcb *, struct sockaddr_in *,
+ in_addr_t *, u_short *, in_addr_t *, u_short *, struct ucred *);
void in_pcbdisconnect(struct inpcb *);
void in_pcbdrop(struct inpcb *);
void in_pcbfree(struct inpcb *);
int in_pcbinshash(struct inpcb *);
-int in_pcbladdr(struct inpcb *, struct in_addr *, struct in_addr *,
+int in_pcbladdr(const struct inpcb *, struct in_addr *, struct in_addr *,
struct ucred *);
int in_pcblbgroup_numa(struct inpcb *, int arg);
void in_pcblisten(struct inpcb *);
diff --git a/sys/netinet/in_pcb_var.h b/sys/netinet/in_pcb_var.h
index 1101199f6b64..e2b0ca386e7f 100644
--- a/sys/netinet/in_pcb_var.h
+++ b/sys/netinet/in_pcb_var.h
@@ -50,7 +50,7 @@ int inp_trylock(struct inpcb *inp, const inp_lookup_t lock);
bool inp_smr_lock(struct inpcb *, const inp_lookup_t);
int in_pcb_lport(struct inpcb *, struct in_addr *, u_short *,
struct ucred *, int);
-int in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *lsa,
+int in_pcb_lport_dest(const struct inpcb *inp, struct sockaddr *lsa,
u_short *lportp, struct sockaddr *fsa, u_short fport,
struct ucred *cred, int lookupflags);
struct inpcb *in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short,