From: bluhm Date: Fri, 12 Jan 2024 10:48:03 +0000 (+0000) Subject: Send UDP packets in parallel. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2d01bf8aac77d5cf0cb543a31d30e91deac73aba;p=openbsd Send UDP packets in parallel. Sending UDP packets via datagram socket is MP safe now. Same applies to raw IPv4 and IPv6, and divert sockets. Switch sosend() from exclusive net lock to shared net lock in combination with per socket lock. TCP and GRE still use exclusive net lock. tested by otto@ and florian@ OK mvs@ --- diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 913649f1f81..9da3bdd2040 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.313 2024/01/11 14:15:11 bluhm Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.314 2024/01/12 10:48:03 bluhm Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -582,7 +582,7 @@ sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top, #define snderr(errno) { error = errno; goto release; } - solock(so); + solock_shared(so); restart: if ((error = sblock(so, &so->so_snd, SBLOCKWAIT(flags))) != 0) goto out; @@ -635,9 +635,9 @@ restart: if (flags & MSG_EOR) top->m_flags |= M_EOR; } else { - sounlock(so); + sounlock_shared(so); error = m_getuio(&top, atomic, space, uio); - solock(so); + solock_shared(so); if (error) goto release; space -= top->m_pkthdr.len; @@ -665,7 +665,7 @@ release: so->so_snd.sb_state &= ~SS_ISSENDING; sbunlock(so, &so->so_snd); out: - sounlock(so); + sounlock_shared(so); m_freem(top); m_freem(control); return (error);