Module Name: src
Committed By: ozaki-r
Date: Sat Oct 11 10:16:49 UTC 2014
Modified Files:
src/sys/net: if_vlan.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/net/if_vlan.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_vlan.c
diff -u src/sys/net/if_vlan.c:1.75 src/sys/net/if_vlan.c:1.76
--- src/sys/net/if_vlan.c:1.75 Thu Oct 9 04:48:12 2014
+++ src/sys/net/if_vlan.c Sat Oct 11 10:16:49 2014
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v
#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 @@ void vlanattach(int);
/* 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 @@ vlanattach(int n)
{
LIST_INIT(&ifv_list);
+ mutex_init(&ifv_mtx, MUTEX_DEFAULT, IPL_NONE);
if_clone_attach(&vlan_cloner);
}
@@ -359,8 +363,12 @@ vlan_unconfig(struct ifnet *ifp)
{
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 @@ vlan_unconfig(struct ifnet *ifp)
if_down(ifp);
ifp->if_flags &= ~(IFF_UP|IFF_RUNNING);
ifp->if_capabilities = 0;
+
+ mutex_exit(&ifv_mtx);
}
/*