diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 832afca510fa..f1b2c616c662 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -290,7 +290,7 @@ pffinddomain(int family) } struct protosw * -pffindtype(int family, int type) +pffindproto(int family, int type, int proto) { struct domain *dp; struct protosw *pr; @@ -300,7 +300,9 @@ pffindtype(int family, int type) return (NULL); for (int i = 0; i < dp->dom_nprotosw; i++) - if ((pr = dp->dom_protosw[i]) != NULL && pr->pr_type == type) + if ((pr = dp->dom_protosw[i]) != NULL && pr->pr_type == type && + (pr->pr_protocol == 0 || proto == 0 || + pr->pr_protocol == proto)) return (pr); return (NULL); diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index a93256cd7f63..360b7b56cee5 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -520,7 +520,7 @@ socreate(int dom, struct socket **aso, int type, int proto, td->td_proc->p_comm); } - prp = pffindtype(dom, type); + prp = pffindproto(dom, type, proto); if (prp == NULL) { /* No support for domain. */ if (pffinddomain(dom) == NULL) @@ -530,8 +530,6 @@ socreate(int dom, struct socket **aso, int type, int proto, return (EPROTOTYPE); return (EPROTONOSUPPORT); } - if (prp->pr_protocol != 0 && proto != 0 && prp->pr_protocol != proto) - return (EPROTONOSUPPORT); MPASS(prp->pr_attach); diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index f05aff962420..3b89c6f78caf 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -236,7 +236,7 @@ char *prcorequests[] = { #ifdef _KERNEL struct domain *pffinddomain(int family); -struct protosw *pffindtype(int family, int type); +struct protosw *pffindproto(int family, int type, int proto); int protosw_register(struct domain *, struct protosw *); int protosw_unregister(struct protosw *);