All incpb locking has been converted to socket receive buffer mutex.
Per PCB mutex inp_mtx is not needed anymore. Also delete PRU related
locking functions. A flag PR_MPSOCKET indicates whether protocol
functions support parallel access with per socket rw-lock.
TCP is the only protocol that is not MP capable from the socket
layer and needs exclusive netlock.
OK mvs@
-/* $OpenBSD: uipc_socket2.c,v 1.157 2024/07/12 17:20:18 mvs Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.158 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
switch (so->so_proto->pr_domain->dom_family) {
case PF_INET:
case PF_INET6:
- if (so->so_proto->pr_usrreqs->pru_lock != NULL) {
+ if (ISSET(so->so_proto->pr_flags, PR_MPSOCKET)) {
NET_LOCK_SHARED();
rw_enter_write(&so->so_lock);
} else
switch (so->so_proto->pr_domain->dom_family) {
case PF_INET:
case PF_INET6:
- if (so->so_proto->pr_usrreqs->pru_unlock != NULL) {
+ if (ISSET(so->so_proto->pr_flags, PR_MPSOCKET)) {
rw_exit_write(&so->so_lock);
NET_UNLOCK_SHARED();
} else
if (rw_status(&netlock) == RW_READ) {
NET_ASSERT_LOCKED();
- if (splassert_ctl > 0 && pru_locked(so) == 0 &&
+ if (splassert_ctl > 0 &&
rw_status(&so->so_lock) != RW_WRITE)
splassert_fail(0, RW_WRITE, __func__);
} else
switch (so->so_proto->pr_domain->dom_family) {
case PF_INET:
case PF_INET6:
- if (so->so_proto->pr_usrreqs->pru_unlock != NULL &&
+ if (ISSET(so->so_proto->pr_flags, PR_MPSOCKET) &&
rw_status(&netlock) == RW_READ) {
rw_exit_write(&so->so_lock);
}
ret = rwsleep_nsec(ident, &netlock, prio, wmesg, nsecs);
- if (so->so_proto->pr_usrreqs->pru_lock != NULL &&
+ if (ISSET(so->so_proto->pr_flags, PR_MPSOCKET) &&
rw_status(&netlock) == RW_READ) {
rw_enter_write(&so->so_lock);
}
-/* $OpenBSD: in_pcb.c,v 1.302 2024/04/19 10:13:58 bluhm Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.303 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
inp->inp_table = table;
inp->inp_socket = so;
refcnt_init_trace(&inp->inp_refcnt, DT_REFCNT_IDX_INPCB);
- mtx_init(&inp->inp_mtx, IPL_SOFTNET);
inp->inp_seclevel.sl_auth = IPSEC_AUTH_LEVEL_DEFAULT;
inp->inp_seclevel.sl_esp_trans = IPSEC_ESP_TRANS_LEVEL_DEFAULT;
inp->inp_seclevel.sl_esp_network = IPSEC_ESP_NETWORK_LEVEL_DEFAULT;
-/* $OpenBSD: in_pcb.h,v 1.157 2024/04/19 10:13:58 bluhm Exp $ */
+/* $OpenBSD: in_pcb.h,v 1.158 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
* N net lock
* t inpt_mtx pcb table mutex
* y inpt_notify pcb table rwlock for notify
- * p inpcb_mtx pcb mutex
* L pf_inp_mtx link pf to inp mutex
* s so_lock socket rwlock
*/
* needed, so that socket layer input have a consistent view at these
* values.
*
- * In soconnect() and sosend() pcb mutex cannot be used. They eventually
- * can call IP output which takes pf lock which is a sleeping lock.
+ * In soconnect() and sosend() a per pcb mutex cannot be used. They
+ * eventually call IP output which takes pf lock which is a sleeping lock.
* Also connect(2) does a route lookup for source selection. There
* route resolve happens, which creates a route, which sends a route
* message, which needs route lock, which is a rw-lock.
*
* So there are three locks. Table mutex is for writing inp_[lf]addr/port
* and lookup, socket rw-lock to separate sockets in system calls, and
- * pcb mutex to protect socket receive buffer. Changing inp_[lf]addr/port
- * takes both per socket rw-lock and global table mutex. Protocol
- * input only reads inp_[lf]addr/port during lookup and is safe. System
- * call only reads when holding socket rw-lock and is safe. The socket
- * layer needs pcb mutex only in soreceive().
- *
- * Function pru_lock() grabs the pcb mutex and its existence indicates
- * that a protocol is MP safe. Otherwise the exclusive net lock is
- * used.
+ * socket buffer mutex to protect socket receive buffer. Changing
+ * inp_[lf]addr/port takes both per socket rw-lock and global table mutex.
+ * Protocol input only reads inp_[lf]addr/port during lookup and is safe.
*/
struct pf_state_key;
caddr_t inp_ppcb; /* pointer to per-protocol pcb */
struct route inp_route; /* cached route */
struct refcnt inp_refcnt; /* refcount PCB, delay memory free */
- struct mutex inp_mtx; /* protect PCB and socket members */
int inp_flags; /* generic IP/datagram flags */
union { /* Header prototype. */
struct ip hu_ip;
-/* $OpenBSD: in_proto.c,v 1.104 2024/04/14 20:46:27 bluhm Exp $ */
+/* $OpenBSD: in_proto.c,v 1.105 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/*
.pr_type = SOCK_DGRAM,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_UDP,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE|PR_MPSOCKET,
.pr_input = udp_input,
.pr_ctlinput = udp_ctlinput,
.pr_ctloutput = ip_ctloutput,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_RAW,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPINPUT,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPINPUT|PR_MPSOCKET,
.pr_input = rip_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_ICMP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = icmp_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_IPV4,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
#if NGIF > 0
.pr_input = in_gif_input,
#else
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_IPV6,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
#if NGIF > 0
.pr_input = in_gif_input,
#else
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_MPLS,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = in_gif_input,
.pr_usrreqs = &rip_usrreqs,
},
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_IGMP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = igmp_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_AH,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = ah46_input,
.pr_ctlinput = ah4_ctlinput,
.pr_ctloutput = rip_ctloutput,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_ESP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = esp46_input,
.pr_ctlinput = esp4_ctlinput,
.pr_ctloutput = rip_ctloutput,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_IPCOMP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = ipcomp46_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_CARP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = carp_proto_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_PFSYNC,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = pfsync_input4,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_DIVERT,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &divert_usrreqs,
.pr_init = divert_init,
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_ETHERIP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = ip_etherip_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,
/* raw wildcard */
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPINPUT,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPINPUT|PR_MPSOCKET,
.pr_input = rip_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,
-/* $OpenBSD: ip_divert.c,v 1.95 2024/03/05 09:45:13 bluhm Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
const struct pr_usrreqs divert_usrreqs = {
.pru_attach = divert_attach,
.pru_detach = divert_detach,
- .pru_lock = divert_lock,
- .pru_unlock = divert_unlock,
- .pru_locked = divert_locked,
.pru_bind = divert_bind,
.pru_shutdown = divert_shutdown,
.pru_send = divert_send,
return (0);
}
-void
-divert_lock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_enter(&inp->inp_mtx);
-}
-
-void
-divert_unlock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_leave(&inp->inp_mtx);
-}
-
-int
-divert_locked(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- return mtx_owned(&inp->inp_mtx);
-}
-
int
divert_bind(struct socket *so, struct mbuf *addr, struct proc *p)
{
-/* $OpenBSD: ip_divert.h,v 1.25 2024/02/03 22:50:09 mvs Exp $ */
+/* $OpenBSD: ip_divert.h,v 1.26 2024/07/12 19:50:35 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
int divert_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int divert_attach(struct socket *, int, int);
int divert_detach(struct socket *);
-void divert_lock(struct socket *);
-void divert_unlock(struct socket *);
-int divert_locked(struct socket *);
int divert_bind(struct socket *, struct mbuf *, struct proc *);
int divert_shutdown(struct socket *);
int divert_send(struct socket *, struct mbuf *, struct mbuf *,
-/* $OpenBSD: ip_var.h,v 1.119 2024/07/02 18:33:47 bluhm Exp $ */
+/* $OpenBSD: ip_var.h,v 1.120 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
rip_chkhdr(struct mbuf *, struct mbuf *);
int rip_attach(struct socket *, int, int);
int rip_detach(struct socket *);
-void rip_lock(struct socket *);
-void rip_unlock(struct socket *);
-int rip_locked(struct socket *);
int rip_bind(struct socket *, struct mbuf *, struct proc *);
int rip_connect(struct socket *, struct mbuf *);
int rip_disconnect(struct socket *);
-/* $OpenBSD: raw_ip.c,v 1.159 2024/04/17 20:48:51 bluhm Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.160 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
const struct pr_usrreqs rip_usrreqs = {
.pru_attach = rip_attach,
.pru_detach = rip_detach,
- .pru_lock = rip_lock,
- .pru_unlock = rip_unlock,
- .pru_locked = rip_locked,
.pru_bind = rip_bind,
.pru_connect = rip_connect,
.pru_disconnect = rip_disconnect,
return (0);
}
-void
-rip_lock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_enter(&inp->inp_mtx);
-}
-
-void
-rip_unlock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_leave(&inp->inp_mtx);
-}
-
-int
-rip_locked(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- return mtx_owned(&inp->inp_mtx);
-}
-
int
rip_bind(struct socket *so, struct mbuf *nam, struct proc *p)
{
-/* $OpenBSD: udp_usrreq.c,v 1.320 2024/04/17 20:48:51 bluhm Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.321 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
const struct pr_usrreqs udp_usrreqs = {
.pru_attach = udp_attach,
.pru_detach = udp_detach,
- .pru_lock = udp_lock,
- .pru_unlock = udp_unlock,
- .pru_locked = udp_locked,
.pru_bind = udp_bind,
.pru_connect = udp_connect,
.pru_disconnect = udp_disconnect,
const struct pr_usrreqs udp6_usrreqs = {
.pru_attach = udp_attach,
.pru_detach = udp_detach,
- .pru_lock = udp_lock,
- .pru_unlock = udp_unlock,
- .pru_locked = udp_locked,
.pru_bind = udp_bind,
.pru_connect = udp_connect,
.pru_disconnect = udp_disconnect,
return (0);
}
-void
-udp_lock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_enter(&inp->inp_mtx);
-}
-
-void
-udp_unlock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_leave(&inp->inp_mtx);
-}
-
-int
-udp_locked(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- return mtx_owned(&inp->inp_mtx);
-}
-
int
udp_bind(struct socket *so, struct mbuf *addr, struct proc *p)
{
-/* $OpenBSD: udp_var.h,v 1.51 2024/02/03 22:50:09 mvs Exp $ */
+/* $OpenBSD: udp_var.h,v 1.52 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
int udp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int udp_attach(struct socket *, int, int);
int udp_detach(struct socket *);
-void udp_lock(struct socket *);
-void udp_unlock(struct socket *);
-int udp_locked(struct socket *);
int udp_bind(struct socket *, struct mbuf *, struct proc *);
int udp_connect(struct socket *, struct mbuf *);
int udp_disconnect(struct socket *);
-/* $OpenBSD: in6_proto.c,v 1.114 2024/04/16 12:40:40 bluhm Exp $ */
+/* $OpenBSD: in6_proto.c,v 1.115 2024/07/12 19:50:35 bluhm Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
.pr_type = SOCK_DGRAM,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_UDP,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE|PR_MPSOCKET,
.pr_input = udp_input,
.pr_ctlinput = udp6_ctlinput,
.pr_ctloutput = ip6_ctloutput,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_RAW,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPINPUT,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPINPUT|PR_MPSOCKET,
.pr_input = rip6_input,
.pr_ctlinput = rip6_ctlinput,
.pr_ctloutput = rip6_ctloutput,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_ICMPV6,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = icmp6_input,
.pr_ctlinput = rip6_ctlinput,
.pr_ctloutput = rip6_ctloutput,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_AH,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = ah46_input,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &rip6_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_ESP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = esp46_input,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &rip6_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_IPCOMP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = ipcomp46_input,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &rip6_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_IPV4,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
#if NGIF > 0
.pr_input = in6_gif_input,
#else
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_IPV6,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
#if NGIF > 0
.pr_input = in6_gif_input,
#else
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_MPLS,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
#if NGIF > 0
.pr_input = in6_gif_input,
#else
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_CARP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = carp6_proto_input,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &rip6_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_DIVERT,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &divert6_usrreqs,
.pr_init = divert6_init,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_ETHERIP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = ip6_etherip_input,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &rip6_usrreqs,
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_GRE,
- .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_input = gre_input6,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &rip6_usrreqs,
/* raw wildcard */
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPINPUT,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPINPUT|PR_MPSOCKET,
.pr_input = rip6_input,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &rip6_usrreqs,
-/* $OpenBSD: ip6_divert.c,v 1.95 2024/02/13 12:22:09 bluhm Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
const struct pr_usrreqs divert6_usrreqs = {
.pru_attach = divert6_attach,
.pru_detach = divert_detach,
- .pru_lock = divert_lock,
- .pru_unlock = divert_unlock,
- .pru_locked = divert_locked,
.pru_bind = divert_bind,
.pru_shutdown = divert_shutdown,
.pru_send = divert6_send,
-/* $OpenBSD: ip6_var.h,v 1.119 2024/07/04 12:50:08 bluhm Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.120 2024/07/12 19:50:35 bluhm Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
struct mbuf *);
int rip6_attach(struct socket *, int, int);
int rip6_detach(struct socket *);
-void rip6_lock(struct socket *);
-void rip6_unlock(struct socket *);
-int rip6_locked(struct socket *);
int rip6_bind(struct socket *, struct mbuf *, struct proc *);
int rip6_connect(struct socket *, struct mbuf *);
int rip6_disconnect(struct socket *);
-/* $OpenBSD: raw_ip6.c,v 1.184 2024/04/17 20:48:51 bluhm Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.185 2024/07/12 19:50:35 bluhm Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
const struct pr_usrreqs rip6_usrreqs = {
.pru_attach = rip6_attach,
.pru_detach = rip6_detach,
- .pru_lock = rip6_lock,
- .pru_unlock = rip6_unlock,
- .pru_locked = rip6_locked,
.pru_bind = rip6_bind,
.pru_connect = rip6_connect,
.pru_disconnect = rip6_disconnect,
return (0);
}
-void
-rip6_lock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_enter(&inp->inp_mtx);
-}
-
-void
-rip6_unlock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_leave(&inp->inp_mtx);
-}
-
-int
-rip6_locked(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- return mtx_owned(&inp->inp_mtx);
-}
-
int
rip6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
{
-/* $OpenBSD: protosw.h,v 1.66 2024/04/14 20:46:27 bluhm Exp $ */
+/* $OpenBSD: protosw.h,v 1.67 2024/07/12 19:50:35 bluhm Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
struct pr_usrreqs {
int (*pru_attach)(struct socket *, int, int);
int (*pru_detach)(struct socket *);
- void (*pru_lock)(struct socket *);
- void (*pru_unlock)(struct socket *);
- int (*pru_locked)(struct socket *so);
int (*pru_bind)(struct socket *, struct mbuf *, struct proc *);
int (*pru_listen)(struct socket *);
int (*pru_connect)(struct socket *, struct mbuf *);
socket */
#define PR_SPLICE 0x0040 /* socket splicing is possible */
#define PR_MPINPUT 0x0080 /* input runs with shared netlock */
+#define PR_MPSOCKET 0x0100 /* socket uses shared netlock */
/*
* The arguments to usrreq are:
return (*so->so_proto->pr_usrreqs->pru_detach)(so);
}
-static inline void
-pru_lock(struct socket *so)
-{
- if (so->so_proto->pr_usrreqs->pru_lock)
- (*so->so_proto->pr_usrreqs->pru_lock)(so);
-}
-
-static inline void
-pru_unlock(struct socket *so)
-{
- if (so->so_proto->pr_usrreqs->pru_unlock)
- (*so->so_proto->pr_usrreqs->pru_unlock)(so);
-}
-
-static inline int
-pru_locked(struct socket *so)
-{
- if (so->so_proto->pr_usrreqs->pru_locked)
- return (*so->so_proto->pr_usrreqs->pru_locked)(so);
- return (0);
-}
-
static inline int
pru_bind(struct socket *so, struct mbuf *nam, struct proc *p)
{