Skip to content

Commit

Permalink
[IPV6]: Make sure error handling is done when calling ip6_route_outpu…
Browse files Browse the repository at this point in the history
…t().

As ip6_route_output() never returns NULL, error checking must be done by
looking at dst->error in stead of comparing dst against NULL.

Signed-off-by: Ville Nuorvala <vnuorval@tcs.hut.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ville Nuorvala authored and David S. Miller committed Oct 19, 2006
1 parent 23c435f commit 4251320
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions net/ipv6/xfrm6_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
static struct dst_ops xfrm6_dst_ops;
static struct xfrm_policy_afinfo xfrm6_policy_afinfo;

static int xfrm6_dst_lookup(struct xfrm_dst **dst, struct flowi *fl)
static int xfrm6_dst_lookup(struct xfrm_dst **xdst, struct flowi *fl)
{
int err = 0;
*dst = (struct xfrm_dst*)ip6_route_output(NULL, fl);
if (!*dst)
err = -ENETUNREACH;
struct dst_entry *dst = ip6_route_output(NULL, fl);
int err = dst->error;
if (!err)
*xdst = (struct xfrm_dst *) dst;
else
dst_release(dst);
return err;
}

Expand Down
10 changes: 5 additions & 5 deletions net/sctp/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,17 @@ static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
}

dst = ip6_route_output(NULL, &fl);
if (dst) {
if (!dst->error) {
struct rt6_info *rt;
rt = (struct rt6_info *)dst;
SCTP_DEBUG_PRINTK(
"rt6_dst:" NIP6_FMT " rt6_src:" NIP6_FMT "\n",
NIP6(rt->rt6i_dst.addr), NIP6(rt->rt6i_src.addr));
} else {
SCTP_DEBUG_PRINTK("NO ROUTE\n");
return dst;
}

return dst;
SCTP_DEBUG_PRINTK("NO ROUTE\n");
dst_release(dst);
return NULL;
}

/* Returns the number of consecutive initial bits that match in the 2 ipv6
Expand Down

0 comments on commit 4251320

Please sign in to comment.