summaryrefslogtreecommitdiff
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-03-02 13:27:41 -0800
committerDavid S. Miller <davem@davemloft.net>2011-03-02 13:27:41 -0800
commit452edd598f60522c11f7f88fdbab27eb36509d1a (patch)
treedf1510e9848e591a412c8bfa724253470c48c4c2 /net/ipv4
parent3872b284087081ee5cb0e4630954c2f7a2153cf5 (diff)
downloadlinux-3.10-452edd598f60522c11f7f88fdbab27eb36509d1a.tar.gz
linux-3.10-452edd598f60522c11f7f88fdbab27eb36509d1a.tar.bz2
linux-3.10-452edd598f60522c11f7f88fdbab27eb36509d1a.zip
xfrm: Return dst directly from xfrm_lookup()
Instead of on the stack. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/icmp.c36
-rw-r--r--net/ipv4/netfilter.c6
-rw-r--r--net/ipv4/route.c7
3 files changed, 24 insertions, 25 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 2a86c8951dc..c23bd8cdeee 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -398,18 +398,14 @@ static struct rtable *icmp_route_lookup(struct net *net, struct sk_buff *skb_in,
if (!fl.fl4_src)
fl.fl4_src = rt->rt_src;
- err = xfrm_lookup(net, (struct dst_entry **)&rt, &fl, NULL, 0);
- switch (err) {
- case 0:
+ rt = (struct rtable *) xfrm_lookup(net, &rt->dst, &fl, NULL, 0);
+ if (!IS_ERR(rt)) {
if (rt != rt2)
return rt;
- break;
- case -EPERM:
+ } else if (PTR_ERR(rt) == -EPERM) {
rt = NULL;
- break;
- default:
- return ERR_PTR(err);
- }
+ } else
+ return rt;
err = xfrm_decode_session_reverse(skb_in, &fl, AF_INET);
if (err)
@@ -438,22 +434,18 @@ static struct rtable *icmp_route_lookup(struct net *net, struct sk_buff *skb_in,
if (err)
goto relookup_failed;
- err = xfrm_lookup(net, (struct dst_entry **)&rt2, &fl, NULL,
- XFRM_LOOKUP_ICMP);
- switch (err) {
- case 0:
+ rt2 = (struct rtable *) xfrm_lookup(net, &rt2->dst, &fl, NULL, XFRM_LOOKUP_ICMP);
+ if (!IS_ERR(rt2)) {
dst_release(&rt->dst);
rt = rt2;
- break;
- case -EPERM:
- return ERR_PTR(err);
- default:
- if (!rt)
- return ERR_PTR(err);
- break;
+ } else if (PTR_ERR(rt2) == -EPERM) {
+ if (rt)
+ dst_release(&rt->dst);
+ return rt2;
+ } else {
+ err = PTR_ERR(rt2);
+ goto relookup_failed;
}
-
-
return rt;
relookup_failed:
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
index 994a1f29ebb..9770bb42795 100644
--- a/net/ipv4/netfilter.c
+++ b/net/ipv4/netfilter.c
@@ -69,7 +69,8 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type)
xfrm_decode_session(skb, &fl, AF_INET) == 0) {
struct dst_entry *dst = skb_dst(skb);
skb_dst_set(skb, NULL);
- if (xfrm_lookup(net, &dst, &fl, skb->sk, 0))
+ dst = xfrm_lookup(net, dst, &fl, skb->sk, 0);
+ if (IS_ERR(dst))
return -1;
skb_dst_set(skb, dst);
}
@@ -102,7 +103,8 @@ int ip_xfrm_me_harder(struct sk_buff *skb)
dst = ((struct xfrm_dst *)dst)->route;
dst_hold(dst);
- if (xfrm_lookup(dev_net(dst->dev), &dst, &fl, skb->sk, 0) < 0)
+ dst = xfrm_lookup(dev_net(dst->dev), dst, &fl, skb->sk, 0);
+ if (IS_ERR(dst))
return -1;
skb_dst_drop(skb);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index e24e4cf2a11..63d37004ee6 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2730,7 +2730,12 @@ int ip_route_output_flow(struct net *net, struct rtable **rp, struct flowi *flp,
flp->fl4_src = (*rp)->rt_src;
if (!flp->fl4_dst)
flp->fl4_dst = (*rp)->rt_dst;
- return xfrm_lookup(net, (struct dst_entry **)rp, flp, sk, 0);
+ *rp = (struct rtable *) xfrm_lookup(net, &(*rp)->dst, flp, sk, 0);
+ if (IS_ERR(*rp)) {
+ err = PTR_ERR(*rp);
+ *rp = NULL;
+ return err;
+ }
}
return 0;