summaryrefslogtreecommitdiff
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-05-15 12:26:01 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-05-15 12:26:01 +0000
commit0fd09d947c319161c5f82677a302896ccec23406 (patch)
tree629e31aca9da15bfe31f0d735efbfd8b07a1c680 /sys/net/if.c
parentae80f51fcf7ad6757bb25f49546f7463a0ae3043 (diff)
Enable the NET_LOCK(), take 3.
Recursions are still marked as XXXSMP. ok deraadt@, bluhm@
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 5f7fb91aa97..9d03d8a1d2e 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.495 2017/05/09 09:31:07 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.496 2017/05/15 12:26:00 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -230,6 +230,12 @@ struct taskq *softnettq;
struct task if_input_task_locked = TASK_INITIALIZER(if_netisr, NULL);
/*
+ * Serialize socket operations to ensure no new sleeping points
+ * are introduced in IP output paths.
+ */
+struct rwlock netlock = RWLOCK_INITIALIZER("netlock");
+
+/*
* Network interface utility routines.
*/
void
@@ -1146,7 +1152,10 @@ if_clone_create(const char *name, int rdomain)
if (ifunit(name) != NULL)
return (EEXIST);
+ /* XXXSMP breaks atomicity */
+ rw_exit_write(&netlock);
ret = (*ifc->ifc_create)(ifc, unit);
+ rw_enter_write(&netlock);
if (ret != 0 || (ifp = ifunit(name)) == NULL)
return (ret);
@@ -1188,7 +1197,10 @@ if_clone_destroy(const char *name)
splx(s);
}
+ /* XXXSMP breaks atomicity */
+ rw_exit_write(&netlock);
ret = (*ifc->ifc_destroy)(ifp);
+ rw_enter_write(&netlock);
return (ret);
}