diff options
-rw-r--r-- | sys/kern/uipc_socket2.c | 12 | ||||
-rw-r--r-- | sys/netinet/in_pcb.c | 3 | ||||
-rw-r--r-- | sys/netinet/in_pcb.h | 20 | ||||
-rw-r--r-- | sys/netinet/in_proto.c | 32 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 31 | ||||
-rw-r--r-- | sys/netinet/ip_divert.h | 5 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 5 | ||||
-rw-r--r-- | sys/netinet/raw_ip.c | 31 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 34 | ||||
-rw-r--r-- | sys/netinet/udp_var.h | 5 | ||||
-rw-r--r-- | sys/netinet6/in6_proto.c | 30 | ||||
-rw-r--r-- | sys/netinet6/ip6_divert.c | 5 | ||||
-rw-r--r-- | sys/netinet6/ip6_var.h | 5 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 31 | ||||
-rw-r--r-- | sys/sys/protosw.h | 28 |
15 files changed, 55 insertions, 222 deletions
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 6f50f5283a7..2855feb61c7 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -365,7 +365,7 @@ solock_shared(struct socket *so) 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 @@ -425,7 +425,7 @@ sounlock_shared(struct socket *so) 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 @@ -460,7 +460,7 @@ soassertlocked(struct socket *so) 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 @@ -481,12 +481,12 @@ sosleep_nsec(struct socket *so, void *ident, int prio, const char *wmesg, 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); } diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 1a6bc7166ec..0df7be79739 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -239,7 +239,6 @@ in_pcballoc(struct socket *so, struct inpcbtable *table, int wait) 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; diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 6e0b656b19f..91a78e10693 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -80,7 +80,6 @@ * 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 */ @@ -94,8 +93,8 @@ * 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. @@ -106,15 +105,9 @@ * * 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; @@ -149,7 +142,6 @@ struct inpcb { 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; diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index a7ba54e52cf..e38cd80f5ac 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -185,7 +185,7 @@ const struct protosw inetsw[] = { .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, @@ -210,7 +210,7 @@ const struct protosw inetsw[] = { .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, @@ -219,7 +219,7 @@ const struct protosw inetsw[] = { .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, @@ -230,7 +230,7 @@ const struct protosw inetsw[] = { .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 @@ -246,7 +246,7 @@ const struct protosw inetsw[] = { .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 @@ -261,7 +261,7 @@ const struct protosw inetsw[] = { .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, }, @@ -270,7 +270,7 @@ const struct protosw inetsw[] = { .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, @@ -284,7 +284,7 @@ const struct protosw inetsw[] = { .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, @@ -295,7 +295,7 @@ const struct protosw inetsw[] = { .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, @@ -306,7 +306,7 @@ const struct protosw inetsw[] = { .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, @@ -330,7 +330,7 @@ const struct protosw inetsw[] = { .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, @@ -342,7 +342,7 @@ const struct protosw inetsw[] = { .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, @@ -354,7 +354,7 @@ const struct protosw inetsw[] = { .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, @@ -366,7 +366,7 @@ const struct protosw inetsw[] = { .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, @@ -377,7 +377,7 @@ const struct protosw inetsw[] = { /* 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, diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 9c050bb12cc..260d23c8f9f 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $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> @@ -65,9 +65,6 @@ const struct sysctl_bounded_args divertctl_vars[] = { 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, @@ -296,32 +293,6 @@ divert_detach(struct socket *so) 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) { diff --git a/sys/netinet/ip_divert.h b/sys/netinet/ip_divert.h index 2c09d517559..2a97639b18d 100644 --- a/sys/netinet/ip_divert.h +++ b/sys/netinet/ip_divert.h @@ -1,4 +1,4 @@ -/* $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> @@ -72,9 +72,6 @@ void divert_packet(struct mbuf *, int, u_int16_t); 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 *, diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index df6f003d8b6..78a8ca4f46c 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -274,9 +274,6 @@ struct mbuf * 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 *); diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 73fd2fd7dd7..4358462db21 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -106,9 +106,6 @@ struct inpcbtable rawcbtable; 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, @@ -514,32 +511,6 @@ rip_detach(struct socket *so) 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) { diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index ecf2a90818f..bb85eb6d2f8 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -125,9 +125,6 @@ u_int udp_recvspace = 40 * (1024 + sizeof(struct sockaddr_in)); 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, @@ -142,9 +139,6 @@ const struct pr_usrreqs udp_usrreqs = { 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, @@ -1140,32 +1134,6 @@ udp_detach(struct socket *so) 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) { diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h index 5731cf4ef1a..ac506c66c94 100644 --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -145,9 +145,6 @@ int udp6_output(struct inpcb *, struct mbuf *, struct mbuf *, 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 *); diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index f73e00b4d2c..a737e995c84 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -136,7 +136,7 @@ const struct protosw inet6sw[] = { .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, @@ -158,7 +158,7 @@ const struct protosw inet6sw[] = { .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, @@ -169,7 +169,7 @@ const struct protosw inet6sw[] = { .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, @@ -204,7 +204,7 @@ const struct protosw inet6sw[] = { .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, @@ -214,7 +214,7 @@ const struct protosw inet6sw[] = { .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, @@ -224,7 +224,7 @@ const struct protosw inet6sw[] = { .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, @@ -235,7 +235,7 @@ const struct protosw inet6sw[] = { .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 @@ -248,7 +248,7 @@ const struct protosw inet6sw[] = { .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 @@ -262,7 +262,7 @@ const struct protosw inet6sw[] = { .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 @@ -277,7 +277,7 @@ const struct protosw inet6sw[] = { .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, @@ -289,7 +289,7 @@ const struct protosw inet6sw[] = { .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, @@ -301,7 +301,7 @@ const struct protosw inet6sw[] = { .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, @@ -312,7 +312,7 @@ const struct protosw inet6sw[] = { .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, @@ -322,7 +322,7 @@ const struct protosw inet6sw[] = { /* 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, diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 0bd114ba390..06111f6d3c8 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $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> @@ -68,9 +68,6 @@ const struct sysctl_bounded_args divert6ctl_vars[] = { 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, diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index bbe59c744ac..1ddbb4b1c0c 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -354,9 +354,6 @@ int rip6_output(struct mbuf *, struct socket *, struct sockaddr *, 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 *); diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index c16c69d53b5..7efbddfdd92 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -108,9 +108,6 @@ struct cpumem *rip6counters; 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, @@ -644,32 +641,6 @@ rip6_detach(struct socket *so) 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) { diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 319cc5c0909..575fdbd9c73 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -67,9 +67,6 @@ struct ifnet; 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 *); @@ -133,6 +130,7 @@ struct protosw { 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: @@ -284,28 +282,6 @@ pru_detach(struct socket *so) 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) { |