Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net introduce if_output_lock()
details: https://anonhg.NetBSD.org/src/rev/021984f91df3
branches: trunk
changeset: 346029:021984f91df3
user: knakahara <knakahara%NetBSD.org@localhost>
date: Mon Jun 20 06:41:15 2016 +0000
description:
introduce if_output_lock()
if_output_lock() calls ifp->if_output() holding KERNEL_LOCK if it is required.
diffstat:
sys/net/if.h | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diffs (40 lines):
diff -r 193e603abcd2 -r 021984f91df3 sys/net/if.h
--- a/sys/net/if.h Mon Jun 20 06:35:05 2016 +0000
+++ b/sys/net/if.h Mon Jun 20 06:41:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.208 2016/06/20 06:35:05 knakahara Exp $ */
+/* $NetBSD: if.h,v 1.209 2016/06/20 06:41:15 knakahara Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -382,6 +382,30 @@
#define IFEF_OUTPUT_MPSAFE 0x0001 /* if_output() can run parallel */
#define IFEF_START_MPSAFE 0x0002 /* if_start() can run parallel */
+static inline bool
+if_output_is_mpsafe(struct ifnet *ifp)
+{
+
+ return ((ifp->if_extflags & IFEF_OUTPUT_MPSAFE) != 0);
+}
+
+static inline int
+if_output_lock(struct ifnet *cifp, struct ifnet *ifp, struct mbuf *m,
+ const struct sockaddr *dst, const struct rtentry *rt)
+{
+
+ if (if_output_is_mpsafe(cifp)) {
+ return (*cifp->if_output)(ifp, m, dst, rt);
+ } else {
+ int ret;
+
+ KERNEL_LOCK(1, NULL);
+ ret = (*cifp->if_output)(ifp, m, dst, rt);
+ KERNEL_UNLOCK_ONE(NULL);
+ return ret;
+ }
+}
+
#define IFFBITS \
"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS" \
"\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \
Home |
Main Index |
Thread Index |
Old Index