Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Protect vlan_unconfig with a mutex
details: https://anonhg.NetBSD.org/src/rev/0654b7ddf0fa
branches: trunk
changeset: 332892:0654b7ddf0fa
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Sat Oct 11 10:16:49 2014 +0000
description:
Protect vlan_unconfig with a mutex
It is not thread-safe but is likely to be executed in concurrent.
See PR 49264 for more detail.
diffstat:
sys/net/if_vlan.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diffs (66 lines):
diff -r 73a47c2b4b83 -r 0654b7ddf0fa sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Sat Oct 11 10:06:15 2014 +0000
+++ b/sys/net/if_vlan.c Sat Oct 11 10:16:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vlan.c,v 1.75 2014/10/09 04:48:12 ozaki-r Exp $ */
+/* $NetBSD: if_vlan.c,v 1.76 2014/10/11 10:16:49 ozaki-r Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.75 2014/10/09 04:48:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.76 2014/10/11 10:16:49 ozaki-r Exp $");
#include "opt_inet.h"
@@ -91,6 +91,7 @@
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/kauth.h>
+#include <sys/mutex.h>
#include <net/bpf.h>
#include <net/if.h>
@@ -180,6 +181,8 @@
/* XXX This should be a hash table with the tag as the basis of the key. */
static LIST_HEAD(, ifvlan) ifv_list;
+static kmutex_t ifv_mtx __cacheline_aligned;
+
struct if_clone vlan_cloner =
IF_CLONE_INITIALIZER("vlan", vlan_clone_create, vlan_clone_destroy);
@@ -191,6 +194,7 @@
{
LIST_INIT(&ifv_list);
+ mutex_init(&ifv_mtx, MUTEX_DEFAULT, IPL_NONE);
if_clone_attach(&vlan_cloner);
}
@@ -359,8 +363,12 @@
{
struct ifvlan *ifv = ifp->if_softc;
- if (ifv->ifv_p == NULL)
+ mutex_enter(&ifv_mtx);
+
+ if (ifv->ifv_p == NULL) {
+ mutex_exit(&ifv_mtx);
return;
+ }
/*
* Since the interface is being unconfigured, we need to empty the
@@ -412,6 +420,8 @@
if_down(ifp);
ifp->if_flags &= ~(IFF_UP|IFF_RUNNING);
ifp->if_capabilities = 0;
+
+ mutex_exit(&ifv_mtx);
}
/*
Home |
Main Index |
Thread Index |
Old Index