summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/netinet6/in6_pcb.c5
-rw-r--r--sys/netinet6/in6_src.c15
-rw-r--r--sys/netinet6/ip6_var.h6
-rw-r--r--sys/netinet6/raw_ip6.c8
-rw-r--r--sys/netinet6/udp6_usrreq.c4
5 files changed, 23 insertions, 15 deletions
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index b62c6af..85424b4 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -317,8 +317,9 @@ in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam,
* Is it the intended behavior?
*/
*plocal_addr6 = in6_selectsrc(sin6, inp->in6p_outputopts,
- inp->in6p_moptions, NULL,
- &inp->in6p_laddr, &ifp, &error);
+ inp, NULL,
+ inp->inp_socket->so_cred,
+ &ifp, &error);
if (ifp && scope_ambiguous &&
(error = in6_setscope(&sin6->sin6_addr, ifp, NULL)) != 0) {
return(error);
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index b6e2856..934ff15 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -170,8 +170,8 @@ static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
struct in6_addr *
in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
- struct ip6_moptions *mopts, struct route_in6 *ro,
- struct in6_addr *laddr, struct ifnet **ifpp, int *errorp)
+ struct inpcb *inp, struct route_in6 *ro, struct ucred *cred,
+ struct ifnet **ifpp, int *errorp)
{
struct in6_addr dst;
struct ifnet *ifp = NULL;
@@ -181,12 +181,18 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
struct in6_addrpolicy *dst_policy = NULL, *best_policy = NULL;
u_int32_t odstzone;
int prefer_tempaddr;
+ struct ip6_moptions *mopts;
dst = dstsock->sin6_addr; /* make a copy for local operation */
*errorp = 0;
if (ifpp)
*ifpp = NULL;
+ if (inp != NULL)
+ mopts = inp->in6p_moptions;
+ else
+ mopts = NULL;
+
/*
* If the source address is explicitly specified by the caller,
* check if the requested source address is indeed a unicast address
@@ -236,8 +242,9 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
/*
* Otherwise, if the socket has already bound the source, just use it.
*/
- if (laddr && !IN6_IS_ADDR_UNSPECIFIED(laddr))
- return (laddr);
+ if (inp != NULL && !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {
+ return (&inp->in6p_laddr);
+ }
/*
* If the address is not specified, choose the best one based on
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index dd6a384..2370737 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -391,9 +391,9 @@ int rip6_usrreq __P((struct socket *,
int dest6_input __P((struct mbuf **, int *, int));
int none_input __P((struct mbuf **, int *, int));
-struct in6_addr *in6_selectsrc __P((struct sockaddr_in6 *,
- struct ip6_pktopts *, struct ip6_moptions *, struct route_in6 *,
- struct in6_addr *, struct ifnet **, int *));
+struct in6_addr *in6_selectsrc __P((struct sockaddr_in6 *, struct ip6_pktopts *,
+ struct inpcb *inp, struct route_in6 *, struct ucred *cred,
+ struct ifnet **, int *));
int in6_selectroute __P((struct sockaddr_in6 *, struct ip6_pktopts *,
struct ip6_moptions *, struct route_in6 *, struct ifnet **,
struct rtentry **, int));
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 85f9f10..f9a7993 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -387,8 +387,8 @@ rip6_output(m, va_alist)
/*
* Source address selection.
*/
- if ((in6a = in6_selectsrc(dstsock, optp, in6p->in6p_moptions, NULL,
- &in6p->in6p_laddr, &oifp, &error)) == NULL) {
+ if ((in6a = in6_selectsrc(dstsock, optp, in6p, NULL, so->so_cred,
+ &oifp, &error)) == NULL) {
if (error == 0)
error = EADDRNOTAVAIL;
goto bad;
@@ -712,8 +712,8 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
INP_WLOCK(inp);
/* Source address selection. XXX: need pcblookup? */
in6a = in6_selectsrc(addr, inp->in6p_outputopts,
- inp->in6p_moptions, NULL,
- &inp->in6p_laddr, &ifp, &error);
+ inp, NULL, so->so_cred,
+ &ifp, &error);
if (in6a == NULL) {
INP_WUNLOCK(inp);
INP_INFO_WUNLOCK(&ripcbinfo);
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c
index 867e13b..03f5ee2 100644
--- a/sys/netinet6/udp6_usrreq.c
+++ b/sys/netinet6/udp6_usrreq.c
@@ -580,8 +580,8 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6,
}
if (!IN6_IS_ADDR_V4MAPPED(faddr)) {
- laddr = in6_selectsrc(sin6, optp, inp->in6p_moptions,
- NULL, &inp->in6p_laddr, &oifp, &error);
+ laddr = in6_selectsrc(sin6, optp, inp, NULL,
+ td->td_ucred, &oifp, &error);
if (oifp && scope_ambiguous &&
(error = in6_setscope(&sin6->sin6_addr,
oifp, NULL))) {
OpenPOWER on IntegriCloud