diff options
| author | Bjoern A. Zeeb <bz@FreeBSD.org> | 2008-08-02 14:55:58 +0000 |
|---|---|---|
| committer | Bjoern A. Zeeb <bz@FreeBSD.org> | 2008-08-02 14:55:58 +0000 |
| commit | 0bee74b86365d7266e25fc9cee0ba0e67b966f2d (patch) | |
| tree | 6ec2894bf983761757b230c45323f4516f442424 /sys/netinet6 | |
| parent | 83ea558e37b506dc28a93690bdee025b281fa150 (diff) | |
Notes
Diffstat (limited to 'sys/netinet6')
| -rw-r--r-- | sys/netinet6/in6_pcb.c | 5 | ||||
| -rw-r--r-- | sys/netinet6/in6_src.c | 17 | ||||
| -rw-r--r-- | sys/netinet6/ip6_var.h | 6 | ||||
| -rw-r--r-- | sys/netinet6/raw_ip6.c | 8 | ||||
| -rw-r--r-- | sys/netinet6/udp6_usrreq.c | 4 |
5 files changed, 25 insertions, 15 deletions
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 28e28d604c15..7f4c7b32fc1b 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -316,8 +316,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 d3a4a3d2cb5c..651ed9df2187 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -164,8 +164,8 @@ static struct in6_addrpolicy *match_addrsel_policy __P((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; @@ -175,12 +175,20 @@ 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) { + INP_LOCK_ASSERT(inp); + 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 @@ -230,8 +238,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 bf7e3ef49ef5..b0858f8ba029 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 96049d67049e..b08d51532d73 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -384,8 +384,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; @@ -696,8 +696,8 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) INP_LOCK(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_UNLOCK(inp); INP_INFO_WUNLOCK(&ripcbinfo); diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index a79d3754ee12..035bcd170a79 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -577,8 +577,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))) { |
