Module Name: src Committed By: ozaki-r Date: Fri Dec 15 07:29:11 UTC 2017
Modified Files: src/sys/net: bpf.c Log Message: Make softint and callout MP-safe To generate a diff of this commit: cvs rdiff -u -r1.221 -r1.222 src/sys/net/bpf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/bpf.c diff -u src/sys/net/bpf.c:1.221 src/sys/net/bpf.c:1.222 --- src/sys/net/bpf.c:1.221 Tue Dec 12 06:26:57 2017 +++ src/sys/net/bpf.c Fri Dec 15 07:29:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.221 2017/12/12 06:26:57 ozaki-r Exp $ */ +/* $NetBSD: bpf.c,v 1.222 2017/12/15 07:29:11 ozaki-r Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.221 2017/12/12 06:26:57 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.222 2017/12/15 07:29:11 ozaki-r Exp $"); #if defined(_KERNEL_OPT) #include "opt_bpf.h" @@ -561,9 +561,10 @@ bpfopen(dev_t dev, int flag, int mode, s #endif getnanotime(&d->bd_btime); d->bd_atime = d->bd_mtime = d->bd_btime; - callout_init(&d->bd_callout, 0); + callout_init(&d->bd_callout, CALLOUT_MPSAFE); selinit(&d->bd_sel); - d->bd_sih = softint_establish(SOFTINT_CLOCK, bpf_softintr, d); + d->bd_sih = softint_establish(SOFTINT_CLOCK|SOFTINT_MPSAFE, + bpf_softintr, d); d->bd_jitcode = NULL; d->bd_filter = NULL; BPF_DLIST_ENTRY_INIT(d); @@ -765,8 +766,10 @@ bpf_softintr(void *cookie) struct bpf_d *d; d = cookie; + mutex_enter(d->bd_mtx); if (d->bd_async) fownsignal(d->bd_pgid, SIGIO, 0, 0, NULL); + mutex_exit(d->bd_mtx); } static void @@ -1231,7 +1234,9 @@ bpf_ioctl(struct file *fp, u_long cmd, v break; case FIOASYNC: /* Send signal on receive packets */ + mutex_enter(d->bd_mtx); d->bd_async = *(int *)addr; + mutex_exit(d->bd_mtx); break; case TIOCSPGRP: /* Process or group to send signals to */