Module Name: src Committed By: knakahara Date: Mon Jun 20 06:41:15 UTC 2016
Modified Files: src/sys/net: if.h Log Message: introduce if_output_lock() if_output_lock() calls ifp->if_output() holding KERNEL_LOCK if it is required. To generate a diff of this commit: cvs rdiff -u -r1.208 -r1.209 src/sys/net/if.h 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.h diff -u src/sys/net/if.h:1.208 src/sys/net/if.h:1.209 --- src/sys/net/if.h:1.208 Mon Jun 20 06:35:05 2016 +++ src/sys/net/if.h Mon Jun 20 06:41:15 2016 @@ -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 @@ typedef struct ifnet { #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" \