On Sat, Sep 03, 2022 at 02:44:56AM +0200, Alexander Bluhm wrote:
> On Sat, Sep 03, 2022 at 02:10:59AM +0300, Vitaliy Makkoveev wrote:
> > On Sat, Sep 03, 2022 at 12:35:41AM +0200, Alexander Bluhm wrote:
> > > This broke socket splicing between inet and inet6 sockets.
> > > sosplice() has this check:
> > > 
> > >         if (sosp->so_proto->pr_usrreqs != so->so_proto->pr_usrreqs) {
> > >                 error = EPROTONOSUPPORT;
> > >                 goto frele;
> > >         }
> > > 
> > > That does not work anymore after splitting {tcp,udp}6_usrreqs.
> > > 
> > > bluhm
> > > 
> > > On Fri, Sep 02, 2022 at 07:12:32AM -0600, Vitaliy Makkoveev wrote:
> > > > CVSROOT:        /cvs
> > > > Module name:    src
> > > > Changes by:     m...@cvs.openbsd.org    2022/09/02 07:12:32
> > > >
> > > > Modified files:
> > > >         sys/kern       : sys_socket.c uipc_usrreq.c
> > > >         sys/net        : if.c pfkeyv2.c rtsock.c
> > > >         sys/netinet    : ip_divert.c ip_gre.c raw_ip.c tcp_usrreq.c
> > > >                          tcp_var.h udp_usrreq.c udp_var.h
> > > >         sys/netinet6   : in6_proto.c ip6_divert.c raw_ip6.c
> > > >         sys/sys        : protosw.h
> > > >
> > > > Log message:
> > > > Move PRU_CONTROL request to (*pru_control)().
> > > >
> > > > The 'proc *' arg is not used for PRU_CONTROL request, so remove it from
> > > > pru_control() wrapper.
> > > >
> > > > Split out {tcp,udp}6_usrreqs from {tcp,udp}_usrreqs and use them for
> > > > inet6 case.
> > > >
> > > > ok guenther@ bluhm@
> > 
> > IIRC it's assumed that inet tcp/udp socket on port N and inet6 tcp/udp
> > socket on the same port N are different sockets, because the protocols
> > are different.
> 
> The sockets you splice togeher can have totally different addresses
> and ports.  They need nothing in common, just put mbufs from one
> into the other.
> 
> So the ability of splicing inet and inet6 sockets looks
> > strange for me. Also I wonder, is this really used?
> 
> Yes.
> 
> > This diff should restore existing behaviour. The `pru_attach' handler is
> > the same for inet and inet6 cases.
> 
> gre also uses rip_attach.  Better use the pru_send, they are unique.
> 

Or may be better to check `pr_type' with the ability of splicing? 

Index: sys/kern/uipc_socket.c
===================================================================
RCS file: /cvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.286
diff -u -p -r1.286 uipc_socket.c
--- sys/kern/uipc_socket.c      28 Aug 2022 18:43:12 -0000      1.286
+++ sys/kern/uipc_socket.c      3 Sep 2022 00:53:39 -0000
@@ -1293,7 +1293,8 @@ sosplice(struct socket *so, int fd, off_
        if ((error = getsock(curproc, fd, &fp)) != 0)
                return (error);
        sosp = fp->f_data;
-       if (sosp->so_proto->pr_usrreqs != so->so_proto->pr_usrreqs) {
+       if ((sosp->so_proto->pr_flags & PR_SPLICE) == 0 ||
+           (sosp->so_proto->pr_type != so->so_proto->pr_type)) {
                error = EPROTONOSUPPORT;
                goto frele;
        }

Reply via email to