Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22113
b: refs/heads/master
c: e40cf35
h: refs/heads/master
i:
  22111: 029190a
v: v3
  • Loading branch information
YOSHIFUJI Hideaki authored and David S. Miller committed Mar 21, 2006
1 parent 237d386 commit 050e14b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fb9de91ea8035b99757d9f8a04aa058c982c361b
refs/heads/master: e40cf3533c712b941d4c8ebb3eca892d55c32c34
57 changes: 25 additions & 32 deletions trunk/net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,6 @@ int ip6_ins_rt(struct rt6_info *rt, struct nlmsghdr *nlh,
return err;
}

/* No rt6_lock! If COW failed, the function returns dead route entry
with dst->error set to errno value.
*/

static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *daddr,
struct in6_addr *saddr)
{
Expand Down Expand Up @@ -439,26 +435,6 @@ static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *dad
return rt;
}

static struct rt6_info *rt6_cow(struct rt6_info *ort, struct in6_addr *daddr,
struct in6_addr *saddr, struct netlink_skb_parms *req)
{
struct rt6_info *rt = rt6_alloc_cow(ort, daddr, saddr);
int err;

if (!rt) {
dst_hold(&ip6_null_entry.u.dst);
return &ip6_null_entry;
}

dst_hold(&rt->u.dst);

err = ip6_ins_rt(rt, NULL, NULL, req);
if (err)
rt->u.dst.error = err;

return rt;
}

static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *daddr)
{
struct rt6_info *rt = ip6_rt_copy(ort);
Expand Down Expand Up @@ -518,15 +494,23 @@ void ip6_route_input(struct sk_buff *skb)

if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) {
struct rt6_info *nrt;
int err;

nrt = rt6_cow(rt, &skb->nh.ipv6h->daddr,
&skb->nh.ipv6h->saddr,
&NETLINK_CB(skb));
nrt = rt6_alloc_cow(rt, &skb->nh.ipv6h->daddr,
&skb->nh.ipv6h->saddr);

dst_release(&rt->u.dst);
rt = nrt;
rt = nrt ? : &ip6_null_entry;

dst_hold(&rt->u.dst);
if (nrt) {
err = ip6_ins_rt(nrt, NULL, NULL,
&NETLINK_CB(skb));
if (!err)
goto out2;
}

if (rt->u.dst.error != -EEXIST || --attempts <= 0)
if (--attempts <= 0)
goto out2;

/* Race condition! In the gap, when rt6_lock was
Expand Down Expand Up @@ -582,13 +566,21 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)

if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) {
struct rt6_info *nrt;
int err;

nrt = rt6_cow(rt, &fl->fl6_dst, &fl->fl6_src, NULL);
nrt = rt6_alloc_cow(rt, &fl->fl6_dst, &fl->fl6_src);

dst_release(&rt->u.dst);
rt = nrt;
rt = nrt ? : &ip6_null_entry;

if (rt->u.dst.error != -EEXIST || --attempts <= 0)
dst_hold(&rt->u.dst);
if (nrt) {
err = ip6_ins_rt(nrt, NULL, NULL, NULL);
if (!err)
goto out2;
}

if (--attempts <= 0)
goto out2;

/* Race condition! In the gap, when rt6_lock was
Expand All @@ -597,6 +589,7 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
dst_release(&rt->u.dst);
goto relookup;
}

out2:
rt->u.dst.lastuse = jiffies;
rt->u.dst.__use++;
Expand Down

0 comments on commit 050e14b

Please sign in to comment.