[PATCH] inetpeer: fix build failed when IPV6 not enabled

Gao feng gaofeng at cn.fujitsu.com
Sat Jun 9 02:12:53 UTC 2012


commit c8a627ed06d6d49bf65015a2185c519335c4c83f
(inetpeer: add namespace support for inetpeer)
makes kernel bulid failed when IPV6 not enabled.

fix this by adding #if IS_ENABLED(CONFIG_IPV6)

Reported-by: Fengguang Wu <wfg at linux.intel.com>
Signed-off-by: Gao feng <gaofeng at cn.fujitsu.com>
---
 net/ipv4/inetpeer.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 1c85273..57f694e 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -151,18 +151,19 @@ static int __net_init inetpeer_net_init(struct net *net)
 	net->ipv4.peers->root = peer_avl_empty_rcu;
 	seqlock_init(&net->ipv4.peers->lock);
 
+#if IS_ENABLED(CONFIG_IPV6)
 	net->ipv6.peers = kzalloc(sizeof(struct inet_peer_base),
 				  GFP_KERNEL);
-	if (net->ipv6.peers == NULL)
-		goto out_ipv6;
+	if (net->ipv6.peers == NULL) {
+		kfree(net->ipv4.peers);
+		return -ENOMEM;
+	}
 
 	net->ipv6.peers->root = peer_avl_empty_rcu;
 	seqlock_init(&net->ipv6.peers->lock);
+#endif
 
 	return 0;
-out_ipv6:
-	kfree(net->ipv4.peers);
-	return -ENOMEM;
 }
 
 static void __net_exit inetpeer_net_exit(struct net *net)
@@ -170,10 +171,11 @@ static void __net_exit inetpeer_net_exit(struct net *net)
 	inetpeer_invalidate_tree(net, AF_INET);
 	kfree(net->ipv4.peers);
 	net->ipv4.peers = NULL;
-
+#if IS_ENABLED(CONFIG_IPV6)
 	inetpeer_invalidate_tree(net, AF_INET6);
 	kfree(net->ipv6.peers);
 	net->ipv6.peers = NULL;
+#endif
 }
 
 static struct pernet_operations inetpeer_ops = {
@@ -433,7 +435,11 @@ static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base,
 static struct inet_peer_base *family_to_base(struct net *net,
 					     int family)
 {
+#if IS_ENABLED(CONFIG_IPV6)
 	return family == AF_INET ? net->ipv4.peers : net->ipv6.peers;
+#else
+	return net->ipv4.peers;
+#endif
 }
 
 /* perform garbage collect on all items stacked during a lookup */
-- 
1.7.7.6



More information about the Containers mailing list