From 317fc6b77d946253ec00f0b536d253fb4781a3de Mon Sep 17 00:00:00 2001 From: mvs Date: Sun, 26 Jun 2022 22:51:58 +0000 Subject: [PATCH] Mark `pipex_enable' as atomic. We never check `pipex_enable' within (*if_qstart)() and we don't worry it's not serialized with the rest of output path. Also we will process already enqueued pipex(4) packets regardless on `pipex_enable' state. Use the local copy of `pipex_enable' within pppx_if_output(), otherwise we loose consistency. pointed and ok by bluhm@ --- sys/net/if_pppx.c | 10 ++++++---- sys/net/pipex.c | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 0aaaedc038f..b103addd284 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.116 2022/06/26 15:50:21 mvs Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.117 2022/06/26 22:51:58 mvs Exp $ */ /* * Copyright (c) 2010 Claudio Jeker @@ -817,7 +817,9 @@ pppx_if_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct pppx_if *pxi = (struct pppx_if *)ifp->if_softc; struct pppx_hdr *th; int error = 0; - int proto; + int pipex_enable_local, proto; + + pipex_enable_local = atomic_load_int(&pipex_enable); NET_ASSERT_LOCKED(); @@ -831,7 +833,7 @@ pppx_if_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, if (ifp->if_bpf) bpf_mtap_af(ifp->if_bpf, dst->sa_family, m, BPF_DIRECTION_OUT); #endif - if (pipex_enable) { + if (pipex_enable_local) { switch (dst->sa_family) { #ifdef INET6 case AF_INET6: @@ -856,7 +858,7 @@ pppx_if_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, } *mtod(m, int *) = proto; - if (pipex_enable) + if (pipex_enable_local) error = if_enqueue(ifp, m); else { M_PREPEND(m, sizeof(struct pppx_hdr), M_DONTWAIT); diff --git a/sys/net/pipex.c b/sys/net/pipex.c index 33e5e2351ef..393a7d563d7 100644 --- a/sys/net/pipex.c +++ b/sys/net/pipex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pipex.c,v 1.140 2022/06/26 21:29:34 mvs Exp $ */ +/* $OpenBSD: pipex.c,v 1.141 2022/06/26 22:51:58 mvs Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -94,7 +94,7 @@ struct pool mppe_key_pool; * L pipex_list_mtx */ -int pipex_enable = 0; /* [N] */ +int pipex_enable = 0; /* [A] */ struct pipex_hash_head pipex_session_list, /* [L] master session list */ pipex_close_wait_list, /* [L] expired session list */ -- 2.20.1