This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.1'.
[unix-history] / sys / nfs / nfs_socket.c
index 904cc51..f3c3c88 100644 (file)
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     @(#)nfs_socket.c        7.23 (Berkeley) 4/20/91
- *
- * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
- * --------------------         -----   ----------------------
- * CURRENT PATCH LEVEL:         1       00053
- * --------------------         -----   ----------------------
- *
- * 08 Sep 92    Rick "gopher I"         Fix "reserved port" bug, fixed for
- *                                             AIX3.2 NFS clients
+ *     From:   @(#)nfs_socket.c        7.23 (Berkeley) 4/20/91
+ *     $Id: nfs_socket.c,v 1.5 1994/05/03 17:49:16 davidg Exp $
  */
 
 /*
  */
 
 /*
@@ -49,6 +42,7 @@
  */
 
 #include "param.h"
  */
 
 #include "param.h"
+#include "systm.h"
 #include "proc.h"
 #include "mount.h"
 #include "kernel.h"
 #include "proc.h"
 #include "mount.h"
 #include "kernel.h"
@@ -154,6 +148,7 @@ int nfs_tcpnodelay = 1;
  * Initialize sockets and congestion for a new NFS connection.
  * We do not free the sockaddr if error.
  */
  * Initialize sockets and congestion for a new NFS connection.
  * We do not free the sockaddr if error.
  */
+int
 nfs_connect(nmp)
        register struct nfsmount *nmp;
 {
 nfs_connect(nmp)
        register struct nfsmount *nmp;
 {
@@ -284,6 +279,7 @@ bad:
  * If this fails the mount point is DEAD!
  * nb: Must be called with the nfs_solock() set on the mount point.
  */
  * If this fails the mount point is DEAD!
  * nb: Must be called with the nfs_solock() set on the mount point.
  */
+int
 nfs_reconnect(rep, nmp)
        register struct nfsreq *rep;
        register struct nfsmount *nmp;
 nfs_reconnect(rep, nmp)
        register struct nfsreq *rep;
        register struct nfsmount *nmp;
@@ -339,6 +335,7 @@ nfs_disconnect(nmp)
  * must be called with an nfs_solock() on the socket.
  * "rep == NULL" indicates that it has been called from a server.
  */
  * must be called with an nfs_solock() on the socket.
  * "rep == NULL" indicates that it has been called from a server.
  */
+int
 nfs_send(so, nam, top, rep)
        register struct socket *so;
        struct mbuf *nam;
 nfs_send(so, nam, top, rep)
        register struct socket *so;
        struct mbuf *nam;
@@ -393,6 +390,7 @@ nfs_send(so, nam, top, rep)
  * For SOCK_STREAM we must be very careful to read an entire record once
  * we have read any of it, even if the system call has been interrupted.
  */
  * For SOCK_STREAM we must be very careful to read an entire record once
  * we have read any of it, even if the system call has been interrupted.
  */
+int
 nfs_receive(so, aname, mp, rep)
        register struct socket *so;
        struct mbuf **aname;
 nfs_receive(so, aname, mp, rep)
        register struct socket *so;
        struct mbuf **aname;
@@ -402,8 +400,8 @@ nfs_receive(so, aname, mp, rep)
        struct uio auio;
        struct iovec aio;
        register struct mbuf *m;
        struct uio auio;
        struct iovec aio;
        register struct mbuf *m;
-       struct mbuf *m2, *mnew, **mbp;
-       caddr_t fcp, tcp;
+       struct mbuf *m2 = 0, *mnew, **mbp;
+       caddr_t fcp, tcp = 0;
        u_long len;
        struct mbuf **getnam;
        int error, siz, mlen, soflags, rcvflg;
        u_long len;
        struct mbuf **getnam;
        int error, siz, mlen, soflags, rcvflg;
@@ -481,7 +479,7 @@ tryagain:
                        }
                        if (error)
                                goto errout;
                        }
                        if (error)
                                goto errout;
-                       len = ntohl(len) & ~0x80000000;
+                       len = ntohl(len) & ~0x80000000ul;
                        /*
                         * This is SERIOUS! We are out of sync with the sender
                         * and forcing a disconnect/reconnect is all I can do.
                        /*
                         * This is SERIOUS! We are out of sync with the sender
                         * and forcing a disconnect/reconnect is all I can do.
@@ -615,6 +613,7 @@ errout:
  * with outstanding requests using the xid, until ours is found.
  */
 /* ARGSUSED */
  * with outstanding requests using the xid, until ours is found.
  */
 /* ARGSUSED */
+int
 nfs_reply(nmp, myrep)
        struct nfsmount *nmp;
        struct nfsreq *myrep;
 nfs_reply(nmp, myrep)
        struct nfsmount *nmp;
        struct nfsreq *myrep;
@@ -624,8 +623,8 @@ nfs_reply(nmp, myrep)
        register int error = 0;
        u_long rxid;
        struct mbuf *mp, *nam;
        register int error = 0;
        u_long rxid;
        struct mbuf *mp, *nam;
-       char *cp;
-       int cnt, xfer;
+/*     char *cp; */
+/*     int cnt, xfer; */
 
        /*
         * Loop around until we get our own reply
 
        /*
         * Loop around until we get our own reply
@@ -735,6 +734,7 @@ nfs_reply(nmp, myrep)
  *       by mrep or error
  * nb: always frees up mreq mbuf list
  */
  *       by mrep or error
  * nb: always frees up mreq mbuf list
  */
+int
 nfs_request(vp, mreq, xid, procnum, procp, tryhard, mp, mrp, mdp, dposp)
        struct vnode *vp;
        struct mbuf *mreq;
 nfs_request(vp, mreq, xid, procnum, procp, tryhard, mp, mrp, mdp, dposp)
        struct vnode *vp;
        struct mbuf *mreq;
@@ -810,7 +810,7 @@ nfs_request(vp, mreq, xid, procnum, procp, tryhard, mp, mrp, mdp, dposp)
         */
        if ((nmp->nm_soflags & PR_ATOMIC) == 0) {
                M_PREPEND(mreq, sizeof(u_long), M_WAIT);
         */
        if ((nmp->nm_soflags & PR_ATOMIC) == 0) {
                M_PREPEND(mreq, sizeof(u_long), M_WAIT);
-               *mtod(mreq, u_long *) = htonl(0x80000000 | len);
+               *mtod(mreq, u_long *) = htonl(0x80000000ul | len);
        }
        rep->r_mreq = mreq;
 
        }
        rep->r_mreq = mreq;
 
@@ -931,6 +931,7 @@ nfsmout:
  * - verify it
  * - fill in the cred struct.
  */
  * - verify it
  * - fill in the cred struct.
  */
+int
 nfs_getreq(so, prog, vers, maxproc, nam, mrp, mdp, dposp, retxid, procnum, cr,
        msk, mtch, wascomp, repstat)                            /* 08 Aug 92*/
        struct socket *so;
 nfs_getreq(so, prog, vers, maxproc, nam, mrp, mdp, dposp, retxid, procnum, cr,
        msk, mtch, wascomp, repstat)                            /* 08 Aug 92*/
        struct socket *so;
@@ -970,6 +971,8 @@ nfs_getreq(so, prog, vers, maxproc, nam, mrp, mdp, dposp, retxid, procnum, cr,
        }
        if (error)
                return (error);
        }
        if (error)
                return (error);
+       if (!mrep)
+               return (EBADRPC);
        md = mrep;
        mrep = nfs_uncompress(mrep);
        if (mrep != md) {
        md = mrep;
        mrep = nfs_uncompress(mrep);
        if (mrep != md) {
@@ -1060,6 +1063,7 @@ nfsmout:
  * Generate the rpc reply header
  * siz arg. is used to decide if adding a cluster is worthwhile
  */
  * Generate the rpc reply header
  * siz arg. is used to decide if adding a cluster is worthwhile
  */
+int
 nfs_rephead(siz, retxid, err, mrq, mbp, bposp)
        int siz;
        u_long retxid;
 nfs_rephead(siz, retxid, err, mrq, mbp, bposp)
        int siz;
        u_long retxid;
@@ -1127,7 +1131,9 @@ nfs_rephead(siz, retxid, err, mrq, mbp, bposp)
  * To avoid retransmission attempts on STREAM sockets (in the future) make
  * sure to set the r_retry field to 0 (implies nm_retry == 0).
  */
  * To avoid retransmission attempts on STREAM sockets (in the future) make
  * sure to set the r_retry field to 0 (implies nm_retry == 0).
  */
-nfs_timer()
+void
+nfs_timer(arg)
+     caddr_t arg;
 {
        register struct nfsreq *rep;
        register struct mbuf *m;
 {
        register struct nfsreq *rep;
        register struct mbuf *m;
@@ -1196,7 +1202,8 @@ nfs_timer()
                        nfsstats.rpcretries++;
                        if ((nmp->nm_flag & NFSMNT_NOCONN) == 0)
                            error = (*so->so_proto->pr_usrreq)(so, PRU_SEND, m,
                        nfsstats.rpcretries++;
                        if ((nmp->nm_flag & NFSMNT_NOCONN) == 0)
                            error = (*so->so_proto->pr_usrreq)(so, PRU_SEND, m,
-                           (caddr_t)0, (struct mbuf *)0, (struct mbuf *)0);
+                           (struct mbuf *)0, (struct mbuf *)0,
+                           (struct mbuf *)0);
                        else
                            error = (*so->so_proto->pr_usrreq)(so, PRU_SEND, m,
                            nmp->nm_nam, (struct mbuf *)0, (struct mbuf *)0);
                        else
                            error = (*so->so_proto->pr_usrreq)(so, PRU_SEND, m,
                            nmp->nm_nam, (struct mbuf *)0, (struct mbuf *)0);
@@ -1256,6 +1263,7 @@ nfs_timer()
  */
 #define NFS_RTO(nmp)   (((nmp)->nm_srtt >> 3) + (nmp)->nm_rttvar)
 
  */
 #define NFS_RTO(nmp)   (((nmp)->nm_srtt >> 3) + (nmp)->nm_rttvar)
 
+void
 nfs_updatetimer(nmp)
        register struct nfsmount *nmp;
 {
 nfs_updatetimer(nmp)
        register struct nfsmount *nmp;
 {
@@ -1304,6 +1312,7 @@ nfs_updatetimer(nmp)
                nmp->nm_window = NFS_MAXWINDOW;
 }
 
                nmp->nm_window = NFS_MAXWINDOW;
 }
 
+void
 nfs_backofftimer(nmp)
        register struct nfsmount *nmp;
 {
 nfs_backofftimer(nmp)
        register struct nfsmount *nmp;
 {
@@ -1339,6 +1348,7 @@ nfs_backofftimer(nmp)
  * Test for a termination signal pending on procp.
  * This is used for NFSMNT_INT mounts.
  */
  * Test for a termination signal pending on procp.
  * This is used for NFSMNT_INT mounts.
  */
+int
 nfs_sigintr(p)
        register struct proc *p;
 {
 nfs_sigintr(p)
        register struct proc *p;
 {
@@ -1349,9 +1359,10 @@ nfs_sigintr(p)
                return (0);
 }
 
                return (0);
 }
 
+void
 nfs_msg(p, server, msg)
        struct proc *p;
 nfs_msg(p, server, msg)
        struct proc *p;
-       char *server, *msg;
+       const char *server, *msg;
 {
        tpr_t tpr;
 
 {
        tpr_t tpr;
 
@@ -1369,6 +1380,7 @@ nfs_msg(p, server, msg)
  * and also to avoid race conditions between the processes with nfs requests
  * in progress when a reconnect is necessary.
  */
  * and also to avoid race conditions between the processes with nfs requests
  * in progress when a reconnect is necessary.
  */
+void
 nfs_solock(flagp)
        register int *flagp;
 {
 nfs_solock(flagp)
        register int *flagp;
 {
@@ -1383,6 +1395,7 @@ nfs_solock(flagp)
 /*
  * Unlock the stream socket for others.
  */
 /*
  * Unlock the stream socket for others.
  */
+void
 nfs_sounlock(flagp)
        register int *flagp;
 {
 nfs_sounlock(flagp)
        register int *flagp;
 {
@@ -1401,6 +1414,7 @@ nfs_sounlock(flagp)
  * if they are the same.
  * If there is any doubt, return FALSE.
  */
  * if they are the same.
  * If there is any doubt, return FALSE.
  */
+int
 nfs_netaddr_match(nam1, nam2)
        struct mbuf *nam1, *nam2;
 {
 nfs_netaddr_match(nam1, nam2)
        struct mbuf *nam1, *nam2;
 {
@@ -1434,6 +1448,7 @@ nfs_netaddr_match(nam1, nam2)
  * - Compare for == with match
  * return TRUE if not equal
  */
  * - Compare for == with match
  * return TRUE if not equal
  */
+int
 nfs_badnam(nam, msk, mtch)
        register struct mbuf *nam, *msk, *mtch;
 {
 nfs_badnam(nam, msk, mtch)
        register struct mbuf *nam, *msk, *mtch;
 {