* [PATCH] inetpeer: fix build failed when IPV6 not enabled
@ 2012-06-09 2:12 Gao feng
2012-06-09 5:20 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Gao feng @ 2012-06-09 2:12 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
wfg-VuQAYsv1563Yd54FQh9/CA
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-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] inetpeer: fix build failed when IPV6 not enabled
2012-06-09 2:12 [PATCH] inetpeer: fix build failed when IPV6 not enabled Gao feng
@ 2012-06-09 5:20 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-06-09 5:20 UTC (permalink / raw)
To: gaofeng; +Cc: netdev, containers, wfg
From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Sat, 9 Jun 2012 10:12:53 +0800
> fix this by adding #if IS_ENABLED(CONFIG_IPV6)
There is not a single UGLY ifdef in inetpeer.c, and I am not going to
allow you to start crapping it up with ifdefs now.
We support ipv6 just fine without ifdefs before your network namespace
changes, so you need to find a way to continue dong so afterwards.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-09 5:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-09 2:12 [PATCH] inetpeer: fix build failed when IPV6 not enabled Gao feng
2012-06-09 5:20 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).