On Sat, Sep 03, 2022 at 10:29:14PM +0300, Vitaliy Makkoveev wrote:
> The last one.
>
> As for the previous PRU_SOCKADDR, introduce in{,6}_peeraddr() and use it
> for inet and inet sockets, except tcp(4).
>
> Also remove *_usrreq() handlers. This makes diff bigger, but I guess we
> don't want to commit code like below:
OK bluhm@
> Index: sys/kern/uipc_usrreq.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/uipc_usrreq.c,v
> retrieving revision 1.184
> diff -u -p -r1.184 uipc_usrreq.c
> --- sys/kern/uipc_usrreq.c 3 Sep 2022 18:48:49 -0000 1.184
> +++ sys/kern/uipc_usrreq.c 3 Sep 2022 19:50:49 -0000
> @@ -127,7 +127,6 @@ int unp_defer; /* [G] number of deferred
> int unp_gcing; /* [G] GC task currently running */
>
> const struct pr_usrreqs uipc_usrreqs = {
> - .pru_usrreq = uipc_usrreq,
> .pru_attach = uipc_attach,
> .pru_detach = uipc_detach,
> .pru_bind = uipc_bind,
> @@ -141,6 +140,7 @@ const struct pr_usrreqs uipc_usrreqs = {
> .pru_abort = uipc_abort,
> .pru_sense = uipc_sense,
> .pru_sockaddr = uipc_sockaddr,
> + .pru_peeraddr = uipc_peeraddr,
> .pru_connect2 = uipc_connect2,
> };
>
> @@ -212,46 +212,6 @@ uipc_setaddr(const struct unpcb *unp, st
> }
> }
>
> -int
> -uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
> - struct mbuf *control, struct proc *p)
> -{
> - struct unpcb *unp = sotounpcb(so);
> - struct socket *so2;
> - int error = 0;
> -
> - if (req != PRU_SEND && control && control->m_len) {
> - error = EOPNOTSUPP;
> - goto release;
> - }
> - if (unp == NULL) {
> - error = EINVAL;
> - goto release;
> - }
> -
> - switch (req) {
> -
> - case PRU_PEERADDR:
> - so2 = unp_solock_peer(so);
> - uipc_setaddr(unp->unp_conn, nam);
> - if (so2 != NULL && so2 != so)
> - sounlock(so2);
> - break;
> -
> - case PRU_SLOWTIMO:
> - break;
> -
> - default:
> - panic("uipc_usrreq");
> - }
> -release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> -}
> -
> /*
> * Both send and receive buffers are allocated PIPSIZ bytes of buffering
> * for stream sockets, although the total for sender and receiver is
> @@ -582,6 +542,19 @@ uipc_sockaddr(struct socket *so, struct
> struct unpcb *unp = sotounpcb(so);
>
> uipc_setaddr(unp, nam);
> + return (0);
> +}
> +
> +int
> +uipc_peeraddr(struct socket *so, struct mbuf *nam)
> +{
> + struct unpcb *unp = sotounpcb(so);
> + struct socket *so2;
> +
> + so2 = unp_solock_peer(so);
> + uipc_setaddr(unp->unp_conn, nam);
> + if (so2 != NULL && so2 != so)
> + sounlock(so2);
> return (0);
> }
>
> Index: sys/net/pfkeyv2.c
> ===================================================================
> RCS file: /cvs/src/sys/net/pfkeyv2.c,v
> retrieving revision 1.251
> diff -u -p -r1.251 pfkeyv2.c
> --- sys/net/pfkeyv2.c 3 Sep 2022 18:48:50 -0000 1.251
> +++ sys/net/pfkeyv2.c 3 Sep 2022 19:50:49 -0000
> @@ -177,8 +177,7 @@ int pfkeyv2_send(struct socket *, struct
> struct mbuf *);
> int pfkeyv2_abort(struct socket *);
> int pfkeyv2_sockaddr(struct socket *, struct mbuf *);
> -int pfkeyv2_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
> - struct mbuf *, struct proc *);
> +int pfkeyv2_peeraddr(struct socket *, struct mbuf *);
> int pfkeyv2_output(struct mbuf *, struct socket *);
> int pfkey_sendup(struct pkpcb *, struct mbuf *, int);
> int pfkeyv2_sa_flush(struct tdb *, void *, int);
> @@ -205,7 +204,6 @@ pfdatatopacket(void *data, int len, stru
> }
>
> const struct pr_usrreqs pfkeyv2_usrreqs = {
> - .pru_usrreq = pfkeyv2_usrreq,
> .pru_attach = pfkeyv2_attach,
> .pru_detach = pfkeyv2_detach,
> .pru_disconnect = pfkeyv2_disconnect,
> @@ -213,6 +211,7 @@ const struct pr_usrreqs pfkeyv2_usrreqs
> .pru_send = pfkeyv2_send,
> .pru_abort = pfkeyv2_abort,
> .pru_sockaddr = pfkeyv2_sockaddr,
> + .pru_peeraddr = pfkeyv2_peeraddr,
> };
>
> const struct protosw pfkeysw[] = {
> @@ -397,42 +396,12 @@ pfkeyv2_sockaddr(struct socket *so, stru
> }
>
> int
> -pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m,
> - struct mbuf *nam, struct mbuf *control, struct proc *p)
> +pfkeyv2_peeraddr(struct socket *so, struct mbuf *nam)
> {
> - struct pkpcb *kp;
> - int error = 0;
> -
> - soassertlocked(so);
> -
> - if (control && control->m_len) {
> - error = EOPNOTSUPP;
> - goto release;
> - }
> -
> - kp = sotokeycb(so);
> - if (kp == NULL) {
> - error = EINVAL;
> - goto release;
> - }
> -
> - switch (req) {
> /* minimal support, just implement a fake peer address */
> - case PRU_PEERADDR:
> - bcopy(&pfkey_addr, mtod(nam, caddr_t), pfkey_addr.sa_len);
> - nam->m_len = pfkey_addr.sa_len;
> - break;
> -
> - default:
> - panic("pfkeyv2_usrreq");
> - }
> -
> - release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> + bcopy(&pfkey_addr, mtod(nam, caddr_t), pfkey_addr.sa_len);
> + nam->m_len = pfkey_addr.sa_len;
> + return (0);
> }
>
> int
> Index: sys/net/rtsock.c
> ===================================================================
> RCS file: /cvs/src/sys/net/rtsock.c,v
> retrieving revision 1.352
> diff -u -p -r1.352 rtsock.c
> --- sys/net/rtsock.c 3 Sep 2022 18:48:50 -0000 1.352
> +++ sys/net/rtsock.c 3 Sep 2022 19:50:49 -0000
> @@ -111,8 +111,6 @@ void rcb_ref(void *, void *);
> void rcb_unref(void *, void *);
> int route_output(struct mbuf *, struct socket *);
> int route_ctloutput(int, struct socket *, int, int, struct mbuf *);
> -int route_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
> - struct mbuf *, struct proc *);
> int route_disconnect(struct socket *);
> int route_shutdown(struct socket *);
> int route_rcvd(struct socket *);
> @@ -120,6 +118,7 @@ int route_send(struct socket *, struct m
> struct mbuf *);
> int route_abort(struct socket *);
> int route_sockaddr(struct socket *, struct mbuf *);
> +int route_peeraddr(struct socket *, struct mbuf *);
> void route_input(struct mbuf *m0, struct socket *, sa_family_t);
> int route_arp_conflict(struct rtentry *, struct rt_addrinfo *);
> int route_cleargateway(struct rtentry *, void *, unsigned int);
> @@ -215,45 +214,6 @@ rcb_unref(void *null, void *v)
> }
>
> int
> -route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
> - struct mbuf *control, struct proc *p)
> -{
> - struct rtpcb *rop;
> - int error = 0;
> -
> - soassertlocked(so);
> -
> - if (control && control->m_len) {
> - error = EOPNOTSUPP;
> - goto release;
> - }
> -
> - rop = sotortpcb(so);
> - if (rop == NULL) {
> - error = EINVAL;
> - goto release;
> - }
> -
> - switch (req) {
> - /* minimal support, just implement a fake peer address */
> - case PRU_PEERADDR:
> - bcopy(&route_src, mtod(nam, caddr_t), route_src.sa_len);
> - nam->m_len = route_src.sa_len;
> - break;
> -
> - default:
> - panic("route_usrreq");
> - }
> -
> - release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> -}
> -
> -int
> route_attach(struct socket *so, int proto)
> {
> struct rtpcb *rop;
> @@ -398,6 +358,15 @@ route_sockaddr(struct socket *so, struct
> }
>
> int
> +route_peeraddr(struct socket *so, struct mbuf *nam)
> +{
> + /* minimal support, just implement a fake peer address */
> + bcopy(&route_src, mtod(nam, caddr_t), route_src.sa_len);
> + nam->m_len = route_src.sa_len;
> + return (0);
> +}
> +
> +int
> route_ctloutput(int op, struct socket *so, int level, int optname,
> struct mbuf *m)
> {
> @@ -2431,7 +2400,6 @@ rt_setsource(unsigned int rtableid, stru
> */
>
> const struct pr_usrreqs route_usrreqs = {
> - .pru_usrreq = route_usrreq,
> .pru_attach = route_attach,
> .pru_detach = route_detach,
> .pru_disconnect = route_disconnect,
> @@ -2440,6 +2408,7 @@ const struct pr_usrreqs route_usrreqs =
> .pru_send = route_send,
> .pru_abort = route_abort,
> .pru_sockaddr = route_sockaddr,
> + .pru_peeraddr = route_peeraddr,
> };
>
> const struct protosw routesw[] = {
> Index: sys/netinet/in_pcb.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/in_pcb.c,v
> retrieving revision 1.274
> diff -u -p -r1.274 in_pcb.c
> --- sys/netinet/in_pcb.c 3 Sep 2022 18:48:50 -0000 1.274
> +++ sys/netinet/in_pcb.c 3 Sep 2022 19:50:49 -0000
> @@ -676,6 +676,17 @@ in_sockaddr(struct socket *so, struct mb
> return (0);
> }
>
> +int
> +in_peeraddr(struct socket *so, struct mbuf *nam)
> +{
> + struct inpcb *inp;
> +
> + inp = sotoinpcb(so);
> + in_setpeeraddr(inp, nam);
> +
> + return (0);
> +}
> +
> /*
> * Pass some notification to all connections of a protocol
> * associated with address dst. The "usual action" will be
> Index: sys/netinet/in_pcb.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet/in_pcb.h,v
> retrieving revision 1.133
> diff -u -p -r1.133 in_pcb.h
> --- sys/netinet/in_pcb.h 3 Sep 2022 18:48:50 -0000 1.133
> +++ sys/netinet/in_pcb.h 3 Sep 2022 19:50:49 -0000
> @@ -309,6 +309,7 @@ int in6_pcbconnect(struct inpcb *, stru
> void in6_setsockaddr(struct inpcb *, struct mbuf *);
> void in6_setpeeraddr(struct inpcb *, struct mbuf *);
> int in6_sockaddr(struct socket *, struct mbuf *);
> +int in6_peeraddr(struct socket *, struct mbuf *);
> #endif /* INET6 */
> void in_pcbinit(struct inpcbtable *, int);
> struct inpcb *
> @@ -320,6 +321,7 @@ void in_rtchange(struct inpcb *, int);
> void in_setpeeraddr(struct inpcb *, struct mbuf *);
> void in_setsockaddr(struct inpcb *, struct mbuf *);
> int in_sockaddr(struct socket *, struct mbuf *);
> +int in_peeraddr(struct socket *, struct mbuf *);
> int in_baddynamic(u_int16_t, u_int16_t);
> int in_rootonly(u_int16_t, u_int16_t);
> int in_pcbselsrc(struct in_addr *, struct sockaddr_in *, struct inpcb *);
> Index: sys/netinet/ip_divert.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_divert.c,v
> retrieving revision 1.85
> diff -u -p -r1.85 ip_divert.c
> --- sys/netinet/ip_divert.c 3 Sep 2022 18:48:50 -0000 1.85
> +++ sys/netinet/ip_divert.c 3 Sep 2022 19:50:49 -0000
> @@ -63,7 +63,6 @@ const struct sysctl_bounded_args divertc
> };
>
> const struct pr_usrreqs divert_usrreqs = {
> - .pru_usrreq = divert_usrreq,
> .pru_attach = divert_attach,
> .pru_detach = divert_detach,
> .pru_bind = divert_bind,
> @@ -72,6 +71,7 @@ const struct pr_usrreqs divert_usrreqs =
> .pru_abort = divert_abort,
> .pru_control = in_control,
> .pru_sockaddr = in_sockaddr,
> + .pru_peeraddr = in_peeraddr,
> };
>
> int divbhashsize = DIVERTHASHSIZE;
> @@ -250,45 +250,6 @@ divert_packet(struct mbuf *m, int dir, u
> if (inp != NULL)
> in_pcbunref(inp);
> m_freem(m);
> -}
> -
> -/*ARGSUSED*/
> -int
> -divert_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
> - struct mbuf *control, struct proc *p)
> -{
> - struct inpcb *inp = sotoinpcb(so);
> - int error = 0;
> -
> - soassertlocked(so);
> -
> - if (inp == NULL) {
> - error = EINVAL;
> - goto release;
> - }
> - switch (req) {
> -
> - case PRU_PEERADDR:
> - in_setpeeraddr(inp, addr);
> - break;
> -
> - case PRU_FASTTIMO:
> - case PRU_SLOWTIMO:
> - case PRU_PROTORCV:
> - case PRU_PROTOSEND:
> - error = EOPNOTSUPP;
> - break;
> -
> - default:
> - panic("divert_usrreq");
> - }
> -
> -release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> }
>
> int
> Index: sys/netinet/ip_divert.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_divert.h,v
> retrieving revision 1.20
> diff -u -p -r1.20 ip_divert.h
> --- sys/netinet/ip_divert.h 28 Aug 2022 18:44:16 -0000 1.20
> +++ sys/netinet/ip_divert.h 3 Sep 2022 19:50:49 -0000
> @@ -70,8 +70,6 @@ extern const struct pr_usrreqs divert_us
> void divert_init(void);
> void divert_packet(struct mbuf *, int, u_int16_t);
> int divert_sysctl(int *, u_int, void *, size_t *, void *, size_t);
> -int divert_usrreq(struct socket *,
> - int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
> int divert_attach(struct socket *, int);
> int divert_detach(struct socket *);
> int divert_bind(struct socket *, struct mbuf *, struct proc *);
> Index: sys/netinet/ip_gre.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_gre.c,v
> retrieving revision 1.83
> diff -u -p -r1.83 ip_gre.c
> --- sys/netinet/ip_gre.c 3 Sep 2022 18:48:50 -0000 1.83
> +++ sys/netinet/ip_gre.c 3 Sep 2022 19:50:49 -0000
> @@ -64,7 +64,6 @@
> #endif
>
> const struct pr_usrreqs gre_usrreqs = {
> - .pru_usrreq = gre_usrreq,
> .pru_attach = rip_attach,
> .pru_detach = rip_detach,
> .pru_bind = rip_bind,
> @@ -75,14 +74,8 @@ const struct pr_usrreqs gre_usrreqs = {
> .pru_abort = rip_abort,
> .pru_control = in_control,
> .pru_sockaddr = in_sockaddr,
> + .pru_peeraddr = in_peeraddr,
> };
> -
> -int
> -gre_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
> - struct mbuf *control, struct proc *p)
> -{
> - return rip_usrreq(so, req, m, nam, control, p);
> -}
>
> int
> gre_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
> Index: sys/netinet/ip_var.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_var.h,v
> retrieving revision 1.103
> diff -u -p -r1.103 ip_var.h
> --- sys/netinet/ip_var.h 28 Aug 2022 18:44:16 -0000 1.103
> +++ sys/netinet/ip_var.h 3 Sep 2022 19:50:49 -0000
> @@ -256,8 +256,6 @@ void rip_init(void);
> int rip_input(struct mbuf **, int *, int, int);
> int rip_output(struct mbuf *, struct socket *, struct sockaddr *,
> struct mbuf *);
> -int rip_usrreq(struct socket *,
> - int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
> int rip_attach(struct socket *, int);
> int rip_detach(struct socket *);
> int rip_bind(struct socket *so, struct mbuf *, struct proc *);
> Index: sys/netinet/raw_ip.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/raw_ip.c,v
> retrieving revision 1.146
> diff -u -p -r1.146 raw_ip.c
> --- sys/netinet/raw_ip.c 3 Sep 2022 18:48:50 -0000 1.146
> +++ sys/netinet/raw_ip.c 3 Sep 2022 19:50:49 -0000
> @@ -104,7 +104,6 @@ struct inpcbtable rawcbtable;
> */
>
> const struct pr_usrreqs rip_usrreqs = {
> - .pru_usrreq = rip_usrreq,
> .pru_attach = rip_attach,
> .pru_detach = rip_detach,
> .pru_bind = rip_bind,
> @@ -115,6 +114,7 @@ const struct pr_usrreqs rip_usrreqs = {
> .pru_abort = rip_abort,
> .pru_control = in_control,
> .pru_sockaddr = in_sockaddr,
> + .pru_peeraddr = in_peeraddr,
> };
>
> /*
> @@ -457,39 +457,6 @@ rip_ctloutput(int op, struct socket *so,
>
> u_long rip_sendspace = RIPSNDQ;
> u_long rip_recvspace = RIPRCVQ;
> -
> -/*ARGSUSED*/
> -int
> -rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
> - struct mbuf *control, struct proc *p)
> -{
> - struct inpcb *inp;
> - int error = 0;
> -
> - soassertlocked(so);
> -
> - inp = sotoinpcb(so);
> - if (inp == NULL) {
> - error = EINVAL;
> - goto release;
> - }
> -
> - switch (req) {
> -
> - case PRU_PEERADDR:
> - in_setpeeraddr(inp, nam);
> - break;
> -
> - default:
> - panic("rip_usrreq");
> - }
> -release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> -}
>
> int
> rip_attach(struct socket *so, int proto)
> Index: sys/netinet/tcp_usrreq.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_usrreq.c,v
> retrieving revision 1.205
> diff -u -p -r1.205 tcp_usrreq.c
> --- sys/netinet/tcp_usrreq.c 3 Sep 2022 18:48:50 -0000 1.205
> +++ sys/netinet/tcp_usrreq.c 3 Sep 2022 19:50:49 -0000
> @@ -112,7 +112,6 @@ u_int tcp_recvspace = TCP_RECVSPACE;
> u_int tcp_autorcvbuf_inc = 16 * 1024;
>
> const struct pr_usrreqs tcp_usrreqs = {
> - .pru_usrreq = tcp_usrreq,
> .pru_attach = tcp_attach,
> .pru_detach = tcp_detach,
> .pru_bind = tcp_bind,
> @@ -129,11 +128,11 @@ const struct pr_usrreqs tcp_usrreqs = {
> .pru_sendoob = tcp_sendoob,
> .pru_control = in_control,
> .pru_sockaddr = tcp_sockaddr,
> + .pru_peeraddr = tcp_peeraddr,
> };
>
> #ifdef INET6
> const struct pr_usrreqs tcp6_usrreqs = {
> - .pru_usrreq = tcp_usrreq,
> .pru_attach = tcp_attach,
> .pru_detach = tcp_detach,
> .pru_bind = tcp_bind,
> @@ -150,6 +149,7 @@ const struct pr_usrreqs tcp6_usrreqs = {
> .pru_sendoob = tcp_sendoob,
> .pru_control = in6_control,
> .pru_sockaddr = tcp_sockaddr,
> + .pru_peeraddr = tcp_peeraddr,
> };
> #endif
>
> @@ -205,62 +205,6 @@ tcp_sogetpcb(struct socket *so, struct i
> }
>
> /*
> - * Process a TCP user request for TCP tb. If this is a send request
> - * then m is the mbuf chain of send data. If this is a timer expiration
> - * (called from the software clock routine), then timertype tells which
> timer.
> - */
> -/*ARGSUSED*/
> -int
> -tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
> - struct mbuf *control, struct proc *p)
> -{
> - struct inpcb *inp;
> - struct tcpcb *otp = NULL, *tp;
> - int error = 0;
> - short ostate;
> -
> - soassertlocked(so);
> -
> - if (control && control->m_len) {
> - error = EINVAL;
> - goto release;
> - }
> -
> - if ((error = tcp_sogetpcb(so, &inp, &tp)))
> - goto release;
> -
> - if (so->so_options & SO_DEBUG) {
> - otp = tp;
> - ostate = tp->t_state;
> - }
> -
> - switch (req) {
> -
> - case PRU_PEERADDR:
> -#ifdef INET6
> - if (inp->inp_flags & INP_IPV6)
> - in6_setpeeraddr(inp, nam);
> - else
> -#endif
> - in_setpeeraddr(inp, nam);
> - break;
> -
> - default:
> - panic("tcp_usrreq");
> - }
> - if (otp)
> - tcp_trace(TA_USER, ostate, tp, otp, NULL, req, 0);
> - return (error);
> -
> - release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> -}
> -
> -/*
> * Export internal TCP state information via a struct tcp_info without
> * leaking any sensitive information. Sequence numbers are reported
> * relative to the initial sequence number.
> @@ -1073,6 +1017,31 @@ tcp_sockaddr(struct socket *so, struct m
> if (so->so_options & SO_DEBUG)
> tcp_trace(TA_USER, tp->t_state, tp, tp, NULL,
> PRU_SOCKADDR, 0);
> + return (0);
> +}
> +
> +int
> +tcp_peeraddr(struct socket *so, struct mbuf *nam)
> +{
> + struct inpcb *inp;
> + struct tcpcb *tp;
> + int error;
> +
> + soassertlocked(so);
> +
> + if ((error = tcp_sogetpcb(so, &inp, &tp)))
> + return (error);
> +
> +#ifdef INET6
> + if (inp->inp_flags & INP_IPV6)
> + in6_setpeeraddr(inp, nam);
> + else
> +#endif
> + in_setpeeraddr(inp, nam);
> +
> + if (so->so_options & SO_DEBUG)
> + tcp_trace(TA_USER, tp->t_state, tp, tp, NULL,
> + PRU_PEERADDR, 0);
> return (0);
> }
>
> Index: sys/netinet/tcp_var.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_var.h,v
> retrieving revision 1.155
> diff -u -p -r1.155 tcp_var.h
> --- sys/netinet/tcp_var.h 3 Sep 2022 18:48:50 -0000 1.155
> +++ sys/netinet/tcp_var.h 3 Sep 2022 19:50:49 -0000
> @@ -716,8 +716,6 @@ void tcp_trace(short, short, struct tcp
> struct tcpcb *
> tcp_usrclosed(struct tcpcb *);
> int tcp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
> -int tcp_usrreq(struct socket *,
> - int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
> int tcp_attach(struct socket *, int);
> int tcp_detach(struct socket *);
> int tcp_bind(struct socket *, struct mbuf *, struct proc *);
> @@ -731,6 +729,7 @@ int tcp_send(struct socket *, struct mb
> struct mbuf *);
> int tcp_abort(struct socket *);
> int tcp_sockaddr(struct socket *, struct mbuf *);
> +int tcp_peeraddr(struct socket *, struct mbuf *);
> int tcp_sense(struct socket *, struct stat *);
> int tcp_rcvoob(struct socket *, struct mbuf *, int);
> int tcp_sendoob(struct socket *, struct mbuf *, struct mbuf *,
> Index: sys/netinet/udp_usrreq.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v
> retrieving revision 1.300
> diff -u -p -r1.300 udp_usrreq.c
> --- sys/netinet/udp_usrreq.c 3 Sep 2022 18:48:50 -0000 1.300
> +++ sys/netinet/udp_usrreq.c 3 Sep 2022 19:50:49 -0000
> @@ -123,7 +123,6 @@ u_int udp_recvspace = 40 * (1024 + sizeo
> /* 40 1K datagrams */
>
> const struct pr_usrreqs udp_usrreqs = {
> - .pru_usrreq = udp_usrreq,
> .pru_attach = udp_attach,
> .pru_detach = udp_detach,
> .pru_bind = udp_bind,
> @@ -134,11 +133,11 @@ const struct pr_usrreqs udp_usrreqs = {
> .pru_abort = udp_abort,
> .pru_control = in_control,
> .pru_sockaddr = in_sockaddr,
> + .pru_peeraddr = in_peeraddr,
> };
>
> #ifdef INET6
> const struct pr_usrreqs udp6_usrreqs = {
> - .pru_usrreq = udp_usrreq,
> .pru_attach = udp_attach,
> .pru_detach = udp_detach,
> .pru_bind = udp_bind,
> @@ -149,6 +148,7 @@ const struct pr_usrreqs udp6_usrreqs = {
> .pru_abort = udp_abort,
> .pru_control = in6_control,
> .pru_sockaddr = in6_sockaddr,
> + .pru_peeraddr = in6_peeraddr,
> };
> #endif
>
> @@ -1072,55 +1072,6 @@ bail:
> release:
> m_freem(m);
> goto bail;
> -}
> -
> -/*ARGSUSED*/
> -int
> -udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
> - struct mbuf *control, struct proc *p)
> -{
> - struct inpcb *inp;
> - int error = 0;
> -
> - soassertlocked(so);
> -
> - inp = sotoinpcb(so);
> - if (inp == NULL) {
> - error = EINVAL;
> - goto release;
> - }
> -
> - /*
> - * Note: need to block udp_input while changing
> - * the udp pcb queue and/or pcb addresses.
> - */
> - switch (req) {
> -
> - case PRU_PEERADDR:
> -#ifdef INET6
> - if (inp->inp_flags & INP_IPV6)
> - in6_setpeeraddr(inp, addr);
> - else
> -#endif /* INET6 */
> - in_setpeeraddr(inp, addr);
> - break;
> -
> - case PRU_FASTTIMO:
> - case PRU_SLOWTIMO:
> - case PRU_PROTORCV:
> - case PRU_PROTOSEND:
> - error = EOPNOTSUPP;
> - break;
> -
> - default:
> - panic("udp_usrreq");
> - }
> -release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> }
>
> int
> Index: sys/netinet/udp_var.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet/udp_var.h,v
> retrieving revision 1.45
> diff -u -p -r1.45 udp_var.h
> --- sys/netinet/udp_var.h 2 Sep 2022 13:12:32 -0000 1.45
> +++ sys/netinet/udp_var.h 3 Sep 2022 19:50:49 -0000
> @@ -143,8 +143,6 @@ int udp6_output(struct inpcb *, struct
> struct mbuf *);
> #endif /* INET6 */
> int udp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
> -int udp_usrreq(struct socket *,
> - int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
> int udp_attach(struct socket *, int);
> int udp_detach(struct socket *);
> int udp_bind(struct socket *, struct mbuf *, struct proc *);
> Index: sys/netinet6/in6_pcb.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/in6_pcb.c,v
> retrieving revision 1.122
> diff -u -p -r1.122 in6_pcb.c
> --- sys/netinet6/in6_pcb.c 3 Sep 2022 18:48:50 -0000 1.122
> +++ sys/netinet6/in6_pcb.c 3 Sep 2022 19:50:50 -0000
> @@ -376,6 +376,17 @@ in6_sockaddr(struct socket *so, struct m
> return (0);
> }
>
> +int
> +in6_peeraddr(struct socket *so, struct mbuf *nam)
> +{
> + struct inpcb *in6p;
> +
> + in6p = sotoinpcb(so);
> + in6_setpeeraddr(in6p, nam);
> +
> + return (0);
> +}
> +
> /*
> * Pass some notification to all connections of a protocol
> * associated with address dst. The local address and/or port numbers
> Index: sys/netinet6/ip6_divert.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/ip6_divert.c,v
> retrieving revision 1.84
> diff -u -p -r1.84 ip6_divert.c
> --- sys/netinet6/ip6_divert.c 3 Sep 2022 18:48:50 -0000 1.84
> +++ sys/netinet6/ip6_divert.c 3 Sep 2022 19:50:50 -0000
> @@ -64,7 +64,6 @@ const struct sysctl_bounded_args divert6
> };
>
> const struct pr_usrreqs divert6_usrreqs = {
> - .pru_usrreq = divert6_usrreq,
> .pru_attach = divert6_attach,
> .pru_detach = divert6_detach,
> .pru_bind = divert6_bind,
> @@ -73,6 +72,7 @@ const struct pr_usrreqs divert6_usrreqs
> .pru_abort = divert6_abort,
> .pru_control = in6_control,
> .pru_sockaddr = in6_sockaddr,
> + .pru_peeraddr = in6_peeraddr,
> };
>
> int divb6hashsize = DIVERTHASHSIZE;
> @@ -256,45 +256,6 @@ divert6_packet(struct mbuf *m, int dir,
> if (inp != NULL)
> in_pcbunref(inp);
> m_freem(m);
> -}
> -
> -/*ARGSUSED*/
> -int
> -divert6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
> - struct mbuf *control, struct proc *p)
> -{
> - struct inpcb *inp = sotoinpcb(so);
> - int error = 0;
> -
> - soassertlocked(so);
> -
> - if (inp == NULL) {
> - error = EINVAL;
> - goto release;
> - }
> - switch (req) {
> -
> - case PRU_PEERADDR:
> - in6_setpeeraddr(inp, addr);
> - break;
> -
> - case PRU_FASTTIMO:
> - case PRU_SLOWTIMO:
> - case PRU_PROTORCV:
> - case PRU_PROTOSEND:
> - error = EOPNOTSUPP;
> - break;
> -
> - default:
> - panic("%s", __func__);
> - }
> -
> -release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> }
>
> int
> Index: sys/netinet6/ip6_divert.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/ip6_divert.h,v
> retrieving revision 1.18
> diff -u -p -r1.18 ip6_divert.h
> --- sys/netinet6/ip6_divert.h 28 Aug 2022 18:44:17 -0000 1.18
> +++ sys/netinet6/ip6_divert.h 3 Sep 2022 19:50:50 -0000
> @@ -70,8 +70,6 @@ extern const struct pr_usrreqs divert6_u
> void divert6_init(void);
> void divert6_packet(struct mbuf *, int, u_int16_t);
> int divert6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
> -int divert6_usrreq(struct socket *,
> - int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
> int divert6_attach(struct socket *, int);
> int divert6_detach(struct socket *);
> int divert6_bind(struct socket *, struct mbuf *, struct proc *);
> Index: sys/netinet6/ip6_var.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/ip6_var.h,v
> retrieving revision 1.101
> diff -u -p -r1.101 ip6_var.h
> --- sys/netinet6/ip6_var.h 28 Aug 2022 18:44:17 -0000 1.101
> +++ sys/netinet6/ip6_var.h 3 Sep 2022 19:50:50 -0000
> @@ -351,8 +351,6 @@ void rip6_ctlinput(int, struct sockaddr
> int rip6_ctloutput(int, struct socket *, int, int, struct mbuf *);
> int rip6_output(struct mbuf *, struct socket *, struct sockaddr *,
> struct mbuf *);
> -int rip6_usrreq(struct socket *,
> - int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
> int rip6_attach(struct socket *, int);
> int rip6_detach(struct socket *);
> int rip6_bind(struct socket *, struct mbuf *, struct proc *);
> Index: sys/netinet6/raw_ip6.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/raw_ip6.c,v
> retrieving revision 1.167
> diff -u -p -r1.167 raw_ip6.c
> --- sys/netinet6/raw_ip6.c 3 Sep 2022 18:48:50 -0000 1.167
> +++ sys/netinet6/raw_ip6.c 3 Sep 2022 19:50:50 -0000
> @@ -106,7 +106,6 @@ struct inpcbtable rawin6pcbtable;
> struct cpumem *rip6counters;
>
> const struct pr_usrreqs rip6_usrreqs = {
> - .pru_usrreq = rip6_usrreq,
> .pru_attach = rip6_attach,
> .pru_detach = rip6_detach,
> .pru_bind = rip6_bind,
> @@ -117,6 +116,7 @@ const struct pr_usrreqs rip6_usrreqs = {
> .pru_abort = rip6_abort,
> .pru_control = in6_control,
> .pru_sockaddr = in6_sockaddr,
> + .pru_peeraddr = in6_peeraddr,
> };
>
> /*
> @@ -574,37 +574,6 @@ rip6_ctloutput(int op, struct socket *so
>
> extern u_long rip6_sendspace;
> extern u_long rip6_recvspace;
> -
> -int
> -rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
> - struct mbuf *control, struct proc *p)
> -{
> - struct inpcb *in6p;
> - int error = 0;
> -
> - soassertlocked(so);
> -
> - in6p = sotoinpcb(so);
> - if (in6p == NULL) {
> - error = EINVAL;
> - goto release;
> - }
> -
> - switch (req) {
> - case PRU_PEERADDR:
> - in6_setpeeraddr(in6p, nam);
> - break;
> -
> - default:
> - panic("%s", __func__);
> - }
> -release:
> - if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> - m_freem(control);
> - m_freem(m);
> - }
> - return (error);
> -}
>
> int
> rip6_attach(struct socket *so, int proto)
> Index: sys/sys/protosw.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/protosw.h,v
> retrieving revision 1.53
> diff -u -p -r1.53 protosw.h
> --- sys/sys/protosw.h 3 Sep 2022 18:48:50 -0000 1.53
> +++ sys/sys/protosw.h 3 Sep 2022 19:50:50 -0000
> @@ -62,10 +62,6 @@ struct stat;
> struct ifnet;
>
> struct pr_usrreqs {
> - /* user request: see list below */
> - int (*pru_usrreq)(struct socket *, int, struct mbuf *,
> - struct mbuf *, struct mbuf *, struct proc *);
> -
> int (*pru_attach)(struct socket *, int);
> int (*pru_detach)(struct socket *);
> int (*pru_bind)(struct socket *, struct mbuf *, struct proc *);
> @@ -84,8 +80,9 @@ struct pr_usrreqs {
> int (*pru_rcvoob)(struct socket *, struct mbuf *, int);
> int (*pru_sendoob)(struct socket *, struct mbuf *, struct mbuf *,
> struct mbuf *);
> - int (*pru_connect2)(struct socket *, struct socket *);
> int (*pru_sockaddr)(struct socket *, struct mbuf *);
> + int (*pru_peeraddr)(struct socket *, struct mbuf *);
> + int (*pru_connect2)(struct socket *, struct socket *);
> };
>
> struct protosw {
> @@ -392,8 +389,7 @@ pru_sockaddr(struct socket *so, struct m
> static inline int
> pru_peeraddr(struct socket *so, struct mbuf *addr)
> {
> - return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
> - PRU_PEERADDR, NULL, addr, NULL, curproc);
> + return (*so->so_proto->pr_usrreqs->pru_peeraddr)(so, addr);
> }
>
> static inline int
> Index: sys/sys/unpcb.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/unpcb.h,v
> retrieving revision 1.39
> diff -u -p -r1.39 unpcb.h
> --- sys/sys/unpcb.h 3 Sep 2022 18:48:50 -0000 1.39
> +++ sys/sys/unpcb.h 3 Sep 2022 19:50:50 -0000
> @@ -112,8 +112,6 @@ struct fdpass {
>
> extern const struct pr_usrreqs uipc_usrreqs;
>
> -int uipc_usrreq(struct socket *, int , struct mbuf *,
> - struct mbuf *, struct mbuf *, struct proc *);
> int uipc_attach(struct socket *, int);
> int uipc_detach(struct socket *);
> int uipc_bind(struct socket *, struct mbuf *, struct proc *);
> @@ -128,6 +126,7 @@ int uipc_send(struct socket *, struct mb
> int uipc_abort(struct socket *);
> int uipc_sense(struct socket *, struct stat *);
> int uipc_sockaddr(struct socket *, struct mbuf *);
> +int uipc_peeraddr(struct socket *, struct mbuf *);
> int uipc_connect2(struct socket *, struct socket *);
>
> void unp_init(void);