[ovs-dev] [PATCH 3/4] datapath: Fix use of rtnl_notify() with Linux 2.6.31.

Ben Pfaff blp at nicira.com
Mon Oct 12 18:14:29 UTC 2009


Linux 2.6.31 changes the return type of rtnl_notify() from 'int' to 'void',
so cope with that.  (All the other callers of rtnl_notify() in Linux 2.6.31
also just return without further checking after calling  it.)
---
 datapath/datapath.c                                |    3 ++-
 .../linux-2.6/compat-2.6/include/linux/rtnetlink.h |   14 ++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index abc5599..aea8cc9 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -165,7 +165,8 @@ static void dp_ifinfo_notify(int event, struct net_bridge_port *port)
 		kfree_skb(skb);
 		goto errout;
 	}
-	err = rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_KERNEL);
+	rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_KERNEL);
+	return;
 errout:
 	if (err < 0)
 		rtnl_set_sk_err(net, RTNLGRP_LINK, err);
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 8bc5156..4af8ab2 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
@@ -4,7 +4,8 @@
 #include_next <linux/rtnetlink.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static inline int rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
+/* Before 2.6.19, rtnl_notify() didn't exist at all, so we implement it. */
+static inline void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
 			      u32 group, struct nlmsghdr *nlh, gfp_t flags)
 {
 	BUG_ON(nlh);		/* not implemented */
@@ -12,7 +13,6 @@ static inline int rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
 		/* errors reported via destination sk->sk_err */
 		nlmsg_multicast(rtnl, skb, 0, group);
 	}
-	return 0;
 }
 
 static inline void rtnl_set_sk_err(struct net *net, u32 group, int error)
@@ -20,10 +20,16 @@ static inline void rtnl_set_sk_err(struct net *net, u32 group, int error)
 	netlink_set_err(rtnl, 0, group, error);
 }
 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+/* Before 2.6.25, rtnl_notify() didn't take a 'net' argument, so drop it. */
 #define rtnl_notify(skb, net, pid, group, nlh, flags) \
-	((void) (net), rtnl_notify(skb, pid, group, nlh, flags))
+	((void) (net), (void) rtnl_notify(skb, pid, group, nlh, flags))
 #define rtnl_set_sk_err(net, group, error) \
 	((void) (net), rtnl_set_sk_err(group, error))
-#endif /* linux kernel < 2.6.25 */
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+/* Before 2.6.31, rtnl_notify() returned an 'int', so cast it to 'void' for
+ * consistency. */
+#define rtnl_notify(skb, net, pid, group, nlh, flags) \
+	((void) rtnl_notify(skb, net, pid, group, nlh, flags))
+#endif
 
 #endif /* linux/rtnetlink.h wrapper */
-- 
1.6.3.3





More information about the dev mailing list