summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-06-10 02:12:36 (GMT)
committerDavid S. Miller <davem@davemloft.net>2012-06-10 02:12:36 (GMT)
commitc0efc887dcadbdbfe171f028acfab9c7c00e9dde (patch)
treed2f628d6c222c6328a6f310378d7227c32ebf183 /net
parent8b51b064a6da90c68af5385a874968829a2a0ed7 (diff)
downloadlinux-c0efc887dcadbdbfe171f028acfab9c7c00e9dde.tar.xz
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@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/inetpeer.c9
-rw-r--r--net/ipv4/ip_fragment.c2
-rw-r--r--net/ipv4/route.c6
-rw-r--r--net/ipv6/route.c2
4 files changed, 6 insertions, 13 deletions
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