Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Protect bridge_list with a mutex
details: https://anonhg.NetBSD.org/src/rev/b829e07abf36
branches: trunk
changeset: 330271:b829e07abf36
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Jul 02 09:51:08 2014 +0000
description:
Protect bridge_list with a mutex
diffstat:
sys/net/if_bridge.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diffs (72 lines):
diff -r 24b261d07191 -r b829e07abf36 sys/net/if_bridge.c
--- a/sys/net/if_bridge.c Wed Jul 02 09:43:16 2014 +0000
+++ b/sys/net/if_bridge.c Wed Jul 02 09:51:08 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridge.c,v 1.85 2014/07/02 09:43:16 ozaki-r Exp $ */
+/* $NetBSD: if_bridge.c,v 1.86 2014/07/02 09:51:08 ozaki-r Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.85 2014/07/02 09:43:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.86 2014/07/02 09:51:08 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_bridge_ipf.h"
@@ -100,6 +100,7 @@
#include <sys/kauth.h>
#include <sys/cpu.h>
#include <sys/cprng.h>
+#include <sys/mutex.h>
#include <net/bpf.h>
#include <net/if.h>
@@ -312,6 +313,7 @@
static const int bridge_control_table_size = __arraycount(bridge_control_table);
static LIST_HEAD(, bridge_softc) bridge_list;
+static kmutex_t bridge_list_lock;
static struct if_clone bridge_cloner =
IF_CLONE_INITIALIZER("bridge", bridge_clone_create, bridge_clone_destroy);
@@ -329,6 +331,7 @@
0, 0, 0, "brtpl", NULL, IPL_NET);
LIST_INIT(&bridge_list);
+ mutex_init(&bridge_list_lock, MUTEX_DEFAULT, IPL_NET);
if_clone_attach(&bridge_cloner);
}
@@ -342,7 +345,6 @@
{
struct bridge_softc *sc;
struct ifnet *ifp;
- int s;
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
ifp = &sc->sc_if;
@@ -386,9 +388,9 @@
if_alloc_sadl(ifp);
- s = splnet();
+ mutex_enter(&bridge_list_lock);
LIST_INSERT_HEAD(&bridge_list, sc, sc_list);
- splx(s);
+ mutex_exit(&bridge_list_lock);
return (0);
}
@@ -415,7 +417,9 @@
while ((bif = LIST_FIRST(&sc->sc_iflist)) != NULL)
bridge_delete_member(sc, bif);
+ mutex_enter(&bridge_list_lock);
LIST_REMOVE(sc, sc_list);
+ mutex_exit(&bridge_list_lock);
splx(s);
Home |
Main Index |
Thread Index |
Old Index