diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index a96ec22c599..069cd862346 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -897,6 +897,10 @@ udp_ctloutput(struct socket *so, struct sockopt *sopt) #if defined(IPSEC) || defined(IPSEC_SUPPORT) #ifdef INET case UDP_ENCAP: + if (!INP_CHECK_SOCKAF(so, AF_INET)) { + INP_WUNLOCK(inp); + return (EINVAL); + } if (!IPSEC_ENABLED(ipv4)) { INP_WUNLOCK(inp); return (ENOPROTOOPT); @@ -944,6 +948,10 @@ udp_ctloutput(struct socket *so, struct sockopt *sopt) #if defined(IPSEC) || defined(IPSEC_SUPPORT) #ifdef INET case UDP_ENCAP: + if (!INP_CHECK_SOCKAF(so, AF_INET)) { + INP_WUNLOCK(inp); + return (EINVAL); + } if (!IPSEC_ENABLED(ipv4)) { INP_WUNLOCK(inp); return (ENOPROTOOPT); diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 4e69608b71d..068b9e7095a 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -1244,7 +1244,7 @@ udp6_disconnect(struct socket *so) #define UDP6_PROTOSW \ .pr_type = SOCK_DGRAM, \ .pr_flags = PR_ATOMIC|PR_ADDR|PR_CAPATTACH, \ - .pr_ctloutput = ip6_ctloutput, \ + .pr_ctloutput = udp_ctloutput, \ .pr_abort = udp6_abort, \ .pr_attach = udp6_attach, \ .pr_bind = udp6_bind, \