Reduce the number of local variables. Remove redundant check that inp
pointer isn't NULL, it is safe, because we are handling IPV6_PKTINFO socket option in this block of code. Also, use in6ifa_withaddr() instead of ifa_withaddr().
This commit is contained in:
parent
04894769f4
commit
3e16fab37b
@ -226,9 +226,6 @@ in6_selectsrc(uint32_t fibnum, struct sockaddr_in6 *dstsock,
|
|||||||
*/
|
*/
|
||||||
if (opts && (pi = opts->ip6po_pktinfo) &&
|
if (opts && (pi = opts->ip6po_pktinfo) &&
|
||||||
!IN6_IS_ADDR_UNSPECIFIED(&pi->ipi6_addr)) {
|
!IN6_IS_ADDR_UNSPECIFIED(&pi->ipi6_addr)) {
|
||||||
struct sockaddr_in6 srcsock;
|
|
||||||
struct in6_ifaddr *ia6;
|
|
||||||
|
|
||||||
/* get the outgoing interface */
|
/* get the outgoing interface */
|
||||||
if ((error = in6_selectif(dstsock, opts, mopts, &ifp, oifp,
|
if ((error = in6_selectif(dstsock, opts, mopts, &ifp, oifp,
|
||||||
fibnum))
|
fibnum))
|
||||||
@ -242,18 +239,14 @@ in6_selectsrc(uint32_t fibnum, struct sockaddr_in6 *dstsock,
|
|||||||
* the interface must be specified; otherwise, ifa_ifwithaddr()
|
* the interface must be specified; otherwise, ifa_ifwithaddr()
|
||||||
* will fail matching the address.
|
* will fail matching the address.
|
||||||
*/
|
*/
|
||||||
bzero(&srcsock, sizeof(srcsock));
|
tmp = pi->ipi6_addr;
|
||||||
srcsock.sin6_family = AF_INET6;
|
|
||||||
srcsock.sin6_len = sizeof(srcsock);
|
|
||||||
srcsock.sin6_addr = pi->ipi6_addr;
|
|
||||||
if (ifp) {
|
if (ifp) {
|
||||||
error = in6_setscope(&srcsock.sin6_addr, ifp, NULL);
|
error = in6_setscope(&tmp, ifp, &odstzone);
|
||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
if (cred != NULL && (error = prison_local_ip6(cred,
|
if (cred != NULL && (error = prison_local_ip6(cred,
|
||||||
&srcsock.sin6_addr, (inp != NULL &&
|
&tmp, (inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)) != 0)
|
||||||
(inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
|
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -262,19 +255,18 @@ in6_selectsrc(uint32_t fibnum, struct sockaddr_in6 *dstsock,
|
|||||||
* ancillary data.
|
* ancillary data.
|
||||||
*/
|
*/
|
||||||
if ((inp->inp_flags & INP_BINDANY) == 0) {
|
if ((inp->inp_flags & INP_BINDANY) == 0) {
|
||||||
ia6 = (struct in6_ifaddr *)ifa_ifwithaddr(
|
ia = in6ifa_ifwithaddr(&tmp, odstzone);
|
||||||
(struct sockaddr *)&srcsock);
|
if (ia == NULL || (ia->ia6_flags & (IN6_IFF_ANYCAST |
|
||||||
if (ia6 == NULL || (ia6->ia6_flags & (IN6_IFF_ANYCAST |
|
|
||||||
IN6_IFF_NOTREADY))) {
|
IN6_IFF_NOTREADY))) {
|
||||||
if (ia6 != NULL)
|
if (ia != NULL)
|
||||||
ifa_free(&ia6->ia_ifa);
|
ifa_free(&ia->ia_ifa);
|
||||||
return (EADDRNOTAVAIL);
|
return (EADDRNOTAVAIL);
|
||||||
}
|
}
|
||||||
bcopy(&ia6->ia_addr.sin6_addr, srcp, sizeof(*srcp));
|
bcopy(&ia->ia_addr.sin6_addr, srcp, sizeof(*srcp));
|
||||||
ifa_free(&ia6->ia_ifa);
|
ifa_free(&ia->ia_ifa);
|
||||||
} else
|
} else
|
||||||
bcopy(&srcsock.sin6_addr, srcp, sizeof(*srcp));
|
bcopy(&tmp, srcp, sizeof(*srcp));
|
||||||
pi->ipi6_addr = srcsock.sin6_addr; /* XXX: this overrides pi */
|
pi->ipi6_addr = tmp; /* XXX: this overrides pi */
|
||||||
if (ifpp)
|
if (ifpp)
|
||||||
*ifpp = ifp;
|
*ifpp = ifp;
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user