datapath: Add rtnl_is_locked compatibility function.
authorJesse Gross <jesse@nicira.com>
Sun, 11 Apr 2010 13:52:40 +0000 (09:52 -0400)
committerJesse Gross <jesse@nicira.com>
Mon, 19 Apr 2010 13:11:56 +0000 (09:11 -0400)
rtnl_is_locked wasn't added until 2.6.26 so provide an implementation
of it.

datapath/linux-2.6/compat-2.6/include/linux/rtnetlink.h

index 4d7bd78..dcee318 100644 (file)
@@ -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 */