Commit fb9de91e authored by YOSHIFUJI Hideaki's avatar YOSHIFUJI Hideaki Committed by David S. Miller

[IPV6]: ROUTE: Clean up reference counting / unlocking for returning object.

Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d5315b50
...@@ -478,7 +478,6 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *d ...@@ -478,7 +478,6 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *d
if (rt == &ip6_null_entry && strict) { \ if (rt == &ip6_null_entry && strict) { \
while ((fn = fn->parent) != NULL) { \ while ((fn = fn->parent) != NULL) { \
if (fn->fn_flags & RTN_ROOT) { \ if (fn->fn_flags & RTN_ROOT) { \
dst_hold(&rt->u.dst); \
goto out; \ goto out; \
} \ } \
if (fn->fn_flags & RTN_RTINFO) \ if (fn->fn_flags & RTN_RTINFO) \
...@@ -508,17 +507,17 @@ void ip6_route_input(struct sk_buff *skb) ...@@ -508,17 +507,17 @@ void ip6_route_input(struct sk_buff *skb)
if ((rt->rt6i_flags & RTF_CACHE)) { if ((rt->rt6i_flags & RTF_CACHE)) {
rt = rt6_device_match(rt, skb->dev->ifindex, strict); rt = rt6_device_match(rt, skb->dev->ifindex, strict);
BACKTRACK(); BACKTRACK();
dst_hold(&rt->u.dst);
goto out; goto out;
} }
rt = rt6_device_match(rt, skb->dev->ifindex, strict); rt = rt6_device_match(rt, skb->dev->ifindex, strict);
BACKTRACK(); BACKTRACK();
dst_hold(&rt->u.dst);
read_unlock_bh(&rt6_lock);
if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) { if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) {
struct rt6_info *nrt; struct rt6_info *nrt;
dst_hold(&rt->u.dst);
read_unlock_bh(&rt6_lock);
nrt = rt6_cow(rt, &skb->nh.ipv6h->daddr, nrt = rt6_cow(rt, &skb->nh.ipv6h->daddr,
&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->saddr,
...@@ -536,14 +535,16 @@ void ip6_route_input(struct sk_buff *skb) ...@@ -536,14 +535,16 @@ void ip6_route_input(struct sk_buff *skb)
dst_release(&rt->u.dst); dst_release(&rt->u.dst);
goto relookup; goto relookup;
} }
dst_hold(&rt->u.dst);
out:
read_unlock_bh(&rt6_lock);
out2: out2:
rt->u.dst.lastuse = jiffies; rt->u.dst.lastuse = jiffies;
rt->u.dst.__use++; rt->u.dst.__use++;
skb->dst = (struct dst_entry *) rt; skb->dst = (struct dst_entry *) rt;
return;
out:
dst_hold(&rt->u.dst);
read_unlock_bh(&rt6_lock);
goto out2;
} }
struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl) struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
...@@ -566,7 +567,6 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl) ...@@ -566,7 +567,6 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
if ((rt->rt6i_flags & RTF_CACHE)) { if ((rt->rt6i_flags & RTF_CACHE)) {
rt = rt6_device_match(rt, fl->oif, strict); rt = rt6_device_match(rt, fl->oif, strict);
BACKTRACK(); BACKTRACK();
dst_hold(&rt->u.dst);
goto out; goto out;
} }
if (rt->rt6i_flags & RTF_DEFAULT) { if (rt->rt6i_flags & RTF_DEFAULT) {
...@@ -577,10 +577,11 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl) ...@@ -577,10 +577,11 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
BACKTRACK(); BACKTRACK();
} }
dst_hold(&rt->u.dst);
read_unlock_bh(&rt6_lock);
if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) { if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) {
struct rt6_info *nrt; struct rt6_info *nrt;
dst_hold(&rt->u.dst);
read_unlock_bh(&rt6_lock);
nrt = rt6_cow(rt, &fl->fl6_dst, &fl->fl6_src, NULL); nrt = rt6_cow(rt, &fl->fl6_dst, &fl->fl6_src, NULL);
...@@ -596,14 +597,14 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl) ...@@ -596,14 +597,14 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
dst_release(&rt->u.dst); dst_release(&rt->u.dst);
goto relookup; goto relookup;
} }
dst_hold(&rt->u.dst);
out:
read_unlock_bh(&rt6_lock);
out2: out2:
rt->u.dst.lastuse = jiffies; rt->u.dst.lastuse = jiffies;
rt->u.dst.__use++; rt->u.dst.__use++;
return &rt->u.dst; return &rt->u.dst;
out:
dst_hold(&rt->u.dst);
read_unlock_bh(&rt6_lock);
goto out2;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment