diff options
| author | mlelstv <mlelstv@NetBSD.org> | 2018-11-04 08:48:01 +0000 |
|---|---|---|
| committer | mlelstv <mlelstv@NetBSD.org> | 2018-11-04 08:48:01 +0000 |
| commit | 82a0de2b335645f567e8923bc78d72301b89607c (patch) | |
| tree | 9a104be2e39211a2131493706f51ad67d712e074 /sys/netinet6/udp6_usrreq.c | |
| parent | f6efd98b8bdf54173e7aab9006c47ffbc0a75540 (diff) | |
Fix error path in ip6 source address selection.
in6_selectsrc previously returned a pointer to an ipv6 address,
the pointer was NULL in case of an error and is checked later
instead of the also returned error code. When in6_selectsrc was
changed to store the address into a buffer, the error code
was still ignored, but the buffer pointer was never set to NULL.
As a result send() to an ipv6 address on a system that isn't
configured for ipv6 no longer returns the expected EADDRAVAIL
but fails later in ip6_output with EOPNOTSUPP when trying to
send from an unspecified address. The wrong error code caused
BIND to log the unexpected errors.
Diffstat (limited to 'sys/netinet6/udp6_usrreq.c')
| -rw-r--r-- | sys/netinet6/udp6_usrreq.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index ee4fc6fdfb3..04caf8bbe6e 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -1,4 +1,4 @@ -/* $NetBSD: udp6_usrreq.c,v 1.141 2018/04/28 13:26:57 maxv Exp $ */ +/* $NetBSD: udp6_usrreq.c,v 1.142 2018/11/04 08:48:01 mlelstv Exp $ */ /* $KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $ */ /* $KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $ */ @@ -63,7 +63,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.141 2018/04/28 13:26:57 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.142 2018/11/04 08:48:01 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -763,7 +763,10 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m, in6p->in6p_moptions, &in6p->in6p_route, &in6p->in6p_laddr, &oifp, &psref, &_laddr); - /* XXX need error check? */ + if (error) + laddr = NULL; + else + laddr = &_laddr; if (oifp && scope_ambiguous && (error = in6_setscope(&sin6->sin6_addr, oifp, NULL))) { @@ -773,7 +776,6 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m, } if_put(oifp, &psref); curlwp_bindx(bound); - laddr = &_laddr; } else { /* * XXX: freebsd[34] does not have in_selectsrc, but |
