diff options
author | 2014-04-18 10:48:29 +0000 | |
---|---|---|
committer | 2014-04-18 10:48:29 +0000 | |
commit | 0039ae5121f443fb1a694aa0cd205482e690200f (patch) | |
tree | 6d779b7c1d3700405ef8ed9a1630d3e20ca045cb /sys/netinet6/raw_ip6.c | |
parent | stop testing altq stuffz (diff) | |
download | wireguard-openbsd-0039ae5121f443fb1a694aa0cd205482e690200f.tar.xz wireguard-openbsd-0039ae5121f443fb1a694aa0cd205482e690200f.zip |
Invert the signature logic of in{,6}_selectsrc, make them return the
error code and pass the resulting source address back to the caller
through a pointer, as suggested by chrisz. This gives us more readable
code, and eases the deletion of useless checks in the callers' error path.
Add a bunch of "0 -> NULL" conversions, while here.
ok chrisz@ mpi@
Diffstat (limited to 'sys/netinet6/raw_ip6.c')
-rw-r--r-- | sys/netinet6/raw_ip6.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 36ccd5afa5b..281ddc77ba9 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.65 2014/04/14 09:06:42 mpi Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.66 2014/04/18 10:48:30 jca Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -413,13 +413,12 @@ rip6_output(struct mbuf *m, ...) { struct in6_addr *in6a; - if ((in6a = in6_selectsrc(dstsock, optp, in6p->inp_moptions6, - &in6p->inp_route6, &in6p->inp_laddr6, &error, - in6p->inp_rtableid)) == 0) { - if (error == 0) - error = EADDRNOTAVAIL; + error = in6_selectsrc(&in6a, dstsock, optp, + in6p->inp_moptions6, &in6p->inp_route6, &in6p->inp_laddr6, + in6p->inp_rtableid); + if (error) goto bad; - } + ip6->ip6_src = *in6a; if (in6p->inp_route6.ro_rt && in6p->inp_route6.ro_rt->rt_flags & RTF_UP) @@ -722,14 +721,11 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, } /* Source address selection. XXX: need pcblookup? */ - in6a = in6_selectsrc(addr, in6p->inp_outputopts6, + error = in6_selectsrc(&in6a, addr, in6p->inp_outputopts6, in6p->inp_moptions6, &in6p->inp_route6, - &in6p->inp_laddr6, &error, in6p->inp_rtableid); - if (in6a == NULL) { - if (error == 0) - error = EADDRNOTAVAIL; + &in6p->inp_laddr6, in6p->inp_rtableid); + if (error) break; - } in6p->inp_laddr6 = *in6a; in6p->inp_faddr6 = addr->sin6_addr; soisconnected(so); |