[ovs-dev] [PATCH 04/16] datapath: Don't read net namespace on kernels that don't use them.

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


Use macros to eliminate the network namespace argument before it
gets to the compiler.  This allows us to specify a namespace on
kernels that know about them and prevent the compiler from complaining
on kernels that don't.
---
 .../linux-2.6/compat-2.6/include/linux/rtnetlink.h |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 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 dcee318..73d7f90 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
@@ -3,9 +3,11 @@
 
 #include_next <linux/rtnetlink.h>
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static inline void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
-			      u32 group, struct nlmsghdr *nlh, gfp_t flags)
+static inline void rtnl_notify(struct sk_buff *skb, u32 pid, u32 group,
+			       struct nlmsghdr *nlh, gfp_t flags)
 {
 	BUG_ON(nlh);		/* not implemented */
 	if (group) {
@@ -14,20 +16,21 @@ static inline void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
 	}
 }
 
-static inline void rtnl_set_sk_err(struct net *net, u32 group, int error)
+static inline void rtnl_set_sk_err(u32 group, int error)
 {
 	netlink_set_err(rtnl, 0, group, error);
 }
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#endif
+
 /* No 'net' parameter in these versions. */
 #define rtnl_notify(skb, net, pid, group, nlh, flags) \
-	((void) (net), (void) rtnl_notify(skb, pid, group, nlh, flags))
+		    ((void) rtnl_notify((skb), (pid), (group), (nlh), (flags)))
 #define rtnl_set_sk_err(net, group, error) \
-	((void) (net), rtnl_set_sk_err(group, error))
+			(rtnl_set_sk_err((group), (error)))
 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
 /* Make the return type effectively 'void' to match Linux 2.6.30+. */
 #define rtnl_notify(skb, net, pid, group, nlh, flags) \
-	((void) rtnl_notify(skb, net, pid, group, nlh, flags))
+	((void) rtnl_notify((skb), (net), (pid), (group), (nlh), (flags)))
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
-- 
1.6.3.3





More information about the dev mailing list