[PATCH] knfsd: SUNRPC: Add a function to format the address in an svc_rqst for printing
[linux-block.git] / fs / nfsd / nfsfh.c
index b06bf9f70efc380b0dad39c891d9060584e97fc0..a0b4282cb2849579aa2b38f0e3c38705cb65dd87 100644 (file)
 #include <linux/mount.h>
 #include <asm/pgtable.h>
 
+#include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/nfsd/nfsd.h>
 
 #define NFSDDBG_FACILITY               NFSDDBG_FH
-#define NFSD_PARANOIA 1
-/* #define NFSD_DEBUG_VERBOSE 1 */
 
 
 static int nfsd_nr_verified;
@@ -182,10 +181,10 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
                /* Check if the request originated from a secure port. */
                error = nfserr_perm;
                if (!rqstp->rq_secure && EX_SECURE(exp)) {
+                       char buf[RPC_MAX_ADDRBUFLEN];
                        printk(KERN_WARNING
-                              "nfsd: request from insecure port (%u.%u.%u.%u:%d)!\n",
-                              NIPQUAD(rqstp->rq_addr.sin_addr.s_addr),
-                              ntohs(rqstp->rq_addr.sin_port));
+                              "nfsd: request from insecure port %s!\n",
+                              svc_print_addr(rqstp, buf, sizeof(buf)));
                        goto out;
                }
 
@@ -230,13 +229,12 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
                                error = nfserrno(PTR_ERR(dentry));
                        goto out;
                }
-#ifdef NFSD_PARANOIA
+
                if (S_ISDIR(dentry->d_inode->i_mode) &&
                    (dentry->d_flags & DCACHE_DISCONNECTED)) {
                        printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n",
                               dentry->d_parent->d_name.name, dentry->d_name.name);
                }
-#endif
 
                fhp->fh_dentry = dentry;
                fhp->fh_export = exp;
@@ -267,12 +265,13 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
        /* Finally, check access permissions. */
        error = nfsd_permission(exp, dentry, access);
 
-#ifdef NFSD_PARANOIA_EXTREME
        if (error) {
-               printk("fh_verify: %s/%s permission failure, acc=%x, error=%d\n",
-                      dentry->d_parent->d_name.name, dentry->d_name.name, access, (error >> 24));
+               dprintk("fh_verify: %s/%s permission failure, "
+                       "acc=%x, error=%d\n",
+                       dentry->d_parent->d_name.name,
+                       dentry->d_name.name,
+                       access, ntohl(error));
        }
-#endif
 out:
        if (exp && !IS_ERR(exp))
                exp_put(exp);