Module Name: src
Committed By: ozaki-r
Date: Wed Jul 2 09:51:08 UTC 2014
Modified Files:
src/sys/net: if_bridge.c
Log Message:
Protect bridge_list with a mutex
To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/net/if_bridge.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/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.85 src/sys/net/if_bridge.c:1.86
--- src/sys/net/if_bridge.c:1.85 Wed Jul 2 09:43:16 2014
+++ src/sys/net/if_bridge.c Wed Jul 2 09:51:08 2014
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: if_bridge.c,
#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 struct bridge_control bridg
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 @@ bridgeattach(int n)
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 @@ bridge_clone_create(struct if_clone *ifc
{
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 @@ bridge_clone_create(struct if_clone *ifc
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 @@ bridge_clone_destroy(struct ifnet *ifp)
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);