protosw: repair protocol selection logic in socket(2)
Pointy hat to: glebius
Fixes: 61f7427f02
This commit is contained in:
parent
1f3d8c09be
commit
24af7808fa
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user