[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20120609.221801.2226110181753212240.davem@davemloft.net>
Date: Sat, 09 Jun 2012 22:18:01 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: wfg@...ux.intel.com
Cc: netdev@...r.kernel.org, gaofeng@...fujitsu.com,
containers@...ts.linux-foundation.org
Subject: Re: [PATCH] inet: Initialize per-netns inetpeer roots in
net/ipv{4,6}/route.c
From: David Miller <davem@...emloft.net>
Date: Sat, 09 Jun 2012 19:09:29 -0700 (PDT)
> From: Fengguang Wu <wfg@...ux.intel.com>
> Date: Sun, 10 Jun 2012 10:08:01 +0800
>
>> And in another config, an old error still triggers:
>>
>> net/ipv4/inetpeer.c: In function ‘family_to_base’:
>> net/ipv4/inetpeer.c:397:50: error: ‘struct net’ has no member named ‘ipv6’
>> net/ipv4/inetpeer.c:398:1: warning: control reaches end of non-void function [-Wreturn-type]
>>
>> I'm building this patch on top of net-next master.
>
> What a fucking mess Gao created, I'll fix this.
>
> Thanks for the report.
I just pushed the following to net-next:
--------------------
inet: Pass inetpeer root into inet_getpeer*() interfaces.
Otherwise we reference potentially non-existing members when
ipv6 is disabled.
Signed-off-by: David S. Miller <davem@...emloft.net>
---
include/net/inetpeer.h | 10 +++++-----
net/ipv4/inetpeer.c | 9 +--------
net/ipv4/ip_fragment.c | 2 +-
net/ipv4/route.c | 6 +++---
net/ipv6/route.c | 2 +-
5 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index 733edc6..b84b32f 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -83,11 +83,11 @@ static inline bool inet_metrics_new(const struct inet_peer *p)
}
/* can be called with or without local BH being disabled */
-struct inet_peer *inet_getpeer(struct net *net,
+struct inet_peer *inet_getpeer(struct inet_peer_base *base,
const struct inetpeer_addr *daddr,
int create);
-static inline struct inet_peer *inet_getpeer_v4(struct net *net,
+static inline struct inet_peer *inet_getpeer_v4(struct inet_peer_base *base,
__be32 v4daddr,
int create)
{
@@ -95,10 +95,10 @@ static inline struct inet_peer *inet_getpeer_v4(struct net *net,
daddr.addr.a4 = v4daddr;
daddr.family = AF_INET;
- return inet_getpeer(net, &daddr, create);
+ return inet_getpeer(base, &daddr, create);
}
-static inline struct inet_peer *inet_getpeer_v6(struct net *net,
+static inline struct inet_peer *inet_getpeer_v6(struct inet_peer_base *base,
const struct in6_addr *v6daddr,
int create)
{
@@ -106,7 +106,7 @@ static inline struct inet_peer *inet_getpeer_v6(struct net *net,
*(struct in6_addr *)daddr.addr.a6 = *v6daddr;
daddr.family = AF_INET6;
- return inet_getpeer(net, &daddr, create);
+ return inet_getpeer(base, &daddr, create);
}
/* can be called from BH context or outside */
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 9d89a38..e4cba56 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -391,12 +391,6 @@ static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base,
call_rcu(&p->rcu, inetpeer_free_rcu);
}
-static struct inet_peer_base *family_to_base(struct net *net,
- int family)
-{
- return family == AF_INET ? net->ipv4.peers : net->ipv6.peers;
-}
-
/* perform garbage collect on all items stacked during a lookup */
static int inet_peer_gc(struct inet_peer_base *base,
struct inet_peer __rcu **stack[PEER_MAXDEPTH],
@@ -434,12 +428,11 @@ static int inet_peer_gc(struct inet_peer_base *base,
return cnt;
}
-struct inet_peer *inet_getpeer(struct net *net,
+struct inet_peer *inet_getpeer(struct inet_peer_base *base,
const struct inetpeer_addr *daddr,
int create)
{
struct inet_peer __rcu **stack[PEER_MAXDEPTH], ***stackptr;
- struct inet_peer_base *base = family_to_base(net, daddr->family);
struct inet_peer *p;
unsigned int sequence;
int invalidated, gccnt = 0;
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 22c6bab..8d07c97 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -184,7 +184,7 @@ static void ip4_frag_init(struct inet_frag_queue *q, void *a)
qp->daddr = arg->iph->daddr;
qp->user = arg->user;
qp->peer = sysctl_ipfrag_max_dist ?
- inet_getpeer_v4(net, arg->iph->saddr, 1) : NULL;
+ inet_getpeer_v4(net->ipv4.peers, arg->iph->saddr, 1) : NULL;
}
static __inline__ void ip4_frag_free(struct inet_frag_queue *q)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index cf78343..2aa663a 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1328,7 +1328,7 @@ void rt_bind_peer(struct rtable *rt, __be32 daddr, int create)
struct net *net = dev_net(rt->dst.dev);
struct inet_peer *peer;
- peer = inet_getpeer_v4(net, daddr, create);
+ peer = inet_getpeer_v4(net->ipv4.peers, daddr, create);
if (peer && cmpxchg(&rt->peer, NULL, peer) != NULL)
inet_putpeer(peer);
@@ -1684,7 +1684,7 @@ unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph,
unsigned short est_mtu = 0;
struct inet_peer *peer;
- peer = inet_getpeer_v4(net, iph->daddr, 1);
+ peer = inet_getpeer_v4(net->ipv4.peers, iph->daddr, 1);
if (peer) {
unsigned short mtu = new_mtu;
@@ -1929,7 +1929,7 @@ static void rt_init_metrics(struct rtable *rt, const struct flowi4 *fl4,
if (fl4 && (fl4->flowi4_flags & FLOWI_FLAG_PRECOW_METRICS))
create = 1;
- rt->peer = peer = inet_getpeer_v4(net, rt->rt_dst, create);
+ rt->peer = peer = inet_getpeer_v4(net->ipv4.peers, rt->rt_dst, create);
if (peer) {
rt->rt_peer_genid = rt_peer_genid();
if (inet_metrics_new(peer))
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9586c27..8fc41d5 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -306,7 +306,7 @@ void rt6_bind_peer(struct rt6_info *rt, int create)
struct net *net = dev_net(rt->dst.dev);
struct inet_peer *peer;
- peer = inet_getpeer_v6(net, &rt->rt6i_dst.addr, create);
+ peer = inet_getpeer_v6(net->ipv6.peers, &rt->rt6i_dst.addr, create);
if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL)
inet_putpeer(peer);
else
--
1.7.10
Powered by blists - more mailing lists