[ovs-dev] [PATCH 03/16] datapath: Add rtnl_is_locked compatibility function.

Jesse Gross jesse at nicira.com
Tue Apr 13 14:41:05 UTC 2010


rtnl_is_locked wasn't added until 2.6.26 so provide an implementation
of it.
---
 .../linux-2.6/compat-2.6/include/linux/rtnetlink.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/datapath/linux-2.6/compat-2.6/include/linux/rtnetlink.h b/datapath/linux-2.6/compat-2.6/include/linux/rtnetlink.h
index 4d7bd78..dcee318 100644
--- a/datapath/linux-2.6/compat-2.6/include/linux/rtnetlink.h
+++ b/datapath/linux-2.6/compat-2.6/include/linux/rtnetlink.h
@@ -30,4 +30,17 @@ static inline void rtnl_set_sk_err(struct net *net, u32 group, int error)
 	((void) rtnl_notify(skb, net, pid, group, nlh, flags))
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
+static inline int rtnl_is_locked(void)
+{
+	if (unlikely(rtnl_trylock())) {
+		rtnl_unlock();
+		return 0;
+	}
+
+	return 1;
+}
+
+#endif
+
 #endif /* linux/rtnetlink.h wrapper */
-- 
1.6.3.3





More information about the dev mailing list