Index | Thread | Search

From:
Alexander Bluhm <alexander.bluhm@gmx.net>
Subject:
Re: const inpcb
To:
tech@openbsd.org
Date:
Tue, 9 Jan 2024 16:05:42 +0100

Download raw body.

Thread
  • Alexander Bluhm:

    const inpcb

    • Alexander Bluhm:

      const inpcb

On Fri, Jan 05, 2024 at 06:47:27PM +0100, Alexander Bluhm wrote:
> Hi,
> 
> Having const struct inpcb * makes argueing about socket lock easier.
> We know where read-only access is.  I have already converted most
> of them, these functions were missed.
> 
> ok?

Anyone?

> Index: netinet/in_pcb.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.c,v
> diff -u -p -r1.283 in_pcb.c
> --- netinet/in_pcb.c	1 Jan 2024 22:16:51 -0000	1.283
> +++ netinet/in_pcb.c	5 Jan 2024 17:28:42 -0000
> @@ -133,7 +133,7 @@ uint64_t in_pcblhash(struct inpcbtable *
>  
>  struct inpcb *in_pcblookup_lock(struct inpcbtable *, struct in_addr, u_int,
>      struct in_addr, u_int, u_int, int);
> -int	in_pcbaddrisavail_lock(struct inpcb *, struct sockaddr_in *, int,
> +int	in_pcbaddrisavail_lock(const struct inpcb *, struct sockaddr_in *, int,
>      struct proc *, int);
>  int	in_pcbpickport(u_int16_t *, const void *, int, const struct inpcb *,
>      struct proc *);
> @@ -365,8 +365,8 @@ in_pcbbind(struct inpcb *inp, struct mbu
>  }
>  
>  int
> -in_pcbaddrisavail_lock(struct inpcb *inp, struct sockaddr_in *sin, int wild,
> -    struct proc *p, int lock)
> +in_pcbaddrisavail_lock(const struct inpcb *inp, struct sockaddr_in *sin,
> +    int wild, struct proc *p, int lock)
>  {
>  	struct socket *so = inp->inp_socket;
>  	struct inpcbtable *table = inp->inp_table;
> @@ -436,8 +436,8 @@ in_pcbaddrisavail_lock(struct inpcb *inp
>  }
>  
>  int
> -in_pcbaddrisavail(struct inpcb *inp, struct sockaddr_in *sin, int wild,
> -    struct proc *p)
> +in_pcbaddrisavail(const struct inpcb *inp, struct sockaddr_in *sin,
> +    int wild, struct proc *p)
>  {
>  	return in_pcbaddrisavail_lock(inp, sin, wild, p, IN_PCBLOCK_GRAB);
>  }
> @@ -962,7 +962,7 @@ in_pcbselsrc(struct in_addr *insrc, stru
>  {
>  	struct ip_moptions *mopts = inp->inp_moptions;
>  	struct route *ro = &inp->inp_route;
> -	struct in_addr *laddr = &inp->inp_laddr;
> +	const struct in_addr *laddr = &inp->inp_laddr;
>  	u_int rtableid = inp->inp_rtableid;
>  	struct sockaddr	*ip4_source = NULL;
>  
> Index: netinet/in_pcb.h
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.h,v
> diff -u -p -r1.147 in_pcb.h
> --- netinet/in_pcb.h	3 Jan 2024 11:07:04 -0000	1.147
> +++ netinet/in_pcb.h	5 Jan 2024 17:33:14 -0000
> @@ -315,7 +315,7 @@ void	 in_losing(struct inpcb *);
>  int	 in_pcballoc(struct socket *, struct inpcbtable *, int);
>  int	 in_pcbbind_locked(struct inpcb *, struct mbuf *, struct proc *);
>  int	 in_pcbbind(struct inpcb *, struct mbuf *, struct proc *);
> -int	 in_pcbaddrisavail(struct inpcb *, struct sockaddr_in *, int,
> +int	 in_pcbaddrisavail(const struct inpcb *, struct sockaddr_in *, int,
>  	    struct proc *);
>  int	 in_pcbconnect(struct inpcb *, struct mbuf *);
>  void	 in_pcbdetach(struct inpcb *);
> @@ -338,9 +338,9 @@ struct inpcb *
>  struct inpcb *
>  	 in6_pcblookup_listen(struct inpcbtable *, struct in6_addr *, u_int,
>  	    struct mbuf *, u_int);
> -int	 in6_pcbaddrisavail_lock(struct inpcb *, struct sockaddr_in6 *, int,
> -	    struct proc *, int);
> -int	 in6_pcbaddrisavail(struct inpcb *, struct sockaddr_in6 *, int,
> +int	 in6_pcbaddrisavail_lock(const struct inpcb *, struct sockaddr_in6 *,
> +	    int, struct proc *, int);
> +int	 in6_pcbaddrisavail(const struct inpcb *, struct sockaddr_in6 *, int,
>  	    struct proc *);
>  int	 in6_pcbconnect(struct inpcb *, struct mbuf *);
>  void	 in6_setsockaddr(struct inpcb *, struct mbuf *);
> @@ -370,7 +370,7 @@ struct rtentry *
>  void	in6_pcbnotify(struct inpcbtable *, struct sockaddr_in6 *,
>  	u_int, const struct sockaddr_in6 *, u_int, u_int, int, void *,
>  	void (*)(struct inpcb *, int));
> -int	in6_selecthlim(struct inpcb *);
> +int	in6_selecthlim(const struct inpcb *);
>  int	in_pcbset_rtableid(struct inpcb *, u_int);
>  void	in_pcbset_laddr(struct inpcb *, const struct sockaddr *, u_int);
>  void	in_pcbunset_faddr(struct inpcb *);
> Index: netinet6/in6_pcb.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_pcb.c,v
> diff -u -p -r1.131 in6_pcb.c
> --- netinet6/in6_pcb.c	7 Dec 2023 16:08:30 -0000	1.131
> +++ netinet6/in6_pcb.c	5 Jan 2024 17:30:55 -0000
> @@ -150,8 +150,8 @@ in6_pcbhash(struct inpcbtable *table, u_
>  }
>  
>  int
> -in6_pcbaddrisavail_lock(struct inpcb *inp, struct sockaddr_in6 *sin6, int wild,
> -    struct proc *p, int lock)
> +in6_pcbaddrisavail_lock(const struct inpcb *inp, struct sockaddr_in6 *sin6,
> +    int wild, struct proc *p, int lock)
>  {
>  	struct socket *so = inp->inp_socket;
>  	struct inpcbtable *table = inp->inp_table;
> @@ -240,8 +240,8 @@ in6_pcbaddrisavail_lock(struct inpcb *in
>  }
>  
>  int
> -in6_pcbaddrisavail(struct inpcb *inp, struct sockaddr_in6 *sin6, int wild,
> -    struct proc *p)
> +in6_pcbaddrisavail(const struct inpcb *inp, struct sockaddr_in6 *sin6,
> +    int wild, struct proc *p)
>  {
>  	return in6_pcbaddrisavail_lock(inp, sin6, wild, p, IN_PCBLOCK_GRAB);
>  }
> Index: netinet6/in6_src.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_src.c,v
> diff -u -p -r1.90 in6_src.c
> --- netinet6/in6_src.c	15 Dec 2023 00:24:56 -0000	1.90
> +++ netinet6/in6_src.c	5 Jan 2024 17:31:50 -0000
> @@ -422,7 +422,7 @@ in6_selectif(struct sockaddr_in6 *dstsoc
>  }
>  
>  int
> -in6_selecthlim(struct inpcb *inp)
> +in6_selecthlim(const struct inpcb *inp)
>  {
>  	if (inp && inp->inp_hops >= 0)
>  		return (inp->inp_hops);