diff options
author | phk <phk@FreeBSD.org> | 2004-11-08 14:44:54 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-11-08 14:44:54 +0000 |
commit | 027fce30f5a18628851fd5615769543ef2e8c6ac (patch) | |
tree | 49490960ea53cad45a1b8763ff91948d8f401931 /sys/kern | |
parent | d24107be6b63ca9ccbc6bca190ef874651886c49 (diff) | |
download | FreeBSD-src-027fce30f5a18628851fd5615769543ef2e8c6ac.zip FreeBSD-src-027fce30f5a18628851fd5615769543ef2e8c6ac.tar.gz |
Initialize struct pr_userreqs in new/sparse style and fill in common
default elements in net_init_domain().
This makes it possible to grep these structures and see any bogosities.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_domain.c | 52 | ||||
-rw-r--r-- | sys/kern/uipc_usrreq.c | 23 |
2 files changed, 59 insertions, 16 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 2ce5080..56b61ed 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -74,13 +74,27 @@ MTX_SYSINIT(domain, &dom_mtx, "domain list", MTX_DEF); * All functions return EOPNOTSUPP. */ struct pr_usrreqs nousrreqs = { - pru_abort_notsupp, pru_accept_notsupp, pru_attach_notsupp, - pru_bind_notsupp, pru_connect_notsupp, pru_connect2_notsupp, - pru_control_notsupp, pru_detach_notsupp, pru_disconnect_notsupp, - pru_listen_notsupp, pru_peeraddr_notsupp, pru_rcvd_notsupp, - pru_rcvoob_notsupp, pru_send_notsupp, pru_sense_null, - pru_shutdown_notsupp, pru_sockaddr_notsupp, pru_sosend_notsupp, - pru_soreceive_notsupp, pru_sopoll_notsupp, pru_sosetlabel_null + .pru_abort = pru_abort_notsupp, + .pru_accept = pru_accept_notsupp, + .pru_attach = pru_attach_notsupp, + .pru_bind = pru_bind_notsupp, + .pru_connect = pru_connect_notsupp, + .pru_connect2 = pru_connect2_notsupp, + .pru_control = pru_control_notsupp, + .pru_detach = pru_detach_notsupp, + .pru_disconnect = pru_disconnect_notsupp, + .pru_listen = pru_listen_notsupp, + .pru_peeraddr = pru_peeraddr_notsupp, + .pru_rcvd = pru_rcvd_notsupp, + .pru_rcvoob = pru_rcvoob_notsupp, + .pru_send = pru_send_notsupp, + .pru_sense = pru_sense_null, + .pru_shutdown = pru_shutdown_notsupp, + .pru_sockaddr = pru_sockaddr_notsupp, + .pru_sosend = pru_sosend_notsupp, + .pru_soreceive = pru_soreceive_notsupp, + .pru_sopoll = pru_sopoll_notsupp, + .pru_sosetlabel = pru_sosetlabel_null }; /* @@ -92,14 +106,30 @@ static void net_init_domain(struct domain *dp) { struct protosw *pr; + struct pr_usrreqs *pu; if (dp->dom_init) (*dp->dom_init)(); for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++){ - if (pr->pr_usrreqs == 0) - panic("domaininit: %ssw[%d] has no usrreqs!", - dp->dom_name, - (int)(pr - dp->dom_protosw)); + pu = pr->pr_usrreqs; + KASSERT(pu != NULL, + ("domaininit: %ssw[%d] has no usrreqs!", + dp->dom_name, (int)(pr - dp->dom_protosw))); +#define DEFAULT(foo, bar) if ((foo) == NULL) (foo) = (bar) + DEFAULT(pu->pru_accept, pru_accept_notsupp); + DEFAULT(pu->pru_connect, pru_connect_notsupp); + DEFAULT(pu->pru_connect2, pru_connect2_notsupp); + DEFAULT(pu->pru_control, pru_control_notsupp); + DEFAULT(pu->pru_listen, pru_listen_notsupp); + DEFAULT(pu->pru_rcvd, pru_rcvd_notsupp); + DEFAULT(pu->pru_rcvoob, pru_rcvoob_notsupp); + DEFAULT(pu->pru_sense, pru_sense_null); + DEFAULT(pu->pru_sosend, sosend); + DEFAULT(pu->pru_soreceive, soreceive); + DEFAULT(pu->pru_sopoll, sopoll); + DEFAULT(pu->pru_sosetlabel, pru_sosetlabel_null); +#undef DEFAULT + if (pr->pr_init) (*pr->pr_init)(); } diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 6b97f94..af93e2e 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -576,11 +576,24 @@ uipc_sockaddr(struct socket *so, struct sockaddr **nam) } struct pr_usrreqs uipc_usrreqs = { - uipc_abort, uipc_accept, uipc_attach, uipc_bind, uipc_connect, - uipc_connect2, pru_control_notsupp, uipc_detach, uipc_disconnect, - uipc_listen, uipc_peeraddr, uipc_rcvd, pru_rcvoob_notsupp, - uipc_send, uipc_sense, uipc_shutdown, uipc_sockaddr, - sosend, soreceive, sopoll, pru_sosetlabel_null + .pru_abort = uipc_abort, + .pru_accept = uipc_accept, + .pru_attach = uipc_attach, + .pru_bind = uipc_bind, + .pru_connect = uipc_connect, + .pru_connect2 = uipc_connect2, + .pru_detach = uipc_detach, + .pru_disconnect = uipc_disconnect, + .pru_listen = uipc_listen, + .pru_peeraddr = uipc_peeraddr, + .pru_rcvd = uipc_rcvd, + .pru_send = uipc_send, + .pru_sense = uipc_sense, + .pru_shutdown = uipc_shutdown, + .pru_sockaddr = uipc_sockaddr, + .pru_sosend = sosend, + .pru_soreceive = soreceive, + .pru_sopoll = sopoll, }; int |