On Wed, Dec 06, 2023 at 12:57:57AM +0100, Alexander Bluhm wrote: > On Wed, Dec 06, 2023 at 01:39:40AM +0300, Vitaliy Makkoveev wrote: > > > Diff makes sense in any case. > > > > > > > Just checked, socket6_send() is identical to socket_send() and needs > > to be reworked in the same way. > > New diff for v4 and v6. The other callers seem to be correct. I > will run this through regress and commit regardless whether it fixes > the reported bug. The current code is wrong anyway. > > ok? AFAIK there is no ip_mroute.c regress coverage. Diff is OK claudio@
> > Index: netinet/ip_mroute.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_mroute.c,v > diff -u -p -r1.139 ip_mroute.c > --- netinet/ip_mroute.c 14 Jun 2023 14:30:08 -0000 1.139 > +++ netinet/ip_mroute.c 5 Dec 2023 19:24:11 -0000 > @@ -1048,11 +1048,18 @@ del_mfc(struct socket *so, struct mbuf * > } > > int > -socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in *src) > +socket_send(struct socket *so, struct mbuf *mm, struct sockaddr_in *src) > { > - if (s != NULL) { > - if (sbappendaddr(s, &s->so_rcv, sintosa(src), mm, NULL) != 0) { > - sorwakeup(s); > + if (so != NULL) { > + struct inpcb *inp = sotoinpcb(so); > + int ret; > + > + mtx_enter(&inp->inp_mtx); > + ret = sbappendaddr(so, &so->so_rcv, sintosa(src), mm, NULL); > + mtx_leave(&inp->inp_mtx); > + > + if (ret != 0) { > + sorwakeup(so); > return (0); > } > } > Index: netinet6/ip6_mroute.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_mroute.c,v > diff -u -p -r1.137 ip6_mroute.c > --- netinet6/ip6_mroute.c 14 Jun 2023 14:30:08 -0000 1.137 > +++ netinet6/ip6_mroute.c 5 Dec 2023 23:55:54 -0000 > @@ -853,11 +853,18 @@ del_m6fc(struct socket *so, struct mf6cc > } > > int > -socket6_send(struct socket *s, struct mbuf *mm, struct sockaddr_in6 *src) > +socket6_send(struct socket *so, struct mbuf *mm, struct sockaddr_in6 *src) > { > - if (s) { > - if (sbappendaddr(s, &s->so_rcv, sin6tosa(src), mm, NULL) != 0) { > - sorwakeup(s); > + if (so != NULL) { > + struct inpcb *inp = sotoinpcb(so); > + int ret; > + > + mtx_enter(&inp->inp_mtx); > + ret = sbappendaddr(so, &so->so_rcv, sin6tosa(src), mm, NULL); > + mtx_leave(&inp->inp_mtx); > + > + if (ret != 0) { > + sorwakeup(so); > return 0; > } > } > -- :wq Claudio