-/* $OpenBSD: uipc_domain.c,v 1.67 2024/08/14 17:52:47 mvs Exp $ */
+/* $OpenBSD: uipc_domain.c,v 1.68 2024/08/16 09:20:34 mvs Exp $ */
/* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */
/*
protocol = name[1];
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
if (pr->pr_protocol == protocol && pr->pr_sysctl) {
- size_t savelen = *oldlenp;
+ size_t savelen;
int error;
- if ((error = sysctl_vslock(oldp, savelen)))
- return (error);
+ if ((pr->pr_flags & PR_MPSYSCTL) == 0) {
+ savelen = *oldlenp;
+ if ((error = sysctl_vslock(oldp, savelen)))
+ return (error);
+ }
error = (*pr->pr_sysctl)(name + 2, namelen - 2,
oldp, oldlenp, newp, newlen);
- sysctl_vsunlock(oldp, savelen);
+ if ((pr->pr_flags & PR_MPSYSCTL) == 0)
+ sysctl_vsunlock(oldp, savelen);
return (error);
}
-/* $OpenBSD: in_proto.c,v 1.107 2024/07/26 14:38:20 bluhm Exp $ */
+/* $OpenBSD: in_proto.c,v 1.108 2024/08/16 09:20:35 mvs Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/*
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_DIVERT,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &divert_usrreqs,
.pr_init = divert_init,
-/* $OpenBSD: ip_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
#include <net/pfvar.h>
+/*
+ * Locks used to protect data:
+ * a atomic
+ */
+
struct inpcbtable divbtable;
struct cpumem *divcounters;
#ifndef DIVERT_SENDSPACE
#define DIVERT_SENDSPACE (65536 + 100)
#endif
-u_int divert_sendspace = DIVERT_SENDSPACE;
+u_int divert_sendspace = DIVERT_SENDSPACE; /* [a] */
#ifndef DIVERT_RECVSPACE
#define DIVERT_RECVSPACE (65536 + 100)
#endif
-u_int divert_recvspace = DIVERT_RECVSPACE;
+u_int divert_recvspace = DIVERT_RECVSPACE; /* [a] */
#ifndef DIVERTHASHSIZE
#define DIVERTHASHSIZE 128
if (error)
return error;
- error = soreserve(so, divert_sendspace, divert_recvspace);
+ error = soreserve(so, atomic_load_int(&divert_sendspace),
+ atomic_load_int(&divert_recvspace));
if (error)
return error;
divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
{
- int error;
-
/* All sysctl names at this level are terminal. */
if (namelen != 1)
return (ENOTDIR);
case DIVERTCTL_STATS:
return (divert_sysctl_divstat(oldp, oldlenp, newp));
default:
- NET_LOCK();
- error = sysctl_bounded_arr(divertctl_vars,
- nitems(divertctl_vars), name, namelen, oldp, oldlenp, newp,
- newlen);
- NET_UNLOCK();
- return (error);
+ return (sysctl_bounded_arr(divertctl_vars,
+ nitems(divertctl_vars), name, namelen, oldp, oldlenp,
+ newp, newlen));
}
/* NOTREACHED */
}
-/* $OpenBSD: in6_proto.c,v 1.117 2024/07/26 14:38:20 bluhm Exp $ */
+/* $OpenBSD: in6_proto.c,v 1.118 2024/08/16 09:20:35 mvs Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_DIVERT,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &divert6_usrreqs,
.pr_init = divert6_init,
-/* $OpenBSD: ip6_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
#include <net/pfvar.h>
+/*
+ * Locks used to protect data:
+ * a atomic
+ */
+
struct inpcbtable divb6table;
struct cpumem *div6counters;
#ifndef DIVERT_SENDSPACE
#define DIVERT_SENDSPACE (65536 + 100)
#endif
-u_int divert6_sendspace = DIVERT_SENDSPACE;
+u_int divert6_sendspace = DIVERT_SENDSPACE; /* [a] */
#ifndef DIVERT_RECVSPACE
#define DIVERT_RECVSPACE (65536 + 100)
#endif
-u_int divert6_recvspace = DIVERT_RECVSPACE;
+u_int divert6_recvspace = DIVERT_RECVSPACE; /* [a] */
#ifndef DIVERTHASHSIZE
#define DIVERTHASHSIZE 128
if (error)
return (error);
- error = soreserve(so, divert6_sendspace, divert6_recvspace);
+ error = soreserve(so, atomic_load_int(&divert6_sendspace),
+ atomic_load_int(&divert6_recvspace));
if (error)
return (error);
divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
void *newp, size_t newlen)
{
- int error;
-
/* All sysctl names at this level are terminal. */
if (namelen != 1)
return (ENOTDIR);
case DIVERT6CTL_STATS:
return (divert6_sysctl_div6stat(oldp, oldlenp, newp));
default:
- NET_LOCK();
- error = sysctl_bounded_arr(divert6ctl_vars,
+ return (sysctl_bounded_arr(divert6ctl_vars,
nitems(divert6ctl_vars), name, namelen, oldp, oldlenp,
- newp, newlen);
- NET_UNLOCK();
- return (error);
+ newp, newlen));
}
/* NOTREACHED */
}
-/* $OpenBSD: protosw.h,v 1.67 2024/07/12 19:50:35 bluhm Exp $ */
+/* $OpenBSD: protosw.h,v 1.68 2024/08/16 09:20:35 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
#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 */
+#define PR_MPSYSCTL 0x0200 /* mp-safe sysctl(2) handler */
/*
* The arguments to usrreq are: