make IPV6_V6ONLY socket option work for UDP as well.
PR: ports/92620 Reported by: Kurt Miller <kurt__at__intricatesoftware.com> MFC after: 1 week
This commit is contained in:
parent
6eef132530
commit
bd1c5824b3
@ -549,7 +549,7 @@ udp6_attach(struct socket *so, int proto, struct thread *td)
|
||||
INP_LOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
inp->inp_vflag |= INP_IPV6;
|
||||
if (!ip6_v6only)
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0)
|
||||
inp->inp_vflag |= INP_IPV4;
|
||||
inp->in6p_hops = -1; /* use kernel default */
|
||||
inp->in6p_cksum = -1; /* just to be sure */
|
||||
@ -653,7 +653,8 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
error = in6_pcbconnect(inp, nam, td->td_ucred);
|
||||
splx(s);
|
||||
if (error == 0) {
|
||||
if (!ip6_v6only) { /* should be non mapped addr */
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
|
||||
/* should be non mapped addr */
|
||||
inp->inp_vflag &= ~INP_IPV4;
|
||||
inp->inp_vflag |= INP_IPV6;
|
||||
}
|
||||
@ -754,7 +755,7 @@ udp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
}
|
||||
|
||||
#ifdef INET
|
||||
if (!ip6_v6only) {
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
|
||||
int hasv4addr;
|
||||
struct sockaddr_in6 *sin6 = 0;
|
||||
|
||||
@ -768,15 +769,6 @@ udp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
if (hasv4addr) {
|
||||
struct pr_usrreqs *pru;
|
||||
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY)) {
|
||||
/*
|
||||
* since a user of this socket set the
|
||||
* IPV6_V6ONLY flag, we discard this
|
||||
* datagram destined to a v4 addr.
|
||||
*/
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) &&
|
||||
!IN6_IS_ADDR_V4MAPPED(&inp->in6p_laddr)) {
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user