-/* $OpenBSD: if_etherip.c,v 1.55 2024/02/13 12:22:09 bluhm Exp $ */
+/* $OpenBSD: if_etherip.c,v 1.56 2024/08/20 07:47:25 mvs Exp $ */
/*
* Copyright (c) 2015 Kazuya GODA <goda@openbsd.org>
*
#include <net/if_etherip.h>
+/*
+ * Locks used to protect data:
+ * a atomic
+ */
+
union etherip_addr {
struct in_addr in4;
struct in6_addr in6;
* We can control the acceptance of EtherIP packets by altering the sysctl
* net.inet.etherip.allow value. Zero means drop them, all else is acceptance.
*/
-int etherip_allow = 0;
+int etherip_allow = 0; /* [a] */
struct cpumem *etheripcounters;
struct etherip_header *eip;
int rxprio;
- if (!etherip_allow && (m->m_flags & (M_AUTH|M_CONF)) == 0) {
+ if (atomic_load_int(ðerip_allow) == 0 &&
+ (m->m_flags & (M_AUTH|M_CONF)) == 0) {
etheripstat_inc(etherips_pdrops);
goto drop;
}
etherip_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;
switch (name[0]) {
case ETHERIPCTL_ALLOW:
- NET_LOCK();
- error = sysctl_int_bounded(oldp, oldlenp, newp, newlen,
- ðerip_allow, 0, 1);
- NET_UNLOCK();
- return (error);
+ return (sysctl_int_bounded(oldp, oldlenp, newp, newlen,
+ ðerip_allow, 0, 1));
case ETHERIPCTL_STATS:
return (etherip_sysctl_etheripstat(oldp, oldlenp, newp));
default:
-/* $OpenBSD: in_proto.c,v 1.109 2024/08/20 07:46:27 mvs Exp $ */
+/* $OpenBSD: in_proto.c,v 1.110 2024/08/20 07:47:25 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_ETHERIP,
- .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
+ .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL,
.pr_input = ip_etherip_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &rip_usrreqs,