diff options
author | rwatson <rwatson@FreeBSD.org> | 2006-07-24 15:20:08 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2006-07-24 15:20:08 +0000 |
commit | 40868fda8a777cd2639ad89e252401b8b27c8c91 (patch) | |
tree | b3a0ac6c1795bad8df68bc26486cfcd7d7e796ec /sys/kern | |
parent | 0dd0f8ec80a478a694b1ee6de99c7b84a2d3aa2b (diff) | |
download | FreeBSD-src-40868fda8a777cd2639ad89e252401b8b27c8c91.zip FreeBSD-src-40868fda8a777cd2639ad89e252401b8b27c8c91.tar.gz |
soreceive_generic(), and sopoll_generic(). Add new functions sosend(),
soreceive(), and sopoll(), which are wrappers for pru_sosend,
pru_soreceive, and pru_sopoll, and are now used univerally by socket
consumers rather than either directly invoking the old so*() functions
or directly invoking the protocol switch method (about an even split
prior to this commit).
This completes an architectural change that was begun in 1996 to permit
protocols to provide substitute implementations, as now used by UDP.
Consumers now uniformly invoke sosend(), soreceive(), and sopoll() to
perform these operations on sockets -- in particular, distributed file
systems and socket system calls.
Architectural head nod: sam, gnn, wollman
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sys_socket.c | 8 | ||||
-rw-r--r-- | sys/kern/uipc_domain.c | 6 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 54 | ||||
-rw-r--r-- | sys/kern/uipc_syscalls.c | 6 | ||||
-rw-r--r-- | sys/kern/uipc_usrreq.c | 6 |
5 files changed, 63 insertions, 17 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 7c352be..4d0a1ac 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -88,7 +88,7 @@ soo_read(fp, uio, active_cred, flags, td) return (error); } #endif - error = so->so_proto->pr_usrreqs->pru_soreceive(so, 0, uio, 0, 0, 0); + error = soreceive(so, 0, uio, 0, 0, 0); NET_UNLOCK_GIANT(); return (error); } @@ -115,8 +115,7 @@ soo_write(fp, uio, active_cred, flags, td) return (error); } #endif - error = so->so_proto->pr_usrreqs->pru_sosend(so, 0, uio, 0, 0, 0, - uio->uio_td); + error = sosend(so, 0, uio, 0, 0, 0, uio->uio_td); if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) { PROC_LOCK(uio->uio_td->td_proc); psignal(uio->uio_td->td_proc, SIGPIPE); @@ -243,8 +242,7 @@ soo_poll(fp, events, active_cred, td) return (error); } #endif - error = (so->so_proto->pr_usrreqs->pru_sopoll) - (so, events, fp->f_cred, td); + error = sopoll(so, events, fp->f_cred, td); NET_UNLOCK_GIANT(); return (error); diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 28cddce..7cd9118 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -119,9 +119,9 @@ protosw_init(struct protosw *pr) 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_sosend, sosend_generic); + DEFAULT(pu->pru_soreceive, soreceive_generic); + DEFAULT(pu->pru_sopoll, sopoll_generic); #undef DEFAULT if (pr->pr_init) (*pr->pr_init)(); diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 973c614..b92e085 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1093,7 +1093,7 @@ out: */ #define snderr(errno) { error = (errno); goto release; } int -sosend(so, addr, uio, top, control, flags, td) +sosend_generic(so, addr, uio, top, control, flags, td) struct socket *so; struct sockaddr *addr; struct uio *uio; @@ -1256,6 +1256,25 @@ out: } #undef snderr +int +sosend(so, addr, uio, top, control, flags, td) + struct socket *so; + struct sockaddr *addr; + struct uio *uio; + struct mbuf *top; + struct mbuf *control; + int flags; + struct thread *td; +{ + + /* XXXRW: Temporary debugging. */ + KASSERT(so->so_proto->pr_usrreqs->pru_sosend != sosend, + ("sosend: protocol calls sosend")); + + return (so->so_proto->pr_usrreqs->pru_sosend(so, addr, uio, top, + control, flags, td)); +} + /* * The part of soreceive() that implements reading non-inline out-of-band * data from a socket. For more complete comments, see soreceive(), from @@ -1361,7 +1380,7 @@ sockbuf_pushsync(struct sockbuf *sb, struct mbuf *nextrecord) * the count in uio_resid. */ int -soreceive(so, psa, uio, mp0, controlp, flagsp) +soreceive_generic(so, psa, uio, mp0, controlp, flagsp) struct socket *so; struct sockaddr **psa; struct uio *uio; @@ -1802,6 +1821,24 @@ out: } int +soreceive(so, psa, uio, mp0, controlp, flagsp) + struct socket *so; + struct sockaddr **psa; + struct uio *uio; + struct mbuf **mp0; + struct mbuf **controlp; + int *flagsp; +{ + + /* XXXRW: Temporary debugging. */ + KASSERT(so->so_proto->pr_usrreqs->pru_soreceive != soreceive, + ("soreceive: protocol calls soreceive")); + + return (so->so_proto->pr_usrreqs->pru_soreceive(so, psa, uio, mp0, + controlp, flagsp)); +} + +int soshutdown(so, how) struct socket *so; int how; @@ -2411,6 +2448,19 @@ int sopoll(struct socket *so, int events, struct ucred *active_cred, struct thread *td) { + + /* XXXRW: Temporary debugging. */ + KASSERT(so->so_proto->pr_usrreqs->pru_sopoll != sopoll, + ("sopoll: protocol calls sopoll")); + + return (so->so_proto->pr_usrreqs->pru_sopoll(so, events, active_cred, + td)); +} + +int +sopoll_generic(struct socket *so, int events, struct ucred *active_cred, + struct thread *td) +{ int revents = 0; SOCKBUF_LOCK(&so->so_snd); diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index a9eaa0d..431fbb9 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -803,8 +803,7 @@ kern_sendit(td, s, mp, flags, control, segflg) ktruio = cloneuio(&auio); #endif len = auio.uio_resid; - error = so->so_proto->pr_usrreqs->pru_sosend(so, mp->msg_name, &auio, - 0, control, flags, td); + error = sosend(so, mp->msg_name, &auio, 0, control, flags, td); if (error) { if (auio.uio_resid != len && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) @@ -1020,8 +1019,7 @@ kern_recvit(td, s, mp, fromseg, controlp) ktruio = cloneuio(&auio); #endif len = auio.uio_resid; - error = so->so_proto->pr_usrreqs->pru_soreceive(so, &fromsa, &auio, - (struct mbuf **)0, + error = soreceive(so, &fromsa, &auio, (struct mbuf **)0, (mp->msg_control || controlp) ? &control : (struct mbuf **)0, &mp->msg_flags); if (error) { diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index e0885c3..42226a1 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -786,9 +786,9 @@ struct pr_usrreqs uipc_usrreqs = { .pru_sense = uipc_sense, .pru_shutdown = uipc_shutdown, .pru_sockaddr = uipc_sockaddr, - .pru_sosend = sosend, - .pru_soreceive = soreceive, - .pru_sopoll = sopoll, + .pru_sosend = sosend_generic, + .pru_soreceive = soreceive_generic, + .pru_sopoll = sopoll_generic, .pru_close = uipc_close, }; |