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_start_lock()



details:   https://anonhg.NetBSD.org/src/rev/b9fd256971e5
branches:  trunk
changeset: 346043:b9fd256971e5
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Jun 20 08:24:36 2016 +0000

description:
introduce if_start_lock()

if_start_lock() calls ifp->if_start() holding KERNEL_LOCK if it is required.

diffstat:

 sys/net/if.h |  22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diffs (36 lines):

diff -r 6c95d3a83af4 -r b9fd256971e5 sys/net/if.h
--- a/sys/net/if.h      Mon Jun 20 08:18:59 2016 +0000
+++ b/sys/net/if.h      Mon Jun 20 08:24:36 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.210 2016/06/20 08:18:59 knakahara Exp $       */
+/*     $NetBSD: if.h,v 1.211 2016/06/20 08:24:36 knakahara Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -406,6 +406,26 @@
                return ret;
        }
 }
+
+static inline bool
+if_start_is_mpsafe(struct ifnet *ifp)
+{
+
+       return ((ifp->if_extflags & IFEF_START_MPSAFE) != 0);
+}
+
+static inline void
+if_start_lock(struct ifnet *ifp)
+{
+
+       if (if_start_is_mpsafe(ifp)) {
+               (*ifp->if_start)(ifp);
+       } else {
+               KERNEL_LOCK(1, NULL);
+               (*ifp->if_start)(ifp);
+               KERNEL_UNLOCK_ONE(NULL);
+       }
+}
 #endif /* _KERNEL */
 
 #define        IFFBITS \



Home | Main Index | Thread Index | Old Index