Commit:     354ecbb9dd89c21708b319da8c4ffd3dd6e6811d
Parent:     40ee5dc6af351c1b3de245abed4bd8e6a4a5646a
Author:     Dr. David Alan Gilbert <[EMAIL PROTECTED]>
AuthorDate: Sat Aug 25 16:09:27 2007 +0100
Committer:  J. Bruce Fields <[EMAIL PROTECTED]>
CommitDate: Tue Oct 9 18:31:57 2007 -0400

    knfsd: Add source address to sunrpc svc errors
    This patch adds the address of the client that caused an error in
    sunrpc/svc.c so that you get errors that look like:
    svc:, port=709: unknown version (3 for prog 100003, nfsd)
    I've seen machines which get bunches of unknown version or similar
    errors from time to time, and while the recent patch to add the service
    helps to find which service has the wrong version it doesn't help find
    the potentially bad client.
    The patch is against a checkout of Linus's git tree made on 2007-08-24.
    One observation is that the svc_print_addr function prints to a buffer
    which in this case makes life a little more complex; it just feels as if
    there must be lots of places that print a connection address - is there
    a better function to use anywhere?
    I think actually there are a few places with semi duplicated code; e.g.
    one_sock_name switches on the address family but only currently has
    IPV4; I wonder how many other places are similar.
    Signed-off-by: Dave Gilbert <[EMAIL PROTECTED]>
    Cc: Randy Dunlap <[EMAIL PROTECTED]>
    Signed-off-by: J. Bruce Fields <[EMAIL PROTECTED]>
    Acked-by:  Neil Brown <[EMAIL PROTECTED]>
 net/sunrpc/svc.c |   40 ++++++++++++++++++++++++++++++----------
 1 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 55ea6df..a4a6bf7 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -777,6 +777,30 @@ svc_register(struct svc_serv *serv, int proto, unsigned 
short port)
+ * Printk the given error with the address of the client that caused it.
+ */
+static int
+__attribute__ ((format (printf, 2, 3)))
+svc_printk(struct svc_rqst *rqstp, const char *fmt, ...)
+       va_list args;
+       int     r;
+       char    buf[RPC_MAX_ADDRBUFLEN];
+       if (!net_ratelimit())
+               return 0;
+       printk(KERN_WARNING "svc: %s: ",
+               svc_print_addr(rqstp, buf, sizeof(buf)));
+       va_start(args, fmt);
+       r = vprintk(fmt, args);
+       va_end(args);
+       return r;
  * Process the RPC request.
@@ -963,14 +987,13 @@ svc_process(struct svc_rqst *rqstp)
        return 0;
-       if (net_ratelimit())
-               printk("svc: short len %Zd, dropping request\n", argv->iov_len);
+       svc_printk(rqstp, "short len %Zd, dropping request\n",
+                       argv->iov_len);
        goto dropit;                    /* drop request */
-       if (net_ratelimit())
-               printk("svc: bad direction %d, dropping request\n", dir);
+       svc_printk(rqstp, "bad direction %d, dropping request\n", dir);
        goto dropit;                    /* drop request */
@@ -1000,8 +1023,7 @@ err_bad_prog:
        goto sendit;
-       if (net_ratelimit())
-               printk("svc: unknown version (%d for prog %d, %s)\n",
+       svc_printk(rqstp, "unknown version (%d for prog %d, %s)\n",
                       vers, prog, progp->pg_name);
@@ -1011,16 +1033,14 @@ err_bad_vers:
        goto sendit;
-       if (net_ratelimit())
-               printk("svc: unknown procedure (%d)\n", proc);
+       svc_printk(rqstp, "unknown procedure (%d)\n", proc);
        svc_putnl(resv, RPC_PROC_UNAVAIL);
        goto sendit;
-       if (net_ratelimit())
-               printk("svc: failed to decode args\n");
+       svc_printk(rqstp, "failed to decode args\n");
        rpc_stat = rpc_garbage_args;
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to