From owner-p4-projects@FreeBSD.ORG Sat Sep 6 16:33:12 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 585EC16A4C1; Sat, 6 Sep 2003 16:33:12 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ED40516A4BF for ; Sat, 6 Sep 2003 16:33:11 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A4F4C43FF9 for ; Sat, 6 Sep 2003 16:33:10 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h86NXA0U083154 for ; Sat, 6 Sep 2003 16:33:10 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h86NX93i083151 for perforce@freebsd.org; Sat, 6 Sep 2003 16:33:09 -0700 (PDT) Date: Sat, 6 Sep 2003 16:33:09 -0700 (PDT) Message-Id: <200309062333.h86NX93i083151@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 37692 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Sep 2003 23:33:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=37692 Change 37692 by marcel@marcel_nfs on 2003/09/06 16:32:13 IFC @37691 Affected files ... .. //depot/projects/uart/conf/files#21 integrate .. //depot/projects/uart/conf/files.alpha#6 integrate .. //depot/projects/uart/conf/files.amd64#6 integrate .. //depot/projects/uart/conf/files.i386#9 integrate .. //depot/projects/uart/conf/files.ia64#8 integrate .. //depot/projects/uart/conf/files.pc98#7 integrate .. //depot/projects/uart/conf/files.sparc64#5 integrate .. //depot/projects/uart/conf/kmod.mk#6 integrate .. //depot/projects/uart/conf/ldscript.ia64#2 integrate .. //depot/projects/uart/dev/puc/puc.c#9 integrate .. //depot/projects/uart/dev/puc/puc_ebus.c#4 integrate .. //depot/projects/uart/dev/puc/puc_pci.c#5 integrate .. //depot/projects/uart/dev/puc/puc_sbus.c#4 integrate .. //depot/projects/uart/dev/puc/pucdata.c#7 integrate .. //depot/projects/uart/dev/puc/pucvar.h#7 integrate .. //depot/projects/uart/dev/smbus/smbus.c#3 integrate .. //depot/projects/uart/dev/uart/uart.h#3 integrate .. //depot/projects/uart/dev/uart/uart_bus.h#27 integrate .. //depot/projects/uart/dev/uart/uart_bus_acpi.c#2 integrate .. //depot/projects/uart/dev/uart/uart_bus_ebus.c#4 integrate .. //depot/projects/uart/dev/uart/uart_bus_isa.c#2 integrate .. //depot/projects/uart/dev/uart/uart_bus_pci.c#4 integrate .. //depot/projects/uart/dev/uart/uart_bus_puc.c#6 integrate .. //depot/projects/uart/dev/uart/uart_core.c#27 integrate .. //depot/projects/uart/dev/uart/uart_cpu.h#8 integrate .. //depot/projects/uart/dev/uart/uart_cpu_alpha.c#4 integrate .. //depot/projects/uart/dev/uart/uart_cpu_amd64.c#2 integrate .. //depot/projects/uart/dev/uart/uart_cpu_i386.c#3 integrate .. //depot/projects/uart/dev/uart/uart_cpu_ia64.c#3 integrate .. //depot/projects/uart/dev/uart/uart_cpu_sparc64.c#11 integrate .. //depot/projects/uart/dev/uart/uart_dev_ns8250.c#26 integrate .. //depot/projects/uart/dev/uart/uart_dev_ns8250.h#3 integrate .. //depot/projects/uart/dev/uart/uart_dev_sab82532.c#26 integrate .. //depot/projects/uart/dev/uart/uart_dev_sab82532.h#2 integrate .. //depot/projects/uart/dev/uart/uart_dev_z8530.c#12 integrate .. //depot/projects/uart/dev/uart/uart_dev_z8530.h#6 integrate .. //depot/projects/uart/dev/uart/uart_if.m#10 integrate .. //depot/projects/uart/dev/uart/uart_tty.c#15 integrate .. //depot/projects/uart/geom/bde/g_bde_crypt.c#2 integrate .. //depot/projects/uart/kern/subr_taskqueue.c#3 integrate .. //depot/projects/uart/kern/subr_witness.c#5 integrate .. //depot/projects/uart/kern/sys_pipe.c#7 integrate .. //depot/projects/uart/modules/Makefile#7 integrate .. //depot/projects/uart/modules/uart/Makefile#5 integrate .. //depot/projects/uart/netinet/ip_mroute.c#5 integrate .. //depot/projects/uart/pci/amdpm.c#4 integrate Differences ... ==== //depot/projects/uart/conf/files#21 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/files,v 1.817 2003/08/29 04:02:18 njl Exp $ +# $FreeBSD: src/sys/conf/files,v 1.819 2003/09/06 23:23:25 marcel Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and ==== //depot/projects/uart/conf/files.alpha#6 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.alpha,v 1.105 2003/08/04 02:39:14 imp Exp $ +# $FreeBSD: src/sys/conf/files.alpha,v 1.106 2003/09/06 23:23:25 marcel Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and ==== //depot/projects/uart/conf/files.amd64#6 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.amd64,v 1.22 2003/08/23 00:59:26 peter Exp $ +# $FreeBSD: src/sys/conf/files.amd64,v 1.23 2003/09/06 23:23:25 marcel Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and ==== //depot/projects/uart/conf/files.i386#9 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.i386,v 1.453 2003/08/31 16:20:34 phk Exp $ +# $FreeBSD: src/sys/conf/files.i386,v 1.454 2003/09/06 23:23:25 marcel Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and ==== //depot/projects/uart/conf/files.ia64#8 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.ia64,v 1.57 2003/08/23 02:33:36 marcel Exp $ +# $FreeBSD: src/sys/conf/files.ia64,v 1.58 2003/09/06 23:23:25 marcel Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and ==== //depot/projects/uart/conf/files.pc98#7 (text+ko) ==== @@ -3,7 +3,7 @@ # # modified for PC-9801 # -# $FreeBSD: src/sys/conf/files.pc98,v 1.277 2003/08/25 07:52:10 nyan Exp $ +# $FreeBSD: src/sys/conf/files.pc98,v 1.278 2003/09/06 23:23:25 marcel Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and ==== //depot/projects/uart/conf/files.sparc64#5 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.sparc64,v 1.45 2003/08/24 01:54:06 jake Exp $ +# $FreeBSD: src/sys/conf/files.sparc64,v 1.46 2003/09/06 23:23:25 marcel Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and ==== //depot/projects/uart/conf/kmod.mk#6 (text+ko) ==== @@ -1,5 +1,5 @@ # From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 -# $FreeBSD: src/sys/conf/kmod.mk,v 1.140 2003/08/22 15:41:44 imp Exp $ +# $FreeBSD: src/sys/conf/kmod.mk,v 1.141 2003/09/06 23:23:25 marcel Exp $ # # The include file handles installing Kernel Loadable Device # drivers (KLD's). ==== //depot/projects/uart/conf/ldscript.ia64#2 (text+ko) ==== @@ -1,9 +1,9 @@ -/* $FreeBSD: src/sys/conf/ldscript.ia64,v 1.9 2003/05/16 06:03:45 marcel Exp $ */ +/* $FreeBSD: src/sys/conf/ldscript.ia64,v 1.10 2003/09/06 05:15:36 marcel Exp $ */ OUTPUT_FORMAT("elf64-ia64-little", "elf64-ia64-little", "elf64-ia64-little") OUTPUT_ARCH(ia64) ENTRY(__start) SEARCH_DIR(/usr/lib); -kernel_text = 0xe000000000500000; +kernel_text = 0xe000000004000000; SECTIONS { /* Read-only sections, merged into text segment: */ ==== //depot/projects/uart/dev/puc/puc.c#9 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/puc/puc.c,v 1.25 2003/08/24 17:54:17 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/puc/puc.c,v 1.26 2003/09/06 21:48:49 marcel Exp $"); /* * Copyright (c) 1996, 1998, 1999 @@ -61,7 +61,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/puc/puc.c,v 1.25 2003/08/24 17:54:17 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/puc/puc.c,v 1.26 2003/09/06 21:48:49 marcel Exp $"); /* * PCI "universal" communication card device driver, glues com, lpt, ==== //depot/projects/uart/dev/puc/puc_ebus.c#4 (text+ko) ==== ==== //depot/projects/uart/dev/puc/puc_pci.c#5 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/puc/puc_pci.c,v 1.6 2003/08/28 21:22:25 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/puc/puc_pci.c,v 1.7 2003/09/06 21:48:50 marcel Exp $"); /* * Copyright (c) 1996, 1998, 1999 @@ -61,7 +61,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/puc/puc_pci.c,v 1.6 2003/08/28 21:22:25 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/puc/puc_pci.c,v 1.7 2003/09/06 21:48:50 marcel Exp $"); #include "opt_puc.h" ==== //depot/projects/uart/dev/puc/puc_sbus.c#4 (text+ko) ==== ==== //depot/projects/uart/dev/puc/pucdata.c#7 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/puc/pucdata.c,v 1.24 2003/08/21 03:54:20 ambrisko Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/puc/pucdata.c,v 1.25 2003/09/06 21:48:50 marcel Exp $"); /* * PCI "universal" communications card driver configuration data (used to ==== //depot/projects/uart/dev/puc/pucvar.h#7 (text+ko) ==== @@ -1,5 +1,5 @@ /* $NetBSD: pucvar.h,v 1.2 1999/02/06 06:29:54 cgd Exp $ */ -/* $FreeBSD: src/sys/dev/puc/pucvar.h,v 1.10 2003/03/15 16:25:40 sobomax Exp $ */ +/* $FreeBSD: src/sys/dev/puc/pucvar.h,v 1.11 2003/09/06 21:48:50 marcel Exp $ */ /*- * Copyright (c) 2002 JF Hay. All rights reserved. ==== //depot/projects/uart/dev/smbus/smbus.c#3 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/smbus/smbus.c,v 1.17 2003/08/24 18:03:44 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/smbus/smbus.c,v 1.18 2003/09/06 13:58:06 dfr Exp $"); #include #include #include @@ -116,5 +116,4 @@ DRIVER_MODULE(smbus, ichsmb, smbus_driver, smbus_devclass, 0, 0); DRIVER_MODULE(smbus, amdpm, smbus_driver, smbus_devclass, 0, 0); DRIVER_MODULE(smbus, viapropm, smbus_driver, smbus_devclass, 0, 0); -DRIVER_MODULE(smbus, nfpm, smbus_driver, smbus_devclass, 0, 0); MODULE_VERSION(smbus, SMBUS_MODVER); ==== //depot/projects/uart/dev/uart/uart.h#3 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_bus.h#27 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_bus_acpi.c#2 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_bus_ebus.c#4 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_bus_isa.c#2 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_bus_pci.c#4 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_bus_puc.c#6 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_core.c#27 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_cpu.h#8 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_cpu_alpha.c#4 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_cpu_amd64.c#2 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_cpu_i386.c#3 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_cpu_ia64.c#3 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_cpu_sparc64.c#11 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_dev_ns8250.c#26 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_dev_ns8250.h#3 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_dev_sab82532.c#26 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_dev_sab82532.h#2 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_dev_z8530.c#12 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_dev_z8530.h#6 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_if.m#10 (text+ko) ==== ==== //depot/projects/uart/dev/uart/uart_tty.c#15 (text+ko) ==== ==== //depot/projects/uart/geom/bde/g_bde_crypt.c#2 (text+ko) ==== @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/geom/bde/g_bde_crypt.c,v 1.16 2003/05/31 19:23:11 phk Exp $ + * $FreeBSD: src/sys/geom/bde/g_bde_crypt.c,v 1.17 2003/09/06 18:37:17 phk Exp $ * * This source file contains the functions responsible for the crypto, keying * and mapping operations on the I/O requests. @@ -159,7 +159,7 @@ } bzero(skey, sizeof skey); bzero(&ci, sizeof ci); - bzero(&ki, sizeof ci); + bzero(&ki, sizeof ki); } /* ==== //depot/projects/uart/kern/subr_taskqueue.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/subr_taskqueue.c,v 1.18 2003/09/05 23:09:22 sam Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/subr_taskqueue.c,v 1.19 2003/09/06 21:05:18 sam Exp $"); #include #include @@ -379,7 +379,7 @@ STAILQ_INIT(&taskqueue_fast->tq_queue); taskqueue_fast->tq_name = "fast"; taskqueue_fast->tq_enqueue = taskqueue_fast_schedule; - mtx_init(&taskqueue_fast->tq_mutex, "taskqueue", NULL, MTX_SPIN); + mtx_init(&taskqueue_fast->tq_mutex, "taskqueue_fast", NULL, MTX_SPIN); mtx_lock(&taskqueue_queues_mutex); STAILQ_INSERT_TAIL(&taskqueue_queues, taskqueue_fast, tq_link); ==== //depot/projects/uart/kern/subr_witness.c#5 (text+ko) ==== @@ -82,7 +82,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/subr_witness.c,v 1.158 2003/08/04 19:24:25 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/subr_witness.c,v 1.159 2003/09/06 21:06:08 sam Exp $"); #include "opt_ddb.h" #include "opt_witness.h" @@ -284,6 +284,7 @@ { "zstty", &lock_class_mtx_spin }, { "ng_node", &lock_class_mtx_spin }, { "ng_worklist", &lock_class_mtx_spin }, + { "taskqueue_fast", &lock_class_mtx_spin }, { "ithread table lock", &lock_class_mtx_spin }, { "sched lock", &lock_class_mtx_spin }, { "callout", &lock_class_mtx_spin }, ==== //depot/projects/uart/kern/sys_pipe.c#7 (text+ko) ==== @@ -66,7 +66,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/sys_pipe.c,v 1.148 2003/08/15 04:31:01 jmg Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/sys_pipe.c,v 1.149 2003/09/06 21:02:10 alc Exp $"); #include "opt_mac.h" @@ -743,9 +743,7 @@ { int i; - GIANT_REQUIRED; PIPE_LOCK_ASSERT(wpipe, MA_NOTOWNED); - if (wpipe->pipe_map.kva) { pmap_qremove(wpipe->pipe_map.kva, wpipe->pipe_map.npages); @@ -754,7 +752,7 @@ vm_offset_t kva = wpipe->pipe_map.kva; wpipe->pipe_map.kva = 0; kmem_free(kernel_map, kva, - wpipe->pipe_buffer.size + PAGE_SIZE); + wpipe->pipe_buffer.size + PAGE_SIZE); atomic_subtract_int(&amountpipekvawired, wpipe->pipe_buffer.size + PAGE_SIZE); } @@ -788,11 +786,11 @@ wpipe->pipe_buffer.cnt = size; wpipe->pipe_state &= ~PIPE_DIRECTW; - PIPE_GET_GIANT(wpipe); + PIPE_UNLOCK(wpipe); bcopy((caddr_t) wpipe->pipe_map.kva + pos, wpipe->pipe_buffer.buffer, size); pipe_destroy_write_buffer(wpipe); - PIPE_DROP_GIANT(wpipe); + PIPE_LOCK(wpipe); } /* @@ -861,9 +859,9 @@ while (!error && (wpipe->pipe_state & PIPE_DIRECTW)) { if (wpipe->pipe_state & PIPE_EOF) { pipelock(wpipe, 0); - PIPE_GET_GIANT(wpipe); + PIPE_UNLOCK(wpipe); pipe_destroy_write_buffer(wpipe); - PIPE_DROP_GIANT(wpipe); + PIPE_LOCK(wpipe); pipeselwakeup(wpipe); pipeunlock(wpipe); error = EPIPE; @@ -886,9 +884,9 @@ */ pipe_clone_write_buffer(wpipe); } else { - PIPE_GET_GIANT(wpipe); + PIPE_UNLOCK(wpipe); pipe_destroy_write_buffer(wpipe); - PIPE_DROP_GIANT(wpipe); + PIPE_LOCK(wpipe); } pipeunlock(wpipe); return (error); ==== //depot/projects/uart/modules/Makefile#7 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/modules/Makefile,v 1.346 2003/08/30 08:01:05 sos Exp $ +# $FreeBSD: src/sys/modules/Makefile,v 1.347 2003/09/06 23:23:26 marcel Exp $ .if !defined(NOCRYPT) || defined(ALL_MODULES) .if exists(${.CURDIR}/../opencrypto) @@ -123,6 +123,7 @@ twe \ tx \ txp \ + uart \ ubsa \ ubsec \ ucom \ @@ -241,7 +242,7 @@ mly \ s3 \ vesa - + .elif ${MACHINE} == "pc98" SUBDIR+=canbepm \ canbus \ ==== //depot/projects/uart/modules/uart/Makefile#5 (text+ko) ==== ==== //depot/projects/uart/netinet/ip_mroute.c#5 (text+ko) ==== @@ -17,7 +17,7 @@ * and PIM-SMv2 and PIM-DM support, advanced API support, * bandwidth metering and signaling * - * $FreeBSD: src/sys/netinet/ip_mroute.c,v 1.91 2003/08/24 08:27:57 hsu Exp $ + * $FreeBSD: src/sys/netinet/ip_mroute.c,v 1.92 2003/09/06 04:53:43 sam Exp $ */ #include "opt_mac.h" @@ -81,6 +81,15 @@ static MALLOC_DEFINE(M_MRTABLE, "mroutetbl", "multicast routing tables"); +/* + * Locking. We use two locks: one for the virtual interface table and + * one for the forwarding table. These locks may be nested in which case + * the VIF lock must always be taken first. Note that each lock is used + * to cover not only the specific data structure but also related data + * structures. It may be better to add more fine-grained locking later; + * it's not clear how performance-critical this code is. + */ + static struct mrtstat mrtstat; SYSCTL_STRUCT(_net_inet_ip, OID_AUTO, mrtstat, CTLFLAG_RW, &mrtstat, mrtstat, @@ -91,14 +100,28 @@ &mfctable, sizeof(mfctable), "S,*mfc[MFCTBLSIZ]", "Multicast Forwarding Table (struct *mfc[MFCTBLSIZ], netinet/ip_mroute.h)"); +static struct mtx mfc_mtx; +#define MFC_LOCK() mtx_lock(&mfc_mtx) +#define MFC_UNLOCK() mtx_unlock(&mfc_mtx) +#define MFC_LOCK_ASSERT() mtx_assert(&mfc_mtx, MA_OWNED) +#define MFC_LOCK_INIT() mtx_init(&mfc_mtx, "mroute mfc table", NULL, MTX_DEF) +#define MFC_LOCK_DESTROY() mtx_destroy(&mfc_mtx) + static struct vif viftable[MAXVIFS]; SYSCTL_OPAQUE(_net_inet_ip, OID_AUTO, viftable, CTLFLAG_RD, &viftable, sizeof(viftable), "S,vif[MAXVIFS]", "Multicast Virtual Interfaces (struct vif[MAXVIFS], netinet/ip_mroute.h)"); +static struct mtx vif_mtx; +#define VIF_LOCK() mtx_lock(&vif_mtx) +#define VIF_UNLOCK() mtx_unlock(&vif_mtx) +#define VIF_LOCK_ASSERT() mtx_assert(&vif_mtx, MA_OWNED) +#define VIF_LOCK_INIT() mtx_init(&vif_mtx, "mroute vif table", NULL, MTX_DEF) +#define VIF_LOCK_DESTROY() mtx_destroy(&vif_mtx) + static u_char nexpire[MFCTBLSIZ]; -static struct callout_handle expire_upcalls_ch; +static struct callout expire_upcalls_ch; #define EXPIRE_TIMEOUT (hz / 4) /* 4x / second */ #define UPCALL_EXPIRE 6 /* number of timeouts */ @@ -149,7 +172,7 @@ */ #define BW_METER_BUCKETS 1024 static struct bw_meter *bw_meter_timers[BW_METER_BUCKETS]; -static struct callout_handle bw_meter_ch; +static struct callout bw_meter_ch; #define BW_METER_PERIOD (hz) /* periodical handling of bw meters */ /* @@ -158,7 +181,7 @@ */ static struct bw_upcall bw_upcalls[BW_UPCALLS_MAX]; static u_int bw_upcalls_n; /* # of pending upcalls */ -static struct callout_handle bw_upcalls_ch; +static struct callout bw_upcalls_ch; #define BW_UPCALLS_PERIOD (hz) /* periodical flush of bw upcalls */ #ifdef PIM @@ -226,6 +249,11 @@ static u_long last_encap_src; static struct vif *last_encap_vif; +/* + * Callout for queue processing. + */ +static struct callout tbf_reprocess_ch; + static u_long X_ip_mcast_src(int vifi); static int X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m, struct ip_moptions *imo); @@ -321,6 +349,8 @@ { struct mfc *rt; + MFC_LOCK_ASSERT(); + for (rt = mfctable[MFCHASH(o,g)]; rt; rt = rt->mfc_next) if ((rt->mfc_origin.s_addr == o) && (rt->mfc_mcastgrp.s_addr == g) && (rt->mfc_stall == NULL)) @@ -515,19 +545,19 @@ static int get_sg_cnt(struct sioc_sg_req *req) { - int s; struct mfc *rt; - s = splnet(); + MFC_LOCK(); rt = mfc_find(req->src.s_addr, req->grp.s_addr); - splx(s); if (rt == NULL) { + MFC_UNLOCK(); req->pktcnt = req->bytecnt = req->wrong_if = 0xffffffff; return EADDRNOTAVAIL; } req->pktcnt = rt->mfc_pkt_cnt; req->bytecnt = rt->mfc_byte_cnt; req->wrong_if = rt->mfc_wrong_if; + MFC_UNLOCK(); return 0; } @@ -539,13 +569,17 @@ { vifi_t vifi = req->vifi; - if (vifi >= numvifs) + VIF_LOCK(); + if (vifi >= numvifs) { + VIF_UNLOCK(); return EINVAL; + } req->icount = viftable[vifi].v_pkt_in; req->ocount = viftable[vifi].v_pkt_out; req->ibytes = viftable[vifi].v_bytes_in; req->obytes = viftable[vifi].v_bytes_out; + VIF_UNLOCK(); return 0; } @@ -572,16 +606,24 @@ ip_mrouter = so; bzero((caddr_t)mfctable, sizeof(mfctable)); + MFC_LOCK_INIT(); + VIF_LOCK_INIT(); bzero((caddr_t)nexpire, sizeof(nexpire)); pim_assert = 0; - expire_upcalls_ch = timeout(expire_upcalls, NULL, EXPIRE_TIMEOUT); + callout_init(&expire_upcalls_ch, CALLOUT_MPSAFE); + callout_reset(&expire_upcalls_ch, EXPIRE_TIMEOUT, expire_upcalls, NULL); bw_upcalls_n = 0; bzero((caddr_t)bw_meter_timers, sizeof(bw_meter_timers)); - bw_upcalls_ch = timeout(expire_bw_upcalls_send, NULL, BW_UPCALLS_PERIOD); - bw_meter_ch = timeout(expire_bw_meter_process, NULL, BW_METER_PERIOD); + callout_init(&bw_upcalls_ch, CALLOUT_MPSAFE); + callout_reset(&bw_upcalls_ch, BW_UPCALLS_PERIOD, + expire_bw_upcalls_send, NULL); + callout_init(&bw_meter_ch, CALLOUT_MPSAFE); + callout_reset(&bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, NULL); + + callout_init(&tbf_reprocess_ch, CALLOUT_MPSAFE); mrt_api_config = 0; @@ -603,9 +645,19 @@ struct ifreq ifr; struct mfc *rt; struct rtdetq *rte; - int s; + + /* + * Detach/disable hooks to the reset of the system. + */ + ip_mrouter = NULL; + mrt_api_config = 0; - s = splnet(); + VIF_LOCK(); + if (encap_cookie) { + encap_detach(encap_cookie); + encap_cookie = NULL; + } + callout_stop(&tbf_reprocess_ch); /* * For each phyint in use, disable promiscuous reception of all IP @@ -627,17 +679,17 @@ bzero((caddr_t)viftable, sizeof(viftable)); numvifs = 0; pim_assert = 0; + VIF_UNLOCK(); + VIF_LOCK_DESTROY(); - untimeout(expire_upcalls, NULL, expire_upcalls_ch); - - mrt_api_config = 0; - bw_upcalls_n = 0; - untimeout(expire_bw_upcalls_send, NULL, bw_upcalls_ch); - untimeout(expire_bw_meter_process, NULL, bw_meter_ch); - /* * Free all multicast forwarding cache entries. */ + MFC_LOCK(); + callout_stop(&expire_upcalls_ch); + callout_stop(&bw_upcalls_ch); + callout_stop(&bw_meter_ch); + for (i = 0; i < MFCTBLSIZ; i++) { for (rt = mfctable[i]; rt != NULL; ) { struct mfc *nr = rt->mfc_next; @@ -654,10 +706,11 @@ rt = nr; } } - bzero((caddr_t)mfctable, sizeof(mfctable)); - + bw_upcalls_n = 0; bzero(bw_meter_timers, sizeof(bw_meter_timers)); + MFC_UNLOCK(); + MFC_LOCK_DESTROY(); /* * Reset de-encapsulation cache @@ -668,15 +721,6 @@ reg_vif_num = VIFI_INVALID; #endif - if (encap_cookie) { - encap_detach(encap_cookie); - encap_cookie = NULL; - } - - ip_mrouter = NULL; - - splx(s); - if (mrtdebug) log(LOG_DEBUG, "ip_mrouter_done\n"); @@ -824,15 +868,22 @@ struct sockaddr_in sin = {sizeof sin, AF_INET}; struct ifaddr *ifa; struct ifnet *ifp; - int error, s; + int error; struct tbf *v_tbf = tbftable + vifcp->vifc_vifi; - if (vifcp->vifc_vifi >= MAXVIFS) + VIF_LOCK(); + if (vifcp->vifc_vifi >= MAXVIFS) { + VIF_UNLOCK(); return EINVAL; - if (vifp->v_lcl_addr.s_addr != INADDR_ANY) + } + if (vifp->v_lcl_addr.s_addr != INADDR_ANY) { + VIF_UNLOCK(); return EADDRINUSE; - if (vifcp->vifc_lcl_addr.s_addr == INADDR_ANY) + } + if (vifcp->vifc_lcl_addr.s_addr == INADDR_ANY) { + VIF_UNLOCK(); return EADDRNOTAVAIL; + } /* Find the interface with an address in AF_INET family */ #ifdef PIM @@ -848,8 +899,10 @@ { sin.sin_addr = vifcp->vifc_lcl_addr; ifa = ifa_ifwithaddr((struct sockaddr *)&sin); - if (ifa == NULL) + if (ifa == NULL) { + VIF_UNLOCK(); return EADDRNOTAVAIL; + } ifp = ifa->ifa_ifp; } @@ -861,17 +914,20 @@ * to encapsulated packets. */ if (encap_cookie == NULL) { + int i; + encap_cookie = encap_attach_func(AF_INET, IPPROTO_IPV4, mroute_encapcheck, (struct protosw *)&mroute_encap_protosw, NULL); if (encap_cookie == NULL) { printf("ip_mroute: unable to attach encap\n"); + VIF_UNLOCK(); return EIO; /* XXX */ } - for (s = 0; s < MAXVIFS; ++s) { - multicast_decap_if[s].if_name = "mdecap"; - multicast_decap_if[s].if_unit = s; + for (i = 0; i < MAXVIFS; ++i) { + multicast_decap_if[i].if_name = "mdecap"; + multicast_decap_if[i].if_unit = i; } } /* @@ -884,6 +940,7 @@ bzero(&vifp->v_route, sizeof(vifp->v_route)); } else { log(LOG_ERR, "source routed tunnels not supported\n"); + VIF_UNLOCK(); return EOPNOTSUPP; } #ifdef PIM @@ -901,18 +958,19 @@ } #endif } else { /* Make sure the interface supports multicast */ - if ((ifp->if_flags & IFF_MULTICAST) == 0) + if ((ifp->if_flags & IFF_MULTICAST) == 0) { + VIF_UNLOCK(); return EOPNOTSUPP; + } /* Enable promiscuous reception of all IP multicasts from the if */ - s = splnet(); error = if_allmulti(ifp, 1); - splx(s); - if (error) + if (error) { + VIF_UNLOCK(); return error; + } } - s = splnet(); /* define parameters for the tbf structure */ vifp->v_tbf = v_tbf; GET_TIME(vifp->v_tbf->tbf_last_pkt_t); @@ -935,11 +993,12 @@ vifp->v_pkt_out = 0; vifp->v_bytes_in = 0; vifp->v_bytes_out = 0; - splx(s); /* Adjust numvifs up if the vifi is higher than numvifs */ if (numvifs <= vifcp->vifc_vifi) numvifs = vifcp->vifc_vifi + 1; + VIF_UNLOCK(); + if (mrtdebug) log(LOG_DEBUG, "add_vif #%d, lcladdr %lx, %s %lx, thresh %x, rate %d\n", vifcp->vifc_vifi, @@ -959,15 +1018,18 @@ del_vif(vifi_t vifi) { struct vif *vifp; - int s; + + VIF_LOCK(); - if (vifi >= numvifs) + if (vifi >= numvifs) { + VIF_UNLOCK(); return EINVAL; + } vifp = &viftable[vifi]; - if (vifp->v_lcl_addr.s_addr == INADDR_ANY) + if (vifp->v_lcl_addr.s_addr == INADDR_ANY) { + VIF_UNLOCK(); return EADDRNOTAVAIL; - - s = splnet(); + } if (!(vifp->v_flags & (VIFF_TUNNEL | VIFF_REGISTER))) if_allmulti(vifp->v_ifp, 0); @@ -1004,7 +1066,7 @@ break; numvifs = vifi; - splx(s); + VIF_UNLOCK(); return 0; } @@ -1059,7 +1121,9 @@ u_long hash; struct rtdetq *rte; u_short nstl; - int s; + + VIF_LOCK(); + MFC_LOCK(); rt = mfc_find(mfccp->mfcc_origin.s_addr, mfccp->mfcc_mcastgrp.s_addr); @@ -1071,16 +1135,15 @@ (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), mfccp->mfcc_parent); - s = splnet(); update_mfc_params(rt, mfccp); - splx(s); + MFC_UNLOCK(); + VIF_UNLOCK(); return 0; } /* * Find the entry for which the upcall was made and update */ - s = splnet(); hash = MFCHASH(mfccp->mfcc_origin.s_addr, mfccp->mfcc_mcastgrp.s_addr); for (rt = mfctable[hash], nstl = 0; rt; rt = rt->mfc_next) { @@ -1142,7 +1205,8 @@ if (rt == NULL) { /* no upcall, so make a new entry */ rt = (struct mfc *)malloc(sizeof(*rt), M_MRTABLE, M_NOWAIT); if (rt == NULL) { - splx(s); + MFC_UNLOCK(); + VIF_UNLOCK(); return ENOBUFS; } @@ -1156,7 +1220,8 @@ mfctable[hash] = rt; } } - splx(s); + MFC_UNLOCK(); + VIF_UNLOCK(); return 0; } @@ -1171,7 +1236,6 @@ struct mfc *rt; struct mfc **nptr; u_long hash; - int s; struct bw_meter *list; origin = mfccp->mfcc_origin; @@ -1181,7 +1245,7 @@ log(LOG_DEBUG,"del_mfc orig %lx mcastgrp %lx\n", (u_long)ntohl(origin.s_addr), (u_long)ntohl(mcastgrp.s_addr)); - s = splnet(); + MFC_LOCK(); hash = MFCHASH(origin.s_addr, mcastgrp.s_addr); for (nptr = &mfctable[hash]; (rt = *nptr) != NULL; nptr = &rt->mfc_next) @@ -1190,7 +1254,7 @@ rt->mfc_stall == NULL) break; if (rt == NULL) { - splx(s); + MFC_UNLOCK(); return EADDRNOTAVAIL; } @@ -1204,9 +1268,9 @@ free(rt, M_MRTABLE); - splx(s); + free_bw_list(list); - free_bw_list(list); + MFC_UNLOCK(); return 0; } @@ -1245,7 +1309,7 @@ struct ip_moptions *imo) { struct mfc *rt; - int s; + int error; vifi_t vifi; if (mrtdebug & DEBUG_FORWARD) @@ -1274,6 +1338,8 @@ return 1; } + VIF_LOCK(); + MFC_LOCK(); if (imo && ((vifi = imo->imo_multicast_vif) < numvifs)) { if (ip->ip_ttl < 255) ip->ip_ttl++; /* compensate for -1 in *_send routines */ @@ -1286,7 +1352,10 @@ (vifp->v_flags & VIFF_TUNNEL) ? "tunnel on " : "", vifp->v_ifp->if_name, vifp->v_ifp->if_unit); } - return ip_mdq(m, ifp, NULL, vifi); + error = ip_mdq(m, ifp, NULL, vifi); + MFC_UNLOCK(); + VIF_UNLOCK(); + return error; } if (rsvpdebug && ip->ip_p == IPPROTO_RSVP) { printf("Warning: IPPROTO_RSVP from %lx to %lx without vif option\n", @@ -1299,20 +1368,24 @@ * Don't forward a packet with time-to-live of zero or one, * or a packet destined to a local-only group. */ - if (ip->ip_ttl <= 1 || ntohl(ip->ip_dst.s_addr) <= INADDR_MAX_LOCAL_GROUP) + if (ip->ip_ttl <= 1 || ntohl(ip->ip_dst.s_addr) <= INADDR_MAX_LOCAL_GROUP) { + MFC_UNLOCK(); + VIF_UNLOCK(); return 0; + } /* * Determine forwarding vifs from the forwarding cache table */ - s = splnet(); ++mrtstat.mrts_mfc_lookups; rt = mfc_find(ip->ip_src.s_addr, ip->ip_dst.s_addr); /* Entry exists, so forward if necessary */ if (rt != NULL) { - splx(s); >>> TRUNCATED FOR MAIL (1000 lines) <<<