Thu Oct 19 01:57:15 2017 UTC ()
Turn on D_MPSAFE flag of bpf_cdevsw that is already MP-safe

Pointed out by k-goda@IIJ


(ozaki-r)
diff -r1.216 -r1.217 src/sys/net/bpf.c

cvs diff -r1.216 -r1.217 src/sys/net/bpf.c (expand / switch to unified diff)

--- src/sys/net/bpf.c 2017/02/20 03:08:38 1.216
+++ src/sys/net/bpf.c 2017/10/19 01:57:15 1.217
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bpf.c,v 1.216 2017/02/20 03:08:38 ozaki-r Exp $ */ 1/* $NetBSD: bpf.c,v 1.217 2017/10/19 01:57:15 ozaki-r Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1990, 1991, 1993 4 * Copyright (c) 1990, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from the Stanford/CMU enet packet filter, 7 * This code is derived from the Stanford/CMU enet packet filter,
8 * (net/enet.c) distributed as part of 4.3BSD, and code contributed 8 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
9 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 9 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
10 * Berkeley Laboratory. 10 * Berkeley Laboratory.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * @(#)bpf.c 8.4 (Berkeley) 1/9/95 36 * @(#)bpf.c 8.4 (Berkeley) 1/9/95
37 * static char rcsid[] = 37 * static char rcsid[] =
38 * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp "; 38 * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp ";
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.216 2017/02/20 03:08:38 ozaki-r Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.217 2017/10/19 01:57:15 ozaki-r Exp $");
43 43
44#if defined(_KERNEL_OPT) 44#if defined(_KERNEL_OPT)
45#include "opt_bpf.h" 45#include "opt_bpf.h"
46#include "sl.h" 46#include "sl.h"
47#include "strip.h" 47#include "strip.h"
48#include "opt_net_mpsafe.h" 48#include "opt_net_mpsafe.h"
49#endif 49#endif
50 50
51#include <sys/param.h> 51#include <sys/param.h>
52#include <sys/systm.h> 52#include <sys/systm.h>
53#include <sys/mbuf.h> 53#include <sys/mbuf.h>
54#include <sys/buf.h> 54#include <sys/buf.h>
55#include <sys/time.h> 55#include <sys/time.h>
@@ -286,27 +286,27 @@ dev_type_open(bpfopen); @@ -286,27 +286,27 @@ dev_type_open(bpfopen);
286 286
287const struct cdevsw bpf_cdevsw = { 287const struct cdevsw bpf_cdevsw = {
288 .d_open = bpfopen, 288 .d_open = bpfopen,
289 .d_close = noclose, 289 .d_close = noclose,
290 .d_read = noread, 290 .d_read = noread,
291 .d_write = nowrite, 291 .d_write = nowrite,
292 .d_ioctl = noioctl, 292 .d_ioctl = noioctl,
293 .d_stop = nostop, 293 .d_stop = nostop,
294 .d_tty = notty, 294 .d_tty = notty,
295 .d_poll = nopoll, 295 .d_poll = nopoll,
296 .d_mmap = nommap, 296 .d_mmap = nommap,
297 .d_kqfilter = nokqfilter, 297 .d_kqfilter = nokqfilter,
298 .d_discard = nodiscard, 298 .d_discard = nodiscard,
299 .d_flag = D_OTHER 299 .d_flag = D_OTHER | D_MPSAFE
300}; 300};
301 301
302bpfjit_func_t 302bpfjit_func_t
303bpf_jit_generate(bpf_ctx_t *bc, void *code, size_t size) 303bpf_jit_generate(bpf_ctx_t *bc, void *code, size_t size)
304{ 304{
305 305
306 membar_consumer(); 306 membar_consumer();
307 if (bpfjit_module_ops.bj_generate_code != NULL) { 307 if (bpfjit_module_ops.bj_generate_code != NULL) {
308 return bpfjit_module_ops.bj_generate_code(bc, code, size); 308 return bpfjit_module_ops.bj_generate_code(bc, code, size);
309 } 309 }
310 return NULL; 310 return NULL;
311} 311}
312 312